예제 #1
0
        public void DeleteMpnWithSku(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            string    CSKUMPNIDS = Data["CSKUMPNIDS"].ToString().Trim();
            ArrayList DelIds     = new ArrayList(CSKUMPNIDS.Split(','));

            DelIds.Remove("");
            OleExec     oleDB   = null;
            T_C_SKU_MPN cSkuMpn = null;

            try
            {
                oleDB   = this.DBPools["SFCDB"].Borrow();
                cSkuMpn = new T_C_SKU_MPN(oleDB, DBTYPE);
                oleDB.BeginTrain();
                foreach (var VARIABLE in (string[])DelIds.ToArray(typeof(string)))
                {
                    oleDB.ThrowSqlExeception = true;
                    Row_C_SKU_MPN rowCSkuMpn = (Row_C_SKU_MPN)cSkuMpn.GetObjByID(VARIABLE, oleDB, DBTYPE);
                    oleDB.ExecSQL(rowCSkuMpn.GetDeleteString(DBTYPE));
                }
                oleDB.CommitTrain();
                StationReturn.Status      = StationReturnStatusValue.Pass;
                StationReturn.MessageCode = "MES00000004";
            }
            catch (Exception e)
            {
                oleDB.RollbackTrain();
                throw e;
            }
            finally
            {
                this.DBPools["SFCDB"].Return(oleDB);
            }
        }
예제 #2
0
        public void QueryMpnBySku(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            string           Sku         = Data["SKUNO"].ToString().Trim();
            OleExec          oleDB       = null;
            T_C_SKU_MPN      cSkuMpn     = null;
            List <C_SKU_MPN> cSkuMpnList = new List <C_SKU_MPN>();

            try
            {
                oleDB       = this.DBPools["SFCDB"].Borrow();
                cSkuMpn     = new T_C_SKU_MPN(oleDB, DBTYPE);
                cSkuMpnList = cSkuMpn.GetMpnBySku(oleDB, Sku);
                if (cSkuMpnList.Count > 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000033";
                    StationReturn.MessagePara.Add(cSkuMpnList.Count);
                    StationReturn.Data = cSkuMpnList;
                }
                else
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000034";
                    StationReturn.Data        = "";
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                this.DBPools["SFCDB"].Return(oleDB);
            }
        }
예제 #3
0
        public void AddMpnWithSku(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            string      Sku = Data["SKUNO"].ToString().Trim(), PartNo = Data["PARTNO"].ToString().Trim(), Mpn = Data["MPN"].ToString().Trim();
            OleExec     oleDB   = null;
            T_C_SKU_MPN cSkuMpn = null;
            T_C_SKU     cSku    = null;

            try
            {
                oleDB   = this.DBPools["SFCDB"].Borrow();
                cSkuMpn = new T_C_SKU_MPN(oleDB, DBTYPE);
                cSku    = new T_C_SKU(oleDB, DBTYPE);
                if (!cSku.SkuIsExist(Sku, oleDB))
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000244";
                    StationReturn.MessagePara = new List <object>()
                    {
                        Sku
                    };
                }
                else if (cSkuMpn.IsExists(oleDB, Sku, PartNo, Mpn))
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000005";
                    StationReturn.Data        = "";
                }
                else
                {
                    Row_C_SKU_MPN rowCSkuMpn = (Row_C_SKU_MPN)cSkuMpn.NewRow();
                    rowCSkuMpn.ID            = cSkuMpn.GetNewID(this.BU, oleDB, DBTYPE);
                    rowCSkuMpn.SKUNO         = Sku;
                    rowCSkuMpn.PARTNO        = PartNo;
                    rowCSkuMpn.MPN           = Mpn;
                    rowCSkuMpn.EDIT_EMP      = this.LoginUser.EMP_NO;
                    rowCSkuMpn.EDIT_TIME     = GetDBDateTime();;
                    oleDB.ThrowSqlExeception = true;
                    oleDB.ExecSQL(rowCSkuMpn.GetInsertString(DBTYPE));
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000002";
                    StationReturn.Data        = "";
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                this.DBPools["SFCDB"].Return(oleDB);
            }
        }
예제 #4
0
        public void UpdateMpnWithSku(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            string id           = Data["ID"].ToString().Trim(),
                   sku          = Data["SKUNO"].ToString().Trim(),
                   partNo       = Data["PARTNO"].ToString().Trim(),
                   mpn          = Data["MPN"].ToString().Trim();
            OleExec     oleDB   = null;
            T_C_SKU_MPN cSkuMpn = null;

            try
            {
                oleDB   = this.DBPools["SFCDB"].Borrow();
                cSkuMpn = new T_C_SKU_MPN(oleDB, DBTYPE);
                Row_C_SKU_MPN rowCSkuMpn = (Row_C_SKU_MPN)cSkuMpn.GetObjByID(id, oleDB, DBTYPE);
                if (cSkuMpn.IsExists(oleDB, sku, partNo, mpn))
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000005";
                    StationReturn.Data        = "";
                }
                else if (rowCSkuMpn != null)
                {
                    rowCSkuMpn.SKUNO         = sku;
                    rowCSkuMpn.PARTNO        = partNo;
                    rowCSkuMpn.MPN           = mpn;
                    rowCSkuMpn.EDIT_EMP      = this.LoginUser.EMP_NO;
                    rowCSkuMpn.EDIT_TIME     = GetDBDateTime();
                    oleDB.ThrowSqlExeception = true;
                    oleDB.ExecSQL(rowCSkuMpn.GetUpdateString(DBTYPE));
                    StationReturn.Status      = StationReturnStatusValue.Pass;
                    StationReturn.MessageCode = "MES00000004";
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                oleDB.ThrowSqlExeception = false;
                this.DBPools["SFCDB"].Return(oleDB);
            }
        }
예제 #5
0
        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;
            }
        }
예제 #6
0
        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 + "未配置規則!");
                    }
                }
            }
        }