Exemple #1
0
        public Message DelCompanyDefineRight(DefineRight dRight)
        {
            Message m = new Message()
            {
                Result = true, TxtMessage = "操作成功。"
            };
            string sqlText = string.Empty;

            try
            {
                //sqlText = string.Format("select COUNT(1) from S_DefineOperRight where CompanyID='{0}' and RightCode='{1}' ", dRight.CompanyID, dRight.RightCode);
                //object count=  SQLHelper.ExecuteScalar(SQLHelper.SchuleConnection, CommandType.Text, sqlText);
                //if (Convert.ToInt32(count) > 0)
                //{
                //    m = new Message() { Result = false, TxtMessage = "操作失败,【权限组使用当中无法删除!】" };
                //    return m;
                //}

                sqlText = string.Format("delete from  S_DefineRightMenu where CompanyID='{0}' and RightCode='{1}' "
                                        + "delete from  S_DefineRight where CompanyID='{0}' and RightCode='{1}' ", dRight.CompanyID, dRight.RightCode);
                SQLHelper.ExecuteScalar(SQLHelper.SchuleConnection, CommandType.Text, sqlText);
                //此处需要清理缓存
                CompanyRightCached.getInstance().RemoveDefineOperRight(dRight.CompanyID);
                CompanyRightCached.getInstance().RemoveDefineRightMenu(dRight.CompanyID);
                CompanyRightCached.getInstance().RemoveDefineRight(dRight.CompanyID);
            }
            catch (Exception e)
            {
                m = new Message()
                {
                    Result = false, TxtMessage = "操作失败,【" + e.Message + "】"
                };
            }
            return(m);
        }
Exemple #2
0
        public Message AddCompanyDefineRight(DefineRight dRight, List <DefineRightMenu> list)
        {
            string  sqlText = string.Empty;
            Message m       = new Message()
            {
                Result = true, TxtMessage = "操作成功。"
            };

            try
            {
                //先删除再执行添加
                if (DelCompanyDefineRight(dRight).Result)
                {
                    sqlText = string.Format("Insert Into S_DefineRight" +
                                            "(RightCode,CompanyID,RightName,Context)" +
                                            "values('{0}','{1}','{2}','{3}')"
                                            , dRight.RightCode, dRight.CompanyID, dRight.RightName, dRight.Context);
                    SQLHelper.ExecuteScalar(SQLHelper.SchuleConnection, CommandType.Text, sqlText);
                    foreach (DefineRightMenu tmp in list)
                    {
                        sqlText = string.Format("Insert Into S_DefineRightMenu" +
                                                "(CompanyID,RightCode,MenuCode)" +
                                                "values('{0}','{1}','{2}')"
                                                , tmp.CompanyID, tmp.RightCode, tmp.MenuCode);
                        SQLHelper.ExecuteScalar(SQLHelper.SchuleConnection, CommandType.Text, sqlText);
                    }
                    m = new Message()
                    {
                        Result = true, TxtMessage = JSon.TToJson <DefineRight>(dRight)
                    };
                }
                else
                {
                    m = new Message()
                    {
                        Result = false, TxtMessage = "操作失败,【删除相同编码权限出错】。"
                    };
                }
            }
            catch (Exception e)
            {
                m = new Message()
                {
                    Result = false, TxtMessage = "操作失败,【" + e.Message + "】。"
                };
            }
            return(m);
        }