private void btnGetSaleBetween_Click(object sender, EventArgs e)
 {
     btnSaveSaleInFile.Visible = true;
     if (ckBoxMonth.Checked)
     {
         var helper = new SaleProductManager();
         dtGrSaleBetween.DataSource = helper.GetSaleMonth(Convert.ToDateTime(dtMonth.Text));
         dtGrSaleBetween.Columns["Id"].Visible = false;
         dtGrSaleBetween.Columns["LabelName"].HeaderText = "Марка";
         dtGrSaleBetween.Columns["Name"].HeaderText = "Название";
         dtGrSaleBetween.Columns["Name"].FillWeight = 250;
         dtGrSaleBetween.Columns["Price"].HeaderText = "Сумма продажи";
         dtGrSaleBetween.Columns["Discount"].HeaderText = "Скидка";
         dtGrSaleBetween.Columns["Count"].HeaderText = "Количество";
         dtGrSaleBetween.Columns["DateTimeSale"].HeaderText = "Дата продажи";
         txtAllPriceGrid.Text = helper.GetAllSalePrice(helper.GetSaleMonth(Convert.ToDateTime(dtMonth.Text))).ToString();
         txtCountProductGrid.Text = helper.GetAllSaleCount(helper.GetSaleMonth(Convert.ToDateTime(dtMonth.Text))).ToString();
     }
     else
     {
         var helper = new SaleProductManager();
         dtGrSaleBetween.DataSource = helper.GetSaleBetween(Convert.ToDateTime(dtBegin.Text), Convert.ToDateTime(dtEnd.Text));
         dtGrSaleBetween.Columns["Id"].Visible = false;
         dtGrSaleBetween.Columns["LabelName"].HeaderText = "Марка";
         dtGrSaleBetween.Columns["Name"].HeaderText = "Название";
         dtGrSaleBetween.Columns["Name"].FillWeight = 250;
         dtGrSaleBetween.Columns["Price"].HeaderText = "Сумма продажи";
         dtGrSaleBetween.Columns["Discount"].HeaderText = "Скидка";
         dtGrSaleBetween.Columns["Count"].HeaderText = "Количество";
         dtGrSaleBetween.Columns["DateTimeSale"].HeaderText = "Дата продажи";
         txtAllPriceGrid.Text = helper.GetAllSalePrice(helper.GetSaleBetween(Convert.ToDateTime(dtBegin.Text), Convert.ToDateTime(dtEnd.Text))).ToString();
         txtCountProductGrid.Text = helper.GetAllSaleCount(helper.GetSaleBetween(Convert.ToDateTime(dtBegin.Text), Convert.ToDateTime(dtEnd.Text))).ToString();
     }
 }
 private void btnSaveSaleInFile_Click(object sender, EventArgs e)
 {
     FolderBrowserDialog FBD = new FolderBrowserDialog();
     if (FBD.ShowDialog() == DialogResult.OK)
     {
         if (ckBoxMonth.Checked)
         {
             var helper = new SaleProductManager();
             if (helper.WriteSaleInFile(helper.GetSaleMonth(Convert.ToDateTime(dtMonth.Text)), FBD.SelectedPath.ToString()) &&
                 helper.WriteStringInFile("Всего продано " + txtCountProductGrid.Text + " шт. на сумму " + txtAllPriceGrid.Text + "000 рублей", FBD.SelectedPath.ToString()))
             {
                 MessageBox.Show("Продажи сохранены в файл!");
             }
             else
             {
                 MessageBox.Show("Упс! Что-то пошло не так!");
             }
         }
         else
         {
             var helper = new SaleProductManager();
             if (helper.WriteSaleInFile(helper.GetSaleBetween(Convert.ToDateTime(dtBegin.Text), Convert.ToDateTime(dtEnd.Text)), FBD.SelectedPath.ToString()) &&
                 helper.WriteStringInFile("Всего продано " + txtCountProductGrid.Text + " шт. на сумму " + txtAllPriceGrid.Text + "000 рублей", FBD.SelectedPath.ToString()))
             {
                 MessageBox.Show("Продажи сохранены в файл!");
             }
             else
             {
                 MessageBox.Show("Упс! Что-то пошло не так!");
             }
         }
     }
 }
Exemple #3
0
 private void ReportSaleDay_Load(object sender, EventArgs e)
 {
     lblNameReports.Text = DateTime.Now.ToShortDateString();
     var temp = new SaleProductManager();
     dtGrSale.DataSource = temp.GetSaleToday(DateTime.Now);
     dtGrSale.Columns["Id"].Visible = false;
     dtGrSale.Columns["LabelName"].HeaderText = "Марка";
     dtGrSale.Columns["Name"].HeaderText = "Название";
     dtGrSale.Columns["Name"].FillWeight = 250;
     dtGrSale.Columns["Price"].HeaderText = "Сумма продажи";
     dtGrSale.Columns["Discount"].HeaderText = "Скидка";
     dtGrSale.Columns["Count"].HeaderText = "Количество";
     dtGrSale.Columns["DateTimeSale"].HeaderText = "Дата продажи";
     txtCountProductGrid.Text = temp.GetAllSaleCount(temp.GetSaleToday(DateTime.Now)).ToString();
     txtAllPriceGrid.Text = temp.GetAllSalePrice(temp.GetSaleToday(DateTime.Now)).ToString();
 }
Exemple #4
0
        private void btnCancelSale_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Отменить продажу?", "Отменить", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            else
            {
                try
                {
                    var helperSale = new SaleProductManager();

                    var helperProduct = new ProductManager();
                    if (helperProduct.DelSale(Convert.ToInt32(txtHiddenIdProduct.Text), Convert.ToInt32(txtHiddenCount.Text)) &&
                       helperSale.DelSale(Convert.ToInt32(txtHiddenId.Text)))
                    {
                        dtGrSale.DataSource = helperSale.GetAllSale();
                        MessageBox.Show("Продажа успешно отменена!");
                        var products = new ProductManager();
                        Form1 form = new Form1();

                       form.dtGridProducts.DataSource = products.GetAllProduct();

                    }
                    else
                    {

                    }
                }
                catch (Exception)
                {

                    MessageBox.Show("Упс! Что-то пошло не так!");
                }

            }
        }
Exemple #5
0
        private void btnSale_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Продать этот товар?", "Продать",
                               MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {

                    return;
                }
                else
                {
                    var prod = new ProductManager();
                    prod.AddSale(Convert.ToInt32(txtHiddenId.Text), Convert.ToInt32(txtСountProduct.Text));
                    var temp = new SaleProductManager();

                    var sale = new SaleProduct()
                    {

                        Name = txtNameProduct.Text.ToString(),
                        Count = Convert.ToInt32(txtСountProduct.Text),
                        Price = Convert.ToInt32(txtPriceProduct.Text),
                        Discount = Convert.ToInt32(txtDiscount.Text),
                        DateTimeSale = DateTime.Now
                    };
                    temp.AddSale(sale, cmbLabel.Text.ToString());
                    dtGridProducts.DataSource = prod.GetAllProduct();
                    if (Convert.ToInt32(txtHiddenIndex.Text) < dtGridProducts.RowCount)
                    {
                        dtGridProducts.ClearSelection();
                        dtGridProducts.Rows[Convert.ToInt32(txtHiddenIndex.Text)].Selected = true;
                        dtGridProducts.FirstDisplayedScrollingRowIndex = Convert.ToInt32(txtHiddenIndex.Text);
                        dtGridProducts.Update();
                    }
                    txtCountProductGrid.Text = prod.GetAllProductCount(prod.GetAllProduct()).ToString();
                    txtAllPriceGrid.Text = prod.GetAllProductPrice(prod.GetAllProduct()).ToString();
                    MessageBox.Show("Товар продан");
                }

            }
            catch (Exception)
            {

                MessageBox.Show("Упс! Что-то пошло не так!");
            }
        }