public static bool ChooseSale(out Sale sale) { var saleDict = new SaleDict(); saleDict._choseMode = true; var success = saleDict.ShowDialog() == DialogResult.OK; sale = saleDict._sale; return success; }
public static void Update(Sale sale) { var saleCard = new SaleCard(); saleCard.GetData(sale); var changed = saleCard.ShowDialog() == DialogResult.OK; if (changed) { sale.ReApply(); Context.Save(); } }
private void Choose() { var row = (DataSourceRow)gridView1.GetFocusedRow(); if (row == null) { return; } _sale = row.GetSale(); DialogResult = DialogResult.OK; }
public static decimal CalcPrice(Product product, BegemotProduct begemotProduct, BegemotSalePrice bsale, Sale sale) { decimal retPrice = CalcRetailPrice(begemotProduct, bsale); product.Price = retPrice; product.PriceOld = retPrice; if (sale != null) { decimal selfPrice = CalcSelfPrice(begemotProduct, bsale); retPrice = sale.CalcSalePrice(retPrice, selfPrice); product.Price = retPrice; } return retPrice; }
private void AddToDict(Product product, BegemotProduct bproduct, Style specialStyle, Sale activeSale) { valueDict.Add(StyleTag.Title, bproduct.GetClearTitle()); valueDict.Add(StyleTag.TitleShort, bproduct.GetTitleShort()); valueDict.Add(StyleTag.TitleClear, bproduct.GetClearTitle()); valueDict.Add(StyleTag.TitleClearShort, bproduct.GetClearShortTitle()); valueDict.Add(StyleTag.Description, bproduct.GetClearDescrption()); valueDict.Add(StyleTag.Price, product.Price.ToString("f2")); valueDict.Add(StyleTag.PriceOld, product.PriceOld.ToString("f2")); var codeProduct = product.GetCode(); valueDict.Add(StyleTag.CodeProduct, codeProduct); if (specialStyle != null) { var codeStyle = specialStyle.GetCode(true); //codeStyle = HttpUtility.UrlEncode(codeStyle); valueDict.Add(StyleTag.CodeStyle, codeStyle); } if (activeSale != null) { var codeSale = activeSale.GetCode(true); // codeSale = HttpUtility.UrlEncode(codeSale); valueDict.Add(StyleTag.CodeSale, codeSale); } var salesLinks = SalesLinks(); valueDict.Add(StyleTag.Sales, salesLinks); var menuLinks = MenuLinks(); valueDict.Add(StyleTag.Menu, menuLinks); }
private void button1_Click(object sender, EventArgs e) { if (_sale == null) { _sale = new Sale(); Context.Inst.SaleSet.Add(_sale); _sale.Algoritm = string.Empty; } var success = SetData(_sale); if (!success) return; _sale.DateUpdate = DateTime.Now; Context.Save(); DialogResult = DialogResult.OK; }
public static void Copy(Sale sale) { var saleCard = new SaleCard(); saleCard.GetData(sale, true); saleCard.ShowDialog(); }
private bool SetData(Sale sale) { if (txtTitle.Text.IsEmpty()) { MessageBox.Show("Не указано название"); return false; } var title = txtTitle.Text; var description = txtDescription.Text; var dateStart = txtDateStart.DateTime; var dateExpire = txtDateExpire.DateTime; var now = DateTime.Now; if (dateStart >= dateExpire || dateExpire < now) { MessageBox.Show("Неправильно указан период"); return false; } var marginMax = txtMarginMax.Text; var marginMin = txtMarginMin.Text; var marginToWholesale = txtMarginToWholesale.Text; var descountToRetail = txtDescountToRetail.Text; Check(marginMax, marginMin, marginToWholesale, descountToRetail); if (string.IsNullOrWhiteSpace(marginToWholesale) && string.IsNullOrWhiteSpace(descountToRetail)) { MessageBox.Show(string.Format("Укажите наценку или скидку")); return false; } var useMax = txtUseMax.Checked; var active = txtActive.Checked; sale.Active = active; sale.Title = title; sale.Description = description; sale.DateStart = dateStart; sale.DateExpire = dateExpire; sale.Style = _style; sale.MarginMax = marginMax; sale.MarginMin = marginMin; sale.MarginToWholesale = marginToWholesale; sale.DescountToRetail = descountToRetail; sale.UseMaxResult = useMax; return true; }
private void GetData(Sale sale, bool isCopy = false) { if (!isCopy) { _sale = sale; txtTitle.Text = sale.Title; } txtActive.Checked = sale.Active; txtDescription.Text = sale.Description; txtDateStart.DateTime = sale.DateStart; txtDateExpire.DateTime = sale.DateExpire; SetStyle(sale.Style); txtMarginMax.Text = sale.MarginMax; txtMarginMin.Text = sale.MarginMin; txtMarginToWholesale.Text = sale.MarginToWholesale; txtDescountToRetail.Text = sale.DescountToRetail; }
private void btnWothoutSale_Click(object sender, EventArgs e) { _sale = null; DialogResult = DialogResult.OK; }
public DataSourceRow(Sale sale) { _sale = sale; }
public SaleCalculator(Sale sale) { _sale = sale; }
public static string GetCode(Sale sale, bool tagMode = false) { if (sale == null) return string.Empty; string code = string.Format("a{0}", Encode(sale.Id)); if (tagMode) { code = string.Format("{0} {1}", prefix, code); code = HttpUtility.UrlEncode(code); } return code; }