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); }
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); }
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); }
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) { Supplier_Header_Model supplierHeader = new Supplier_Header_Model(); try { supplierHeader.Table_Indicator = DAL.IntReturn(text.Substring(0, 1)); supplierHeader.Action_Code = text.Substring(1, 1); supplierHeader.Lsp_Identification = text.Substring(2, 4).ToString(); string supplierCode = text.Substring(6, 20); supplierHeader.Supplier_Code = supplierCode.Substring(14, 6).ToString(); supplierHeader.Supplier_Name = text.Substring(26, 35).Replace("'", "\""); supplierHeader.Supplier_Status = DAL.IntReturn(text.Substring(61, 2)); supplierHeader.Supplier_Type = DAL.IntReturn(text.Substring(63, 2)); supplierHeader.Buyer_User_Id = text.Substring(65, 6); supplierHeader.Supplier_Fiscal_Number = text.Substring(71, 15); supplierHeader.Way_Of_Order = DAL.IntReturn(text.Substring(86, 1)); supplierHeader.Language_Code = text.Substring(87, 2); supplierHeader.Currency_Code = text.Substring(89, 3); //string warehouse= text.Substring(92, 5); supplierHeader.Warehouse_Number = text.Substring(92, 5); string dateRecord = text.Substring(97, 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)); supplierHeader.Date_Record = new DateTime(year, month, day); supplierHeader.Default_Logistic_Flow = int.Parse(text.Substring(105, 2)); supplierHeader.Supplier_Registration_Number = text.Substring(107, 15); supplierHeader.FILENAME = fileName; string sql = string.Format("select * from MM_Supplier_Header where Supplier_Code = '{0}' and Warehouse_Number='{1}' ", supplierHeader.Supplier_Code, supplierHeader.Warehouse_Number); DataTable supplierHeaderTable = DAL.SELECT_SQL(sql); int count = DAL.IntReturn(supplierHeaderTable.Rows.Count); if (count > 0 && supplierHeader.Supplier_Status == 1) { supplierHeader.EditDate = DateTime.Now; check = supplierHeader.Update(fileName, text); result.result(check, supplierHeader.Supplier_Status.ToString(), supplierHeader.Supplier_Code); } else if (count > 0 && (supplierHeader.Supplier_Status == 5 || supplierHeader.Supplier_Status == 9)) { supplierHeader.EditDate = DateTime.Now; check = supplierHeader.Update(fileName, text); result.result(check, supplierHeader.Supplier_Status.ToString(), supplierHeader.Supplier_Code); } else if (count == 0 && supplierHeader.Supplier_Status == 1) { supplierHeader.AddDate = DateTime.Now; supplierHeader.EditDate = DateTime.Now; check = supplierHeader.Add(fileName, text); result.result(check, supplierHeader.Supplier_Status.ToString(), supplierHeader.Supplier_Code); } else { check = false; result.result(check, supplierHeader.Supplier_Status.ToString(), supplierHeader.Supplier_Code); } } catch (Exception e) { string category = "supplierHeader"; error.HandleError(fileName, text, e.Message.ToString(), category); check = false; result.result(check, supplierHeader.Supplier_Status.ToString(), supplierHeader.Supplier_Code); } } else if (indicator == 2) { Supplier_Detail_Model supplierDetail = new Supplier_Detail_Model(); try { supplierDetail.Table_Indicator = DAL.IntReturn(text.Substring(0, 1)); supplierDetail.Action_Code = text.Substring(1, 1); supplierDetail.Lsp_Identification = text.Substring(2, 4); string supplierCode = text.Substring(6, 20); supplierDetail.Supplier_Code = supplierCode.Substring(14, 6).ToString(); supplierDetail.Address_Indicator = DAL.IntReturn(text.Substring(26, 2)); supplierDetail.Contact_Person = text.Substring(28, 35); supplierDetail.Building = text.Substring(63, 28); supplierDetail.Town = text.Substring(119, 25); supplierDetail.Phone = text.Substring(144, 15); supplierDetail.Fax_Number = text.Substring(159, 18); supplierDetail.Postal_Code = text.Substring(176, 11); supplierDetail.DC_Phone_Number = text.Substring(188, 15); supplierDetail.Origin = text.Substring(221, 4); supplierDetail.Supplier_Repressentative = text.Substring(225, 35); supplierDetail.Warehouse_Number = text.Substring(260, 5).ToString(); string dateRecord = text.Substring(265, 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)); supplierDetail.Date_Record = new DateTime(year, month, day); supplierDetail.Email_Address = text.Substring(273, 100); supplierDetail.FILENAME = fileName; string sql = string.Format("select * from MM_Supplier_Detail where Supplier_Code = '{0}' and Warehouse_Number='{1}' ", supplierDetail.Supplier_Code, supplierDetail.Warehouse_Number); DataTable supplierDetailTable = DAL.SELECT_SQL(sql); int count = DAL.IntReturn(supplierDetailTable.Rows.Count); if (count > 0) { supplierDetail.Editdate = DateTime.Now; check = supplierDetail.Update(fileName, text); result.result(check, "U", supplierDetail.Supplier_Code); } else if (count == 0) { supplierDetail.AddDate = DateTime.Now; supplierDetail.Editdate = DateTime.Now; check = supplierDetail.Add(fileName, text); result.result(check, "I", supplierDetail.Supplier_Code); } } catch (Exception e) { string category = "supplierDetail"; error.HandleError(fileName, text, e.Message.ToString(), category); check = false; result.result(check, "", supplierDetail.Supplier_Code); } } return(result); }