예제 #1
0
 protected void rgRoles_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     DayCareBAL.RoleService     proxyRole = new DayCareBAL.RoleService();
     DayCarePL.RoleProperties[] Roles     = proxyRole.LoadRoles();
     if (Roles != null && Roles.Length > 0)
     {
         rgRoles.DataSource = Roles.ToList().FindAll(name => !name.Name.Equals(DayCarePL.Common.SCHOOL_ADMINISTRATOR));
     }
 }
예제 #2
0
 public static void BindRoles(DropDownList ddlRol)
 {
     try
     {
         DayCareBAL.RoleService     objRoleService = new DayCareBAL.RoleService();
         DayCarePL.RoleProperties[] Roles          = objRoleService.LoadRoles();
         if (Roles != null && Roles.Length > 0)
         {
             ddlRol.DataSource     = Roles.ToList().FindAll(role => !role.Name.Equals(DayCarePL.Common.SCHOOL_ADMINISTRATOR));
             ddlRol.DataTextField  = "Name";
             ddlRol.DataValueField = "Id";
             ddlRol.DataBind();
         }
         ddlRol.Items.Insert(0, new ListItem("--Select--", DayCarePL.Common.GUID_DEFAULT));
     }
     catch
     {
     }
 }
예제 #3
0
        public bool SubmitRecord(object sender, GridCommandEventArgs e)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.Role, "SubmitRecord", "Submit record method called", DayCarePL.Common.GUID_DEFAULT);
            bool result = false;

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.Role, "SubmitRecord", "Debug Submit Record Of Role", DayCarePL.Common.GUID_DEFAULT);
                DayCareBAL.RoleService   proxyRole = new DayCareBAL.RoleService();
                DayCarePL.RoleProperties objRole   = new DayCarePL.RoleProperties();

                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 "Name":
                                {
                                    objRole.Name = (e.Item.FindControl("txtName") as TextBox).Text;
                                    break;
                                }

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

                    if (e.CommandName != "PerformInsert")
                    {
                        objRole.Id = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString());
                        if (!objRole.Name.Trim().Equals(hdnName.Value.Trim()))
                        {
                            bool ans = Common.CheckDuplicate("Role", "Name", objRole.Name, "update", objRole.Id.ToString());
                            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 = Common.CheckDuplicate("Role", "Name", objRole.Name, "insert", "");
                        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        = proxyRole.Save(objRole);
                }
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.Role, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }