private void UpdateProductData(Excel.Application xlApp, DataRow[] drSellers, DateTime SummaryCreationDate) { try { ProductMaster ObjProductMaster = CommonFunctions.ObjProductMaster; lblStatus.Text = "Loading Product Inventory file"; DataTable dtProductInventory = CommonFunctions.ReturnDataTableFromExcelWorksheet("Inventory", ProductInventoryFilePath, "*"); DataRow[] drProductsInventory = dtProductInventory.DefaultView.ToTable().Select("", "[StockName] asc"); ObjProductMaster.LoadProductInventoryFile(drProductsInventory); lblStatus.Text = "Processing Product Inventory file"; for (int i = 0; i < drSellers.Length; i++) { lblStatus.Text = "Updating Product Inventory file for Seller " + (i + 1) + " of " + drSellers.Length; String SheetName = drSellers[i]["Seller Name"].ToString().Trim().Replace(":", ""). Replace("\\", "").Replace("/", ""). Replace("?", "").Replace("*", ""). Replace("[", "").Replace("]", ""); //DataTable dtSellerInvoice = CommonFunctions.ReturnDataTableFromExcelWorksheet(SheetName, SellerSummaryFilePath, "*", "A6:F100000"); ReportType EnumReportType = (CommonFunctions.ObjGeneralSettings.SummaryLocation == 0 ? ReportType.INVOICE : ReportType.QUOTATION); Invoice ObjInvoice = CommonFunctions.GetInvoiceTemplate(EnumReportType); DataTable dtSellerInvoice = ObjInvoice.LoadInvoice(SheetName, SellerSummaryFilePath); if (dtSellerInvoice == null) { continue; } dtSellerInvoice.DefaultView.RowFilter = "IsNull([Sl No], 0) > 0"; DataRow[] drProducts = dtSellerInvoice.DefaultView.ToTable().Select("", "[Sl No] asc"); ObjProductMaster.UpdateProductInventoryDataFromInvoice(drProducts); } ObjProductMaster.ComputeStockNetData("Sale"); lblStatus.Text = "Updating Product Inventory file"; ObjProductMaster.UpdateProductInventoryFile(xlApp, SummaryCreationDate, ProductInventoryFilePath); lblStatus.Text = "Completed updating Product Inventory file"; lblStatus.Text = "Updating Product Stock History file"; ObjProductMaster.UpdateProductStockHistoryFile(xlApp, SummaryCreationDate, "Sale", ProductStockHistoryFilePath); lblStatus.Text = "Completed updating Product Stock History file"; CommonFunctions.ObjProductMaster.ResetStockProducts(); } catch (Exception ex) { CommonFunctions.ShowErrorDialog("UpdateOrderMasterForm.UpdateProductData()", ex); throw; } }