Пример #1
0
        public void LoadProductMaster(DataTable dtProductMaster, DataTable dtPriceGroupMaster, DataTable dtHSNMaster)
        {
            try
            {
                ObjProductMaster = new ProductMaster();
                ObjProductMaster.Initialize();

                for (int i = 0; i < dtPriceGroupMaster.Rows.Count; i++)
                {
                    DataRow dtRow = dtPriceGroupMaster.Rows[i];
                    //PriceGroup	Discount	DiscountType	Description	Default

                    PriceGroupDetails ObjPriceGroupDetails = new PriceGroupDetails();
                    ObjPriceGroupDetails.Name         = dtRow["PriceGroup"].ToString().Trim();
                    ObjPriceGroupDetails.Discount     = Double.Parse(dtRow["Discount"].ToString().Trim());
                    ObjPriceGroupDetails.DiscountType = PriceGroupDetails.GetDiscountType(dtRow["DiscountType"].ToString().Trim());
                    ObjPriceGroupDetails.IsDefault    = (Int32.Parse(dtRow["Default"].ToString().Trim()) == 1);
                    ObjPriceGroupDetails.Description  = dtRow["Description"].ToString();

                    ObjProductMaster.AddPriceGroupToCache(ObjPriceGroupDetails);
                }

                LoadHSNMasterData(dtHSNMaster);

                for (int i = 0; i < dtProductMaster.Rows.Count; i++)
                {
                    DataRow dtRow = dtProductMaster.Rows[i];
                    //SlNo	ItemName	VendorName	PurchasePrice	SellingPrice	Wholesale	Retail  StockName   HSNCode UnitsOfMeasurement
                    ProductDetails ObjProductDetails = new ProductDetails();
                    ObjProductDetails.ItemName           = dtRow["ItemName"].ToString();
                    ObjProductDetails.StockName          = dtRow["StockName"].ToString();
                    ObjProductDetails.VendorName         = dtRow["VendorName"].ToString();
                    ObjProductDetails.Units              = Double.Parse(dtRow["Units"].ToString());
                    ObjProductDetails.PurchasePrice      = Double.Parse(dtRow["PurchasePrice"].ToString());
                    ObjProductDetails.SellingPrice       = Double.Parse(dtRow["SellingPrice"].ToString());
                    ObjProductDetails.HSNCode            = dtRow["HSNCode"].ToString();
                    ObjProductDetails.UnitsOfMeasurement = dtRow["UnitOfMeasurement"].ToString();
                    ObjProductDetails.ListPrices         = new Double[ObjProductMaster.ListPriceGroups.Count];
                    for (int j = 0; j < ObjProductDetails.ListPrices.Length; j++)
                    {
                        ObjProductDetails.ListPrices[j] = Double.NaN;
                        if (!dtRow.Table.Columns.Contains(ObjProductMaster.ListPriceGroups[j].Name))
                        {
                            continue;
                        }
                        if (dtRow[ObjProductMaster.ListPriceGroups[j].Name] == DBNull.Value)
                        {
                            continue;
                        }
                        if (String.IsNullOrEmpty(dtRow[ObjProductMaster.ListPriceGroups[j].Name].ToString().Trim()))
                        {
                            continue;
                        }
                        ObjProductDetails.ListPrices[j] = Double.Parse(dtRow[ObjProductMaster.ListPriceGroups[j].Name].ToString().Trim());
                    }

                    ObjProductMaster.AddProductToCache(ObjProductDetails);
                }

                ObjProductMaster.UpdateStockProductIndexes();
                ObjProductMaster.UpdateHSNProductIndexes();
            }
            catch (Exception ex)
            {
                CommonFunctions.ShowErrorDialog("ProductLine.LoadProductMaster()", ex);
            }
        }
Пример #2
0
        public void LoadVendorMaster(DataTable dtVendorMaster, DataTable dtDiscountGroupMaster)
        {
            try
            {
                ObjVendorMaster = new VendorMaster();
                ObjVendorMaster.Initialize();

                #region Load Line from Vendor Master
                CommonFunctions.ListVendorLines = new List <String>();
                Boolean ContainsBlanks = false;
                for (int i = 0; i < dtVendorMaster.Rows.Count; i++)
                {
                    DataRow dtRow = dtVendorMaster.Rows[i];
                    String  Line  = dtRow["Line"].ToString().Replace("<", "").Replace(">", "").ToUpper();
                    if (Line.Trim().Length == 0)
                    {
                        ContainsBlanks = true;
                    }
                    else if (!CommonFunctions.ListVendorLines.Contains(Line))
                    {
                        CommonFunctions.ListVendorLines.Add(Line);
                    }
                }

                CommonFunctions.ListVendorLines.Sort();
                CommonFunctions.ListVendorLines.Insert(0, "<All>");
                if (ContainsBlanks)
                {
                    CommonFunctions.ListVendorLines.Add("<Blanks>");
                }
                #endregion

                #region Load Discount Groups
                for (int i = 0; i < dtDiscountGroupMaster.Rows.Count; i++)
                {
                    DataRow dtRow = dtDiscountGroupMaster.Rows[i];
                    //DiscountGroup	Discount	DiscountType	Default	Description

                    DiscountGroupDetails ObjDiscountGroupDetails = new DiscountGroupDetails();
                    ObjDiscountGroupDetails.Name         = dtRow["DiscountGroup"].ToString().Trim();
                    ObjDiscountGroupDetails.Discount     = Double.Parse(dtRow["Discount"].ToString().Trim());
                    ObjDiscountGroupDetails.DiscountType = PriceGroupDetails.GetDiscountType(dtRow["DiscountType"].ToString().Trim());
                    ObjDiscountGroupDetails.IsDefault    = (Int32.Parse(dtRow["Default"].ToString().Trim()) == 1);
                    ObjDiscountGroupDetails.Description  = dtRow["Description"].ToString().Trim();

                    ObjVendorMaster.AddDiscountGroupToCache(ObjDiscountGroupDetails);
                }
                #endregion

                #region Load Vendor Details
                for (int i = 0; i < dtVendorMaster.Rows.Count; i++)
                {
                    DataRow dtRow = dtVendorMaster.Rows[i];
                    //SlNo	VendorName	Address	TINNumber	Phone	Line	OldBalance	PriceGroup	DiscountGroup

                    VendorDetails ObjVendorDetails = new VendorDetails();
                    ObjVendorDetails.VendorName    = dtRow["VendorName"].ToString().Trim();
                    ObjVendorDetails.Address       = dtRow["Address"].ToString().Trim();
                    ObjVendorDetails.TINNumber     = dtRow["TINNumber"].ToString().Trim();
                    ObjVendorDetails.Phone         = dtRow["Phone"].ToString().Trim();
                    ObjVendorDetails.Line          = dtRow["Line"].ToString().Trim();
                    ObjVendorDetails.PriceGroup    = "";
                    ObjVendorDetails.DiscountGroup = "";

                    if (dtRow["PriceGroup"] != DBNull.Value && dtRow["PriceGroup"].ToString().Trim().Length > 0)
                    {
                        ObjVendorDetails.PriceGroup = dtRow["PriceGroup"].ToString().Trim();
                    }
                    if (dtRow["DiscountGroup"] != DBNull.Value && dtRow["DiscountGroup"].ToString().Trim().Length > 0)
                    {
                        ObjVendorDetails.DiscountGroup = dtRow["DiscountGroup"].ToString().Trim();
                    }

                    ObjVendorMaster.AddVendorToCache(ObjVendorDetails, ObjProductMaster.ListPriceGroups);
                }
                #endregion
            }
            catch (Exception ex)
            {
                CommonFunctions.ShowErrorDialog("ProductLine.LoadVendorMaster()", ex);
            }
        }