Example #1
0
        /// <summary>
        /// 刪除用戶信息
        /// </summary>
        public void DeleteInformation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec  sfcdb     = null;
            string   DeleteSql = "";
            string   strid     = "";
            T_c_user DeleteInformation;

            Newtonsoft.Json.Linq.JArray ID = (Newtonsoft.Json.Linq.JArray)Data["ID"];
            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                sfcdb.BeginTrain();
                DeleteInformation = new T_c_user(sfcdb, DBTYPE);
                for (int i = 0; i < ID.Count; i++)
                {
                    strid = ID[i].ToString();
                    Row_c_user row = (Row_c_user)DeleteInformation.GetObjByID(strid, sfcdb);
                    DeleteSql += row.GetDeleteString(DBTYPE) + ";\n";
                }
                DeleteSql = "begin\n" + DeleteSql + "end;";
                sfcdb.ExecSQL(DeleteSql);
                StationReturn.Status      = StationReturnStatusValue.Pass;
                StationReturn.MessageCode = "MES00000004";
                sfcdb.CommitTrain();
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception e)
            {
                sfcdb.RollbackTrain();
                this.DBPools["SFCDB"].Return(sfcdb);
                throw e;
            }
        }
Example #2
0
        /// <summary>
        ///修改用戶密碼
        /// </summary>
        public void UpdatePassword(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec  sfcdb     = null;
            string   UpdateSql = "";
            T_c_user UserInformation;
            string   OldPwd    = Data["OLDPWD"].ToString();
            string   NewPwd    = Data["NEWPWD"].ToString();
            string   ConNewPwd = Data["CONNEWPWD"].ToString();

            try
            {
                sfcdb           = this.DBPools["SFCDB"].Borrow();
                UserInformation = new T_c_user(sfcdb, DBTYPE);
                Row_c_user row = (Row_c_user)UserInformation.GetObjByID(LoginUser.ID, sfcdb);

                if (OldPwd == row.EMP_PASSWORD)
                {
                    if (NewPwd == ConNewPwd)
                    {
                        row.ID           = LoginUser.ID;
                        row.EMP_PASSWORD = ConNewPwd;
                        row.EDIT_EMP     = LoginUser.EMP_NO;
                        row.EDIT_TIME    = GetDBDateTime();

                        UpdateSql = row.GetUpdateString(DBTYPE);
                        sfcdb.ExecSQL(UpdateSql);
                        StationReturn.Status  = StationReturnStatusValue.Pass;
                        StationReturn.Message = "密碼更新成功";
                        StationReturn.Data    = "";
                        this.DBPools["SFCDB"].Return(sfcdb);
                    }
                    else
                    {
                        StationReturn.Status  = StationReturnStatusValue.Fail;
                        StationReturn.Message = "前後兩次輸入密碼不一致";
                        StationReturn.Data    = NewPwd + " <> " + ConNewPwd;
                        this.DBPools["SFCDB"].Return(sfcdb);
                    }
                }
                else
                {
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = "舊密碼不正確";
                    StationReturn.Data    = OldPwd;
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
            }
            catch (Exception e)
            {
                this.DBPools["SFCDB"].Return(sfcdb);
                throw e;
            }
        }
Example #3
0
        /// <summary>
        ///給用戶添加角色 INSERT C_USER_ROLE,并更新C_USER LEVEL_FLAG欄位的值 0表示普通用戶,1表示普通管理員,9 IT所有
        /// </summary>
        public void AddUserRolePrivilege(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec       sfcdb = null;
            string        InsertSql = "", UpdateSql = "";
            T_c_user_role UserRoler;
            T_c_user      EmpLevel;
            string        EMP_NO     = Data["EMP_NO"].ToString();
            string        LEVEL_FLAG = Data["LEVEL_FLAG"].ToString();

            //    string[] ROLE_ID = Data["ROLE_ID"].ToString().Trim('[').Trim(']').Split(',');
            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                sfcdb.BeginTrain();
                UserRoler = new T_c_user_role(sfcdb, DBTYPE);
                EmpLevel  = new T_c_user(sfcdb, DBTYPE);
                string USER_ID = UserRoler.GetUserID(EMP_NO, sfcdb);

                foreach (string item in Data["ROLE_ID"])
                {
                    string strroleid = item.Trim('\'').Trim('\"');
                    if (UserRoler.CheckUserRole(USER_ID, strroleid, sfcdb))
                    {
                        Row_c_user_role row = (Row_c_user_role)UserRoler.NewRow();
                        row.ID          = UserRoler.GetNewID(BU, sfcdb);
                        row.USER_ID     = USER_ID;
                        row.ROLE_ID     = strroleid;
                        row.EDIT_EMP    = LoginUser.EMP_NO;
                        row.SYSTEM_NAME = SystemName;
                        row.EDIT_TIME   = GetDBDateTime();
                        InsertSql      += row.GetInsertString(DBTYPE) + ";\n";
                    }
                    else
                    {
                        sfcdb.RollbackTrain();
                        StationReturn.Status  = StationReturnStatusValue.Fail;
                        StationReturn.Message = "該用戶已擁有該角色";
                        StationReturn.Data    = "";
                        this.DBPools["SFCDB"].Return(sfcdb);
                        return;
                    }
                }

                InsertSql = "begin\n" + InsertSql + "end;";
                sfcdb.ExecSQL(InsertSql);

                if (EmpLevel.CheckEmpLevel(USER_ID, LEVEL_FLAG, sfcdb))
                {
                    Row_c_user RowLevel = (Row_c_user)EmpLevel.GetObjByID(USER_ID, sfcdb);
                    RowLevel.ID        = USER_ID;
                    RowLevel.EMP_LEVEL = LEVEL_FLAG;
                    RowLevel.EDIT_EMP  = LoginUser.EMP_NO;
                    RowLevel.EDIT_TIME = GetDBDateTime();

                    UpdateSql = RowLevel.GetUpdateString(DBTYPE);
                    sfcdb.ExecSQL(UpdateSql);
                }

                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;
            }
        }
Example #4
0
        /// <summary>
        /// 更新用戶信息
        /// </summary>
        public void UpdateInformation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec  sfcdb     = null;
            string   UpdateSql = "";
            T_c_user GetInformation;
            string   ID            = Data["ID"].ToString();
            string   FACTORY       = Data["FACTORY"].ToString();
            string   BU_NAME       = Data["BU_NAME"].ToString();
            string   EMP_NO        = Data["EMP_NO"].ToString();
            string   EMP_PASSWORD  = Data["EMP_PASSWORD"].ToString();
            string   EMP_NAME      = Data["EMP_NAME"].ToString();
            string   DPT_NAME      = Data["DPT_NAME"].ToString();
            string   POSITION_NAME = Data["POSITION_NAME"].ToString();
            string   MAIL_ADDRESS  = Data["MAIL_ADDRESS"].ToString();
            string   PHONE_NUMBER  = Data["PHONE_NUMBER"].ToString();
            string   LOCATION      = Data["LOCATION"].ToString();
            string   AGENT_EMP_NO  = Data["AGENT_EMP_NO"].ToString();
            string   EMP_DESC      = Data["EMP_DESC"].ToString();
            string   EMP_EN_NAME   = Data["EMP_EN_NAME"].ToString();

            try
            {
                sfcdb          = this.DBPools["SFCDB"].Borrow();
                GetInformation = new T_c_user(sfcdb, DBTYPE);
                Row_c_user row = (Row_c_user)GetInformation.GetObjByID(Data["ID"].ToString(), sfcdb);
                row.ID                   = ID;
                row.FACTORY              = FACTORY;
                row.BU_NAME              = BU_NAME;
                row.EMP_NO               = EMP_NO;
                row.EMP_PASSWORD         = EMP_PASSWORD;
                row.EMP_NAME             = EMP_NAME;
                row.DPT_NAME             = DPT_NAME;
                row.POSITION_NAME        = POSITION_NAME;
                row.MAIL_ADDRESS         = MAIL_ADDRESS;
                row.PHONE_NUMBER         = PHONE_NUMBER;
                row.LOCATION             = LOCATION;
                row.AGENT_EMP_NO         = AGENT_EMP_NO;
                row.EMP_DESC             = EMP_DESC;
                row.EMP_EN_NAME          = EMP_EN_NAME;
                row.EDIT_TIME            = GetDBDateTime();
                row.CHANGE_PASSWORD_TIME = GetDBDateTime();

                ///CHECK 用戶密碼
                string STRPWD = GetInformation.CheckPWD(EMP_PASSWORD, sfcdb);
                if (STRPWD != "Pass")
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = STRPWD;
                    return;
                }

                /// CHECK EMAIL地址
                string STRMAIL = GetInformation.CheckMail(MAIL_ADDRESS.ToLower(), sfcdb);
                if (STRMAIL != "Pass")
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = STRMAIL;
                    return;
                }

                ///CHECK 電話號碼
                if (!GetInformation.CheckPhone(PHONE_NUMBER, sfcdb))
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = "电话号码填寫格式不正確";
                    return;
                }

                UpdateSql = row.GetUpdateString(DBTYPE);
                sfcdb.ExecSQL(UpdateSql);
                StationReturn.Status      = StationReturnStatusValue.Pass;
                StationReturn.MessageCode = "MES00000001";
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception e)
            {
                this.DBPools["SFCDB"].Return(sfcdb);
                throw e;
            }
        }