예제 #1
0
        /// <summary>
        /// 刪除角色ID信息刪除C_ROLE表,C_ROLE_PRIVILEGE ,C_USER_ROLE
        /// </summary>
        public void DeleteRole(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec            sfcdb     = null;
            string             DeleteSql = "";
            string             strid     = "";
            T_C_ROLE           GetRoleInformation;
            T_C_ROLE_PRIVILEGE GetRolePrivilegeInfo;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                sfcdb.BeginTrain();
                GetRoleInformation   = new T_C_ROLE(sfcdb, DBTYPE);
                GetRolePrivilegeInfo = new T_C_ROLE_PRIVILEGE(sfcdb, DBTYPE);
                foreach (string item in Data["ID"])
                {
                    strid = item.Trim('\'').Trim('\"');
                    if (GetRoleInformation.CheckRole(strid, sfcdb))
                    {
                        Row_C_ROLE row = (Row_C_ROLE)GetRoleInformation.GetObjByID(strid, sfcdb);
                        DeleteSql += row.GetDeleteString(DBTYPE) + ";\n";
                        if (!GetRolePrivilegeInfo.CheckRolePrivilege(strid, sfcdb)) //檢查C_ROLE_PRIVILEGE是否有添加角色權限,如果存在就刪除
                        {
                            Row_C_PRIVILEGE PrivilegeRow = (Row_C_PRIVILEGE)GetRolePrivilegeInfo.GetObjByRoleID(strid, sfcdb);
                            DeleteSql += PrivilegeRow.GetDeleteString(DBTYPE) + ";\n";
                        }
                    }
                    else
                    {
                        sfcdb.RollbackTrain();
                        StationReturn.Status  = StationReturnStatusValue.Fail;
                        StationReturn.Message = "該角色已被賦予用戶使用,不能刪除";
                        StationReturn.Data    = "";
                        this.DBPools["SFCDB"].Return(sfcdb);
                        return;
                    }
                }

                DeleteSql = "BEGIN\n" + DeleteSql + "END;";

                sfcdb.ExecSQL(DeleteSql);
                sfcdb.CommitTrain();
                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "刪除成功";
                sfcdb.CommitTrain();
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception e)
            {
                sfcdb.RollbackTrain();
                this.DBPools["SFCDB"].Return(sfcdb);
                throw e;
            }
        }
예제 #2
0
        /// <summary>
        /// 更新角色ID信息,更新C_ROLE表相關內容
        /// </summary>
        public void UpdateRole(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec  sfcdb     = null;
            string   UpdateSql = "";
            T_C_ROLE GetRoleInformation;
            string   ID        = Data["ID"].ToString();
            string   ROLE_NAME = Data["ROLE_NAME"].ToString();
            string   ROLE_DESC = Data["ROLE_DESC"].ToString();
            string   ROLE_TYPE = Data["ROLE_TYPE"].ToString();

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                GetRoleInformation = new T_C_ROLE(sfcdb, DBTYPE);
                Row_C_ROLE row = (Row_C_ROLE)GetRoleInformation.GetObjByID(Data["ID"].ToString(), sfcdb);
                row.ID          = ID;
                row.ROLE_NAME   = ROLE_NAME;
                row.ROLE_DESC   = ROLE_DESC;
                row.ROLE_TYPE   = ROLE_TYPE;
                row.EDIT_EMP    = LoginUser.EMP_NO;
                row.SYSTEM_NAME = SystemName;
                row.EDIT_TIME   = GetDBDateTime();

                UpdateSql = row.GetUpdateString(DBTYPE);
                sfcdb.ExecSQL(UpdateSql);
                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "更新成功";
                StationReturn.Data    = "";
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception e)
            {
                this.DBPools["SFCDB"].Return(sfcdb);
                throw e;
            }
        }