public static bool Delete(RightFunction rightFunction)
        {
            using (var conn = new SqlConnection(Conn.getConn()))
            {
                if (conn.State != ConnectionState.Open)
                    conn.Open();

                using (var trans = conn.BeginTransaction())
                {
                    //1、删除功能信息
                    var result = Delete(rightFunction, conn, trans);
                    if (!result)
                    {
                        trans.Rollback();
                        return false;
                    }
                    //2、删除当前功能对应的功能分组信息
                    RightLkFunctionGroupDal.DeleteByFunctionSysid(new RightLkFunctionGroup { FunctionSysid = rightFunction.Sysid }, conn, trans);

                    //3、删除当前功能对应的功能命令信息
                    RightLkFunctionCommandDal.DeleteByFunctionSysid(new RightLkFunctionCommand { FunctionSysid = rightFunction.Sysid }, conn, trans);

                    //4、删除当前功能对应的权限分配信息
                    RightDal.DeleteByFunctionSysid(new Right { FunctionSysid = rightFunction.Sysid }, conn, trans);

                    trans.Commit();
                }

                if (conn.State != ConnectionState.Closed)
                    conn.Close();
            }

            return true;
        }
Beispiel #2
0
        //新增数据
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <returns></returns>
        internal override bool Add()
        {
            EditEntity = null;
            pageViewMain.SelectedPage = pageEditData;
            UI.ClearUi(pageEditData);
            UI.ReadOnlyUi(pageEditData, false);

            return true;
        }
        public static bool Insert(RightFunction rightFunction, SqlConnection conn, SqlTransaction trans)
        {
            const string sql = @"
            INSERT INTO T_RIGHT_FUNCTION(SYSID,FUNC_CODE,FUNC_NAME,FUNC_PARAM,CREATED_ON,CREATED_BY,MODIFIED_ON,MODIFIED_BY,RECORD_STATUS)
            VALUES(@Sysid,@FuncCode,@FuncName,@FuncParam,CONVERT(NVARCHAR(50),GETDATE(),121),@CreatedBy,CONVERT(NVARCHAR(50),GETDATE(),121),@ModifiedBy,@RecordStatus)

            ";

            return Dapper.Save(rightFunction, sql, conn, trans);
        }
Beispiel #4
0
        public static bool Delete(RightFunction rightFunction, SqlConnection conn, SqlTransaction trans)
        {
            const string sql = @"
DELETE FROM T_RIGHT_FUNCTION
WHERE SYSID=@Sysid

";

            return(Dapper.Save(rightFunction, sql, conn, trans));
        }
Beispiel #5
0
        public static bool Insert(RightFunction rightFunction, SqlConnection conn, SqlTransaction trans)
        {
            const string sql = @"
INSERT INTO T_RIGHT_FUNCTION(SYSID,FUNC_CODE,FUNC_NAME,FUNC_PARAM,CREATED_ON,CREATED_BY,MODIFIED_ON,MODIFIED_BY,RECORD_STATUS)
VALUES(@Sysid,@FuncCode,@FuncName,@FuncParam,CONVERT(NVARCHAR(50),GETDATE(),121),@CreatedBy,CONVERT(NVARCHAR(50),GETDATE(),121),@ModifiedBy,@RecordStatus)

";

            return(Dapper.Save(rightFunction, sql, conn, trans));
        }
        public static bool Delete(RightFunction rightFunction, SqlConnection conn, SqlTransaction trans)
        {
            const string sql = @"
            DELETE FROM T_RIGHT_FUNCTION
            WHERE SYSID=@Sysid

            ";

            return Dapper.Save(rightFunction, sql, conn, trans);
        }
Beispiel #7
0
        public static bool Update(RightFunction rightFunction, SqlConnection conn, SqlTransaction trans)
        {
            const string sql = @"
UPDATE T_RIGHT_FUNCTION
SET FUNC_CODE=@FuncCode,FUNC_NAME=@FuncName,FUNC_PARAM=@FuncParam,CREATED_BY=@CreatedBy,MODIFIED_ON=CONVERT(NVARCHAR(50),GETDATE(),121),MODIFIED_BY=@ModifiedBy,RECORD_STATUS=@RecordStatus
WHERE SYSID=@Sysid

";

            return(Dapper.Save(rightFunction, sql, conn, trans));
        }
Beispiel #8
0
        public static List <RightFunction> QueryMutileFunction(RightFunction rightFunction)
        {
            const string sql = @"
SELECT SYSID AS Sysid,FUNC_CODE AS FuncCode,FUNC_NAME AS FuncName,FUNC_PARAM AS FuncParam
    ,CREATED_ON AS CreatedOn,CREATED_BY AS CreatedBy,MODIFIED_ON AS ModifiedOn
    ,MODIFIED_BY AS ModifiedBy,RECORD_STATUS AS RecordStatus
FROM T_RIGHT_FUNCTION WITH(NOLOCK) 
WHERE 1 = 1
	AND FUNC_CODE = @FuncCode 
    AND FUNC_PARAM = @FuncParam ";

            return(Dapper.Query <RightFunction>(sql, rightFunction));
        }
 public static bool InsertRightFunction(RightFunction rightFunction, out string msg)
 {
     var rightFunctions = RightFunctionDal.QueryMutileFunction(rightFunction);
     if (rightFunctions != null && rightFunctions.Count > 0)
     {
         msg = string.Format("功能编号{0}、功能参数{1}的记录已经存在", rightFunction.FuncCode, rightFunction.FuncParam);
         return false;
     }
     if (!RightFunctionDal.Insert(rightFunction))
     {
         msg = "新增失败";
         return false;
     }
     msg = "新增成功";
     return true;
 }
Beispiel #10
0
        public static bool InsertRightFunction(RightFunction rightFunction, out string msg)
        {
            var rightFunctions = RightFunctionDal.QueryMutileFunction(rightFunction);

            if (rightFunctions != null && rightFunctions.Count > 0)
            {
                msg = string.Format("功能编号{0}、功能参数{1}的记录已经存在", rightFunction.FuncCode, rightFunction.FuncParam);
                return(false);
            }
            if (!RightFunctionDal.Insert(rightFunction))
            {
                msg = "新增失败";
                return(false);
            }
            msg = "新增成功";
            return(true);
        }
Beispiel #11
0
        public static bool Delete(RightFunction rightFunction)
        {
            using (var conn = new SqlConnection(Conn.getConn()))
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                using (var trans = conn.BeginTransaction())
                {
                    //1、删除功能信息
                    var result = Delete(rightFunction, conn, trans);
                    if (!result)
                    {
                        trans.Rollback();
                        return(false);
                    }
                    //2、删除当前功能对应的功能分组信息
                    RightLkFunctionGroupDal.DeleteByFunctionSysid(new RightLkFunctionGroup {
                        FunctionSysid = rightFunction.Sysid
                    }, conn, trans);

                    //3、删除当前功能对应的功能命令信息
                    RightLkFunctionCommandDal.DeleteByFunctionSysid(new RightLkFunctionCommand {
                        FunctionSysid = rightFunction.Sysid
                    }, conn, trans);

                    //4、删除当前功能对应的权限分配信息
                    RightDal.DeleteByFunctionSysid(new Right {
                        FunctionSysid = rightFunction.Sysid
                    }, conn, trans);

                    trans.Commit();
                }

                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }
            }

            return(true);
        }
Beispiel #12
0
 public static bool UpdateRightFunction(RightFunction rightFunction, out string msg)
 {
     var rightFunctions = RightFunctionDal.QueryMutileFunction(rightFunction);
     if (rightFunctions != null && rightFunctions.Count > 0)
     {
         if (rightFunctions.FindAll(p => p.Sysid != rightFunction.Sysid).Count > 0)
         {
             msg = string.Format("功能编号{0}、功能参数{1}的记录已经存在", rightFunction.FuncCode, rightFunction.FuncParam);
             return false;
         }
     }
     if (!RightFunctionDal.Update(rightFunction))
     {
         msg = "修改失败";
         return false;
     }
     msg = "修改成功";
     return true;
 }
Beispiel #13
0
        public static bool UpdateRightFunction(RightFunction rightFunction, out string msg)
        {
            var rightFunctions = RightFunctionDal.QueryMutileFunction(rightFunction);

            if (rightFunctions != null && rightFunctions.Count > 0)
            {
                if (rightFunctions.FindAll(p => p.Sysid != rightFunction.Sysid).Count > 0)
                {
                    msg = string.Format("功能编号{0}、功能参数{1}的记录已经存在", rightFunction.FuncCode, rightFunction.FuncParam);
                    return(false);
                }
            }
            if (!RightFunctionDal.Update(rightFunction))
            {
                msg = "修改失败";
                return(false);
            }
            msg = "修改成功";
            return(true);
        }
Beispiel #14
0
 public static bool DeleteRightFunction(RightFunction rightFunction)
 {
     return(RightFunctionDal.Delete(rightFunction));
 }
Beispiel #15
0
 //删除数据
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <returns></returns>
 internal override bool Delete()
 {
     if (EditEntity == null)
     {
         UI.ShowWarn("请选择待删除数据");
         return false;
     }
     if (!UI.Confirm("确定要删除吗?"))
         return false;
     if (!RightFunctionBll.DeleteRightFunction(EditEntity))
     {
         UI.ShowError("删除失败");
         return false;
     }
     EditEntity = null;
     UI.ClearUi(pageEditData);
     return true;
 }
Beispiel #16
0
 public static bool DeleteRightFunction(RightFunction rightFunction)
 {
     return RightFunctionDal.Delete(rightFunction);
 }
Beispiel #17
0
        //设置选中的实体
        /// <summary>
        /// 设置选中的实体
        /// </summary>
        private void SetSelectedEntity()
        {
            if (grdQueryResult.SelectedRows == null ||
                grdQueryResult.SelectedRows.Count <= 0)
                return;

            EditEntity = grdQueryResult.SelectedRows[0].DataBoundItem as RightFunction;

            InitEditForm();
        }
Beispiel #18
0
        //用编辑框数据填充实体
        /// <summary>
        /// 用编辑框数据填充实体
        /// </summary>
        private void BuildEntity()
        {
            if (CurrentOperationStatus == OperationStatus.New)
                EditEntity = new RightFunction
                    {
                        Sysid = Sysid.NewId(""),
                        CreatedBy = GloableData.Instance.UserId
                    };

            EditEntity.ModifiedBy = GloableData.Instance.UserId;

            EditEntity.FuncCode = UI.GetValue(txtFuncCode);
            EditEntity.FuncName = UI.GetValue(txtFuncName);
            EditEntity.FuncParam = UI.GetValue(txtFuncParam);
            EditEntity.RecordStatus = UI.GetValue(chkIsEnable);
        }
Beispiel #19
0
        public static List<RightFunction> QueryMutileFunction(RightFunction rightFunction)
        {
            const string sql = @"
            SELECT SYSID AS Sysid,FUNC_CODE AS FuncCode,FUNC_NAME AS FuncName,FUNC_PARAM AS FuncParam
            ,CREATED_ON AS CreatedOn,CREATED_BY AS CreatedBy,MODIFIED_ON AS ModifiedOn
            ,MODIFIED_BY AS ModifiedBy,RECORD_STATUS AS RecordStatus
            FROM T_RIGHT_FUNCTION WITH(NOLOCK)
            WHERE 1 = 1
            AND FUNC_CODE = @FuncCode
            AND FUNC_PARAM = @FuncParam ";

            return Dapper.Query<RightFunction>(sql, rightFunction);
        }
Beispiel #20
0
        public static bool Update(RightFunction rightFunction, SqlConnection conn, SqlTransaction trans)
        {
            const string sql = @"
            UPDATE T_RIGHT_FUNCTION
            SET FUNC_CODE=@FuncCode,FUNC_NAME=@FuncName,FUNC_PARAM=@FuncParam,CREATED_BY=@CreatedBy,MODIFIED_ON=CONVERT(NVARCHAR(50),GETDATE(),121),MODIFIED_BY=@ModifiedBy,RECORD_STATUS=@RecordStatus
            WHERE SYSID=@Sysid

            ";

            return Dapper.Save(rightFunction, sql, conn, trans);
        }
        //初始化功能命令关系
        /// <summary>
        /// 初始化功能命令关系
        /// </summary>
        private void InitFuncCommands(RightFunction rightFunction)
        {
            if (rightFunction == null)
                return;

            var list =
                RightLkFunctionCommandBll.QueryRightLkFunctionCommand(new QueryCondition { Resv01 = rightFunction.Sysid });
            gridViewCommand.ValueChanging -= gridViewCommand_ValueChanging;

            _commandsInDb = new List<DictionaryItem>();
            foreach (var row in gridViewCommand.Rows)
            {
                var command = row.DataBoundItem as DictionaryItem;
                if (command == null)
                    continue;

                var isChecked = list.FindAll(p => p.CommandSysid == command.Sysid).Count > 0;
                if (isChecked)
                {
                    var copiedCommand = Mapper.Map<DictionaryItem, DictionaryItem>(command);
                    _commandsInDb.Add(copiedCommand);
                }
                row.Cells[0].Value = isChecked;
            }

            gridViewCommand.ValueChanging += gridViewCommand_ValueChanging;
        }