コード例 #1
0
 protected void rgEmploymentStatus_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     try
     {
         DayCareBAL.EmploymentStatusService Loadproxy = new DayCareBAL.EmploymentStatusService();
         Guid SchoolId = new Guid();
         if (Session["SchoolId"] != null)
         {
             SchoolId = new Guid(Session["SchoolId"].ToString());
         }
         rgEmploymentStatus.DataSource = Loadproxy.LoadEmploymentStatus(SchoolId);
     }
     catch (Exception ex)
     {
         DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.EmploymentStatus, "rgEmploymentStatus_NeedDataSource", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
     }
 }
コード例 #2
0
        public bool SubmitRecord(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.EmploymentStatus, "SubmitRecord", "Submit record method called", DayCarePL.Common.GUID_DEFAULT);
            bool result = false;

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.EmploymentStatus, "SubmitRecord", " Debug Submit record method called of EmploymentStatus", DayCarePL.Common.GUID_DEFAULT);

                DayCareBAL.EmploymentStatusService   proxySave     = new DayCareBAL.EmploymentStatusService();
                DayCarePL.EmploymentStatusProperties objEmployment = new DayCarePL.EmploymentStatusProperties();

                Telerik.Web.UI.GridDataItem item = (Telerik.Web.UI.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 IGridEditableColumn)
                        {
                            IGridEditableColumn editableCol = (column as IGridEditableColumn);
                            if (editableCol.IsEditable)
                            {
                                IGridColumnEditor editor = editMan.GetColumnEditor(editableCol);
                                switch (column.UniqueName)
                                {
                                case "Status":
                                {
                                    objEmployment.Status = (editor as GridTextBoxColumnEditor).Text.Trim().ToString();
                                    ViewState["Staus"]   = objEmployment.Status;
                                    break;
                                }

                                case "Active":
                                {
                                    objEmployment.Active = (editor as GridCheckBoxColumnEditor).Value;
                                    break;
                                }

                                case "Comments":
                                {
                                    objEmployment.Comments = (e.Item.FindControl("txtComments") as TextBox).Text.Trim().ToString();
                                    ViewState["Comments"]  = objEmployment.Comments;
                                    break;
                                }
                                }
                            }
                        }
                    }
                    if (Session["SchoolId"] != null)
                    {
                        objEmployment.SchoolId = new Guid(Session["SchoolId"].ToString());
                    }
                    if (Session["StaffId"] != null)
                    {
                        objEmployment.LastModifiedById = new Guid(Session["StaffId"].ToString());
                    }
                    if (e.CommandName != "PerformInsert")
                    {
                        objEmployment.Id = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString());
                        if (!objEmployment.Id.ToString().Equals(hdnName.Value.Trim()))
                        {
                            bool ans = proxySave.CheckDuplicateEmploymentStatusName(objEmployment.Status, objEmployment.Id, objEmployment.SchoolId);
                            if (ans)
                            {
                                MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                                MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Already Exist", "false"));
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        bool ans = proxySave.CheckDuplicateEmploymentStatusName(objEmployment.Status, objEmployment.Id, objEmployment.SchoolId);
                        if (ans)
                        {
                            MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Already Exist", "false"));
                            return(false);
                        }
                    }
                    hdnName.Value = "";
                    result        = proxySave.Save(objEmployment);
                    if (result == true)
                    {
                        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.EmploymentStatus, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }