public KPListDetail(string ID, KPListItem _Item, OleExec sfcdb) { ListItem = _Item; T_C_KP_List_Item_Detail T = new T_C_KP_List_Item_Detail(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle); Row_C_KP_List_Item_Detail R = (Row_C_KP_List_Item_Detail)T.GetObjByID(ID, sfcdb); if (R != null) { value = R.GetDataObject(); } else { throw new Exception($@"查詢不到ID為:{ID} KP_List_Item_Detail"); } }
public void UpLoadKPList(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow(); SFCDB.BeginTrain(); try { string Skuno = Data["SkuNo"].ToString(); string ListName = Data["ListName"].ToString(); Newtonsoft.Json.Linq.JToken ListData = Data["ListData"]; T_C_KP_LIST T = new T_C_KP_LIST(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle); string NewListID = T.GetNewID(this.BU, SFCDB); Row_C_KP_LIST R = (Row_C_KP_LIST)T.NewRow(); DateTime Now = DateTime.Now; T_C_KP_List_Item TItem = new T_C_KP_List_Item(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle); Row_C_KP_List_Item RItem = (Row_C_KP_List_Item)TItem.NewRow(); T_C_KP_List_Item_Detail TDetail = new T_C_KP_List_Item_Detail(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle); Row_C_KP_List_Item_Detail RDetail = (Row_C_KP_List_Item_Detail)TDetail.NewRow(); KPListBase oldList = KPListBase.GetKPListByListName(ListName, SFCDB); if (oldList != null) { oldList.ReMoveFromDB(SFCDB); } R.ID = NewListID; R.SKUNO = Skuno.Trim(); R.LISTNAME = ListName; R.EDIT_EMP = this.LoginUser.EMP_NO; R.EDIT_TIME = Now; SFCDB.ExecSQL(R.GetInsertString(MESDataObject.DB_TYPE_ENUM.Oracle)); //Item PartNO KPName Station QTY ScanType DataTable dt = new DataTable(); dt.Columns.Add("Item"); dt.Columns.Add("PartNO"); dt.Columns.Add("KPName"); dt.Columns.Add("Station"); dt.Columns.Add("QTY"); dt.Columns.Add("ScanType"); List <DataRow> ListItem = new List <DataRow>(); for (int i = 0; i < ListData.Count(); i++) { DataRow dr = dt.NewRow(); dr["Item"] = ListData[i]["Item"].ToString(); dr["PartNO"] = ListData[i]["PartNO"].ToString(); dr["KPName"] = ListData[i]["KPName"].ToString(); dr["Station"] = ListData[i]["Station"].ToString(); dr["QTY"] = ListData[i]["QTY"].ToString(); dr["ScanType"] = ListData[i]["ScanType"].ToString(); dt.Rows.Add(dr); ListItem.Add(dr); } Dictionary <string, string> Item = new Dictionary <string, string>(); for (int i = 0; i < dt.Rows.Count; i++) { if (!Item.ContainsKey(dt.Rows[i]["Item"].ToString())) { Item.Add(dt.Rows[i]["Item"].ToString(), dt.Rows[i]["PartNO"].ToString()); } } string[] itemNo = new string[Item.Keys.Count]; Item.Keys.CopyTo(itemNo, 0); for (int i = 0; i < itemNo.Length; i++) { List <DataRow> Items = ListItem.FindAll(TT => TT["Item"].ToString() == itemNo[i]); for (int j = 0; j < Items.Count; j++) { if (j == 0) { RItem.ID = TItem.GetNewID(BU, SFCDB); RItem.LIST_ID = NewListID; RItem.KP_NAME = Items[j]["KPName"].ToString(); RItem.KP_PARTNO = Items[j]["PartNO"].ToString(); RItem.STATION = Items[j]["Station"].ToString(); RItem.QTY = double.Parse(Items[j]["QTY"].ToString()); RItem.SEQ = i; RItem.EDIT_EMP = this.LoginUser.EMP_NO; RItem.EDIT_TIME = Now; SFCDB.ExecSQL(RItem.GetInsertString(MESDataObject.DB_TYPE_ENUM.Oracle)); } RDetail.ID = TDetail.GetNewID(BU, SFCDB); RDetail.ITEM_ID = RItem.ID; RDetail.SCANTYPE = Items[j]["ScanType"].ToString(); RDetail.SEQ = j + 1; RDetail.EDIT_EMP = RItem.EDIT_EMP; RDetail.EDIT_TIME = Now; SFCDB.ExecSQL(RDetail.GetInsertString(MESDataObject.DB_TYPE_ENUM.Oracle)); } } StationReturn.Status = StationReturnStatusValue.Pass; } catch (Exception ee) { SFCDB.RollbackTrain(); this.DBPools["SFCDB"].Return(SFCDB); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000037"; StationReturn.MessagePara.Add(ee.Message); return; } SFCDB.CommitTrain(); this.DBPools["SFCDB"].Return(SFCDB); }
public void UpdateSNKP(WorkOrder woObject, List <R_SN> snList, BaseClass.MESStationBase Station) { T_C_KP_LIST t_c_kp_list = new T_C_KP_LIST(Station.SFCDB, Station.DBType); T_C_KP_List_Item t_c_kp_list_item = new T_C_KP_List_Item(Station.SFCDB, Station.DBType); T_C_KP_List_Item_Detail t_c_kp_list_item_detail = new T_C_KP_List_Item_Detail(Station.SFCDB, Station.DBType); T_R_SN_KP t_r_sn_kp = new T_R_SN_KP(Station.SFCDB, Station.DBType); T_C_SKU_MPN t_c_sku_mpn = new T_C_SKU_MPN(Station.SFCDB, Station.DBType); T_C_KP_Rule c_kp_rule = new T_C_KP_Rule(Station.SFCDB, Station.DBType); Row_R_SN_KP rowSNKP; List <C_KP_List_Item> kpItemList = new List <C_KP_List_Item>(); List <C_SKU_MPN> skuMpnList = new List <C_SKU_MPN>(); List <C_KP_List_Item_Detail> itemDetailList = new List <C_KP_List_Item_Detail>(); C_KP_Rule kpRule = new C_KP_Rule(); int scanseq = 0; int result; string skuMpn = ""; try { kpItemList = t_c_kp_list_item.GetItemObjectByListId(woObject.KP_LIST_ID, Station.SFCDB); if (kpItemList == null || kpItemList.Count == 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { woObject.SkuNO })); } foreach (R_SN r_sn in snList) { result = t_r_sn_kp.DeleteBySNID(r_sn.ID, Station.SFCDB); if (result <= 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000083", new string[] { "R_SN_KP:" + r_sn.SN, "DELETE" })); } foreach (C_KP_List_Item kpItem in kpItemList) { itemDetailList = t_c_kp_list_item_detail.GetItemDetailObjectByItemId(kpItem.ID, Station.SFCDB); if (itemDetailList == null || itemDetailList.Count == 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000255", new string[] { woObject.SkuNO })); } skuMpnList = t_c_sku_mpn.GetMpnBySkuAndPartno(Station.SFCDB, woObject.SkuNO, kpItem.KP_PARTNO); if (skuMpnList.Count != 0) { skuMpn = skuMpnList[0].MPN; } foreach (C_KP_List_Item_Detail itemDetail in itemDetailList) { scanseq = scanseq + 1; kpRule = c_kp_rule.GetKPRule(Station.SFCDB, kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE); if (kpRule == null) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000256", new string[] { kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE })); } if (kpRule.REGEX == "") { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000256", new string[] { kpItem.KP_PARTNO, skuMpn, itemDetail.SCANTYPE })); } rowSNKP = (Row_R_SN_KP)t_r_sn_kp.NewRow(); rowSNKP.ID = t_r_sn_kp.GetNewID(Station.BU, Station.SFCDB); rowSNKP.R_SN_ID = r_sn.ID; rowSNKP.SN = r_sn.SN; rowSNKP.VALUE = ""; rowSNKP.PARTNO = kpItem.KP_PARTNO; rowSNKP.KP_NAME = kpItem.KP_NAME; rowSNKP.MPN = skuMpn; rowSNKP.SCANTYPE = itemDetail.SCANTYPE; rowSNKP.ITEMSEQ = kpItem.SEQ; rowSNKP.SCANSEQ = scanseq; rowSNKP.DETAILSEQ = itemDetail.SEQ; rowSNKP.STATION = kpItem.STATION; rowSNKP.REGEX = kpRule.REGEX; rowSNKP.VALID_FLAG = 1; rowSNKP.EXKEY1 = ""; rowSNKP.EXVALUE1 = ""; rowSNKP.EXKEY2 = ""; rowSNKP.EXVALUE2 = ""; rowSNKP.EDIT_EMP = Station.LoginUser.EMP_NO; rowSNKP.EDIT_TIME = Station.GetDBDateTime(); result = Convert.ToInt32(Station.SFCDB.ExecSQL(rowSNKP.GetInsertString(Station.DBType))); if (result <= 0) { throw new MESDataObject.MESReturnMessage(MESDataObject.MESReturnMessage.GetMESReturnMessage("MES00000083", new string[] { "R_SN_KP:" + r_sn.SN, "ADD" })); } } } } } catch (Exception ex) { throw ex; } }