Пример #1
0
        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
        {
            int deptID = GetSelectedDataKeyID(Grid1);

            if (e.CommandName == "Delete")
            {
                // 在操作之前进行权限检查
                if (!CheckPower("CoreDeptDelete"))
                {
                    CheckPowerFailWithAlert();
                    return;
                }

                int userCount = DB.Users.Where(u => u.Dept.ID == deptID).Count();
                if (userCount > 0)
                {
                    Alert.ShowInTop("删除失败!需要先清空属于此部门的用户!");
                    return;
                }

                int childCount = DB.Depts.Where(d => d.Parent.ID == deptID).Count();
                if (childCount > 0)
                {
                    Alert.ShowInTop("删除失败!请先删除子部门!");
                    return;
                }

                DB.Depts.Delete <Dept>(d => d.ID == deptID);

                DeptHelper.Reload();
                BindGrid();
            }
        }
Пример #2
0
        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
        {
            int deptID = GetSelectedDataKeyID(Grid1);

            if (e.CommandName == "Delete")
            {
                // 在操作之前进行权限检查
                if (!CheckPower("CoreDeptDelete"))
                {
                    CheckPowerFailWithAlert();
                    return;
                }
                int V_ITOTALCOUNT  = -1;
                int V_SSTARTINDEX  = 0;
                int V_SPERPAGESIZE = 20;
                UserModel.DeptID = deptID;
                DataSet ds = XASYU.BLL.DataBaseQuery.query_SYS_USERS(userBean, UserModel, ref V_ITOTALCOUNT, V_SSTARTINDEX, V_SPERPAGESIZE);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    Alert.ShowInTop("删除失败!需要先清空属于此部门的用户!");
                    return;
                }

                int VL_ITOTALCOUNT  = -1;
                int VL_SSTARTINDEX  = 0;
                int VL_SPERPAGESIZE = 20;
                DeptModel.ParentID = deptID;
                DataSet ds1 = XASYU.BLL.DataBaseQuery.query_SYS_DEPTS(userBean, DeptModel, ref VL_ITOTALCOUNT, VL_SSTARTINDEX, VL_SPERPAGESIZE);
                if (ds1 != null && ds1.Tables.Count > 0 && ds1.Tables[0] != null && ds1.Tables[0].Rows.Count > 0)
                {
                    Alert.ShowInTop("删除失败!请先删除子部门!");
                    return;
                }

                DeptModel.ID     = deptID;
                DeptModel.OpType = DataOperationType.Delete;
                XASYU.BLL.DataBaseManager.op_SYS_DEPTS(userBean, DeptModel);
                depHelp.Reload();
                BindGrid();
            }
        }
Пример #3
0
        public async Task <IActionResult> OnPostDept_DoPostBackAsync(string[] Grid1_fields, string actionType, int?deletedRowID)
        {
            if (actionType == "delete")
            {
                // 在操作之前进行权限检查
                if (!CheckPower("CoreDeptDelete"))
                {
                    CheckPowerFailWithAlert();
                    return(UIHelper.Result());
                }

                int userCount = await DB.Users.Where(u => u.Dept.ID == deletedRowID.Value).CountAsync();

                if (userCount > 0)
                {
                    Alert.ShowInTop("删除失败!需要先清空属于此部门的用户!");
                    return(UIHelper.Result());
                }

                int childCount = await DB.Depts.Where(d => d.Parent.ID == deletedRowID.Value).CountAsync();

                if (childCount > 0)
                {
                    Alert.ShowInTop("删除失败!请先删除子部门!");
                    return(UIHelper.Result());
                }

                var dept = await DB.Depts.Where(d => d.ID == deletedRowID.Value).FirstOrDefaultAsync();

                DB.Depts.Remove(dept);
                await DB.SaveChangesAsync();
            }


            DeptHelper.Reload();
            UIHelper.Grid("Grid1").DataSource(DeptHelper.Depts, Grid1_fields);

            return(UIHelper.Result());
        }
Пример #4
0
        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
        {
            int deptID = GetSelectedDataKeyID(Grid1);

            if (e.CommandName == "Delete")
            {
                // 在操作之前进行权限检查
                if (!CheckPower("CoreDeptDelete"))
                {
                    CheckPowerFailWithAlert();
                    return;
                }

                IList <ICriterion> qryListUser = new List <ICriterion>();
                qryListUser.Add(Expression.Eq("DeptID", deptID));
                int userCount = Core.Container.Instance.Resolve <IServiceUsers>().GetRecordCountByFields(qryListUser);
                //int userCount = DB.Users.Where(u => u.Dept.ID == deptID).Count();
                if (userCount > 0)
                {
                    Alert.ShowInTop("删除失败!需要先清空属于此部门的用户!");
                    return;
                }

                IList <ICriterion> qryList = new List <ICriterion>();
                qryList.Add(Expression.Eq("ParentID", deptID));
                int childCount = Core.Container.Instance.Resolve <IServiceDepts>().GetRecordCountByFields(qryList);
                //int childCount = DB.Depts.Where(d => d.Parent.ID == deptID).Count();
                if (childCount > 0)
                {
                    Alert.ShowInTop("删除失败!请先删除子部门!");
                    return;
                }

                Core.Container.Instance.Resolve <IServiceDepts>().Delete(deptID);

                DeptHelper.Reload();
                BindGrid();
            }
        }
Пример #5
0
 protected void Window1_Close(object sender, EventArgs e)
 {
     DeptHelper.Reload();
     BindGrid();
 }