I am new to C# and a novice in coupling techniques. I am creating a reservation system for our school library. I already created a writer method that needs a file name and input only.
What syntax should I use for my if statement to differentiate AM from PM? Also, what syntax should I use for my other form for the 12 am reset? I do believe if the program is not working, the reset will not happen.
As you can see, the red background of the label is red(which means past time or someone has reserved it).
MY CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;
namespace MMCM_Library
{
internal class TimerBuffer
{
ReadandWriteTxtfile Writer = new ReadandWriteTxtfile();
public void Resetat12am() //I'll call this in the main form
{
Writer.Write("DCR1_9am.txt", "0");
Writer.Write("DCR1_11am.txt", "0");
Writer.Write("DCR1_1pm.txt", "0");
Writer.Write("DCR1_3pm.txt", "0");
Writer.Write("DCR2_9am.txt", "0");
Writer.Write("DCR2_11am.txt", "0");
Writer.Write("DCR2_1pm.txt", "0");
Writer.Write("DCR2_3pm.txt", "0");
Writer.Write("DCR3_9am.txt", "0");
Writer.Write("DCR3_11am.txt", "0");
Writer.Write("DCR3_1pm.txt", "0");
Writer.Write("DCR3_3pm.txt", "0");
Writer.Write("DCR4_9am.txt", "0");
Writer.Write("DCR4_11am.txt", "0");
Writer.Write("DCR4_1pm.txt", "0");
Writer.Write("DCR4_3pm.txt", "0");
}
public void TimePassed() //I'll call this in the loading of the main form and upon reservation
{
DateTime currentTime = DateTime.Now;
if (currentTime.Hour >= 9)
{
Writer.Write("DCR1_9am.txt", "1");
Writer.Write("DCR2_9am.txt", "1");
Writer.Write("DCR3_9am.txt", "1");
Writer.Write("DCR4_9am.txt", "1");
}
if (currentTime.Hour >= 11)
{
Writer.Write("DCR1_11am.txt", "1");
Writer.Write("DCR2_11am.txt", "1");
Writer.Write("DCR3_11am.txt", "1");
Writer.Write("DCR4_11am.txt", "1");
}
if (currentTime.Hour >= 1)
{
Writer.Write("DCR1_1pm.txt", "1");
Writer.Write("DCR2_1pm.txt", "1");
Writer.Write("DCR3_1pm.txt", "1");
Writer.Write("DCR4_1pm.txt", "1");
}
//more.....
}
}
}