private void DeleteSB_Click(object sender, EventArgs e) { WareDiscountsLogic dicounts = new WareDiscountsLogic(manager); dicounts.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value)); manager.Save(); Fill(); }
private void FillDiscounts() { WareDiscountsLogic discountsLogic = new WareDiscountsLogic(manager); CardTypesDiscountsLogic typeDiscountsLogic = new CardTypesDiscountsLogic(manager); if (availableDiscounts == null) { availableDiscounts = new List<WareDiscount>(); availableDiscounts = discountsLogic.GetAll(); } if (acceptedDiscounts == null) { acceptedDiscounts = new List<WareDiscount>(); if (id != null & acceptedDiscounts.Count() == 0) { acceptedDiscounts = typeDiscountsLogic.GetAll(Convert.ToInt32(id)).Select(a => a.WareDiscount).Distinct().ToList(); } } //else //{ // availableDiscounts = acceptedDiscounts.SkipWhile(a => acceptedDiscounts.Contains(a)).ToList(); //} AvailableDiscountsGV.AutoGenerateColumns = false; AvailableDiscountsGV.DataSource = availableDiscounts.Where(a => !acceptedDiscounts.Contains(a)).ToList(); AvailableDiscountsGV.Update(); if (AvailableDiscountsGV.RowCount > 0) AvailableDiscountsGV.Rows[0].Selected = true; AcceptedDiscountsGV.AutoGenerateColumns = false; AcceptedDiscountsGV.DataSource = acceptedDiscounts.Select(a => a).ToList(); AcceptedDiscountsGV.Update(); }
private void AddBt_Click(object sender, EventArgs e) { WareDiscountsLogic discountsLogic = new WareDiscountsLogic(manager); int discoutId = Convert.ToInt32(AvailableDiscountsGV.SelectedRows[0].Cells["DiscountID"].Value); acceptedDiscounts.Add(discountsLogic.Get(discoutId)); FillDiscounts(); }
private void RemoveBt_Click(object sender, EventArgs e) { WareDiscountsLogic discountsLogic = new WareDiscountsLogic(manager); int discoutId = Convert.ToInt32(AcceptedDiscountsGV.CurrentRow.Cells["DiscountID0"].Value); acceptedDiscounts.Remove(discountsLogic.Get(discoutId)); FillDiscounts(); }
private void FillDataGV() { WareDiscountsLogic discounts = new WareDiscountsLogic(manager); DataGV.AutoGenerateColumns = false; int?discountTypeId = null; if (DiscountTypesCB.SelectedItem != null) { discountTypeId = Convert.ToInt32(DiscountTypesCB.SelectedValue); } bool?active = ActiveCB.Checked; DataGV.DataSource = discounts.GetAll(discountTypeId, active); DataGV.Update(); }
private void SaveBt_Click(object sender, EventArgs e) { WareDiscountsLogic discounts = new WareDiscountsLogic(manager); int discountTypeId = Convert.ToInt32(DiscountTypesCB.SelectedValue); string name = NameTB.Text; bool active = ActiveCB.Checked; decimal defaultDiscountPercent = DefaultDiscountPercentNUD.Value; if (mode == "new") { discounts.Create(name, active, discountTypeId, defaultDiscountPercent); } if (mode == "edit") { discounts.Update(Convert.ToInt32(id), name, active, discountTypeId, defaultDiscountPercent); } manager.Save(); this.Close(); }
private void Fill() { WareDiscountTypesLogic discountTypes = new WareDiscountTypesLogic(manager); DiscountTypesCB.DataSource = discountTypes.GetAll(); DiscountTypesCB.ValueMember = "ID"; DiscountTypesCB.DisplayMember = "Name"; DiscountTypesCB.Update(); if (mode == "edit") { if (id != null) { WareDiscountsLogic discounts = new WareDiscountsLogic(manager); WareDiscount discount = discounts.Get(Convert.ToInt32(id)); if (discount != null) { NameTB.Text = discount.Name; ActiveCB.Checked = discount.Active; DefaultDiscountPercentNUD.Value = discount.DefaultDiscountPercent; //int i = 0; foreach (WareDiscountType a in DiscountTypesCB.Items) { if (a.ID == discount.DiscountTypeID) { DiscountTypesCB.SelectedItem = a; } } } } //WareDiscountType discountTypes = discountTypes.Get(Convert.ToInt32(id)); //if (currency != null) //{ // NameTB.Text = currency.Name; //} } }
private void FillDiscounts() { WareDiscountsLogic discountsLogic = new WareDiscountsLogic(manager); CardTypesDiscountsLogic typeDiscountsLogic = new CardTypesDiscountsLogic(manager); if (availableDiscounts == null) { availableDiscounts = new List <WareDiscount>(); availableDiscounts = discountsLogic.GetAll(); } if (acceptedDiscounts == null) { acceptedDiscounts = new List <WareDiscount>(); if (id != null & acceptedDiscounts.Count() == 0) { acceptedDiscounts = typeDiscountsLogic.GetAll(Convert.ToInt32(id)).Select(a => a.WareDiscount).Distinct().ToList(); } } //else //{ // availableDiscounts = acceptedDiscounts.SkipWhile(a => acceptedDiscounts.Contains(a)).ToList(); //} AvailableDiscountsGV.AutoGenerateColumns = false; AvailableDiscountsGV.DataSource = availableDiscounts.Where(a => !acceptedDiscounts.Contains(a)).ToList(); AvailableDiscountsGV.Update(); if (AvailableDiscountsGV.RowCount > 0) { AvailableDiscountsGV.Rows[0].Selected = true; } AcceptedDiscountsGV.AutoGenerateColumns = false; AcceptedDiscountsGV.DataSource = acceptedDiscounts.Select(a => a).ToList(); AcceptedDiscountsGV.Update(); }
private void Fill() { WareDiscountTypesLogic discountTypes = new WareDiscountTypesLogic(manager); DiscountTypesCB.DataSource = discountTypes.GetAll(); DiscountTypesCB.ValueMember = "ID"; DiscountTypesCB.DisplayMember = "Name"; DiscountTypesCB.Update(); if (mode == "edit") { if (id != null) { WareDiscountsLogic discounts = new WareDiscountsLogic(manager); WareDiscount discount = discounts.Get(Convert.ToInt32(id)); if (discount != null) { NameTB.Text = discount.Name; ActiveCB.Checked = discount.Active; DefaultDiscountPercentNUD.Value = discount.DefaultDiscountPercent; //int i = 0; foreach (WareDiscountType a in DiscountTypesCB.Items) { if (a.ID == discount.DiscountTypeID) DiscountTypesCB.SelectedItem = a; } } } //WareDiscountType discountTypes = discountTypes.Get(Convert.ToInt32(id)); //if (currency != null) //{ // NameTB.Text = currency.Name; //} } }
private void FillDataGV() { WareDiscountsLogic discounts = new WareDiscountsLogic(manager); DataGV.AutoGenerateColumns = false; int? discountTypeId = null; if (DiscountTypesCB.SelectedItem != null) discountTypeId = Convert.ToInt32(DiscountTypesCB.SelectedValue); bool? active = ActiveCB.Checked; DataGV.DataSource = discounts.GetAll(discountTypeId, active); DataGV.Update(); }