public void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { DateTime current = DateTime.Now; //Setting the time to 7PM if ((current.Hour == 7 && current.Minute == 30 && current.Second == 00) || (current.Hour < 00 && current.Minute == 0 && current.Second == 0)) { //MessageBox.Show("Reports have been generated.", "Check Notifications", MessageBoxButtons.OK, MessageBoxIcon.Information); file = Utilities3.generatePDF(); //Generates the pdf at 7PM (Or between 7PM and 12Midnight) and saves it in local computer. Utilities3.sendEmail(file); //Sends the file to a given location (Location is specified at sendEmail() method. //file is a String where it comprises of the location (Address) where the generated PDF is located. You can change it in generatePDF() method. //check out sendEmail(String file) for more information. try { //Thread managements. Have doubts on this. UpdateMessageBox upd = UpdateTheMessageBox; Invoke(upd); } catch (Exception ex) { //MessageBox.Show(ex.ToString()); } } }
void UpdateTheMessageBox(String str) { MessageBox.Show("Reports are generated for the day!"); MessageBox.Show("Reports are generated for the day22222!"); file = Utilities3.generatePDF(); Utilities3.sendEmail(file); showNotification(); }
private void cashier_form_Load(object sender, EventArgs e) { showNotification(); //Initiating the timer if (DateTime.Now.Day == 28) //Ever29th of the month, a monthly report will get emailed. { file2 = Utilities3.generateMothlyReportS(); Utilities3.sendEmail(file2); } timer = new System.Timers.Timer(); timer.Interval = 1000; timer.Elapsed += Timer_Elapsed; timer.Start(); }