/// <summary> /// 新增稱重參數記錄 /// </summary> /// <param name="requestValue"></param> /// <param name="Data"></param> /// <param name="StationReturn"></param> public void AddWT(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { OleExec sfcdb = null; T_C_WT_CONFIG TCWT = null; Row_C_WT_CONFIG RCWT = null; C_WT_CONFIG CWT = null; string sql = ""; string SKU_EditRow = string.Empty; string strReturn = ""; try { sfcdb = this.DBPools["SFCDB"].Borrow(); SKU_EditRow = Data["SKU_EditRow"].ToString(); CWT = (C_WT_CONFIG)JsonConvert.Deserialize(SKU_EditRow, typeof(C_WT_CONFIG)); TCWT = new T_C_WT_CONFIG(sfcdb, this.DBTYPE); RCWT = (Row_C_WT_CONFIG)TCWT.NewRow(); RCWT.ID = TCWT.GetNewID(BU, sfcdb); RCWT.SKUNO = CWT.SKUNO; RCWT.BMINVALUE = CWT.BMINVALUE; RCWT.BMAXVALUE = CWT.BMAXVALUE; RCWT.CMINVALUE = CWT.CMINVALUE; RCWT.CMAXVALUE = CWT.CMAXVALUE; RCWT.ONLINE_FLAG = CWT.ONLINE_FLAG; RCWT.EDIT_EMP = LoginUser.EMP_NO; RCWT.EDIT_TIME = GetDBDateTime(); sql = RCWT.GetInsertString(this.DBTYPE); strReturn = sfcdb.ExecSQL(sql); WriteIntoMESLog(sfcdb, BU, "WTConfig", "MESStation.Config.WTConfig", "AddWT", "新增稱重記錄", sql.Substring(0, sql.Length - 1 > 900 ? 900 : sql.Length - 1), LoginUser.EMP_NO); //如果數據更新成功,則返回數據更新的記錄數,如果為Begn...END返回為-1,可被 Int32.Parse 方法轉換成 int if (Int32.Parse(strReturn) > -2) { StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "Add Successful!"; StationReturn.Data = RCWT.ID; } else { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "數據更新失敗!"; StationReturn.Data = strReturn; } } catch (Exception e) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "Add Fail!"; StationReturn.Data = e.Message; } finally { if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } } }
/// <summary> /// 依據ID清單Approve稱重工站 /// </summary> /// <param name="requestValue"></param> /// <param name="Data"></param> /// <param name="StationReturn"></param> public void ApproveWTByID(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { OleExec sfcdb = null; T_C_WT_CONFIG TCWT = null; Row_C_WT_CONFIG RCWT = null; string sql = ""; string strReturn = ""; try { sfcdb = this.DBPools["SFCDB"].Borrow(); sfcdb.BeginTrain(); TCWT = new T_C_WT_CONFIG(sfcdb, this.DBTYPE); RCWT = (Row_C_WT_CONFIG)TCWT.NewRow(); foreach (string item in Data["IDList"]) { string strID = item.Trim('\'').Trim('\"'); RCWT = (Row_C_WT_CONFIG)TCWT.GetObjByID(strID, sfcdb); RCWT.APPROVE_EMP = (string)Data["LoginUserEmp"]; RCWT.APPROVE_TIME = GetDBDateTime(); sql += RCWT.GetUpdateString(this.DBTYPE) + ";\n"; } strReturn = sfcdb.ExecSQL("Begin\n" + sql + "End;"); WriteIntoMESLog(sfcdb, BU, "WTConfig", "MESStation.Config.WTConfig", "ApproveWT", "簽核稱重記錄", sql.Substring(0, sql.Length - 1 > 900 ? 900 : sql.Length - 1), LoginUser.EMP_NO); //如果數據更新成功,則返回數據更新的記錄數,如果為Begn...END返回為-1,可被 Int32.Parse 方法轉換成 int if (Int32.Parse(strReturn) > -2) { StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "Approve成功!"; } else { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "Approve 數據更新失敗!"; StationReturn.Data = strReturn; } sfcdb.CommitTrain(); }catch (Exception e) { sfcdb.RollbackTrain(); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "Approve失敗或該記錄已經不存在!"; StationReturn.Data = e.Message; } finally { if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } } }