Exemplo n.º 1
0
        public void DeleteWorkClass(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            //string id = Data["CLASS_ID"].ToString().Trim();
            Newtonsoft.Json.Linq.JArray idArray = (Newtonsoft.Json.Linq.JArray)Data["CLASS_ID"];
            OleExec          oleDB     = null;
            T_C_WORK_CLASS   workClass = null;
            Row_C_WORK_CLASS workClassRow;

            if (idArray.Count == 0)
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000006";
                StationReturn.MessagePara.Add("CLASS ID");
                StationReturn.Data = "";
                return;
            }
            try
            {
                oleDB = this.DBPools["SFCDB"].Borrow();
                oleDB.ThrowSqlExeception = true;
                oleDB.BeginTrain();
                workClass = new T_C_WORK_CLASS(oleDB, DBTYPE);
                for (int i = 0; i < idArray.Count; i++)
                {
                    workClassRow = (Row_C_WORK_CLASS)workClass.GetObjByID(idArray[i].ToString(), oleDB, DBTYPE);

                    oleDB.ExecSQL(workClassRow.GetDeleteString(DBTYPE));
                }
                oleDB.CommitTrain();
                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "MES00000004";
                StationReturn.Data    = "";
                this.DBPools["SFCDB"].Return(oleDB);
            }
            catch (Exception exception)
            {
                oleDB.RollbackTrain();
                this.DBPools["SFCDB"].Return(oleDB);
                throw exception;
            }
        }
Exemplo n.º 2
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;
            }
        }