예제 #1
0
파일: PriceData.cs 프로젝트: rymarrv/Compas
 private void Fill()
 {
     FillWares();
     FillPriceGroups();
     WarePricesLogic prices = new WarePricesLogic(manager);
     if (mode == "edit")
     {
         WarePrice price = prices.Get(Convert.ToInt32(id));
         if (price != null)
         {
             int i = 0;
             foreach (var a in WareCB.Items)
             {
                 if (price.WareID == ((WareView)a).ID)
                 {
                     WareCB.SelectedIndex = i;
                     break;
                 }
                 i++;
             }
             PriceGroupsCB.SelectedItem = price.WarePriceGroup;
             AllowDiscountCB.Checked = price.AllowDiscount;
             PurchasePriceNUD.Value = price.PurchasePriceForUnit;
             SalePriceNUD.Value = price.SalePriceForUnit;
         }
     }
 }
예제 #2
0
        private void RecalculatePrices()
        {
            int     wareId                = Convert.ToInt32(WareLUE.EditValue);
            int     priceGroupId          = Convert.ToInt32(PriceGroupsCBE.EditValue);
            decimal discount              = Convert.ToDecimal(DiscountForUnitTB.Text);
            decimal unitQuantity          = Convert.ToDecimal(UnitQuantityTB.Text);
            decimal secondaryUnitQuantity = Convert.ToDecimal(SecondaryUnitQuantityTB.Text);
            decimal salePriceForUnit      = Convert.ToDecimal(SalePriceForUnitTB.Text);

            WarePricesLogic prices = new WarePricesLogic(manager);
            WarePrice       price  = prices.Get(wareId, priceGroupId);

            decimal endSalePriceForUnit = salePriceForUnit - discount;
            decimal salePrice           = endSalePriceForUnit * unitQuantity;

            EndSalePriceForUnitTB.Text = endSalePriceForUnit.ToString("n2");
            SalePriceTB.Text           = salePrice.ToString("n2");

            if (price != null)
            {
                MessageL.Text = "";
            }
            else
            {
                MessageL.Text = "Ціну не знайдено.";
            }
        }
예제 #3
0
 private void DeleteSB_Click(object sender, EventArgs e)
 {
     WarePricesLogic prices = new WarePricesLogic(manager);
     prices.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value));
     manager.Save();
     Fill();
 }
예제 #4
0
        private void Fill()
        {
            FillWares();
            FillPriceGroups();
            WarePricesLogic prices = new WarePricesLogic(manager);

            if (mode == "edit")
            {
                WarePrice price = prices.Get(Convert.ToInt32(id));
                if (price != null)
                {
                    int i = 0;
                    foreach (var a in WareCB.Items)
                    {
                        if (price.WareID == ((WareView)a).ID)
                        {
                            WareCB.SelectedIndex = i;
                            break;
                        }
                        i++;
                    }
                    PriceGroupsCB.SelectedItem = price.WarePriceGroup;
                    AllowDiscountCB.Checked    = price.AllowDiscount;
                    PurchasePriceNUD.Value     = price.PurchasePriceForUnit;
                    SalePriceNUD.Value         = price.SalePriceForUnit;
                }
            }
        }
예제 #5
0
        private void SaveBt_Click(object sender, EventArgs e)
        {
            WarePricesLogic prices = new WarePricesLogic(manager);

            int     wareId               = Convert.ToInt32(WareCB.SelectedValue);
            int     warePriceGroupId     = Convert.ToInt32(PriceGroupsCB.SelectedValue);
            int?    documentId           = null;
            bool    allowDiscount        = AllowDiscountCB.Checked;
            decimal purchasePriceForUnit = PurchasePriceNUD.Value;
            decimal salePriceForUnit     = SalePriceNUD.Value;
            bool    active               = PriceActiveCB.Checked;

            if (mode == "new")
            {
                prices.Create(wareId, warePriceGroupId, documentId, allowDiscount,
                              purchasePriceForUnit, salePriceForUnit, active);
            }
            if (mode == "edit")
            {
                prices.Update(Convert.ToInt32(id), wareId, warePriceGroupId, documentId, allowDiscount,
                              purchasePriceForUnit, salePriceForUnit, active);
            }
            manager.Save();

            this.Close();
        }
예제 #6
0
        private void DeleteSB_Click(object sender, EventArgs e)
        {
            WarePricesLogic prices = new WarePricesLogic(manager);

            prices.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value));
            manager.Save();
            Fill();
        }
예제 #7
0
        private void FillPrices()
        {
            if (wareSelectorUC1.WareID != null)
            {
                int wareId = Convert.ToInt32(/*WaresGV.SelectedRows[0].Cells["WareID"].Value*/ wareSelectorUC1.WareID);
                //int priceGroupId = Convert.ToInt32(PriceGroupsCBE.EditValue);
                decimal discount              = Convert.ToDecimal(DiscountForUnitNUD.Value);
                decimal unitQuantity          = Convert.ToDecimal(UnitQuantityNUD.Value);
                decimal secondaryUnitQuantity = Convert.ToDecimal(SecondaryUnitQuantityNUD.Value);

                WarePricesLogic prices = new WarePricesLogic(manager);
                WarePrice       price  = prices.GetAll(wareId).OrderByDescending(a => a.Active).FirstOrDefault();

                if (price != null)
                {
                    UnitPriceNUD.Value = price.SalePriceForUnit;
                }
                else
                {
                    UnitPriceNUD.Value = 0;
                }
            }
        }
예제 #8
0
        private void Fill()
        {
            WarePricesLogic prices     = new WarePricesLogic(manager);
            var             pricesList = prices.GetAll(wareId).Select(a => new
            {
                a.ID,
                a.WareID,
                a.WarePriceGroupID,
                a.DocumentID,
                a.AllowDiscount,
                a.PurchasePriceForUnit,
                a.SalePriceForUnit,
                a.Active,
                a.Ware.Name,
                UnitID             = a.Ware.UnitID,
                UnitName           = a.Ware.WareUnit == null ? "" : a.Ware.WareUnit.Name,
                CategoryID         = a.Ware.CategoryID,
                CategoryName       = a.Ware.WareCategory == null ? "" : a.Ware.WareCategory.Name,
                WarePriceGroupName = a.WarePriceGroup == null ? "" : a.WarePriceGroup.Name,
                ManufacturerName   = a.Ware.WareManufacturer == null ? "" : a.Ware.WareManufacturer.Name,
                ManufacturerID     = a.Ware.ManufacturerID
            });

            view = new SortableBindingList <PricesView>();


            //var waresList = wares.GetAll(name, categoryId, manufacturerId, unitId).Select(a => new
            //{
            //    a.ID,
            //    Name = a.Name,
            //    UnitName = a.WareUnit != null ? a.WareUnit.Name : "",
            //    ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "",
            //    CategoryName = a.WareCategory != null ? a.WareCategory.Name : ""
            //});//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList();

            foreach (var a in pricesList)
            {
                PricesView pv = new PricesView();
                pv.ID               = a.ID;
                pv.WareName         = a.Name;
                pv.CategoryID       = a.CategoryID;
                pv.CategoryName     = a.CategoryName;
                pv.ManufacturerName = a.ManufacturerName;
                pv.UnitName         = a.UnitName;
                pv.DocumentID       = a.DocumentID;
                pv.ManufacturerID   = a.ManufacturerID;

                pv.PurshasePriceForUnit = a.PurchasePriceForUnit;
                pv.SalePriceForUnit     = a.SalePriceForUnit;
                pv.UnitID             = a.UnitID;
                pv.UnitName           = a.UnitName;
                pv.WareID             = a.WareID;
                pv.WarePriceGroupID   = a.WarePriceGroupID;
                pv.WarePriceGroupName = a.WarePriceGroupName;

                pv.AllowDiscount = a.AllowDiscount;
                pv.Active        = a.Active;
                view.Add(pv);
            }

            //BindingListView<WareView> view = new BindingListView<WareView>(viewList);
            //bs.DataSource = view;
            //bs.Sort = columnName;

            //SortableBindingList<PricesView> viewList = new SortableBindingList<PricesView>(view);
            DataGV.DataSource = view;
            DataGV.Update();
        }
예제 #9
0
파일: PriceData.cs 프로젝트: rymarrv/Compas
        private void SaveBt_Click(object sender, EventArgs e)
        {
            WarePricesLogic prices = new WarePricesLogic(manager);

            int wareId = Convert.ToInt32(WareCB.SelectedValue);
            int warePriceGroupId = Convert.ToInt32(PriceGroupsCB.SelectedValue);
            int? documentId = null;
            bool allowDiscount = AllowDiscountCB.Checked;
            decimal purchasePriceForUnit = PurchasePriceNUD.Value;
            decimal salePriceForUnit = SalePriceNUD.Value;
            bool active = PriceActiveCB.Checked;

            if (mode == "new")
            {
                prices.Create(wareId, warePriceGroupId, documentId, allowDiscount,
                    purchasePriceForUnit, salePriceForUnit, active);
            }
            if (mode == "edit")
            {
                prices.Update(Convert.ToInt32(id), wareId, warePriceGroupId, documentId, allowDiscount,
                    purchasePriceForUnit, salePriceForUnit, active);
            }
            manager.Save();

            this.Close();
        }
예제 #10
0
        private void RecalculatePrices()
        {
            int wareId = Convert.ToInt32(WareLUE.EditValue);
            int priceGroupId = Convert.ToInt32(PriceGroupsCBE.EditValue);
            decimal discount = Convert.ToDecimal(DiscountForUnitTB.Text);
            decimal unitQuantity = Convert.ToDecimal(UnitQuantityTB.Text);
            decimal secondaryUnitQuantity = Convert.ToDecimal(SecondaryUnitQuantityTB.Text);
            decimal salePriceForUnit = Convert.ToDecimal(SalePriceForUnitTB.Text);

            WarePricesLogic prices = new WarePricesLogic(manager);
            WarePrice price = prices.Get(wareId, priceGroupId);

            decimal endSalePriceForUnit = salePriceForUnit - discount;
            decimal salePrice = endSalePriceForUnit * unitQuantity;

            EndSalePriceForUnitTB.Text = endSalePriceForUnit.ToString("n2");
            SalePriceTB.Text = salePrice.ToString("n2");

            if (price != null)
            {
                MessageL.Text = "";
            }
            else
            {

                MessageL.Text = "Ціну не знайдено.";
            }
        }
예제 #11
0
        private void Fill()
        {
            WarePricesLogic prices = new WarePricesLogic(manager);
            var pricesList = prices.GetAll(wareId).Select(a => new
            {
                a.ID,
                a.WareID,
                a.WarePriceGroupID,
                a.DocumentID,
                a.AllowDiscount,
                a.PurchasePriceForUnit,
                a.SalePriceForUnit,
                a.Active,
                a.Ware.Name,
                UnitID = a.Ware.UnitID,
                UnitName = a.Ware.WareUnit == null ? "" : a.Ware.WareUnit.Name,
                CategoryID = a.Ware.CategoryID,
                CategoryName = a.Ware.WareCategory == null ? "" : a.Ware.WareCategory.Name,
                WarePriceGroupName = a.WarePriceGroup == null ? "" : a.WarePriceGroup.Name,
                ManufacturerName = a.Ware.WareManufacturer == null ? "" : a.Ware.WareManufacturer.Name,
                ManufacturerID = a.Ware.ManufacturerID
            });

            view = new SortableBindingList<PricesView>();

            //var waresList = wares.GetAll(name, categoryId, manufacturerId, unitId).Select(a => new
            //{
            //    a.ID,
            //    Name = a.Name,
            //    UnitName = a.WareUnit != null ? a.WareUnit.Name : "",
            //    ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "",
            //    CategoryName = a.WareCategory != null ? a.WareCategory.Name : ""
            //});//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList();

            foreach (var a in pricesList)
            {
                PricesView pv = new PricesView();
                pv.ID = a.ID;
                pv.WareName = a.Name;
                pv.CategoryID = a.CategoryID;
                pv.CategoryName = a.CategoryName;
                pv.ManufacturerName = a.ManufacturerName;
                pv.UnitName = a.UnitName;
                pv.DocumentID = a.DocumentID;
                pv.ManufacturerID = a.ManufacturerID;

                pv.PurshasePriceForUnit = a.PurchasePriceForUnit;
                pv.SalePriceForUnit = a.SalePriceForUnit;
                pv.UnitID = a.UnitID;
                pv.UnitName = a.UnitName;
                pv.WareID = a.WareID;
                pv.WarePriceGroupID = a.WarePriceGroupID;
                pv.WarePriceGroupName = a.WarePriceGroupName;

                pv.AllowDiscount = a.AllowDiscount;
                pv.Active = a.Active;
                view.Add(pv);
            }

            //BindingListView<WareView> view = new BindingListView<WareView>(viewList);
            //bs.DataSource = view;
            //bs.Sort = columnName;

            //SortableBindingList<PricesView> viewList = new SortableBindingList<PricesView>(view);
            DataGV.DataSource = view;
            DataGV.Update();
        }