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; } }
public SN_KP(List <R_SN_KP> _Value, string Wo, string Skuno, OleExec SFCDB) { KPS = _Value; T_C_SKU_MPN TCSM = new T_C_SKU_MPN(SFCDB, DB_TYPE_ENUM.Oracle); MPNs = TCSM.GetMpnBySku(SFCDB, Skuno); T_R_WO_KP_Repalce TRWKR = new T_R_WO_KP_Repalce(SFCDB, DB_TYPE_ENUM.Oracle); List <R_WO_KP_Repalce> Repalce1 = TRWKR.GetWoRepalceKP(Wo, SFCDB); T_C_KP_Rule TCKR = new T_C_KP_Rule(SFCDB, DB_TYPE_ENUM.Oracle); KPRule = TCKR.GetDataBySkuWo(Wo, Skuno, SFCDB); for (int i = 0; i < Repalce1.Count; i++) { if (!Repalce.ContainsKey(Repalce1[i].PARTNO)) { Repalce.Add(Repalce1[i].PARTNO, new List <R_WO_KP_Repalce>()); } Repalce[Repalce1[i].PARTNO].Add(Repalce1[i]); } for (int i = 0; i < KPS.Count; i++) { if (KPS[i].VALUE == "" || KPS[i].VALUE == null) { C_KP_Rule rule = KPRule.Find(T => T.PARTNO == KPS[i].PARTNO && T.SCANTYPE == KPS[i].SCANTYPE); if (rule == null) { List <R_WO_KP_Repalce> rep = null; try { rep = Repalce[KPS[i].PARTNO]; } catch { } if (rep != null) { for (int j = 0; j < rep.Count; j++) { rule = KPRule.Find(T => T.PARTNO == rep[j].REPALCEPARTNO && T.SCANTYPE == KPS[i].SCANTYPE); if (rule == null) { continue; } else { break; } } if (rule == null) { throw new Exception(KPS[i].PARTNO + "的替代料" + rep[i].REPALCEPARTNO + "," + KPS[i].SCANTYPE + "未配置規則!"); } } throw new Exception(KPS[i].PARTNO + "," + KPS[i].SCANTYPE + "未配置規則!"); } } } }