protected void rgChildAbsentHistory_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { try { if (e.Item.ItemType == GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.Item) { DayCarePL.ChildAbsentHistoryProperties objChildAbsentHistory = e.Item.DataItem as DayCarePL.ChildAbsentHistoryProperties; if (objChildAbsentHistory != null) { Label lblStartDate = e.Item.FindControl("lblStartDate") as Label; Label lblEndDate = e.Item.FindControl("lblEndDate") as Label; if (objChildAbsentHistory.StartDate != null) { //lblStartDate.Text = Convert.ToDateTime(objChildAbsentHistory.StartDate).ToShortDateString().ToString(); lblStartDate.Text = string.Format("{0:MM/dd/yy}", objChildAbsentHistory.StartDate); } if (objChildAbsentHistory.EndDate != null) { //lblEndDate.Text = Convert.ToDateTime(objChildAbsentHistory.EndDate).ToShortDateString().ToString(); lblEndDate.Text = string.Format("{0:MM/dd/yy}", objChildAbsentHistory.EndDate); } lblChild.Text = "of " + objChildAbsentHistory.ChildFullName; } } if (e.Item.ItemType == GridItemType.EditItem) { DayCarePL.ChildAbsentHistoryProperties objChildAbsentHistory = e.Item.DataItem as DayCarePL.ChildAbsentHistoryProperties; RadDatePicker rdpStartDate = e.Item.FindControl("rdpStartDate") as RadDatePicker; RadDatePicker rdpEndDate = e.Item.FindControl("rdpEndDate") as RadDatePicker; DropDownList ddlAbsentReason = e.Item.FindControl("ddlAbsentReson") as DropDownList; Guid SchooId = new Guid(); if (Session["SchoolId"] != null) { SchooId = new Guid(Session["SchoolId"].ToString()); } Common.BindAbsentReson(ddlAbsentReason, SchooId); if (objChildAbsentHistory != null) { if (ddlAbsentReason.Items != null && ddlAbsentReason.Items.Count > 0) { ddlAbsentReason.SelectedValue = objChildAbsentHistory.AbsentReasonId.ToString(); } if (objChildAbsentHistory.StartDate != null) { rdpStartDate.SelectedDate = objChildAbsentHistory.StartDate; } if (objChildAbsentHistory.EndDate != null) { rdpEndDate.SelectedDate = objChildAbsentHistory.EndDate; } } } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.ChildAbsentHistory, "rgChildAbsentHistory_ItemDataBound", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); } }
public static bool Save(DayCarePL.ChildAbsentHistoryProperties objChildAbsentHistory) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clChildAbsentHistory, "Save", "Execute Save Method", DayCarePL.Common.GUID_DEFAULT); SqlConnection conn = clConnection.CreateConnection(); bool result = false; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clChildAbsentHistory, "Save", "Debug Save Method", DayCarePL.Common.GUID_DEFAULT); clConnection.OpenConnection(conn); SqlCommand cmd; if (objChildAbsentHistory.Id.ToString().Equals(DayCarePL.Common.GUID_DEFAULT)) { cmd = clConnection.CreateCommand("spAddChildAbsentHistory", conn); cmd.Parameters.Add(clConnection.GetInputParameter("@CreatedDateTime", DateTime.Now)); cmd.Parameters.Add(clConnection.GetInputParameter("@CreatedById", objChildAbsentHistory.CreatedById)); } else { cmd = clConnection.CreateCommand("spUpdateChildAbsentHistory", conn); cmd.Parameters.Add(clConnection.GetInputParameter("@Id", objChildAbsentHistory.Id)); } cmd.Parameters.Add(clConnection.GetInputParameter("@ChildSchoolYearId", objChildAbsentHistory.ChildSchoolYearId)); cmd.Parameters.Add(clConnection.GetInputParameter("@Comments", objChildAbsentHistory.Comments)); cmd.Parameters.Add(clConnection.GetInputParameter("@AbsentReasonId", objChildAbsentHistory.AbsentReasonId)); cmd.Parameters.Add(clConnection.GetInputParameter("@StartDate", objChildAbsentHistory.StartDate)); cmd.Parameters.Add(clConnection.GetInputParameter("@EndDate", objChildAbsentHistory.EndDate)); cmd.Parameters.Add(clConnection.GetInputParameter("@LastModifiedDatetime", DateTime.Now)); cmd.Parameters.Add(clConnection.GetInputParameter("@LastModifiedById", objChildAbsentHistory.LastModifiedById)); cmd.Parameters.Add(clConnection.GetOutputParameter("@status", SqlDbType.Bit)); cmd.ExecuteNonQuery(); if (Convert.ToBoolean(cmd.Parameters["@status"].Value)) { result = true; } else { result = false; } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clChildAbsentHistory, "Save", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } finally { clConnection.CloseConnection(conn); } return(result); }
public bool SubmitRecord(object sender, GridCommandEventArgs e) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.ChildAbsentHistory, "SubmitRecord", "Submit record method called", DayCarePL.Common.GUID_DEFAULT); bool result = false; try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.ChildAbsentHistory, "SubmitRecord", "Debug Submit Record Of SchoolYear", DayCarePL.Common.GUID_DEFAULT); DayCareBAL.ChildAbsentHistoryService proxyChildAbsentHistory = new DayCareBAL.ChildAbsentHistoryService(); DayCarePL.ChildAbsentHistoryProperties objChildAbsentHistory = new DayCarePL.ChildAbsentHistoryProperties(); GridDataItem item = (GridDataItem)e.Item; var InsertItem = e.Item as Telerik.Web.UI.GridEditableItem; Telerik.Web.UI.GridEditManager editMan = InsertItem.EditManager; if (InsertItem != null) { foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns) { if (column is GridEditableColumn) { IGridEditableColumn editTableColumn = (column as IGridEditableColumn); if (editTableColumn.IsEditable) { IGridColumnEditor editor = editMan.GetColumnEditor(editTableColumn); switch (column.UniqueName) { case "AbsentReason": { objChildAbsentHistory.AbsentReasonId = new Guid((item["AbsentReason"].Controls[1] as DropDownList).SelectedValue); break; } case "StartDate": { if ((e.Item.FindControl("rdpStartDate") as RadDatePicker).SelectedDate != null) { objChildAbsentHistory.StartDate = (e.Item.FindControl("rdpStartDate") as RadDatePicker).SelectedDate.Value; } break; } case "EndDate": { if ((e.Item.FindControl("rdpEndDate") as RadDatePicker).SelectedDate != null) { objChildAbsentHistory.EndDate = (e.Item.FindControl("rdpEndDate") as RadDatePicker).SelectedDate.Value; } break; } case "Comment": { objChildAbsentHistory.Comments = (e.Item.FindControl("txtComment") as TextBox).Text; break; } } } } } if (objChildAbsentHistory.StartDate != null && objChildAbsentHistory.EndDate != null) { if (objChildAbsentHistory.StartDate > objChildAbsentHistory.EndDate) { MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Start Date must be less than End Date.", "false")); return(false); } } if (ViewState["ChildSchoolYearId"] != null) { objChildAbsentHistory.ChildSchoolYearId = new Guid(ViewState["ChildSchoolYearId"].ToString()); } if (e.CommandName != "PerformInsert") { if (Session["StaffId"] != null) { objChildAbsentHistory.LastModifiedById = new Guid(Session["StaffId"].ToString()); } objChildAbsentHistory.Id = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString()); } else { if (Session["StaffId"] != null) { objChildAbsentHistory.CreatedById = new Guid(Session["StaffId"].ToString()); } } result = proxyChildAbsentHistory.Save(objChildAbsentHistory); if (result) { MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager; MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Saved Successfully", "false")); } } } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.ChildAbsentHistory, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); result = false; } return(result); }
public bool Save(DayCarePL.ChildAbsentHistoryProperties objChildAbsentHistory) { return(DayCareDAL.clChildAbsentHistory.Save(objChildAbsentHistory)); }
public static List <DayCarePL.ChildAbsentHistoryProperties> LoadChildAbsentHistory(Guid ChildSchoolYearId) { DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.clChildAbsentHistory, "LoadChildAbsentHistory", "Execute LoadChildAbsentHistory Method", DayCarePL.Common.GUID_DEFAULT); clConnection.DoConnection(); DayCareDataContext db = new DayCareDataContext(); try { DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.clChildAbsentHistory, "LoadChildAbsentHistory", "Debug LoadChildAbsentHistory Method", DayCarePL.Common.GUID_DEFAULT); DayCarePL.ChildAbsentHistoryProperties objChildAbsentHistory; List <DayCarePL.ChildAbsentHistoryProperties> lstChildAbsentHistory = new List <DayCarePL.ChildAbsentHistoryProperties>(); #region Old Code //SortedList sl = new SortedList(); //sl.Add("@ChildSchoolYearId", ChildSchoolYearId); //DataSet ds = clConnection.GetDataSet("spGetChildAbsentHistory", sl); //if (ds != null && ds.Tables.Count > 0) //{ // if (ds.Tables[0].Rows.Count > 0) // { // for (int iRow = 0; iRow < ds.Tables[0].Rows.Count; iRow++) // { // objChildAbsentHistory = new DayCarePL.ChildAbsentHistoryProperties(); // objChildAbsentHistory.Id = new Guid(ds.Tables[0].Rows[iRow]["Id"].ToString()); // objChildAbsentHistory.ChildSchoolYearId = new Guid(ds.Tables[0].Rows[iRow]["ChildSchoolYearId"].ToString()); // objChildAbsentHistory.ChildFullName = Convert.ToString(ds.Tables[0].Rows[iRow]["ChildName"]); // objChildAbsentHistory.AbsentReasonId = new Guid(ds.Tables[0].Rows[iRow]["AbsentReasonId"].ToString()); // objChildAbsentHistory.AbsentReason = Convert.ToString(ds.Tables[0].Rows[iRow]["AbsentReason"]); // if (!string.IsNullOrEmpty(ds.Tables[0].Rows[iRow]["StartDate"].ToString())) // { // objChildAbsentHistory.StartDate = Convert.ToDateTime(ds.Tables[0].Rows[iRow]["StartDate"].ToString()); // } // if (!string.IsNullOrEmpty(ds.Tables[0].Rows[iRow]["EndDate"].ToString())) // { // objChildAbsentHistory.EndDate = Convert.ToDateTime(ds.Tables[0].Rows[iRow]["EndDate"].ToString()); // } // if (!string.IsNullOrEmpty(ds.Tables[0].Rows[iRow]["Comments"].ToString())) // { // objChildAbsentHistory.Comments = Convert.ToString(ds.Tables[0].Rows[iRow]["Comments"]); // } // if (!string.IsNullOrEmpty(ds.Tables[0].Rows[iRow]["CreatedDateTime"].ToString())) // { // objChildAbsentHistory.CreatedDateTime = Convert.ToDateTime(ds.Tables[0].Rows[iRow]["CreatedDateTime"]); // } // if (!string.IsNullOrEmpty(ds.Tables[0].Rows[iRow]["CreatedById"].ToString())) // { // objChildAbsentHistory.CreatedById = new Guid(ds.Tables[0].Rows[iRow]["CreatedById"].ToString()); // } // if (!string.IsNullOrEmpty(ds.Tables[0].Rows[iRow]["LastModifiedDatetime"].ToString())) // { // objChildAbsentHistory.LastModifiedDatetime = Convert.ToDateTime(ds.Tables[0].Rows[iRow]["LastModifiedDatetime"]); // } // if (!string.IsNullOrEmpty(ds.Tables[0].Rows[iRow]["LastModifiedById"].ToString())) // { // objChildAbsentHistory.LastModifiedById = new Guid(ds.Tables[0].Rows[iRow]["LastModifiedById"].ToString()); // } // lstChildAbsentHistory.Add(objChildAbsentHistory); // } // } //} #endregion var data = db.spGetChildAbsentHistory(ChildSchoolYearId); foreach (var d in data) { objChildAbsentHistory = new DayCarePL.ChildAbsentHistoryProperties(); objChildAbsentHistory.Id = d.Id; objChildAbsentHistory.ChildSchoolYearId = d.ChildSchoolYearId; objChildAbsentHistory.ChildFullName = d.ChildName; objChildAbsentHistory.AbsentReasonId = d.AbsentReasonId; objChildAbsentHistory.AbsentReason = d.AbsentReason; if (d.StartDate != null) { objChildAbsentHistory.StartDate = d.StartDate; } if (d.EndDate != null) { objChildAbsentHistory.EndDate = d.EndDate; } objChildAbsentHistory.Comments = d.Comments; if (d.CreatedDateTime != null) { objChildAbsentHistory.CreatedDateTime = d.CreatedDateTime; } if (d.CreatedById != null) { objChildAbsentHistory.CreatedById = d.CreatedById; } if (d.LastModifiedDatetime != null) { objChildAbsentHistory.LastModifiedDatetime = d.LastModifiedDatetime; } if (d.LastModifiedById != null) { objChildAbsentHistory.LastModifiedById = d.LastModifiedById; } lstChildAbsentHistory.Add(objChildAbsentHistory); } return(lstChildAbsentHistory); } catch (Exception ex) { DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.clChildAbsentHistory, "LoadChildAbsentHistory", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT); return(null); } }