public static void UpdateWOKeypartID(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras) { if (Paras.Count != 1) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050")); } MESStationSession sessionWO = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); if (sessionWO == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE })); } try { int result; WorkOrder objWorkorder = new WorkOrder(); objWorkorder = (WorkOrder)sessionWO.Value; T_C_KP_LIST t_c_kp_list = new T_C_KP_LIST(Station.SFCDB, Station.DBType); T_R_WO_BASE t_r_wo_base = new T_R_WO_BASE(Station.SFCDB, Station.DBType); Row_R_WO_BASE rowWOBase; List <string> kpList = t_c_kp_list.GetListIDBySkuno(objWorkorder.SkuNO, Station.SFCDB); if (kpList.Count == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { objWorkorder.SkuNO })); } rowWOBase = (Row_R_WO_BASE)t_r_wo_base.GetObjByID(objWorkorder.ID, Station.SFCDB); rowWOBase.KP_LIST_ID = kpList[0].ToString(); result = Station.SFCDB.ExecSqlNoReturn(rowWOBase.GetUpdateString(Station.DBType), null); if (result <= 0) { //報錯信息待改 throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { objWorkorder.WorkorderNo })); } Station.AddMessage("MES00000063", new string[] { objWorkorder.WorkorderNo }, StationMessageState.Pass); } catch (Exception ex) { throw ex; } }
public void CutWoBySNId(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JToken Data, MESStationReturn StationReturn) { OleExec sfcdb = null; try { string wo = Data["WO"].ToString().ToUpper().Trim(); string closeFlag = Data["CLOSEFLAG"].ToString().ToUpper().Trim(); Newtonsoft.Json.Linq.JArray arrayId = (Newtonsoft.Json.Linq.JArray)Data["ID"]; sfcdb = this.DBPools["SFCDB"].Borrow(); sfcdb.ThrowSqlExeception = true; T_R_WO_BASE t_r_wo_base = new T_R_WO_BASE(sfcdb, DBTYPE); R_WO_BASE r_wo_base = t_r_wo_base.GetWoByWoNo(wo, sfcdb); if (r_wo_base == null) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000164", new string[] { wo })); } T_R_SN t_r_sn = new T_R_SN(sfcdb, DBTYPE); Row_R_SN rowSN; for (int i = 0; i < arrayId.Count; i++) { rowSN = (Row_R_SN)t_r_sn.GetObjByID(arrayId[i].ToString(), sfcdb); rowSN.SN = "CUT_" + rowSN.SN; rowSN.WORKORDERNO = "CUT_" + rowSN.WORKORDERNO; rowSN.SKUNO = "CUT_" + rowSN.SKUNO; rowSN.EDIT_EMP = LoginUser.EMP_NO; rowSN.EDIT_TIME = GetDBDateTime(); sfcdb.ExecSQL(rowSN.GetUpdateString(DBTYPE)); } Row_R_WO_BASE rowWoBase = (Row_R_WO_BASE)t_r_wo_base.GetObjByID(r_wo_base.ID, sfcdb); rowWoBase.WORKORDER_QTY = r_wo_base.WORKORDER_QTY - Convert.ToDouble(arrayId.Count); rowWoBase.INPUT_QTY = r_wo_base.INPUT_QTY - Convert.ToDouble(arrayId.Count); rowWoBase.EDIT_EMP = LoginUser.EMP_NO; rowWoBase.EDIT_TIME = GetDBDateTime(); if (closeFlag == "1") { rowWoBase.CLOSED_FLAG = closeFlag; rowWoBase.CLOSE_DATE = GetDBDateTime(); } sfcdb.ExecSQL(rowWoBase.GetUpdateString(DBTYPE)); this.DBPools["SFCDB"].Return(sfcdb); StationReturn.Data = r_wo_base; StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.MessageCode = "MES00000210"; StationReturn.MessagePara.Add(wo); StationReturn.MessagePara.Add(arrayId.Count); } catch (Exception exception) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000037"; StationReturn.MessagePara.Add(exception.Message); StationReturn.Data = exception.Message; if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } } }
public void CutWoByNum(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JToken Data, MESStationReturn StationReturn) { string wo = Data["WO"].ToString().ToUpper().Trim(); string closeFlag = Data["CLOSEFLAG"].ToString().ToUpper().Trim(); double num = 0; OleExec sfcdb = null; try { sfcdb = this.DBPools["SFCDB"].Borrow(); sfcdb.ThrowSqlExeception = true; T_R_WO_BASE t_r_wo_base = new T_R_WO_BASE(sfcdb, DBTYPE); R_WO_BASE r_wo_base = t_r_wo_base.GetWoByWoNo(wo, sfcdb); if (r_wo_base == null) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000164", new string[] { wo })); } try { num = Convert.ToDouble(Data["NUM"].ToString().ToUpper().Trim()); } catch { throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180731151259", new string[] { Data["NUM"].ToString().ToUpper().Trim() })); } if (num <= 0) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MSGCODE20180731151259", new string[] { Data["NUM"].ToString().ToUpper().Trim() })); } if (r_wo_base.WORKORDER_QTY - r_wo_base.INPUT_QTY < num) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000208", new string[] { wo, num.ToString(), (r_wo_base.WORKORDER_QTY - r_wo_base.INPUT_QTY).ToString() })); } Row_R_WO_BASE rowWoBase = (Row_R_WO_BASE)t_r_wo_base.GetObjByID(r_wo_base.ID, sfcdb); rowWoBase.WORKORDER_QTY = r_wo_base.WORKORDER_QTY - Convert.ToDouble(num); if (closeFlag == "1") { rowWoBase.CLOSED_FLAG = closeFlag; rowWoBase.CLOSE_DATE = GetDBDateTime(); } rowWoBase.EDIT_EMP = LoginUser.EMP_NO; rowWoBase.EDIT_TIME = GetDBDateTime(); sfcdb.ExecSQL(rowWoBase.GetUpdateString(DBTYPE)); this.DBPools["SFCDB"].Return(sfcdb); StationReturn.Data = r_wo_base; StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.MessageCode = "MES00000210"; StationReturn.MessagePara.Add(wo); StationReturn.MessagePara.Add(num); } catch (Exception exception) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000037"; StationReturn.MessagePara.Add(exception.Message); StationReturn.Data = exception.Message; if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } } }