public ActionResult BindFromToTime1(string AppointmentType, string DoctorID, string AppointmentDate) { string Mode = ""; BL_PatientAppointmentSchedule _PatientAppointment = new BL_PatientAppointmentSchedule(); PatientAppointment.PatientAppointmentNO = AppointmentType; PatientAppointment.DoctorID = DoctorID; DataSet dsDoctorTimedetail = new DataSet(); if (PatientAppointment.PatientAppointmentNO == "Weekly") { dsDoctorTimedetail = _PatientAppointment.GetPatientAppointmentDetailForDoctorDetail(HospitalID, LocationID, Convert.ToInt32(PatientAppointment.DoctorID), PatientAppointment.PatientAppointmentNO, Convert.ToString(Convert.ToDateTime(AppointmentDate).DayOfWeek.ToString()), Convert.ToDateTime(AppointmentDate)); } else if (PatientAppointment.PatientAppointmentNO == "Monthly") { dsDoctorTimedetail = _PatientAppointment.GetPatientAppointmentDetailForDoctorDetail(HospitalID, LocationID, Convert.ToInt32(PatientAppointment.DoctorID), PatientAppointment.PatientAppointmentNO, Convert.ToString(Convert.ToDateTime(AppointmentDate).Day), Convert.ToDateTime(AppointmentDate)); } else { dsDoctorTimedetail = _PatientAppointment.GetPatientAppointmentDetailForDoctorDetail(HospitalID, LocationID, Convert.ToInt32(PatientAppointment.DoctorID), PatientAppointment.PatientAppointmentNO, "Daily", Convert.ToDateTime(AppointmentDate)); } GetEmptyDatasetPatientSchedule(); //foreach (DataRow drMainDetail in dsDoctorTimedetail.Tables[0].Rows) //{ string FromTime; string ToTime; // // DateTime Endtime; // FromTime = Convert.ToDateTime(drMainDetail["FromTime"]).ToString("hh:mm:ss"); // Totime = Convert.ToDateTime(drMainDetail["ToTime"]).ToString("hh:mm:ss"); //} // if (dsDoctorTimedetail.Tables[0].Rows.Count > 0) // { // int PerAppointment = 0; // //Endtime = Convert.ToDateTime(drMainDetail["ToTime"].ToString()); // PerAppointment = Convert.ToInt32(drMainDetail["PerAppointmentTimeinMinute"].ToString()); // if (PatientAppointment.PatientAppointmentNO != "OnCalls") // { // for (int i = 1; Convert.ToInt32(drMainDetail["NoOfAppointment"].ToString()) >= i; i++) // { // DataView dvDetail = new DataView(dsDoctorTimedetail.Tables[1], "DoctorAppoinmentScheduleID = " + drMainDetail["DoctorAppoinmentScheduleID"].ToString() + " and NoOfAppointment = " + i + "", "", DataViewRowState.CurrentRows); // Totime = Convert.ToDateTime(FromTime).AddMinutes(+PerAppointment).ToString("hh:mm:ss"); // if (Mode.ToString() == "Edit") // { // if (i == NoOfAppointment) // { // dvDetail = new DataView(dsDoctorTimedetail.Tables[1], "DoctorAppoinmentScheduleID = " + drMainDetail["DoctorAppoinmentScheduleID"].ToString() + " and NoOfAppointment = " + 0 + "", "", DataViewRowState.CurrentRows); // } // } // if (dvDetail.Count == 0) // { // DataRow dr = dsDoctorSchedule.Tables[0].NewRow(); // dr["FromTime"] = FromTime; // dr["ToTime"] = Totime; // dr["FromToTime"] = "" + Convert.ToDateTime(FromTime).TimeOfDay + " To " + Convert.ToDateTime(Totime).TimeOfDay + ""; // dr["DoctorAppoinmentScheduleID"] = drMainDetail["DoctorAppoinmentScheduleID"].ToString(); // dr["NoOfAppointment"] = i; // dsDoctorSchedule.Tables[0].Rows.Add(dr); // } // FromTime = Totime; // } // } // else // { // DataRow dr = dsDoctorSchedule.Tables[0].NewRow(); // dr["FromTime"] = Convert.ToString(FromTime); // dr["ToTime"] = Convert.ToString(Totime); // dr["FromToTime"] = "" + FromTime + " To " + Totime + ""; // dr["DoctorAppoinmentScheduleID"] = drMainDetail["DoctorAppoinmentScheduleID"].ToString(); // dr["NoOfAppointment"] = 0; // dsDoctorSchedule.Tables[0].Rows.Add(dr); // } // } //} // DataRow drAppointment = dsDoctorSchedule.Tables[0].NewRow(); List <string[]> fillFromTO = new List <string[]>(); List <string> fillFromTO1 = new List <string>(); foreach (DataRow dr in dsDoctorTimedetail.Tables[0].Rows) { fillFromTO.Add(new string[] { FromTime = Convert.ToDateTime(dr["FromTime"]).ToString("hh:mm"), ToTime = Convert.ToDateTime(dr["ToTime"]).ToString("hh:mm"), //FromTime = Convert.ToDateTime(dr["FromTime"].ToString("hh:mm:ss")), // ToTime= Convert.ToDateTime(dr["ToTime"].ToString("hh:mm:ss")) }); } //if (Mode.ToString() == "Edit") //{ // NoOfAppointment = 0; //} return(new JsonResult { Data = fillFromTO, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult BindFromToTime(string AppointmentType, string DoctorID, string AppointmentDate) { string Mode = ""; BL_PatientAppointmentSchedule _PatientAppointment = new BL_PatientAppointmentSchedule(); PatientAppointment.PatientAppointmentNO = AppointmentType; PatientAppointment.DoctorID = DoctorID; DataSet dsDoctorTimedetail = new DataSet(); if (PatientAppointment.PatientAppointmentNO == "Weekly") { dsDoctorTimedetail = _PatientAppointment.GetPatientAppointmentDetailForDoctorDetail(HospitalID, LocationID, Convert.ToInt32(PatientAppointment.DoctorID), PatientAppointment.PatientAppointmentNO, Convert.ToString(Convert.ToDateTime(AppointmentDate).DayOfWeek.ToString()), Convert.ToDateTime(AppointmentDate)); } else if (PatientAppointment.PatientAppointmentNO == "Monthly") { dsDoctorTimedetail = _PatientAppointment.GetPatientAppointmentDetailForDoctorDetail(HospitalID, LocationID, Convert.ToInt32(PatientAppointment.DoctorID), PatientAppointment.PatientAppointmentNO, Convert.ToString(Convert.ToDateTime(AppointmentDate).Day.ToString()), Convert.ToDateTime(AppointmentDate)); } else { dsDoctorTimedetail = _PatientAppointment.GetPatientAppointmentDetailForDoctorDetail(HospitalID, LocationID, Convert.ToInt32(PatientAppointment.DoctorID), PatientAppointment.PatientAppointmentNO, "Daily", Convert.ToDateTime(AppointmentDate)); } GetEmptyDatasetPatientSchedule(); foreach (DataRow drMainDetail in dsDoctorTimedetail.Tables[0].Rows) { if (dsDoctorTimedetail.Tables[0].Rows.Count > 0) { string FromTime; string Totime; DateTime Endtime; int PerAppointment = 0; string Totime1; if (dsDoctorTimedetail.Tables[3].Rows.Count > 0) { FromTime = Convert.ToDateTime(dsDoctorTimedetail.Tables[3].Rows[0]["FromTime"]).ToString("hh:mm tt"); Totime = Convert.ToDateTime(dsDoctorTimedetail.Tables[3].Rows[0]["ToTime"]).ToString("hh:mm tt"); Totime1 = Convert.ToDateTime(dsDoctorTimedetail.Tables[3].Rows[0]["ToTime"]).ToString("hh:mm tt"); } else { FromTime = Convert.ToDateTime(drMainDetail["FromTime"]).ToString("hh:mm tt"); Totime = Convert.ToDateTime(drMainDetail["ToTime"]).ToString("hh:mm tt"); Totime1 = Convert.ToDateTime(drMainDetail["ToTime"]).ToString("hh:mm tt"); } //Endtime = Convert.ToDateTime(drMainDetail["ToTime"].ToString()); PerAppointment = Convert.ToInt32(drMainDetail["PerAppointmentTimeinMinute"].ToString()); if (PatientAppointment.PatientAppointmentNO != "OnCalls") { for (int i = 1; Convert.ToInt32(drMainDetail["NoOfAppointment"].ToString()) >= i; i++) { DataView dvDetail = new DataView(dsDoctorTimedetail.Tables[1], "DoctorAppoinmentScheduleID = " + drMainDetail["DoctorAppoinmentScheduleID"].ToString() + " and NoOfAppointment = " + i + "", "", DataViewRowState.CurrentRows); Totime = Convert.ToDateTime(FromTime).AddMinutes(+PerAppointment).ToString("hh:mm tt"); if (Convert.ToDateTime(Totime) > Convert.ToDateTime(Totime1)) { break; } if (Mode.ToString() == "Edit") { if (i == NoOfAppointment) { dvDetail = new DataView(dsDoctorTimedetail.Tables[1], "DoctorAppoinmentScheduleID = " + drMainDetail["DoctorAppoinmentScheduleID"].ToString() + " and NoOfAppointment = " + 0 + "", "", DataViewRowState.CurrentRows); } } if (dvDetail.Count == 0) { DataRow dr = dsDoctorSchedule.Tables[0].NewRow(); dr["FromTime"] = FromTime; dr["ToTime"] = Totime; dr["FromToTime"] = "" + Convert.ToDateTime(FromTime).ToString("hh:mm tt") + " To " + Convert.ToDateTime(Totime).ToString("hh:mm tt") + ""; dr["DoctorAppoinmentScheduleID"] = drMainDetail["DoctorAppoinmentScheduleID"].ToString(); dr["NoOfAppointment"] = i; dsDoctorSchedule.Tables[0].Rows.Add(dr); } else { if (dsDoctorTimedetail.Tables[3].Rows.Count > 0) { Connect(); SqlCommand cmd = new SqlCommand("update PatientAppointmentDetails set FromTime='" + FromTime + "' , ToTime='" + Totime + "' where DoctorAppoinmentScheduleID=" + dsDoctorTimedetail.Tables[0].Rows[0]["DoctorAppoinmentScheduleID"].ToString() + " and NoOfAppointment=" + i + " and AppointmentDate='" + AppointmentDate + "' and HospitalID=" + HospitalID + " and LocationID=" + LocationID + " and RowStatus=0", con); con.Open(); int a = cmd.ExecuteNonQuery(); con.Close(); } } //--- FromTime = Totime; } } else { DataRow dr = dsDoctorSchedule.Tables[0].NewRow(); dr["FromTime"] = Convert.ToString(FromTime); dr["ToTime"] = Convert.ToString(Totime); dr["FromToTime"] = "" + FromTime + " To " + Totime + ""; dr["DoctorAppoinmentScheduleID"] = drMainDetail["DoctorAppoinmentScheduleID"].ToString(); dr["NoOfAppointment"] = 0; dsDoctorSchedule.Tables[0].Rows.Add(dr); } } } DataRow drAppointment = dsDoctorSchedule.Tables[0].NewRow(); List <string[]> fillFromTO = new List <string[]>(); List <string> fillFromTO1 = new List <string>(); if (dsDoctorTimedetail.Tables[3].Rows.Count > 0) { foreach (DataRow dr in dsDoctorTimedetail.Tables[3].Rows) { if (Convert.ToBoolean(dr["CancelAppointment"].ToString()) == true) { dsDoctorTimedetail.Reset(); return(new JsonResult { Data = "Doctor Not Comming", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } } foreach (DataRow dr in dsDoctorSchedule.Tables[0].Rows) { fillFromTO.Add(new string[] { dr["FromToTime"].ToString(), dr["NoOfAppointment"].ToString() }); } if (Mode.ToString() == "Edit") { NoOfAppointment = 0; } return(new JsonResult { Data = fillFromTO, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }