示例#1
0
        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;
        }
示例#2
0
 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();
     }
 }
示例#3
0
        private void Choose()
        {
            var row = (DataSourceRow)gridView1.GetFocusedRow();
            if (row == null)
            {
                return;
            }

            _sale = row.GetSale();

            DialogResult = DialogResult.OK;
        }
示例#4
0
        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;
        }
示例#5
0
        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);
        }
示例#6
0
        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;
        }
示例#7
0
 public static void Copy(Sale sale)
 {
     var saleCard = new SaleCard();
     saleCard.GetData(sale, true);
     saleCard.ShowDialog();
 }
示例#8
0
        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;
        }
示例#9
0
        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;
        }
示例#10
0
 private void btnWothoutSale_Click(object sender, EventArgs e)
 {
     _sale = null;
     DialogResult = DialogResult.OK;
 }
示例#11
0
 public DataSourceRow(Sale sale)
 {
     _sale = sale;
 }
示例#12
0
 public SaleCalculator(Sale sale)
 {
     _sale = sale;
 }
示例#13
0
        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;
        }