예제 #1
0
        /// <summary>
        /// 創建新用戶
        /// </summary>
        /// <param name="requestValue"></param>
        /// <param name="Data"></param>
        /// <param name="StationReturn"></param>
        public void RegisterNewUser(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec  sfcdb = null;
            T_c_user USER;

            try
            {
                sfcdb = this.DBPools["SFCDB"].Borrow();
                USER  = new T_c_user(sfcdb, DBTYPE);
                Row_c_user UserRow = (Row_c_user)USER.NewRow();
                UserRow.ID                   = USER.GetNewID(BU, sfcdb);
                UserRow.FACTORY              = Data["FACTORY"].ToString();
                UserRow.BU_NAME              = Data["BU_NAME"].ToString();
                UserRow.EMP_NO               = Data["EMP_NO"].ToString();
                UserRow.EMP_PASSWORD         = Data["EMP_PASSWORD"].ToString();
                UserRow.EMP_NAME             = Data["EMP_NAME"].ToString();
                UserRow.EMP_LEVEL            = "0";//Data["EMP_LEVEL"].ToString();///創建用戶默認全部為普通用戶 0表示普通用戶,1表示可編輯本部門角色權限的用戶,9表示後台管理,能操作權限相關的任何動作
                UserRow.DPT_NAME             = Data["DPT_NAME"].ToString();
                UserRow.POSITION_NAME        = Data["POSITION_NAME"].ToString();
                UserRow.MAIL_ADDRESS         = Data["MAIL_ADDRESS"].ToString().ToLower();
                UserRow.PHONE_NUMBER         = Data["PHONE_NUMBER"].ToString();
                UserRow.LOCATION             = Data["LOCATION"].ToString();
                UserRow.LOCK_FLAG            = "N";
                UserRow.AGENT_EMP_NO         = Data["AGENT_EMP_NO"].ToString();
                UserRow.CHANGE_PASSWORD_TIME = GetDBDateTime();
                UserRow.EMP_DESC             = Data["EMP_DESC"].ToString();
                UserRow.EDIT_TIME            = GetDBDateTime();
                UserRow.EDIT_EMP             = Data["EMP_NO"].ToString();
                UserRow.EMP_EN_NAME          = Data["EMP_EN_NAME"].ToString();

                if (Data["FACTORY"].ToString() == null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = "";
                    return;
                }

                if (Data["BU_NAME"].ToString() == null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = "廠別為空";
                    return;
                }

                if (Data["EMP_NO"].ToString() == null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = "工號為空";
                    return;
                }
                if (Data["DPT_NAME"].ToString() == null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = "所屬部門";
                    return;
                }

                if (Data["EMP_NAME"].ToString() == null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = "員工姓名為空";
                    return;
                }

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

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

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

                DataTable userstr = new DataTable();
                userstr = USER.SelectC_Userbyempno(UserRow.EMP_NO, sfcdb, this.DBTYPE);
                if (userstr.Rows.Count != 0)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000012";
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
                else
                {
                    string strRet = sfcdb.ExecSQL(UserRow.GetInsertString(this.DBTYPE));

                    if (strRet == "1")
                    {
                        StationReturn.Status      = StationReturnStatusValue.Pass;
                        StationReturn.MessageCode = "MES00000013";
                        this.DBPools["SFCDB"].Return(sfcdb);
                    }
                    else
                    {
                        StationReturn.Status      = StationReturnStatusValue.Fail;
                        StationReturn.MessageCode = "MES00000014";
                        this.DBPools["SFCDB"].Return(sfcdb);
                    }
                }
            }
            catch (Exception e)
            {
                this.DBPools["SFCDB"].Return(sfcdb);
                throw e;
            }
        }
예제 #2
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;
            }
        }