コード例 #1
0
        public JObject Update_Model_South(string sku)
        {
            JObject pack = new JObject();

            try
            {
                PackInfor_Model_Update_South packModel = new PackInfor_Model_Update_South();
                string    sql         = string.Format("[PP_MM_UPDATE_PACK]'SOUTH','{0}'", sku);
                DataTable dt          = DAL.SELECT_SQL(sql);
                string    sku_current = sku.TrimStart('0');

                packModel.packkey = sku_current + "_MMSOUTH";
                int qtyPerPallet = DAL.IntReturn(dt.Rows[0]["PALLET_NEW"]);
                packModel.packdescr = sku_current + "_MMSOUTH";
                packModel.packuom1  = "CS";
                int qtyPerCase = DAL.IntReturn(dt.Rows[0]["Number_Mu_Carton"]);
                packModel.casecnt       = qtyPerCase.ToString();
                packModel.packuom3      = "MU";
                packModel.cartonizeuom3 = "N";
                packModel.pallet        = qtyPerPallet.ToString();



                int qtyInnerPack = DAL.IntReturn(dt.Rows[0]["INNERPACK_NEW"]);
                packModel.innerpack = qtyInnerPack.ToString();

                decimal carton_lenght1 = DAL.DecimalReturn(dt.Rows[0]["Carton_Length"]);
                decimal carton_width1  = DAL.DecimalReturn(dt.Rows[0]["Carton_Width"]);
                decimal carton_height1 = DAL.DecimalReturn(dt.Rows[0]["Carton_Height"]);
                packModel.lengthuom1 = carton_lenght1.ToString();
                packModel.widthuom1  = carton_width1.ToString();
                packModel.heightuom1 = carton_height1.ToString();


                decimal carton_lenght3 = DAL.DecimalReturn(dt.Rows[0]["Selling_Unit_Length"]);
                decimal carton_width3  = DAL.DecimalReturn(dt.Rows[0]["Selling_Unit_Width"]);
                decimal carton_height3 = DAL.DecimalReturn(dt.Rows[0]["Selling_Unit_Height"]);
                packModel.lengthuom3 = carton_lenght3.ToString();
                packModel.widthuom3  = carton_width3.ToString();
                packModel.heightuom3 = carton_height3.ToString();

                packModel.whseid  = "wmwhse10";
                packModel.addwho  = "Admin";
                packModel.editwho = "Admin";
                string output = JsonConvert.SerializeObject(packModel);
                pack = JObject.Parse(output);
            }
            catch (Exception e)
            {
                string step = string.Format(Constant.MODEL_PACK, "SOUTH");
                resultMapping.Handle_Error_Mapping(sku, e.ToString(), step);
            }
            return(pack);
        }
コード例 #2
0
        public JObject Create_ModelPack(string sku)
        {
            JObject pack = new JObject();

            try
            {
                PackInfor_Model packModel = new PackInfor_Model();
                string          sql       = string.Format("[PR_MM_PACK_INFORMATION_NORTH]'{0}'", sku);
                DataTable       dt        = DAL.SELECT_SQL(sql);
                sku = sku.TrimStart('0');
                packModel.packkey = sku;
                int qtyPerPallet = DAL.IntReturn(dt.Rows[0]["Number_Mu_Pallet"]);
                packModel.pallet    = qtyPerPallet.ToString();
                packModel.packuom4  = "PL";
                packModel.packdescr = qtyPerPallet + " PC per pallet";
                packModel.packuom1  = "CS";

                int qtyInCnt        = DAL.IntReturn(dt.Rows[0]["Number_Mu_Carton"].ToString());
                int qtyPerLayer     = DAL.IntReturn(dt.Rows[0]["Number_Mu_Layer"].ToString());
                int casecntPerLayer = qtyPerLayer / qtyInCnt;

                packModel.palletti = casecntPerLayer.ToString();
                packModel.pallethi = dt.Rows[0]["Number_Layer_Pallet"].ToString();

                packModel.casecnt       = dt.Rows[0]["Number_Mu_Carton"].ToString();
                packModel.packuom3      = "MU";
                packModel.cartonizeuom3 = "N";

                decimal carton_lenght      = DAL.DecimalReturn(dt.Rows[0]["Carton_Length"]);
                decimal carton_width       = DAL.DecimalReturn(dt.Rows[0]["Carton_Width"]);
                decimal carton_height      = DAL.DecimalReturn(dt.Rows[0]["Carton_Height"]);
                decimal carton_grossWeight = DAL.DecimalReturn(dt.Rows[0]["Carton_GrossWeight"]);

                packModel.lengthuom1 = carton_lenght.ToString();
                packModel.widthuom1  = carton_width.ToString();
                packModel.heightuom1 = carton_height.ToString();
                packModel.weightuom1 = carton_grossWeight.ToString();

                packModel.ext_udf_str1 = dt.Rows[0]["susr1"].ToString();
                packModel.whseid       = "wmwhse3";
                packModel.addwho       = "Admin";
                packModel.editwho      = "Admin";
                string output = JsonConvert.SerializeObject(packModel);
                pack = JObject.Parse(output);
            }
            catch (Exception e)
            {
                string step = string.Format(Constant.MODEL_PACK, "NORTH");
                resultMapping.Handle_Error_Mapping(sku, e.ToString(), step);
            }
            return(pack);
        }
コード例 #3
0
        public JObject Create_ModelPack_South(string sku)
        {
            JObject pack = new JObject();

            try
            {
                PackInfor_Model_South packModel = new PackInfor_Model_South();
                string    sql = string.Format("select * from MM_Articles where Article_Number='{0}' and Warehouse_Number='90071'", sku);
                DataTable dt  = DAL.SELECT_SQL(sql);
                sku = sku.TrimStart('0');

                packModel.packkey = sku + "_MMSOUTH";
                int qtyPerPallet = DAL.IntReturn(dt.Rows[0]["Number_Mu_Pallet"]);
                packModel.packdescr = sku + "_MMSOUTH";
                packModel.packuom1  = "CS";
                int qtyPerCase = DAL.IntReturn(dt.Rows[0]["Number_Mu_Carton"]);
                packModel.casecnt       = qtyPerCase.ToString();
                packModel.packuom3      = "MU";
                packModel.cartonizeuom3 = "N";

                decimal carton_lenght1 = DAL.DecimalReturn(dt.Rows[0]["Carton_Length"]);
                decimal carton_width1  = DAL.DecimalReturn(dt.Rows[0]["Carton_Width"]);
                decimal carton_height1 = DAL.DecimalReturn(dt.Rows[0]["Carton_Height"]);
                packModel.lengthuom1 = carton_lenght1.ToString();
                packModel.widthuom1  = carton_width1.ToString();
                packModel.heightuom1 = carton_height1.ToString();


                decimal carton_lenght3 = DAL.DecimalReturn(dt.Rows[0]["Selling_Unit_Length"]);
                decimal carton_width3  = DAL.DecimalReturn(dt.Rows[0]["Selling_Unit_Width"]);
                decimal carton_height3 = DAL.DecimalReturn(dt.Rows[0]["Selling_Unit_Height"]);
                packModel.lengthuom3 = carton_lenght3.ToString();
                packModel.widthuom3  = carton_width3.ToString();
                packModel.heightuom3 = carton_height3.ToString();

                packModel.whseid  = "wmwhse10";
                packModel.addwho  = "Admin";
                packModel.editwho = "Admin";
                string output = JsonConvert.SerializeObject(packModel);
                pack = JObject.Parse(output);
            }
            catch (Exception e)
            {
                string step = string.Format(Constant.MODEL_PACK, "SOUTH");
                resultMapping.Handle_Error_Mapping(sku, e.ToString(), step);
            }
            return(pack);
        }
コード例 #4
0
        public ResultDatabase_Model InsertDatabase(string text, int indicator, string fileName)
        {
            ResultDatabase_Model result = new ResultDatabase_Model();
            Response_ReadFile    error  = new Response_ReadFile();
            bool check = false;

            if (indicator == 1)
            {
                ClsMM_Orders_Header orderHeader = new ClsMM_Orders_Header();
                try
                {
                    orderHeader.Table_Indicator    = DAL.IntReturn(text.Substring(0, 1));
                    orderHeader.Lsp_Identification = text.Substring(1, 4);

                    string orderNumber = text.Substring(5, 20);
                    orderHeader.Order_Number = orderNumber.Substring(3, 17);

                    orderHeader.Order_Type = text.Substring(25, 4);

                    string storeNumber = text.Substring(29, 10);
                    orderHeader.Store_Number = storeNumber.Substring(5, 5);

                    string deliveryDate = text.Substring(39, 8);
                    int    year         = DAL.IntReturn(deliveryDate.Substring(0, 4));
                    int    month        = DAL.IntReturn(deliveryDate.Substring(4, 2));
                    int    day          = DAL.IntReturn(deliveryDate.Substring(6, 2));
                    orderHeader.Plan_Delivery_Date = new DateTime(year, month, day);

                    string warehouse = text.Substring(47, 20);
                    orderHeader.Warehouse_Number = warehouse.Substring(15, 5);

                    string email = text.Substring(67, 20);
                    orderHeader.MM_Email_Number = email.Substring(15, 5);

                    string memoField = text.Substring(87, 255);
                    orderHeader.Memo_Field = memoField.Substring(0, 59);

                    string dateRecord = text.Substring(342, 8);
                    int    year1      = DAL.IntReturn(dateRecord.Substring(0, 4));
                    int    month1     = DAL.IntReturn(dateRecord.Substring(4, 2));
                    int    day1       = DAL.IntReturn(dateRecord.Substring(6, 2));
                    orderHeader.Date_Record = new DateTime(year1, month1, day1);

                    orderHeader.Action_Type = text.Substring(350, 1);

                    string commercial = text.Substring(351, 10);
                    orderHeader.Commercial_Supplier_Number = commercial.Substring(4, 5);

                    string dateToWarehouse = text.Substring(361, 8);
                    int    year2           = DAL.IntReturn(dateToWarehouse.Substring(0, 4));
                    int    month2          = DAL.IntReturn(dateToWarehouse.Substring(4, 2));
                    int    day2            = DAL.IntReturn(dateToWarehouse.Substring(6, 2));
                    orderHeader.Plan_Delivery_To_Warehouse = new DateTime(year2, month2, day2);

                    string orderDate = text.Substring(369, 8);
                    int    year3     = DAL.IntReturn(orderDate.Substring(0, 4));
                    int    month3    = DAL.IntReturn(orderDate.Substring(4, 2));
                    int    day3      = DAL.IntReturn(orderDate.Substring(6, 2));
                    orderHeader.Order_Date = new DateTime(year3, month3, day3);


                    orderHeader.Free_Text1 = text.Substring(377, 20);
                    orderHeader.Free_Text2 = text.Substring(397, 20);

                    orderHeader.Order_Logistic_Type   = DAL.IntReturn(text.Substring(417, 2));
                    orderHeader.Customer_Store_Number = DAL.IntReturn(text.Substring(419, 2));
                    orderHeader.Customer_Number       = text.Substring(421, 6);
                    orderHeader.FILENAME = fileName;
                    string    sql = string.Format("select * from MM_ORDERS_HEADER where Order_Number = '{0}'", orderHeader.Order_Number);
                    DataTable orderHeaderTable = DAL.SELECT_SQL(sql);
                    int       count            = DAL.IntReturn(orderHeaderTable.Rows.Count);
                    if (count > 0 && (orderHeader.Action_Type == "I" || orderHeader.Action_Type == "D"))
                    {
                        orderHeader.EDITDATE = DateTime.Now;
                        check = orderHeader.Update(fileName, text);
                        result.result(check, orderHeader.Action_Type, orderHeader.Order_Number);
                    }
                    else if (count == 0 && orderHeader.Action_Type == "I")
                    {
                        orderHeader.ADDDATE  = DateTime.Now;
                        orderHeader.EDITDATE = DateTime.Now;
                        check = orderHeader.Add(fileName, text);
                        result.result(check, orderHeader.Action_Type, orderHeader.Order_Number);
                    }
                    else
                    {
                        check = false;
                        result.result(check, orderHeader.Action_Type, orderHeader.Order_Number);
                    }
                }
                catch (Exception e)
                {
                    string category = "orderHeader";
                    error.HandleError(fileName, text, e.Message.ToString(), category);
                    check = false;
                    result.result(check, orderHeader.Action_Type, orderHeader.Order_Number);
                }
            }
            else if (indicator == 2)
            {
                ClsMM_Orders_Detail orderDetail = new ClsMM_Orders_Detail();
                try
                {
                    orderDetail.Table_Indicator    = DAL.IntReturn(text.Substring(0, 1));
                    orderDetail.Lsp_Identification = text.Substring(1, 4);

                    string orderNumber = text.Substring(5, 20);
                    orderDetail.Order_Number = orderNumber.Substring(3, 17);

                    string storeNumber = text.Substring(63, 10);
                    orderDetail.Store_Number = storeNumber.Substring(5, 5);

                    string sku = text.Substring(91, 10);
                    orderDetail.Article_Number = sku.Substring(2, 8);


                    int quantity = DAL.IntReturn(text.Substring(101, 10));
                    orderDetail.Order_Quantity = DAL.DecimalReturn(DAL.ChangeValue(3, quantity));

                    string dateRecord = text.Substring(111, 8);
                    int    year       = DAL.IntReturn(dateRecord.Substring(0, 4));
                    int    month      = DAL.IntReturn(dateRecord.Substring(4, 2));
                    int    day        = DAL.IntReturn(dateRecord.Substring(6, 2));
                    orderDetail.Date_Record = new DateTime(year, month, day);

                    orderDetail.Action_Code = text.Substring(119, 1);

                    string warehouse = text.Substring(120, 20);
                    orderDetail.Warehouse_Number = warehouse.Substring(15, 5);

                    orderDetail.Orderline_Fretext = text.Substring(140, 15);

                    string po = text.Substring(155, 20);
                    orderDetail.Purchase_Order = po.Substring(0, 12);

                    string email = text.Substring(175, 20);
                    orderDetail.MM_Mail_Number = email.Substring(0, 5);

                    string article = text.Substring(195, 10);
                    orderDetail.Buying_Article_Number = article.Substring(2, 8);

                    int price = DAL.IntReturn(text.Substring(205, 13));
                    orderDetail.Article_Selling_Price = DAL.DecimalReturn(DAL.ChangeValue(2, price));

                    orderDetail.FILENAME = fileName;

                    string    sql = string.Format("select * from MM_ORDERS_DETAIL where Order_Number = '{0}' and Article_Number='{1}'", orderDetail.Order_Number, orderDetail.Article_Number);
                    DataTable orderHeaderTable = DAL.SELECT_SQL(sql);
                    int       count            = DAL.IntReturn(orderHeaderTable.Rows.Count);
                    if (count > 0 && (orderDetail.Action_Code == "I" || orderDetail.Action_Code == "D"))
                    {
                        orderDetail.EDITDATE = DateTime.Now;
                        check = orderDetail.Update(fileName, text);
                        result.result(check, orderDetail.Action_Code, orderDetail.Order_Number);
                    }
                    else if (count == 0 && orderDetail.Action_Code == "I")
                    {
                        orderDetail.ADDDATE  = DateTime.Now;
                        orderDetail.EDITDATE = DateTime.Now;
                        check = orderDetail.Add(fileName, text);
                        result.result(check, orderDetail.Action_Code, orderDetail.Order_Number);
                    }
                    else
                    {
                        check = false;
                        result.result(check, orderDetail.Action_Code, orderDetail.Order_Number);
                    }
                }
                catch (Exception e)
                {
                    string category = "orderDetail";
                    error.HandleError(fileName, text, e.Message.ToString(), category);
                    check = false;
                    result.result(check, orderDetail.Action_Code, orderDetail.Order_Number);
                }
            }
            return(result);
        }
コード例 #5
0
        public ResultDatabase_Model InsertDatabase(string text, int indicator, string fileName)
        {
            bool check = false;
            ResultDatabase_Model result = new ResultDatabase_Model();
            Response_ReadFile    error  = new Response_ReadFile();

            if (indicator == 3)
            {
                Articles_Model article = new Articles_Model();
                try
                {
                    article.Table_Indicator = DAL.IntReturn(text.Substring(0, 1));
                    article.Action_Code     = text.Substring(1, 1);

                    article.Lsp_Identification = text.Substring(2, 4);

                    string sku = text.Substring(6, 20);
                    article.Article_Number = sku.Substring(12, 8);

                    string shipFrom = text.Substring(26, 20);
                    article.Supplier_Code = shipFrom.Substring(14, 6);

                    int buyingUnit = DAL.IntReturn(text.Substring(58, 7));
                    article.Buying_Unit = DAL.DecimalReturn(DAL.ChangeValue(3, buyingUnit));

                    article.Selling_Unit = DAL.IntReturn(text.Substring(65, 4));

                    string orderUnit = text.Substring(69, 4);
                    article.Ordering_Unit = orderUnit.Substring(1, 3);


                    article.Article_Type   = DAL.IntReturn(text.Substring(73, 1));
                    article.Article_Status = DAL.IntReturn(text.Substring(75, 1));
                    article.Buyer_User_Id  = text.Substring(93, 6);
                    article.Desc_Article   = text.Substring(99, 33).Replace("'", "\"");
                    article.Packing_Type   = text.Substring(132, 2);


                    article.Article_Related = DAL.IntReturn(text.Substring(134, 20));


                    article.EAN_Code = text.Substring(154, 14);

                    string supplierArticle = text.Substring(168, 14);
                    article.Supplier_Article_Number = supplierArticle.Substring(0, 8);


                    article.Article_Desc     = text.Substring(182, 33);
                    article.Number_Mu_Carton = DAL.IntReturn(text.Substring(215, 6));
                    article.Number_Mu_Layer  = DAL.IntReturn(text.Substring(221, 6));
                    article.Number_Mu_Pallet = DAL.IntReturn(text.Substring(227, 6));

                    int cartonLength = DAL.IntReturn(text.Substring(233, 8));
                    article.Carton_Length = DAL.DecimalReturn(DAL.ChangeValue(2, cartonLength));

                    int cartonGrossweight = DAL.IntReturn(text.Substring(241, 9));
                    article.Carton_GrossWeight = DAL.DecimalReturn(DAL.ChangeValue(2, cartonGrossweight));

                    int cartonNetweight = DAL.IntReturn(text.Substring(250, 9));
                    article.Carton_NetWeight = DAL.DecimalReturn(DAL.ChangeValue(2, cartonNetweight));


                    article.Warehouse_Number = text.Substring(259, 5);

                    string dateRecord = text.Substring(264, 8);
                    int    year       = DAL.IntReturn(dateRecord.Substring(0, 4));
                    int    month      = DAL.IntReturn(dateRecord.Substring(4, 2));
                    int    day        = DAL.IntReturn(dateRecord.Substring(6, 2));
                    article.Date_Record             = new DateTime(year, month, day);
                    article.Logistic_Deposit_Type   = DAL.IntReturn(text.Substring(272, 1));
                    article.Logistic_Flow_Indicator = DAL.IntReturn(text.Substring(273, 2));
                    article.Ordering_Indicator      = DAL.IntReturn(text.Substring(275, 1));

                    article.Link_Logistic_Deposit = DAL.IntReturn(text.Substring(276, 20));

                    article.Expiry_Days = DAL.IntReturn(text.Substring(296, 3));
                    article.Expiry_Days_Checking_Indicator = DAL.IntReturn(text.Substring(299, 1));
                    article.Minimum_Expiry_Days            = DAL.IntReturn(text.Substring(300, 5));
                    article.Pallet_Indicator    = DAL.IntReturn(text.Substring(305, 1));
                    article.Number_Layer_Pallet = DAL.IntReturn(text.Substring(306, 2));
                    article.Number_Units_Inbox  = DAL.IntReturn(text.Substring(308, 5));

                    int grossVolumSelling = DAL.IntReturn(text.Substring(314, 15));
                    article.Gross_Volume = DAL.DecimalReturn(DAL.ChangeValue(3, grossVolumSelling));

                    article.Measure_Unit_GrossVolume = text.Substring(329, 3);
                    article.Packing_Type             = text.Substring(332, 2);

                    int cartonWidth = DAL.IntReturn(text.Substring(334, 8));
                    article.Carton_Width = DAL.DecimalReturn(DAL.ChangeValue(2, cartonWidth));

                    int cartonHeight = DAL.IntReturn(text.Substring(342, 8));
                    article.Carton_Height = DAL.DecimalReturn(DAL.ChangeValue(2, cartonHeight));


                    article.UOM_Carton_Size   = text.Substring(350, 3);
                    article.UOM_Carton_Weight = text.Substring(353, 3);

                    int cartonGrossVolume = DAL.IntReturn(text.Substring(356, 15));
                    article.Carton_Gross_Volume = DAL.DecimalReturn(DAL.ChangeValue(3, cartonGrossVolume));


                    article.UOM_Carton_Volume   = text.Substring(371, 3);
                    article.Selling_Unit_Length = DAL.IntReturn(text.Substring(374, 6));
                    article.Selling_Unit_Width  = DAL.IntReturn(text.Substring(380, 6));
                    article.Selling_Unit_Height = DAL.IntReturn(text.Substring(386, 6));
                    article.UOM_Selling_Size    = text.Substring(392, 3);



                    int grossweightSelling = DAL.IntReturn(text.Substring(395, 9));
                    article.Grossweight_Selling = DAL.DecimalReturn(DAL.ChangeValue(2, grossweightSelling));


                    int netwweightSelling = DAL.IntReturn(text.Substring(404, 9));
                    article.Netweight_Selling = DAL.DecimalReturn(DAL.ChangeValue(2, netwweightSelling));



                    article.UOM_Selling_Weight     = text.Substring(413, 3);
                    article.Article_Group_Number   = DAL.IntReturn(text.Substring(416, 3));;
                    article.Artice_Subgroup_Number = DAL.IntReturn(text.Substring(419, 3));
                    article.Excise_Tax_Indicator   = DAL.IntReturn(text.Substring(422, 1));

                    int exciseTaxAmount = DAL.IntReturn(text.Substring(423, 15));
                    article.Excise_Tax_Amount = DAL.DecimalReturn(DAL.ChangeValue(3, exciseTaxAmount));


                    article.High_Value_Indicator     = DAL.IntReturn(text.Substring(438, 1));
                    article.Storage_Temperature_Desc = text.Substring(439, 25);
                    article.Remark   = text.Substring(464, 33);
                    article.FILENAME = fileName;

                    string    sql      = string.Format("select * from MM_Articles where Article_Number='{0}'", article.Article_Number);
                    DataTable skuTable = DAL.SELECT_SQL(sql);
                    int       count    = DAL.IntReturn(skuTable.Rows.Count);

                    if (count > 0)
                    {
                        article.EditDate = DateTime.Now;

                        check = article.Update(fileName, text);
                        result.result(check, article.Article_Status.ToString(), article.Article_Number);
                    }
                    else if (count == 0)
                    {
                        article.EditDate = DateTime.Now;
                        article.AddDate  = DateTime.Now;
                        check            = article.Add(fileName, text);
                        result.result(check, article.Article_Status.ToString(), article.Article_Number);
                    }
                    else
                    {
                        check = false;
                        result.result(check, article.Article_Status.ToString(), article.Article_Number);
                    }
                }
                catch (Exception e)
                {
                    string category = "article";
                    error.HandleError(fileName, text, e.Message.ToString(), category);
                    check = false;
                    result.result(check, article.Article_Status.ToString(), article.Article_Number);
                }
            }
            else if (indicator == 4)
            {
                BarcodeArticles_Model barcodeArticle = new BarcodeArticles_Model();
                try
                {
                    barcodeArticle.Table_Indicator    = DAL.IntReturn(text.Substring(0, 1));
                    barcodeArticle.Action_Code        = text.Substring(1, 1);
                    barcodeArticle.Lsp_Identification = text.Substring(2, 4);

                    string sku = text.Substring(6, 20);
                    barcodeArticle.Article_Number = sku.Substring(12, 8);

                    string barcode = text.Substring(26, 20);
                    barcodeArticle.Barcode = barcode.Substring(0, 14);

                    barcodeArticle.Warehouse_Number = text.Substring(56, 5);

                    string dateRecord = text.Substring(61, 8);
                    int    year       = DAL.IntReturn(dateRecord.Substring(0, 4));
                    int    month      = DAL.IntReturn(dateRecord.Substring(4, 2));
                    int    day        = DAL.IntReturn(dateRecord.Substring(6, 2));
                    barcodeArticle.Date_Record = new DateTime(year, month, day);

                    barcodeArticle.Barcode_Sequence_Number = DAL.IntReturn(text.Substring(69, 3));
                    barcodeArticle.FILENAME = fileName;

                    string    sql         = string.Format("select * from MM_Barcode_Articles where Article_Number='{0}' and Barcode ='{1}'", barcodeArticle.Article_Number, barcodeArticle.Barcode);
                    DataTable altSkuTable = DAL.SELECT_SQL(sql);
                    int       count       = DAL.IntReturn(altSkuTable.Rows.Count);
                    if (count > 0)
                    {
                        barcodeArticle.Editdate = DateTime.Now;
                        check = barcodeArticle.Update(fileName, text);
                        result.result(check, "U", barcodeArticle.Article_Number);
                    }
                    else
                    {
                        barcodeArticle.AddDate  = DateTime.Now;
                        barcodeArticle.Editdate = DateTime.Now;
                        check = barcodeArticle.Add(fileName, text);
                        result.result(check, "I", barcodeArticle.Article_Number);
                    }
                }
                catch (Exception e)
                {
                    string category = "barcodeArticle";
                    error.HandleError(fileName, text, e.Message.ToString(), category);
                    check = false;
                    result.result(check, "", barcodeArticle.Article_Number);
                }
            }
            return(result);
        }
コード例 #6
0
ファイル: POController.cs プロジェクト: tducthang7192/MM-EDI
        public ResultDatabase_Model InsertDatabase(string text, int indicator, string fileName)
        {
            ResultDatabase_Model result = new ResultDatabase_Model();
            Response_ReadFile    error  = new Response_ReadFile();
            bool check = false;

            if (indicator == 1)
            {
                MM_PO_Header poHeader = new MM_PO_Header();
                try
                {
                    poHeader.Table_Indicator    = DAL.IntReturn(text.Substring(0, 1));
                    poHeader.Lsp_Identification = text.Substring(1, 4);

                    string orderNumber = text.Substring(5, 20);
                    poHeader.Order_Number = orderNumber.Substring(3, 17);

                    poHeader.Order_Type = text.Substring(25, 4);

                    string supplier = text.Substring(29, 10);
                    poHeader.Supplier_Number = supplier.Substring(4, 6);

                    string deliveryDate = text.Substring(39, 8);
                    int    year         = DAL.IntReturn(deliveryDate.Substring(0, 4));
                    int    month        = DAL.IntReturn(deliveryDate.Substring(4, 2));
                    int    day          = DAL.IntReturn(deliveryDate.Substring(6, 2));
                    poHeader.Plan_Delivery_Date = new DateTime(year, month, day);

                    string warehouse = text.Substring(47, 20);
                    poHeader.Warehouse_Number = warehouse.Substring(15, 5);

                    string email = text.Substring(67, 20);
                    poHeader.MM_Email_Number = email.Substring(0, 5);

                    poHeader.Memo_Field = text.Substring(87, 255);

                    string dateRecord = text.Substring(342, 8);
                    int    year1      = DAL.IntReturn(dateRecord.Substring(0, 4));
                    int    month1     = DAL.IntReturn(dateRecord.Substring(4, 2));
                    int    day1       = DAL.IntReturn(dateRecord.Substring(6, 2));
                    poHeader.Date_Record = new DateTime(year1, month1, day1);

                    poHeader.Action_Type = text.Substring(350, 1);

                    string commercialSupplier = text.Substring(351, 10);
                    poHeader.Commercial_Supplier_Number = commercialSupplier.Substring(3, 6);

                    string orderDate = text.Substring(361, 8);
                    int    year3     = DAL.IntReturn(orderDate.Substring(0, 4));
                    int    month3    = DAL.IntReturn(orderDate.Substring(4, 2));
                    int    day3      = DAL.IntReturn(orderDate.Substring(6, 2));
                    poHeader.Order_Date = new DateTime(year3, month3, day3);

                    poHeader.Free_Text1 = text.Substring(369, 20);
                    poHeader.Free_Text2 = text.Substring(389, 20);
                    poHeader.FILENAME   = fileName;

                    string    sql   = string.Format("select * from MM_PO_HEADER where Order_Number = '{0}'", poHeader.Order_Number);
                    DataTable dt    = DAL.SELECT_SQL(sql);
                    int       count = DAL.IntReturn(dt.Rows.Count);

                    if (count == 0)
                    {
                        poHeader.ADDDATE  = DateTime.Now;
                        poHeader.EDITDATE = DateTime.Now;
                        check             = poHeader.Add(fileName, text);
                        result.result(check, poHeader.Action_Type, poHeader.Order_Number);
                    }
                    else
                    {
                        poHeader.EDITDATE = DateTime.Now;
                        check             = poHeader.Update(fileName, text);
                        result.result(check, poHeader.Action_Type, poHeader.Order_Number);
                    }
                }
                catch (Exception e)
                {
                    string Category = "poHeader";
                    error.HandleError(fileName, text, e.Message.ToString(), Category);
                    check = false;
                    result.result(check, poHeader.Action_Type, poHeader.Order_Number);
                }
            }
            else if (indicator == 2)
            {
                MM_PO_Detail poDetail = new MM_PO_Detail();
                try
                {
                    poDetail.Table_Indicator    = DAL.IntReturn(text.Substring(0, 1));
                    poDetail.Lsp_Identification = text.Substring(1, 4);

                    string orderNumber = text.Substring(5, 20);
                    poDetail.Order_Number = orderNumber.Substring(3, 17);

                    string sku = text.Substring(81, 10);
                    poDetail.Article_Number = sku.Substring(2, 8);

                    int qty = DAL.IntReturn(text.Substring(91, 10));
                    poDetail.Order_Quantity = DAL.DecimalReturn(DAL.ChangeValue(3, qty));

                    string dateRecord = text.Substring(101, 8);
                    int    year       = DAL.IntReturn(dateRecord.Substring(0, 4));
                    int    month      = DAL.IntReturn(dateRecord.Substring(4, 2));
                    int    day        = DAL.IntReturn(dateRecord.Substring(6, 2));
                    poDetail.Date_Record = new DateTime(year, month, day);

                    poDetail.Action_Type = text.Substring(109, 1);
                    string warehouse = text.Substring(110, 20);
                    poDetail.Warehouse_Number = warehouse.Substring(15, 5);
                    poDetail.Orderline        = text.Substring(130, 20);
                    string email = text.Substring(150, 20);
                    poDetail.MM_Email_Number = email.Substring(0, 5);

                    poDetail.FILENAME = fileName;
                    string    sql = string.Format("select * from MM_PO_DETAIL where Order_Number = '{0}' and Article_Number= '{1}'", poDetail.Order_Number, poDetail.Article_Number);
                    DataTable supplierHeaderTable = DAL.SELECT_SQL(sql);
                    int       count = DAL.IntReturn(supplierHeaderTable.Rows.Count);

                    if (count == 0)
                    {
                        poDetail.ADDDATE  = DateTime.Now;
                        poDetail.EDITDATE = DateTime.Now;
                        check             = poDetail.Add(fileName, text);
                        result.result(check, poDetail.Action_Type, poDetail.Order_Number);
                    }
                    else
                    {
                        poDetail.EDITDATE = DateTime.Now;
                        check             = poDetail.Update(fileName, text);
                        result.result(check, poDetail.Action_Type, poDetail.Order_Number);
                    }
                }
                catch (Exception e)
                {
                    string Category = "poDetail";
                    error.HandleError(fileName, text, e.Message.ToString(), Category);
                    check = false;
                    result.result(check, poDetail.Action_Type, poDetail.Order_Number);
                }
            }
            else if (indicator == 3)
            {
                MM_PO_Detail_XD poDetailXd = new MM_PO_Detail_XD();
                try
                {
                    poDetailXd.Table_Indicator    = DAL.IntReturn(text.Substring(0, 1));
                    poDetailXd.Lsp_Identification = text.Substring(1, 4);

                    string orderNumber = text.Substring(5, 20);
                    poDetailXd.Order_Number = orderNumber.Substring(3, 17);

                    string sku = text.Substring(63, 10);
                    poDetailXd.Article_Number = sku.Substring(2, 8);

                    string storeNumber = text.Substring(73, 10);
                    poDetailXd.Store_Number = storeNumber.Substring(8, 2);

                    int qty = DAL.IntReturn(text.Substring(83, 10));
                    poDetailXd.Order_Quantity = DAL.DecimalReturn(DAL.ChangeValue(3, qty));

                    string warehouse = text.Substring(93, 20);
                    poDetailXd.Warehouse_Number = warehouse.Substring(15, 5);

                    string saleOrder = text.Substring(121, 20);
                    poDetailXd.Sale_Order = saleOrder.Substring(3, 17);


                    string mail = text.Substring(141, 20);
                    poDetailXd.Metro_Mail = mail.Substring(0, 5);

                    string articleNumber = text.Substring(161, 10);
                    poDetailXd.Buying_Article_Number = articleNumber.Substring(0, 7);

                    poDetailXd.FILENAME = fileName;
                    string    sql = string.Format("select * from MM_PO_DETAIL_XD where Order_Number = '{0}' and Sale_Order='{1}' and Article_Number='{2}'", poDetailXd.Order_Number, poDetailXd.Sale_Order, poDetailXd.Article_Number);
                    DataTable supplierHeaderTable = DAL.SELECT_SQL(sql);
                    int       count = DAL.IntReturn(supplierHeaderTable.Rows.Count);

                    if (count == 0)
                    {
                        poDetailXd.ADDDATE  = DateTime.Now;
                        poDetailXd.EDITDATE = DateTime.Now;
                        check = poDetailXd.Add(fileName, text);
                        result.result(check, "", poDetailXd.Order_Number);
                    }
                    else
                    {
                        poDetailXd.EDITDATE = DateTime.Now;
                        check = poDetailXd.Update(fileName, text);
                        result.result(check, "", poDetailXd.Order_Number);
                    }
                }
                catch (Exception e)
                {
                    string Category = "poDetailXd";
                    error.HandleError(fileName, text, e.Message.ToString(), Category);
                    check = false;
                    result.result(check, "", poDetailXd.Order_Number);
                }
            }
            return(result);
        }
コード例 #7
0
        public JArray Create_ModelSku()
        {
            JArray    items = new JArray();
            string    sql   = string.Format("exec PR_MM_ARTICLES_INFORMATION '{0}'", "SOUTH");
            DataTable dt    = DAL.SELECT_SQL(sql);

            if (dt.Rows.Count > 0)
            {
                int count = dt.Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    try
                    {
                        SkuInfor_Model_South item = new SkuInfor_Model_South();
                        item.storerkey = "OW9600";
                        string sku = dt.Rows[i]["Article_Number"].ToString().Trim();
                        code = dt.Rows[i]["Article_Number"].ToString().Trim();
                        sku  = sku.TrimStart('0');

                        int     qtyPerCase         = DAL.IntReturn(dt.Rows[0]["Number_Mu_Carton"]);
                        decimal carton_grossWeight = DAL.DecimalReturn(dt.Rows[i]["Carton_GrossWeight"]);
                        decimal carton_netWeight   = DAL.DecimalReturn(dt.Rows[i]["Carton_NetWeight"]);
                        decimal carton_cube        = DAL.DecimalReturn(dt.Rows[i]["Carton_Gross_Volume"]);
                        decimal carton_length      = DAL.DecimalReturn(dt.Rows[i]["Carton_Length"]);
                        decimal carton_width       = DAL.DecimalReturn(dt.Rows[i]["Carton_Width"]);
                        decimal carton_height      = DAL.DecimalReturn(dt.Rows[i]["Carton_Height"]);
                        decimal grossWeight        = (carton_grossWeight / qtyPerCase);
                        grossWeight = Math.Round(grossWeight, 5);
                        decimal netWeight      = grossWeight;
                        decimal cube_cm3       = ((carton_length * carton_width * carton_height) / qtyPerCase);
                        decimal tareWeight_cm3 = grossWeight - netWeight;
                        item.sku                  = sku;
                        item.descr                = dt.Rows[i]["Desc_Article"].ToString().Trim().Replace("'", "\"");
                        item.addwho               = "addmin";
                        item.editwho              = "admin";
                        item.sourceversion        = "0";
                        item.susr1                = dt.Rows[i]["susr1"].ToString().Trim().TrimStart('0');
                        item.susr2                = dt.Rows[i]["susr2"].ToString().Trim();
                        item.susr3                = dt.Rows[i]["susr3"].ToString().Trim();
                        item.susr4                = dt.Rows[i]["susr4"].ToString().Trim();
                        item.susr5                = dt.Rows[i]["susr5"].ToString().Trim();
                        item.susr6                = dt.Rows[i]["susr6"].ToString().Trim();
                        item.susr7                = dt.Rows[i]["susr7"].ToString().Trim();
                        item.susr8                = dt.Rows[i]["susr8"].ToString().Trim();
                        item.susr9                = dt.Rows[i]["susr9"].ToString().Trim();
                        item.susr10               = dt.Rows[i]["susr10"].ToString().Trim();
                        item.packkey              = sku + "_MMSOUTH";
                        item.rfdefaultpack        = sku + "_MMSOUTH";
                        item.itemcharacteristic1  = dt.Rows[i]["Article_Group1"].ToString().Trim(); //dt.Rows[i]["Article_Group_Number"].ToString().Trim();
                        item.itemcharacteristic2  = dt.Rows[i]["Article_Group2"].ToString().Trim(); //dt.Rows[i]["Artice_Subgroup_Number"].ToString().Trim();
                        item.stdgrosswgt          = grossWeight.ToString();
                        item.stdnetwgt            = netWeight.ToString();
                        item.stdcube              = cube_cm3.ToString();
                        item.tare                 = tareWeight_cm3.ToString();
                        item.onreceiptcopypackkey = "0";
                        item.rotateby             = "Lot";
                        string logisticFlow = dt.Rows[i]["Logistic_Flow_Indicator"].ToString().Trim();


                        if (logisticFlow == "19")
                        {
                            item.shelflifeindicator    = "Y";
                            item.toexpiredays          = dt.Rows[i]["Expiry_Days"].ToString().Trim();
                            item.lottablevalidationkey = "MMSOUTH";
                            item.flowthruitem          = "Y";
                            item.cartonizeft           = "1";
                            item.groupfteach           = "1";
                        }
                        else
                        {
                            item.shelflifeindicator = "N";
                            item.toexpiredays       = "0";
                            #region

                            /*nếu shelflifeindicator là N thì phải để shelflife= 0 , nếu không
                             * sẽ báo lỗi localizedMessage internal server*/
                            #endregion
                            item.shelflife             = "0";
                            item.lottablevalidationkey = "MMSOUTH";
                            item.flowthruitem          = "Y";
                            item.cartonizeft           = "1"; // item.cartonizeft = "1";
                            item.groupfteach           = "1";
                        }

                        item.odeweight    = "1";
                        item.rfdefaultuom = "MU";

                        item.putawaystrategykey    = "STD";
                        item.newallocationstrategy = "CS";//CS

                        item.barcodeconfigkey  = "";
                        item.collection        = "";
                        item.shelflifecodetype = "E"; // M -manufacturing E- expriation
                        item.lottable01label   = "Lottable01";
                        item.lottable02label   = "Lottable02";
                        item.lottable03label   = "Lottable03";
                        item.lottable04label   = "Manufacturing Date";
                        item.lottable05label   = "Expiration Date";
                        item.lottable06label   = "Lottable06";
                        item.lottable07label   = "Lottable07";
                        item.lottable08label   = "Lottable08";
                        item.lottable09label   = "ASN";
                        item.lottable10label   = "PO";
                        item.snumlength        = "0";
                        item.snumincrlength    = "0";
                        item.allowmultilotlpn  = "1";

                        string output = JsonConvert.SerializeObject(item);

                        JObject objectitem = JObject.Parse(output);
                        items.Add(objectitem);
                    }
                    catch (Exception e)
                    {
                        string step = string.Format(Constant.MODEL_SKU, "SOUTH");
                        resultMapping.Handle_Error_Mapping(code, e.ToString(), step);
                        continue;
                    }
                }
            }
            return(items);
        }