Exemplo n.º 1
0
        public void UpdateWorkClass(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            string           strID        = Data["CLASS_ID"].ToString().Trim();
            string           newClassName = Data["NEW_CLASS_NAME"].ToString().Trim();
            string           startTime    = Data["START_TIME"].ToString().Trim();
            string           endTime      = Data["END_TIME"].ToString().Trim();
            OleExec          oleDB        = null;
            T_C_WORK_CLASS   workClass    = null;
            Row_C_WORK_CLASS workClassRow = null;

            if (string.IsNullOrEmpty(strID))
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000006";
                StationReturn.MessagePara.Add("CLASS ID");
                StationReturn.Data = "";
                return;
            }
            if (string.IsNullOrEmpty(startTime))
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000006";
                StationReturn.MessagePara.Add("START TIME");
                StationReturn.Data = "";
                return;
            }
            if (string.IsNullOrEmpty(endTime))
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000006";
                StationReturn.MessagePara.Add("END TIME");
                StationReturn.Data = "";
                return;
            }
            try
            {
                oleDB        = this.DBPools["SFCDB"].Borrow();
                workClass    = new T_C_WORK_CLASS(oleDB, DBTYPE);
                workClassRow = (Row_C_WORK_CLASS)workClass.NewRow();
                if (!workClass.WorkClassIsExistByID(strID, oleDB))
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000007";
                    StationReturn.Data        = "";
                }
                else if (!string.IsNullOrEmpty(newClassName) && workClass.WorkClassIsExistByName(newClassName, oleDB))
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000008";
                    StationReturn.MessagePara.Add(newClassName);
                    StationReturn.Data = "";
                }
                else
                {
                    workClassRow = (Row_C_WORK_CLASS)workClass.GetObjByID(strID, oleDB, DBTYPE);
                    if (!string.IsNullOrEmpty(newClassName))
                    {
                        workClassRow.NAME = newClassName;
                    }
                    if (!string.IsNullOrEmpty(startTime))
                    {
                        workClassRow.START_TIME = startTime;
                    }
                    if (!string.IsNullOrEmpty(endTime))
                    {
                        workClassRow.END_TIME = endTime;
                    }
                    oleDB.ThrowSqlExeception = true;
                    oleDB.ExecSQL(workClassRow.GetUpdateString(DBTYPE));
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000003";
                    StationReturn.Data        = "";
                }
                this.DBPools["SFCDB"].Return(oleDB);
            }
            catch (Exception exception)
            {
                this.DBPools["SFCDB"].Return(oleDB);
                throw exception;
            }
        }
Exemplo n.º 2
0
        public void AddWorkClass(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            string         className = Data["CLASS_NAME"].ToString().Trim();
            string         startTime = Data["START_TIME"].ToString().Trim();
            string         endTime   = Data["END_TIME"].ToString().Trim();
            bool           isExist   = false;
            OleExec        oleDB     = null;
            T_C_WORK_CLASS workClass = null;

            if (string.IsNullOrEmpty(className))
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000006";
                StationReturn.MessagePara.Add("CLASS NAME");
                StationReturn.Data = "";
                return;
            }
            if (string.IsNullOrEmpty(startTime))
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000006";
                StationReturn.MessagePara.Add("START TIME");
                StationReturn.Data = "";
                return;
            }
            if (string.IsNullOrEmpty(endTime))
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000006";
                StationReturn.MessagePara.Add("END TIME");
                StationReturn.Data = "";
                return;
            }
            try
            {
                oleDB     = this.DBPools["SFCDB"].Borrow();
                workClass = new T_C_WORK_CLASS(oleDB, DBTYPE);
                if (workClass.WorkClassIsExistByName(className, oleDB))
                {
                    StationReturn.MessagePara.Add(className);
                    isExist = true;
                }
                if (workClass.TimeIsExist(startTime, oleDB))
                {
                    StationReturn.MessagePara.Add(startTime);
                    isExist = true;
                }
                if (workClass.TimeIsExist(endTime, oleDB))
                {
                    StationReturn.MessagePara.Add(endTime);
                    isExist = true;
                }
                if (isExist)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000008";
                    StationReturn.Data        = "";
                }
                else
                {
                    Row_C_WORK_CLASS workClassRow = (Row_C_WORK_CLASS)workClass.NewRow();
                    workClassRow.ID          = workClass.GetNewID(this.BU, oleDB, DBTYPE);
                    workClassRow.NAME        = className;
                    workClassRow.START_TIME  = startTime;
                    workClassRow.END_TIME    = endTime;
                    oleDB.ThrowSqlExeception = true;
                    oleDB.ExecSQL(workClassRow.GetInsertString(DBTYPE));
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000002";
                    StationReturn.Data        = "";
                }
                this.DBPools["SFCDB"].Return(oleDB);
            }
            catch (Exception exctption)
            {
                this.DBPools["SFCDB"].Return(oleDB);
                throw exctption;
            }
        }