public static bool Save(DayCarePL.ChildScheduleProperties objChildSchedule) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clChildSchedule, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); SqlConnection conn = clConnection.CreateConnection(); try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clChildSchedule, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.OpenConnection(conn); SqlCommand cmd; if (objChildSchedule.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { cmd = clConnection.CreateCommand("spAddChildSchedule", conn); cmd.Parameters.Add(clConnection.GetInputParameter("@CreatedDateTime", DateTime.Now)); cmd.Parameters.Add(clConnection.GetInputParameter("@CreatedById", objChildSchedule.CreatedById)); } else { cmd = clConnection.CreateCommand("spUpdateChildSchedule", conn); } if (!objChildSchedule.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { cmd.Parameters.Add(clConnection.GetInputParameter("@Id", objChildSchedule.Id)); } cmd.Parameters.Add(clConnection.GetInputParameter("@ChildSchoolYearId", objChildSchedule.ChildSchoolYearId)); cmd.Parameters.Add(clConnection.GetInputParameter("@SchoolProgramId", objChildSchedule.SchoolProgramId)); //cmd.Parameters.Add(clConnection.GetInputParameter("@ProgClassCategoryId", objChildSchedule.ProgClassCategoryId)); cmd.Parameters.Add(clConnection.GetInputParameter("@ProgClassRoomId", objChildSchedule.ProgClassRoomId)); cmd.Parameters.Add(clConnection.GetInputParameter("@ProgScheduleId", objChildSchedule.ProgScheduleId)); cmd.Parameters.Add(clConnection.GetInputParameter("@BeginDate", objChildSchedule.BeginDate)); cmd.Parameters.Add(clConnection.GetInputParameter("@EndDate", objChildSchedule.EndDate)); cmd.Parameters.Add(clConnection.GetInputParameter("@Discount", objChildSchedule.Discount)); cmd.Parameters.Add(clConnection.GetInputParameter("@LastModifiedById", objChildSchedule.LastModifiedById)); cmd.Parameters.Add(clConnection.GetInputParameter("@LastModifiedDateTime", DateTime.Now)); cmd.Parameters.Add(clConnection.GetOutputParameter("@status", SqlDbType.Bit)); cmd.ExecuteNonQuery(); if (Convert.ToBoolean(cmd.Parameters["@status"].Value)) { return(true); } return(false); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clChildSchedule, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(false); } finally { clConnection.CloseConnection(conn); } }
protected void LoadDataById(Guid ChildScheduleId, Guid ChildSchoolYearId) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.ChildSchedule, "LoadDataById", "LoadDataById method called", DayCarePL.Common.GUID_DEFAULT); try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.ChildSchedule, "LoadDataById", "Debug LoadDataById called", DayCarePL.Common.GUID_DEFAULT); DayCareBAL.ChildScheduleService proxyChildSchedule = new DayCareBAL.ChildScheduleService(); Guid SchoolId = new Guid(Session["SchoolId"].ToString()); DayCarePL.ChildScheduleProperties objChildSchedule = proxyChildSchedule.LoadChildScheduleById(ChildScheduleId, ChildSchoolYearId); if (objChildSchedule != null) { ddlProgram.SelectedValue = objChildSchedule.SchoolProgramId.ToString(); lblSchoolProgramId.Text = objChildSchedule.SchoolProgramId.ToString(); GetProgClassCategory(SchoolId, new Guid(ddlProgram.SelectedValue)); GetProgClassRoom(SchoolId, new Guid(ddlProgram.SelectedValue)); GetProgSchedule(SchoolId, new Guid(ddlProgram.SelectedValue)); //if (objChildSchedule.ProgClassCategoryId != null) //{ // ddlClassCategory.SelectedValue = objChildSchedule.ProgClassCategoryId.ToString(); // lblProgClassCategoryId.Text = objChildSchedule.ProgClassCategoryId.ToString(); //} if (objChildSchedule.ProgClassRoomId != null) { ddlClassRoom.SelectedValue = objChildSchedule.ProgClassRoomId.ToString(); } if (objChildSchedule.ProgScheduleId != null) { ddlProgSchedule.SelectedValue = objChildSchedule.ProgScheduleId.ToString(); lblProgScheduleId.Text = objChildSchedule.ProgScheduleId.ToString(); } if (objChildSchedule.BeginDate != null) { rdpBeginDate.SelectedDate = objChildSchedule.BeginDate; } if (objChildSchedule.EndDate != null) { rdpEndDate.SelectedDate = objChildSchedule.EndDate; } txtDiscount.Text = objChildSchedule.Discount.ToString(); } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.ChildSchedule, "LoadDataById", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); } }
public static List <DayCarePL.ChildScheduleProperties> LoadChildSchedule(Guid ChildSchoolYearId) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clChildSchedule, "LoadChildSchedule", "Execute LoadChildSchedule Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clChildSchedule, "LoadChildSchedule", "Debug LoadChildSchedule Method", DayCarePL.Common.GUID_DEFAULT); List <DayCarePL.ChildScheduleProperties> lstChildSchedule = new List <DayCarePL.ChildScheduleProperties>(); DayCarePL.ChildScheduleProperties objChildSchedule; var data = db.spGetChildScheduleList(ChildSchoolYearId); foreach (var d in data) { objChildSchedule = new DayCarePL.ChildScheduleProperties(); objChildSchedule.Id = d.Id; objChildSchedule.ChildSchoolYearId = d.ChildSchoolYearId; objChildSchedule.SchoolProgramId = d.SchoolProgramId; objChildSchedule.SchoolProgramTitle = d.SchoolProgram; //objChildSchedule.ProgClassCategoryId = d.ProgClassCategoryId; //objChildSchedule.ProgClassCategoryName = d.ProgClassCategory; objChildSchedule.StaffFullName = d.FullName; objChildSchedule.ProgClassRoomId = d.ProgClassRoomId; objChildSchedule.ProgClassRoomName = d.ProgClassRoom; objChildSchedule.Discount = Convert.ToDouble(d.Discount); objChildSchedule.ProgScheduleId = d.ProgScheduleId; objChildSchedule.ProgScheduleDay = d.Day; objChildSchedule.ProgScheduleBeginTime = d.BeginTime; objChildSchedule.ProgScheduleEndTime = d.EndTime.Value; objChildSchedule.BeginDate = d.BeginDate; objChildSchedule.EndDate = d.EndDate.Value; objChildSchedule.CreatedById = d.CreatedById; objChildSchedule.CreatedDateTime = d.CreatedDateTime; objChildSchedule.LastModifiedById = d.LastModifiedById; objChildSchedule.LastModifiedDatetime = d.LastModifiedDatetime; lstChildSchedule.Add(objChildSchedule); } return(lstChildSchedule); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clChildSchedule, "LoadChildSchedule", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(null); } }
public bool SubmitRecord() { bool result = false; try { DayCareBAL.ChildScheduleService proxyChildSchedule = new DayCareBAL.ChildScheduleService(); DayCarePL.ChildScheduleProperties objChildSchedule = new DayCarePL.ChildScheduleProperties(); objChildSchedule.ChildSchoolYearId = GetChildSchoolYearId(); objChildSchedule.SchoolProgramId = new Guid(ddlProgram.SelectedValue); //objChildSchedule.ProgClassCategoryId = new Guid(ddlClassCategory.SelectedValue); DayCareBAL.ProgScheduleService proxyProgClassCategory = new DayCareBAL.ProgScheduleService(); List <DayCarePL.ProgScheduleProperties> lstProgClassCategory = proxyProgClassCategory.LoadProgScheduleForChildSchedule(GetSchoolId(), new Guid(ddlProgram.SelectedValue)); if (lstProgClassCategory != null && lstProgClassCategory.Count > 0) { objChildSchedule.ProgClassRoomId = lstProgClassCategory.Find(cr => cr.Id.Equals(new Guid(ddlProgSchedule.SelectedValue))).ProgClassRoomId; } objChildSchedule.ProgScheduleId = new Guid(ddlProgSchedule.SelectedValue); if (rdpBeginDate.SelectedDate != null) { objChildSchedule.BeginDate = rdpBeginDate.SelectedDate.Value; } if (rdpEndDate.SelectedDate != null) { objChildSchedule.EndDate = rdpEndDate.SelectedDate.Value; } if (!string.IsNullOrEmpty(txtDiscount.Text.Trim())) { objChildSchedule.Discount = Convert.ToDouble(txtDiscount.Text.Trim()); } else { objChildSchedule.Discount = 0; } if (ViewState["SelectedChildScheduleId"] != null) { objChildSchedule.Id = new Guid(ViewState["SelectedChildScheduleId"].ToString()); int CountChildData = proxyChildSchedule.GetCountChildData(GetChildSchoolYearId()); if (CountChildData == 1) { if (!proxyChildSchedule.CheckProgramIdPrimaryOrNotForChildSchedule(new Guid(ddlProgram.SelectedValue))) { MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please select Primary subject first", "false")); return(false); } } } else { if (Session["StaffId"] != null) { objChildSchedule.CreatedById = new Guid(Session["StaffId"].ToString()); } } if (Session["StaffId"] != null) { objChildSchedule.LastModifiedById = new Guid(Session["StaffId"].ToString()); } if (proxyChildSchedule.Save(objChildSchedule)) { ClearAll(); rgChildSchedule.MasterTableView.Rebind(); MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Saved Successfully", "false")); rgChildSchedule.MasterTableView.CurrentPageIndex = 0; result = true; } else { MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Internal Error", "false")); result = false; } } catch (Exception ex) { result = false; } return(result); }
protected void btnSave_Click(object sender, EventArgs e) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.ChildSchedule, "btnSave_Click", "btnSave_Click called", DayCarePL.Common.GUID_DEFAULT); try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.ChildSchedule, "btnSave_Click", "Debug btnSave_Click called", DayCarePL.Common.GUID_DEFAULT); DayCareBAL.ChildScheduleService proxyChildSchedule = new DayCareBAL.ChildScheduleService(); DayCarePL.ChildScheduleProperties objChildSchedule = new DayCarePL.ChildScheduleProperties(); //bool IsSelectedProgramPrimary = (lblSchoolProgramId.Text.Equals(ddlProgram.SelectedValue) && lblProgClassCategoryId.Text.Equals(ddlClassCategory.SelectedValue) && lblProgScheduleId.Text.Equals(ddlProgSchedule.SelectedValue)); bool IsSelectedProgramPrimary = (lblSchoolProgramId.Text.Equals(ddlProgram.SelectedValue) && lblProgScheduleId.Text.Equals(ddlProgSchedule.SelectedValue)); if (!IsSelectedProgramPrimary) { bool IsRoomAvailableForChild = proxyChildSchedule.CheckAvailableClassForChild(GetSchoolId(), new Guid(ddlProgSchedule.SelectedValue), GetChildSchoolYearId(), new Guid(ddlProgram.SelectedValue)); if (IsRoomAvailableForChild == false) { MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Class Room is not availabe", "false")); return; } if (proxyChildSchedule.CheckDupicateChildSchedule(GetChildSchoolYearId(), new Guid(ddlProgram.SelectedValue), new Guid(ddlProgSchedule.SelectedValue))) {// ddlClassCategory.SelectedValue is pass through this function but not check from DB. MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Child schedule already exists", "false")); return; } } if (rdpBeginDate.SelectedDate != null && rdpEndDate != null) { if (rdpBeginDate.SelectedDate.Value > rdpEndDate.SelectedDate.Value) { MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Start Date must less than End Date", "false")); return; } } bool IsPrimaryInDB = proxyChildSchedule.IsPrimaryProgramInChildSchedule(GetChildSchoolYearId()); bool IsPrimarySchoolProgramInDropDown = proxyChildSchedule.CheckProgramIdPrimaryOrNotForChildSchedule(new Guid(ddlProgram.SelectedValue)); if (IsPrimaryInDB || IsPrimarySchoolProgramInDropDown) { SubmitRecord(); } else { MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please select Primary subject first", "false")); return; } #region Old Functinality ( Only one Primary Program and other Secondary) //if (IsPrimaryInDB)// || IsPrimarySchoolProgramInDropDown) //{ // if (IsSelectedProgramPrimary) // { // SubmitRecord(); // } // else // { // if (IsPrimarySchoolProgramInDropDown) // { // MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; // MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Program require only one primary", "false")); // return; // } // else // { // SubmitRecord(); // } // } //} //else //{ // if (IsPrimarySchoolProgramInDropDown) // { // SubmitRecord(); // } // else // { // MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; // MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Please select Primary subject first", "false")); // return; // } //} #endregion } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.ChildSchedule, "btnSave_Click", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); } }
public bool Save(DayCarePL.ChildScheduleProperties objChildSchedule) { return(DayCareDAL.clChildSchedule.Save(objChildSchedule)); }