public ActionResult DoctorAppointmentSchedule(DoctorAppointmentSchedule location) { try { Buisness_Logic.Master.BL_AddDoctorAppointment Bl_obj = new Buisness_Logic.Master.BL_AddDoctorAppointment(); if (location.AppointmentType == "Monthly") { if (Request.Form["month"] != null) { location.monthweek = Request.Form["month"].ToString(); } } if (location.AppointmentType == "Weekly") { if (Request.Form["week1"] != null) { location.monthweek = Request.Form["week1"].ToString(); } } int ID = location.DoctorAppoinmentScheduleID; if (Bl_obj.save(location)) { if (ID > 0) { TempData["msg"] = "DoctorAppointment Updated Successfully"; ModelState.Clear(); } else { TempData["msg"] = "DoctorAppointment Saved Successfully"; ModelState.Clear(); } } location.StoreAllDoctorAppointment = Bl_obj.SelectAllDoctorAppointment(); return(RedirectToAction("DoctorAppointmentSchedule", "DoctorAppointmentSchedule", location)); } catch (Exception ex) { TempData["msg"] = ex.Message; return(RedirectToAction("DoctorAppointmentSchedule", "DoctorAppointmentSchedule", location)); } }
public bool save(DoctorAppointmentSchedule obd) { bool flag; try { Connect(); con.Open(); SqlCommand cmd = new SqlCommand("IUDoctorAppointmentSchedule", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@HospitalID", HospitalID); cmd.Parameters.AddWithValue("@LocationID", LocationID); if (obd.DoctorAppoinmentScheduleID == 0) { cmd.Parameters.AddWithValue("@DoctorAppoinmentScheduleID", 0); cmd.Parameters.AddWithValue("@Mode", "Add"); cmd.Parameters["@DoctorAppoinmentScheduleID"].Direction = ParameterDirection.Output; } else { cmd.Parameters.AddWithValue("@DoctorAppoinmentScheduleID", obd.DoctorAppoinmentScheduleID); cmd.Parameters.AddWithValue("@Mode", "Edit"); } //cmd.Parameters.AddWithValue("@DoctorID", obd.DoctorID); if (obd.DoctorID == null) { cmd.Parameters.AddWithValue("@DoctorID", 0); } else { cmd.Parameters.AddWithValue("@DoctorID", obd.DoctorID); } //cmd.Parameters.AddWithValue("@ReferenceCode", 1); cmd.Parameters.AddWithValue("@AppointmentType ", obd.AppointmentType); cmd.Parameters.AddWithValue("@EndDurationDate", DBNull.Value); cmd.Parameters.AddWithValue("@NoOfAppointment", obd.NoOfAppointment); cmd.Parameters.AddWithValue("@PerAppointmentTimeinMinute", obd.PerAppointmentTimeinMinute); //cmd.Parameters.AddWithValue("@FromDate", obd.FromDate); if (obd.FromDate == null) { SqlParameter param1 = new SqlParameter { ParameterName = "@FromDate", SqlDbType = SqlDbType.Date, Value = obd.FromDate.ToString("yyyy-MM-dd") }; cmd.Parameters.Add(param1); //cmd.Parameters.AddWithValue("@FromDate", obd.FromDate); } else { SqlParameter param1 = new SqlParameter { ParameterName = "@FromDate", SqlDbType = SqlDbType.Date, Value = DateTime.Now.ToString("yyyy-MM-dd") }; cmd.Parameters.Add(param1); } // cmd.Parameters.AddWithValue("@FromDate", obd.FromDate); cmd.Parameters.AddWithValue("@FromTime", obd.FromTime.ToString("HH:mm tt")); cmd.Parameters.AddWithValue("@ToTime", obd.ToTime.ToString("HH:mm tt")); //cmd.Parameters.AddWithValue("@EndDurationDate", obd.EndDurationDate); cmd.Parameters.AddWithValue("@EndDurationStatus", obd.EndDurationStatus); cmd.Parameters.AddWithValue("@CreationID", UserID); int i = cmd.ExecuteNonQuery(); if (i == 1) { obd.DoctorAppoinmentScheduleID = Convert.ToInt32(cmd.Parameters["@DoctorAppoinmentScheduleID"].Value); } con.Close(); if (obd.DoctorAppoinmentScheduleID > 0) { //string[] day; if (obd.monthweek == null) { obd.monthweek = ""; } string[] day = obd.monthweek.Split(','); for (int j = 0; j < day.Length; j++) { if (obd.AppointmentType == "Weekly") { { con.Open(); SqlCommand cmd1 = new SqlCommand("IUDoctorAppointmentScheduleDetail", con); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@HospitalID", HospitalID); cmd1.Parameters.AddWithValue("@LocationID", LocationID); cmd1.Parameters.AddWithValue("@DoctorAppoinmentScheduleDetailID", 0); cmd1.Parameters.AddWithValue("@DoctorAppoinmentScheduleID", obd.DoctorAppoinmentScheduleID); cmd1.Parameters.AddWithValue("@AppointmentType", obd.AppointmentType); cmd1.Parameters.AddWithValue("@DayDate", day[j]); cmd1.Parameters.AddWithValue("@CreationID", UserID); cmd1.Parameters.AddWithValue("@Mode", "Add"); int cmf = cmd1.ExecuteNonQuery(); con.Close(); } } else if (obd.AppointmentType == "Monthly") { con.Open(); SqlCommand cmd1 = new SqlCommand("IUDoctorAppointmentScheduleDetail", con); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@HospitalID", HospitalID); cmd1.Parameters.AddWithValue("@LocationID", LocationID); cmd1.Parameters.AddWithValue("@DoctorAppoinmentScheduleDetailID", 0); cmd1.Parameters.AddWithValue("@DoctorAppoinmentScheduleID", obd.DoctorAppoinmentScheduleID); cmd1.Parameters.AddWithValue("@AppointmentType", obd.AppointmentType); cmd1.Parameters.AddWithValue("@DayDate", day[j]); cmd1.Parameters.AddWithValue("@CreationID", UserID); cmd1.Parameters.AddWithValue("@Mode", "Add"); int cmf = cmd1.ExecuteNonQuery(); con.Close(); } } if (obd.monthweek == "") { con.Open(); SqlCommand cmd1 = new SqlCommand("IUDoctorAppointmentScheduleDetail", con); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@HospitalID", HospitalID); cmd1.Parameters.AddWithValue("@LocationID", LocationID); cmd1.Parameters.AddWithValue("@DoctorAppoinmentScheduleDetailID", 0); cmd1.Parameters.AddWithValue("@DoctorAppoinmentScheduleID", obd.DoctorAppoinmentScheduleID); cmd1.Parameters.AddWithValue("@AppointmentType", obd.AppointmentType); cmd1.Parameters.AddWithValue("@DayDate", obd.AppointmentType); cmd1.Parameters.AddWithValue("@CreationID", UserID); cmd1.Parameters.AddWithValue("@Mode", "Add"); int cmf = cmd1.ExecuteNonQuery(); con.Close(); } flag = true; } else { flag = false; } } #pragma warning disable CS0168 // The variable 'ex' is declared but never used catch (Exception ex) #pragma warning restore CS0168 // The variable 'ex' is declared but never used { flag = false; } return(flag); }