Beispiel #1
0
        protected void Grd_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            SYS_RoleOfUser sysRoleOfUser = new SYS_RoleOfUser();
            SYS_Roles      roles         = new SYS_Roles();

            roles.Name           = e.NewValues["Name"] + "";
            roles.IDOrganization = int.Parse(e.NewValues["IDOrganization"] + "");
            if (CheckRole(roles.Name))
            {
                throw new Exception(string.Format("Trùng tên đơn vị! Vui lòng chọn lại."));
            }
            try
            {
                if (CheckRole(roles.Name) == false)
                {
                    int RoleID = _ISYS_RolesService.InsertSYS_Roles(roles);
                    //sysRoleOfUser.RoleId = RoleID;
                    //sysRoleOfUser.UserId = (int)Session["UserId"];
                    //isyRoleOfUserService.InsertSYS_RoleOfUser(sysRoleOfUser);
                    _DataBind();
                    e.Cancel = true;
                    Grd.CancelEdit();
                    //WriteLog("Insert " + e.NewValues["Name"], Action.Create);
                }
                else
                {
                    throw new Exception(string.Format("Trùng tên! Vui lòng nhập lại."));
                }
            }
            catch (Exception)
            {
                throw new Exception("Trùng tên! Vui lòng nhập lại.");
            }
        }
Beispiel #2
0
        protected void Grd_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            Entity.SYS_Roles roles = new Entity.SYS_Roles();
            roles.ID             = (int)e.Keys["ID"];
            roles.Name           = e.NewValues["Name"] + "";
            roles.IDOrganization = int.Parse(e.NewValues["IDOrganization"] + "");
            if ((int)e.NewValues["IDOrganization"] != (int)e.OldValues["IDOrganization"])
            {
                if (CheckIDOrganization(roles.IDOrganization))
                {
                    throw new Exception(string.Format("Trùng tên đơn vị! Vui lòng chọn lại."));
                }
            }

            if (e.OldValues["Name"] + "" != e.NewValues["Name"] + "")
            {
                if (CheckRole(roles.Name))
                {
                    throw new Exception(string.Format("Trùng tên nhóm quyền! Vui lòng nhập lại."));
                }
            }

            _ISYS_RolesService.UpdateSYS_Roles(roles);
            _DataBind();
            e.Cancel = true;
            Grd.CancelEdit();
            //WriteLog("Update " + e.NewValues["Name"],Action.Update);
        }