예제 #1
0
        public DataTable GetBomMaterialData(string workorder)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("ErpGroup", typeof(string)));
            dt.Columns.Add(new DataColumn("PartNumber", typeof(string)));
            dt.Columns.Add(new DataColumn("PartDesc", typeof(string)));
            dt.Columns.Add(new DataColumn("Quantity", typeof(string)));
            dt.Columns.Add(new DataColumn("CompName", typeof(string)));
            dt.Columns.Add(new DataColumn("ProcessLayer", typeof(string)));
            dt.Columns.Add(new DataColumn("ProductFlag", typeof(string)));

            KeyValue[] bomDataFilter       = new KeyValue[] { new KeyValue("WORKORDER_NUMBER", workorder), new KeyValue("BOM_ALTERNATIVE", "0") };
            string[]   bomDataResultKeys   = new string[] { "MACHINE_GROUP_NUMBER", "PART_NUMBER", "PART_DESC", "SETUP_FLAG", "QUANTITY", "COMP_NAME", "PROCESS_LAYER", "PRODUCT_FLAG" };
            string[]   bomDataResultValues = new string[] { };
            LogHelper.Info("begin api mdataGetBomData (Work Order:" + workorder + ")");
            int    error    = imsapi.mdataGetBomData(sessionContext, init.configHandler.StationNumber, bomDataFilter, bomDataResultKeys, out bomDataResultValues);
            string errorMsg = UtilityFunction.GetZHSErrorString(error, init, sessionContext);

            LogHelper.Info("end api mdataGetBomData (result code = " + error + ")");
            if (error != 0)
            {
                view.errorHandler(2, init.lang.ERROR_API_CALL_ERROR + " mdataGetBomData " + error + "(" + errorMsg + ")", "");
                return(null);
            }
            else
            {
                string strErpGroup = GetErpGroupNumber(init.configHandler.StationNumber, workorder);
                int    loop        = bomDataResultKeys.Length;
                int    count       = bomDataResultValues.Length;
                for (int i = 0; i < count; i += loop)
                {
                    if (bomDataResultValues[i + 3] == "1")
                    {
                        //S08SMDXX-02000
                        string strMachineGroup = bomDataResultValues[i].ToString();
                        //S08SMD04-02000-01
                        string strStationNo = init.configHandler.StationNumber;
                        if (strErpGroup == strMachineGroup)
                        {
                            DataRow row = dt.NewRow();
                            row["ErpGroup"]     = bomDataResultValues[i].ToString();
                            row["PartNumber"]   = bomDataResultValues[i + 1].ToString();
                            row["PartDesc"]     = bomDataResultValues[i + 2].ToString();
                            row["Quantity"]     = bomDataResultValues[i + 4].ToString();
                            row["CompName"]     = bomDataResultValues[i + 5].ToString();
                            row["ProcessLayer"] = bomDataResultValues[i + 6].ToString();
                            row["ProductFlag"]  = bomDataResultValues[i + 7].ToString();
                            dt.Rows.Add(row);
                        }
                    }
                }
                view.errorHandler(0, init.lang.ERROR_API_CALL_ERROR + " mdataGetBomData " + error, "");
            }
            return(dt);
        }
예제 #2
0
        public DataTable GetBomMaterialData(string workorder, string erpGroup)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("PartNo", typeof(string)));
            dt.Columns.Add(new DataColumn("MaterialBinNumber", typeof(string)));
            dt.Columns.Add(new DataColumn("Qty", typeof(string)));
            dt.Columns.Add(new DataColumn("CompName", typeof(string)));
            dt.Columns.Add(new DataColumn("ErpGroup", typeof(string)));
            KeyValue[] bomDataFilter       = new KeyValue[] { new KeyValue("WORKORDER_NUMBER", workorder), new KeyValue("PROCESS_BASED", "1") };
            string[]   bomDataResultKeys   = new string[] { "PART_NUMBER", "QUANTITY", "MACHINE_GROUP_NUMBER" };
            string[]   bomDataResultValues = new string[] { };
            LogHelper.Info("begin api mdataGetBomData (Work Order:" + workorder + ")");
            int    error    = imsapi.mdataGetBomData(sessionContext, init.configHandler.StationNumber, bomDataFilter, bomDataResultKeys, out bomDataResultValues);
            string errorMsg = UtilityFunction.GetZHSErrorString(error, init, sessionContext);

            LogHelper.Info("end api mdataGetBomData (result code = " + error + ")");
            if (error != 0)
            {
                view.errorHandler(2, init.lang.ERROR_API_CALL_ERROR + " mdataGetBomData " + error + "(" + errorMsg + ")", "");
                return(null);
            }
            else
            {
                int loop  = bomDataResultKeys.Length;
                int count = bomDataResultValues.Length;
                for (int i = 0; i < count; i += loop)
                {
                    if (erpGroup == bomDataResultValues[i + 2].ToString())
                    {
                        DataRow row = dt.NewRow();
                        row["PartNo"]            = bomDataResultValues[i].ToString();
                        row["CompName"]          = bomDataResultValues[i + 1].ToString();
                        row["ErpGroup"]          = bomDataResultValues[i + 2].ToString();
                        row["MaterialBinNumber"] = "";
                        row["Qty"] = "";
                        dt.Rows.Add(row);
                    }
                }
                view.errorHandler(0, init.lang.ERROR_API_CALL_ERROR + " mdataGetBomData " + error, "");
            }
            return(dt);
        }