Exemple #1
0
 protected void rgChildAbsentHistory_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     try
     {
         DayCareBAL.ChildAbsentHistoryService proxyChildAbsentHistory = new DayCareBAL.ChildAbsentHistoryService();
         rgChildAbsentHistory.DataSource = proxyChildAbsentHistory.LoadChildAbsentHistory(new Guid(ViewState["ChildSchoolYearId"].ToString()));
     }
     catch (Exception ex)
     {
         DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.ChildAbsentHistory, "rgChildAbsentHistory_NeedDataSource", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
     }
 }
Exemple #2
0
        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);
        }