/// <summary> /// Adds the specified number of minutes to the schedule end time. /// </summary> /// <param name="minutes">The number of minutes to add.</param> public void AddEndTime(int minutes) { DateTime newEndTime = EndTime.AddMinutes(minutes); DateTime startTime = StartTime; EndTime = newEndTime > startTime ? newEndTime : startTime.AddMinutes(1); }
private bool IsNearTheEndTime(DateTime time) { DateTime endtime_with_diff = EndTime.AddMinutes((-1) * Parameter.disconnection_diff_min); if (time > endtime_with_diff) { return(true); } return(false); }
private void DispatcherTimer_Tick(object sender, EventArgs e) { try { EndTime = dbContext.Db.GetDate().AddMinutes(1); StartTime = EndTime.AddMinutes(-30); executeSearchCommand(); } catch (Exception ex) { LogHelper.Logger.Error("自动刷新日志时错误!", ex); } }
private void SetNextNotificationTime(TimeSpan time) { if (time.TotalHours > 3) { // the first notification is 3 hours before the timer expires. NextNotificationTime = EndTime.AddHours(-3); } else { if (time.TotalMinutes > 60) { NextNotificationTime = EndTime.AddHours(-1); } else { if (time.TotalMinutes > 30) { NextNotificationTime = EndTime.AddMinutes(-30); } else { if (time.TotalMinutes > 15) { NextNotificationTime = EndTime.AddMinutes(-15); } else { if (time.TotalMinutes > 5) { NextNotificationTime = EndTime.AddMinutes(-5); } else { if (time.TotalMinutes > 1) { NextNotificationTime = EndTime.AddMinutes(-1); } else { NextNotificationTime = EndTime; } } } } } } }
/// <summary> /// Обрабатывает один фрейм игры, на текущий момент времени. /// </summary> public void Iterate() { if (GameStatus != GameStatusType.InProgress && GameStatus != GameStatusType.Stopped) { return; } lock (_locker) { // Запоминаем время начала итерации DateTime curTime = DateTime.Now; int eventsCount = NewEvents.Count; // STEP 1: Обрабатываем все ивенты (если они есть) if (eventsCount > 0) { // Получаем список ивентов, обрабатываемый на текущей итерации List <GameEvent> processedEvents = NewEvents.GetRange(0, eventsCount).OrderBy(x => x.AddDate).ToList(); NewEvents.RemoveRange(0, eventsCount); // Выполняем каждый ивент foreach (GameEvent currentEvent in processedEvents) { currentEvent.Run(this); } // Добавляем все обработанные ивенты в список StoredEvents.AddRange(processedEvents); } // STEP 2: Добавляем новые ивенты, если прошло необходимое время (подсказка, слив адреса, слив задания) if (GameStatus != GameStatusType.Stopped) { foreach (LocalTeam t in Teams) { // Получение первого задания, если прошло достаточно времени и команда еще не начала играть. if (t.Progress == null) { if (curTime > ((DateTime)LaunchTime).AddSeconds(Setting.SecondsDelayStart * Teams.IndexOf(t))) { NewEvents.Add(new TeamStartsPlay(curTime, t.Id)); } continue; } if (t.Progress.IsAllTaskCompleted()) { continue; } // Кол-во секунд, прошедшее со сдачи последнего задания double lastCompleteTaskSec = curTime.Subtract(t.Progress.LastTaskCompleteTime).TotalSeconds; // Кол-во секунд, прошедшее с получения последней подсказки double lastHintSec = curTime.Subtract(t.Progress.LastHintTime).TotalSeconds; // ... сливаем задание if (lastCompleteTaskSec > (Setting.TaskDropDelaySec + Setting.Hint2DelaySec + Setting.Hint1DelaySec)) { NewEvents.Add(new TeamDropTask(curTime, t.Id, t.Progress.CurrentTaskIndex)); } // ... сливаем адрес else if (lastCompleteTaskSec > (Setting.Hint2DelaySec + Setting.Hint1DelaySec) && lastHintSec > Setting.Hint2DelaySec) { NewEvents.Add(new TeamGetAddress(curTime, t.Id, t.Progress.CurrentTaskIndex)); } // ... сливаем подсказку else if (lastCompleteTaskSec > (Setting.Hint1DelaySec) && lastHintSec > Setting.Hint1DelaySec) { NewEvents.Add(new TeamGetHint(curTime, t.Id, t.Progress.CurrentTaskIndex)); } } } // STEP 3: Анализируем пришедшие сообщения от пользователей и добавляем новые ивенты List <Message> inputMessages = Noticer.PullInput(); foreach (Message m in inputMessages) { LocalTeam playerTeam = Teams.First(x => x.Id == m.Player.TeamId); if (playerTeam.Progress == null) { m.Player.SendMessage(Noticer, $"Ваша команда еще не получила первое задание."); continue; } if (playerTeam.Progress.GetCurrentTask() == null) { m.Player.SendMessage(Noticer, $"Ваша команда уже выполнила все задания."); continue; } switch (m.Text) { case "задание": m.Player.SendMessage(Noticer, $"Какая-то подсказка."); continue; } if (playerTeam.Progress.GetCurrentTask().Code == m.Text) { NewEvents.Add(new PlayerCompletedTask(curTime, playerTeam.Id, m.Player.Id, playerTeam.Progress.CurrentTaskIndex)); } else { NewEvents.Add(new PlayerFailedTask(curTime, playerTeam.Id, m.Player.Id, playerTeam.Progress.CurrentTaskIndex)); } } // STEP 4: Завершение игры // Переводим игру в статус "останавливается", если пришло время конца игры. if (GameStatus == GameStatusType.InProgress && curTime.Subtract((DateTime)LaunchTime).TotalMinutes > Setting.GameDurationMin) { NewEvents.Add(new GameStopped(DateTime.Now)); } // Если после остановки игры прошло необходимое кол-во минут - завершаем игру. if (GameStatus == GameStatusType.Stopped && EndTime != null && curTime > EndTime?.AddMinutes(Setting.GameClosingDurationMin)) { GameStatus = GameStatusType.Ended; SendBroadcastMessage("Приём кодов завершён."); } } }
public void getappointment(DataTable dt) { try { string dr_color = "0", dr_mobile = "0", dr_email = ""; if (dt.Rows.Count > 0) { dr_color = dt.Rows[0]["calendar_color"].ToString(); name = "Dr " + dt.Rows[0]["doctor_name"].ToString(); dr_mobile = dt.Rows[0]["mobile_number"].ToString(); dr_email = dt.Rows[0]["email_id"].ToString(); } Dateonly = Convert.ToDateTime(DateTime.Now.ToLocalTime()); DateTime StartT, EndTime; StartT = dpStartTimeDate.Value.Date; EndTime = dpStartTimeDate.Value.Date; StartT = StartT.AddHours(cmbStartTime.SelectedIndex / 12); EndTime = EndTime.AddHours(cmbEndTime.SelectedIndex / 12); int md = cmbStartTime.SelectedIndex % 12; int en_ms = cmbEndTime.SelectedIndex % 12; StartT1 = StartT.AddMinutes(md * 5); EndTime = EndTime.AddMinutes(en_ms * 5); var diff = EndTime.Subtract(StartT); diff1 = Convert.ToString(diff.Minutes); if (Dateonly > StartT) { MessageBox.Show("Appointment Date should be greater than Current Date...", "Appointment", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (cmbStartTime.SelectedIndex <= cmbEndTime.SelectedIndex) { if (appointment_id != "") { j = this.ctrlr.apntupdate(Convert.ToDateTime(StartT1).ToString("yyyy-MM-dd HH:mm"), diff1, txtDescription.Text, dr_id, compoprocedure.Text, name, appointment_id); this.ctrlr.save_log(doctor_id, "Appointment", "logged user edits appointment", "Edit"); } else { j = this.ctrlr.insappointment(Convert.ToDateTime(Dateonly).ToString("yyyy-MM-dd"), Convert.ToDateTime(StartT1).ToString("yyyy-MM-dd H:mm:ss"), diff1, txtDescription.Text, patient_id, linkLabel_Name.Text, dr_id, p_mobile, p_email, compoprocedure.Text, name); this.ctrlr.save_log(doctor_id, "Appointment", "logged user adds new appointment", "Add"); } if (checkBox1.Checked) { DataTable sms = this.ctrlr.smsdetails(); smsdetails(sms); DataTable ptnt = this.ctrlr.Get_Patient_Details(patient_id); Get_Patient_Details(ptnt); DataTable rem = this.ctrlr.smsreminder(); smsreminder(rem); } if (checkBox3.Checked) { if (dr_mobile != "0") { string number = "91" + dr_mobile; string type = "LNG"; text = "You have an appointment on " + dpStartTimeDate.Value.ToShortDateString() + " " + cmbStartTime.Text + " With " + patient_name + " for " + compoprocedure.Text + " at " + clinicn + "," + contact_no; string smsdctr = this.ctrlr.SendSMS(smsName, smsPass, number, text, type); //For Remainder SMS if (day_time != null) { if (dpStartTimeDate.Value > DateTime.Now.Date) { text = "You have an appointment on " + dpStartTimeDate.Value.ToShortDateString() + " " + cmbStartTime.Text + " With " + patient_name + " for " + compoprocedure.Text + " at " + clinicn + "," + contact_no; string smsdctr2 = this.ctrlr.SendSMS(smsName, smsPass, number, text, "DRTOMS", patient_id.ToString(), StartT1.ToString("dd/MM/yyyy") + " 09:10:00 am", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")); } } if (before_time != null) { if (dpStartTimeDate.Value > DateTime.Now.Date) { text = "You have an appointment on " + dpStartTimeDate.Value.ToShortDateString() + " " + cmbStartTime.Text + " With " + patient_name + " for " + compoprocedure.Text + " at " + clinicn + "," + contact_no; string smsdctr3 = this.ctrlr.SendSMS(smsName, smsPass, number, text, "DRTOMS", patient_id.ToString(), StartT1.ToString("dd/MM/yyyy") + before_time, DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")); } } } }//Doctor SMS End if (checkBox2.Checked) { DataTable email = this.ctrlr.send_email(); send_email(email); }// email end if (checkBox4.Checked) // Doctor Email { if (dr_email != "") { DataTable email = this.ctrlr.send_email(); send_email(email); } }// Doctor Email end if (j > 0) { var form2 = new PappyjoeMVC.View.Show_Appointment(); form2.patient_id = patient_id; form2.doctor_id = doctor_id; form2.Closed += (sender1, args) => this.Close(); this.Hide(); form2.Show(); } else { MessageBox.Show("Inseration Failed!..", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Appointment Time is incorrect,Please change the time", "Appointment", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error !..", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//对期号查询进行处理 private void IssueInquiry(string TransMessage) { System.Xml.XmlDocument XmlDoc = new XmlDocument(); XmlDoc.Load(new StringReader(TransMessage)); System.Xml.XmlNodeList nodes = XmlDoc.GetElementsByTagName("response"); System.Xml.XmlNodeList nodesIssue = XmlDoc.GetElementsByTagName("issue"); string LotteryName = ""; string Number = ""; DateTime StartTime; DateTime EndTime; if (nodes != null) { if (nodes[0].Attributes["code"].Value == "0000") { if (nodesIssue != null) { for (int i = 0; i < nodesIssue.Count; i++) { LotteryName = nodesIssue[i].Attributes["gameName"].Value; //彩种 Number = nodesIssue[i].Attributes["number"].Value; //期号 StartTime = DateTime.Parse(nodesIssue[i].Attributes["startTime"].Value); //奖期开始时间 EndTime = DateTime.Parse(nodesIssue[i].Attributes["stopTime"].Value); //奖期结束时间 int LotteryID = GetLotteryID(LotteryName); if (LotteryName == "ssc") { string IntervalType = DAL.Functions.F_GetLotteryIntervalType(LotteryID); int Interval = int.Parse(IntervalType.Substring(1, IntervalType.IndexOf(";") - 1)); StartTime = EndTime.AddMinutes(-Interval); } if (LotteryID > 0) { if (new DAL.Tables.T_Isuses().GetCount("LotteryID = " + LotteryID.ToString() + " and [Name] = '" + Shove._Web.Utility.FilteSqlInfusion(Number) + "'") < 1) { long IssueID = -1; string ReturnDescription = ""; if (DAL.Procedures.P_IsuseAdd(LotteryID, Number, StartTime, EndTime, "", ref IssueID, ref ReturnDescription) < 0) { new Log("ElectronTicket\\HPCQ").Write("写入恒朋-重庆电子票网关通知的期号错误,彩种:" + LotteryName + ",期号:" + Number); return; } if (IssueID < 0) { new Log("ElectronTicket\\HPCQ").Write("写入恒朋-重庆电子票网关通知的期号错误:" + ReturnDescription + ",彩种:" + LotteryName + ",期号:" + Number); return; } } } System.Threading.Thread.Sleep(2000); //进行休眠两秒 } } } } }
private void cmdOK_Click(object sender, EventArgs e) { try { string neworold = "0"; DataTable dtpSearch = new DataTable(); DataTable dtb = this.cntrl.patient_details(txt_p_name.Text); Appointment_for_newPAtient(dtb); if (cmbStartTime.SelectedIndex <= cmbEndTime.SelectedIndex) { if (patient_id != "0") { string dr_id = combodoctor.GetItemText(combodoctor.SelectedValue); string dr_color = "0"; long app_id = 0; DateTime Dateonly = DateTime.Now.Date; string dr_mobile = "0"; string dr_email = ""; DataTable dt_d = this.cntrl.Get_calenderColor(dr_id); if (dt_d.Rows.Count > 0) { dr_color = dt_d.Rows[0][0].ToString(); dr_mobile = dt_d.Rows[0][1].ToString(); dr_email = dt_d.Rows[0][2].ToString(); } string diff1 = "0"; DateTime StartTime1 = DateTime.Now.Date; // string Stime; if (EditingEvent.RecurrenceState == CalendarEventRecurrenceState.xtpCalendarRecurrenceNotRecurring || EditingEvent.RecurrenceState == CalendarEventRecurrenceState.xtpCalendarRecurrenceException) { DateTime StartTime, EndTime; StartTime = dpStartTimeDate.Value; EndTime = dpStartTimeDate.Value; StartTime = StartTime.AddHours(cmbStartTime.SelectedIndex / 12); EndTime = EndTime.AddHours(cmbEndTime.SelectedIndex / 12); int st_ms = 0; st_ms = cmbStartTime.SelectedIndex % 12; StartTime = StartTime.AddMinutes(st_ms * 5); st_ms = cmbEndTime.SelectedIndex % 12; EndTime = EndTime.AddMinutes(st_ms * 5); EditingEvent.StartTime = StartTime; EditingEvent.EndTime = EndTime; var diff = EndTime.Subtract(StartTime); if (diff.Hours.ToString() != "") { int valh = diff.Hours; valh = valh * 60; int valm = diff.Minutes; diff1 = Convert.ToString(valh + valm); } else { diff1 = Convert.ToString(diff.Minutes); } StartTime1 = StartTime; } DateTime Dateonly1 = DateTime.Now; //if (Dateonly1 > StartTime1) //{ // MessageBox.Show("Appointment Date should be greater than Current Date...", "Appointment", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} if (IsNewEvent) { DateTime StartT; StartT = dpStartTimeDate.Value; StartT = StartT.AddHours(cmbStartTime.SelectedIndex / 12); int md = cmbStartTime.SelectedIndex % 12; StartT = StartT.AddMinutes(md * 5); //*********Booking Name***********// string Name = ""; DataTable doctor = this.cntrl.get_doctor_login(PappyjoeMVC.Model.Connection.MyGlobals.Doctor_id); if (doctor.Rows.Count > 0) { if (doctor.Rows[0]["login_type"].ToString() == "doctor") { Name = "Dr "; } Name = Name + doctor.Rows[0]["doctor_name"].ToString(); } dtpSearch = this.cntrl.patient_details_byname(txt_p_name.Text); if (dtpSearch.Rows.Count <= 0) { this.cntrl.insappointment(Convert.ToDateTime(Dateonly).ToString("yyyy-MM-dd"), Convert.ToDateTime(StartT).ToString("yyyy-MM-dd HH:mm"), diff1, txtDescription.Text, patient_id, txt_p_name.Text, dr_id, txt_p_mobile.Text, txt_p_email.Text, compoprocedure.Text, Name); this.cntrl.save_log(doctor_id, "Appointment", "logged user adds new appointment", "Add"); } else { this.cntrl.insappointment(Convert.ToDateTime(Dateonly).ToString("yyyy-MM-dd"), Convert.ToDateTime(StartT).ToString("yyyy-MM-dd HH:mm"), diff1, txtDescription.Text, patient_id, patient_name, dr_id, lab_p_ph.Text, lab_p_email.Text, compoprocedure.Text, Name); this.cntrl.save_log(doctor_id, "Appointment", "logged user adds new appointment", "Add"); } DataTable dt_a = this.cntrl.appointmentId(); if (dt_a.Rows.Count > 0) { app_id = Convert.ToInt32(dt_a.Rows[dt_a.Rows.Count - 1][0].ToString()); } EditingEvent.Subject = patient_name; EditingEvent.Location = Convert.ToString(cmbStartTime.GetItemText(cmbStartTime.SelectedItem)) + "-" + Convert.ToString(cmbEndTime.GetItemText(cmbEndTime.SelectedItem)); EditingEvent.Body = Convert.ToString(app_id); EditingEvent.Label = Convert.ToInt32(dr_color); EditingEvent.AllDayEvent = (chkAllDayEvent.Checked ? true : false); EditingEvent.BusyStatus = (CalendarEventBusyStatus)cmbShowTimeAs.SelectedIndex; EditingEvent.PrivateFlag = (chkPrivate.Checked ? true : false); EditingEvent.MeetingFlag = (chkMeeting.Checked ? true : false); EditingEvent.Reminder = chkReminder.Checked; if (EditingEvent.Reminder) { CalReminderMinutes pRmd = (CalReminderMinutes)cmbReminder.SelectedItem; if (pRmd != null) { EditingEvent.ReminderMinutesBeforeStart = pRmd.m_nMinutes; } } Main_Calendar.Instance.wndCalendarControl.DataProvider.AddEvent(EditingEvent); string clinic = "", locality = "", contact_no = ""; System.Data.DataTable clinicname = this.cntrl.clinicdetails(); clinic = clinicname.Rows[0]["name"].ToString(); contact_no = clinicname.Rows[0]["contact_no"].ToString(); if (checkBox1.Checked) { string text = ""; string smsName = "", smsPass = ""; DataTable sms = this.cntrl.smsdetails(); if (sms.Rows.Count > 0) { smsName = sms.Rows[0]["smsName"].ToString(); smsPass = sms.Rows[0]["smsPass"].ToString(); } SMS_model a = new SMS_model(); DataTable pat = this.cntrl.Get_Patient_Details(patient_id); DataTable smsreminder = this.cntrl.Get_reminderSmS(); DataTable smslanguage = this.cntrl.sms_lang(); if (smsreminder.Rows.Count > 0) { send_on_day = smsreminder.Rows[0]["send_on_day"].ToString(); send_before_day = smsreminder.Rows[0]["send_before_day"].ToString(); day_time = smsreminder.Rows[0]["day_time"].ToString(); before_time = smsreminder.Rows[0]["day_time"].ToString(); } if (pat.Rows.Count > 0) { string number = "91" + pat.Rows[0]["primary_mobile_number"].ToString(); string type = "LNG"; if (neworold == "1") { a.SendSMS(smsName, smsPass, number, "Dear " + pat.Rows[0]["pt_name"].ToString() + " welcome to " + clinic + "," + contact_no, type); } if (smslanguage.Rows.Count > 0) { string smslang = smslanguage.Rows[0]["Prescription_lang"].ToString(); DataTable smstemplate = this.cntrl.smstemplate(smslang, pat.Rows[0]["pt_name"].ToString(), compoprocedure.Text, StartT.ToString("dd/MM/yyyy"), cmbStartTime.Text, combodoctor.Text, clinic, contact_no); if (smstemplate.Rows.Count > 0) { text = smstemplate.Rows[0]["Template"].ToString(); a.SendSMS(smsName, smsPass, number, text, type); this.cntrl.save_Pt_SMS(patient_id, pat.Rows[0]["pt_name"].ToString(), compoprocedure.Text, StartT.ToString("dd/MM/yyyy"), cmbStartTime.Text, combodoctor.Text); }// } string sddsds = ""; //text = "Dear " + pat.Rows[0]["pt_name"].ToString() + " " + "Your appointment for " + compoprocedure.Text + " has been confirmed at " + StartT.ToString("dd/MM/yyyy") + " " + cmbStartTime.Text + " with " + "Dr " + combodoctor.Text + " Regards " + clinic + "," + contact_no; //a.SendSMS(smsName, smsPass, number, text); //this.cntrl.save_Pt_SMS(patient_id, pat.Rows[0]["pt_name"].ToString(), compoprocedure.Text, StartT.ToString("dd/MM/yyyy"), cmbStartTime.Text, combodoctor.Text); ////For Reminder SMS----- if (day_time != null) { if (dpStartTimeDate.Value > DateTime.Now.Date) { text = "Dear " + pat.Rows[0]["pt_name"].ToString() + ", " + "Today you have an appointment at " + clinic + " on " + StartT.ToString("dd/MM/yyyy") + " " + cmbStartTime.Text + " for " + compoprocedure.Text + " .Regards " + clinic + "," + contact_no; a.SendSMS(smsName, smsPass, number, text, "DRTOMS", patient_id.ToString(), StartT.ToString("dd/MM/yyyy") + " 09:10:00 am", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")); } } if (before_time != null) { if (dpStartTimeDate.Value > DateTime.Now.Date) { text = "Dear " + pat.Rows[0]["pt_name"].ToString() + ", " + "Today you have an appointment at " + clinic + " on " + StartT.ToString("dd/MM/yyyy") + " " + cmbStartTime.Text + " for " + compoprocedure.Text + " .Regards " + clinic + "," + contact_no; a.SendSMS(smsName, smsPass, number, text, "DRTOMS", patient_id.ToString(), StartT.ToString("dd/MM/yyyy") + before_time, DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")); } } } } if (checkBox3.Checked) { if (dr_mobile != "0") { string text = ""; string smsName = "", smsPass = ""; SMS_model a = new SMS_model(); string number = "91" + dr_mobile; string type = "LNG"; text = "You have an appointment on " + dpStartTimeDate.Value.ToShortDateString() + " " + cmbStartTime.Text + " With " + txt_p_name.Text + " for " + compoprocedure.Text + " at " + clinic + "," + contact_no; a.SendSMS(smsName, smsPass, number, text, type); //For Remainder SMS if (day_time != null) { if (dpStartTimeDate.Value > DateTime.Now.Date) { text = "You have an appointment on " + dpStartTimeDate.Value.ToShortDateString() + " " + cmbStartTime.Text + " With " + txt_p_name.Text + " for " + compoprocedure.Text + " at " + clinic + "," + contact_no; // a.SendSMS(smsName, smsPass, number, text); a.SendSMS(smsName, smsPass, number, text, "DRTOMS", patient_id.ToString(), StartT.ToString("dd/MM/yyyy") + " 09:10:00 am", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")); } } if (before_time != null) { if (dpStartTimeDate.Value > DateTime.Now.Date) { text = "You have an appointment on " + dpStartTimeDate.Value.ToShortDateString() + " " + cmbStartTime.Text + " With " + txt_p_name.Text + " for " + compoprocedure.Text + " at " + clinic + "," + contact_no; a.SendSMS(smsName, smsPass, number, text, "DRTOMS", patient_id.ToString(), StartT.ToString("dd/MM/yyyy") + before_time, DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")); } } } } if (checkBox2.Checked) { string email = "", emailName = "", emailPass = ""; string query = "select email_address,pt_name from tbl_patient where id='" + patient_id + "'"; DataTable sr = this.cntrl.getpatemail(patient_id); if (sr.Rows.Count > 0) { email = sr.Rows[0]["email_address"].ToString(); DataTable sms = this.cntrl.send_email(); if (sms.Rows.Count > 0) { emailName = sms.Rows[0]["emailName"].ToString(); emailPass = sms.Rows[0]["emailPass"].ToString(); try { string sr1 = "<table align='center' style='width:700px;border: 1px solid ;border-collapse: collapse; background: #EAEAEA; height:500px'><tr><td align='left' height='27'><FONT color='#666666' face='Arial' SIZE=2> Appointment Reminder:" + dpStartTimeDate.Value.ToString("ddd, dd MMM yyyy") + ' ' + cmbStartTime.Text + " @ " + clinic + "</font></td></tr><tr><td align='left' height='400px'><table height='423' align='center' style='width:600px; background: #FFFFFF; height:400px'><tr><td align='left' height='6px'><FONT color='#000000' face='Arial' SIZE=6>" + clinic + "</font></td></tr><tr><td align='left' height='1px' bgcolor='#666666'></td></tr><tr><td align='left' height='62' valign='bottom'><FONT color='#000000' face='Arial' SIZE=3>Good morning <b>" + sr.Rows[0]["pt_name"].ToString() + "</b></font></td></tr> <tr><td align='left' height='197' valign='top'> Just to remind you about your appointment at " + clinic + ".<table><tbody><tr><td width='188' height='31' valign='bottom' align='right'>WHEN :</td><td width='30' height='31' valign='bottom' align='right'></td><td width='358' valign='bottom'> <strong>" + dpStartTimeDate.Value.ToString("ddd, dd MMM yyyy") + ' ' + cmbStartTime.Text + "</strong></td> </tr><tr><td height='76' valign='top' align='right'>WHERE :</td><td width='30' height='31' valign='bottom' align='right'></td><td valign='top'>" + locality + "</td></tr></tbody></table> For any queries, contact us at : " + contact_no + "</td> </tr><tr><td align='left' height='1px' bgcolor='#666666'></td></tr> <tr><td height='25' align='right' valign='bottom'>Powered by </td></tr> <tr><td height='81' align='right' valign='top'><img src='http://pappyjoe.com/assets/images/pappyjoe-logo.PNG' alt='pappyjoe official logo'> </td></tr></table></td></tr></table>"; MailMessage message = new MailMessage(); message.From = new MailAddress(email); message.To.Add(email); message.BodyEncoding = System.Text.Encoding.GetEncoding(1252); //bijeesh message.IsBodyHtml = true; //bijeesh SmtpClient smtp = new SmtpClient("smtp.gmail.com"); message.Subject = "Appointment Reminder: " + dpStartTimeDate.Value.ToString("ddd, dd MMM yyyy") + ' ' + cmbStartTime.Text + " @ " + clinic; message.Body = sr1.ToString(); smtp.Port = 587; smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential(emailName, emailPass); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Send(message); } catch (Exception ex) { } } } } if (checkBox4.Checked) // Doctor Email { string emailName = "", emailPass = ""; if (dr_email != "") { DataTable sms = this.cntrl.send_email(); if (sms.Rows.Count > 0) { emailName = sms.Rows[0]["emailName"].ToString(); emailPass = sms.Rows[0]["emailPass"].ToString(); try { string sr1 = "<table align='center' style='width:700px;border: 1px solid ;border-collapse: collapse; background: #EAEAEA; height:500px'><tr><td align='left' height='27'><FONT color='#666666' face='Arial' SIZE=2> Appointment Reminder:" + dpStartTimeDate.Value.ToString("ddd, dd MMM yyyy") + ' ' + cmbStartTime.Text + " @ " + clinic + "</font></td></tr><tr><td align='left' height='400px'><table height='423' align='center' style='width:600px; background: #FFFFFF; height:400px'><tr><td align='left' height='6px'><FONT color='#000000' face='Arial' SIZE=6>" + clinic + "</font></td></tr><tr><td align='left' height='1px' bgcolor='#666666'></td></tr><tr><td align='left' height='62' valign='bottom'><FONT color='#000000' face='Arial' SIZE=3>Dear <b>" + combodoctor.Text + "</b></font></td></tr> <tr><td align='left' height='197' valign='top'> Just to remind you about your appointment at " + clinic + ".<table><tbody><tr><td width='188' height='31' valign='bottom' align='right'>WHEN :</td><td width='30' height='31' valign='bottom' align='right'></td><td width='358' valign='bottom'> <strong>" + dpStartTimeDate.Value.ToString("ddd, dd MMM yyyy") + ' ' + cmbStartTime.Text + "</strong></td> </tr><tr><td height='31' valign='top' align='right'>PATIENT :</td><td width='30' height='31' valign='bottom' align='right'></td><td valign='top'>" + txt_p_name.Text + "</td></tr><tr><td height='76' valign='top' align='right'>FOR :</td><td width='30' height='31' valign='bottom' align='right'></td><td valign='top'>" + compoprocedure.Text + "</td></tr></tbody></table> For any queries, contact us at : " + contact_no + "</td> </tr><tr><td align='left' height='1px' bgcolor='#666666'></td></tr> <tr><td height='25' align='right' valign='bottom'>Powered by </td></tr> <tr><td height='81' align='right' valign='top'><img src='http://pappyjoe.com/assets/images/pappyjoe-logo.PNG' alt='pappyjoe official logo'> </td></tr></table></td></tr></table>"; MailMessage message = new MailMessage(); message.From = new MailAddress(dr_email); message.To.Add(dr_email); message.BodyEncoding = System.Text.Encoding.GetEncoding(1252); //bijeesh message.IsBodyHtml = true; //bijeesh SmtpClient smtp = new SmtpClient("smtp.gmail.com"); message.Subject = "Appointment(s) scheduled for Today: " + dpStartTimeDate.Value.ToString("ddd, dd MMM yyyy") + ' ' + cmbStartTime.Text + " @ " + clinic; message.Body = sr1.ToString(); smtp.Port = 587; smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential(emailName, emailPass); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Send(message); } catch (Exception ex) { } } } }// Doctor Email end } else { DateTime StartT; StartT = dpStartTimeDate.Value; StartT = StartT.AddHours(cmbStartTime.SelectedIndex / 12); int md = cmbStartTime.SelectedIndex % 12; StartT = StartT.AddMinutes(md * 5); EditingEvent.Subject = patient_name; EditingEvent.Location = Convert.ToString(cmbStartTime.GetItemText(cmbStartTime.SelectedItem)) + "-" + Convert.ToString(cmbEndTime.GetItemText(cmbEndTime.SelectedItem)); EditingEvent.Body = Convert.ToString(gpl_app_id); EditingEvent.Label = Convert.ToInt32(dr_color); if (cmbStartTime.SelectedIndex % 2 > 0) { StartT = StartT.AddMinutes(30); } this.cntrl.update_appointment(Convert.ToDateTime(StartT), diff1, txtDescription.Text, compoprocedure.Text, patient_id, patient_name, dr_id, lab_p_ph.Text, lab_p_email.Text, gpl_app_id); } EditingEvent = null; Main_Calendar.Instance.ContextEvent = null; Main_Calendar.Instance.wndCalendarControl.Populate(); Main_Calendar.Instance.wndCalendarControl.RedrawControl(); if (Convert.ToDateTime(DateTime.Today.ToString("d")) == dpStartTimeDate.Value) { Main_Calendar.Instance.listAppointment("0"); } this.Close(); Main_Calendar.Instance.Activate(); } else { } } else { MessageBox.Show("Appointment Date should be greater than Current Date...", "Appointment", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (dtpSearch.Rows.Count <= 0) { status1 = 1; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Note Add a new event private void cmdOK_Click(object sender, System.EventArgs e) { if (EditingEvent.RecurrenceState == CalendarEventRecurrenceState.xtpCalendarRecurrenceNotRecurring || EditingEvent.RecurrenceState == CalendarEventRecurrenceState.xtpCalendarRecurrenceException) { DateTime StartTime, EndTime; StartTime = dpStartTimeDate.Value; EndTime = dpEndTimeDate.Value; StartTime = StartTime.AddHours(cmbStartTime.SelectedIndex / 2); EndTime = EndTime.AddHours(cmbEndTime.SelectedIndex / 2); if (cmbStartTime.SelectedIndex % 2 > 0) { StartTime = StartTime.AddMinutes(30); } if (cmbEndTime.SelectedIndex % 2 > 0) { EndTime = EndTime.AddMinutes(30); } EditingEvent.StartTime = StartTime; EditingEvent.EndTime = EndTime; } EditingEvent.Subject = txtSubject.Text; EditingEvent.Location = txtLocation.Text; EditingEvent.Body = txtDescription.Text; EditingEvent.AllDayEvent = (chkAllDayEvent.Checked ? true : false); EditingEvent.Label = cmbLabel.SelectedIndex; EditingEvent.BusyStatus = (CalendarEventBusyStatus)cmbShowTimeAs.SelectedIndex; EditingEvent.PrivateFlag = (chkPrivate.Checked ? true : false); EditingEvent.MeetingFlag = (chkMeeting.Checked ? true : false); EditingEvent.Reminder = chkReminder.Checked; if (EditingEvent.Reminder) { CalReminderMinutes pRmd = (CalReminderMinutes)cmbReminder.SelectedItem; if (pRmd != null) { EditingEvent.ReminderMinutesBeforeStart = pRmd.m_nMinutes; } } if (IsNewEvent) { frmMain.Instance.wndCalendarControl.DataProvider.AddEvent(EditingEvent); } else { frmMain.Instance.wndCalendarControl.DataProvider.ChangeEvent(EditingEvent); } EditingEvent = null; frmMain.Instance.ContextEvent = null; frmMain.Instance.wndCalendarControl.Populate(); frmMain.Instance.wndCalendarControl.RedrawControl(); this.Close(); frmMain.Instance.Activate(); }