コード例 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var frm = new FrmSales();

            frm.dto = dto;
            this.Hide();
            frm.ShowDialog();
            this.Visible = true;

            dto = bll.Select();
            dataGridView1.DataSource = dto.Sales;
            CleanFilter();
        }
コード例 #2
0
 private void FrmDeleted_Load(object sender, EventArgs e)
 {
     cmbDeletedData.Items.Add("Category");
     cmbDeletedData.Items.Add("Customer");
     cmbDeletedData.Items.Add("Product");
     cmbDeletedData.Items.Add("Sales");
     dto = bll.Select(true);
     dataGridView1.DataSource            = dto.Sales;
     dataGridView1.Columns[0].HeaderText = "Customer Name";
     dataGridView1.Columns[1].HeaderText = "Product Name";
     dataGridView1.Columns[2].HeaderText = "Category Name";
     dataGridView1.Columns[6].HeaderText = "Sales Amount";
     dataGridView1.Columns[7].HeaderText = "Price";
     dataGridView1.Columns[8].HeaderText = "Sales Date";
     dataGridView1.Columns[3].Visible    = false;
     dataGridView1.Columns[4].Visible    = false;
     dataGridView1.Columns[5].Visible    = false;
     dataGridView1.Columns[9].Visible    = false;
     dataGridView1.Columns[10].Visible   = false;
     dataGridView1.Columns[11].Visible   = false;
     dataGridView1.Columns[12].Visible   = false;
     dataGridView1.Columns[13].Visible   = false;
 }
コード例 #3
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (detail.SalesID == 0)
     {
         MessageBox.Show("Please select asales from table");
     }
     else
     {
         FrmSales frm = new FrmSales();
         frm.isUpdate = true;
         frm.detail   = detail;
         frm.dto      = dto;
         this.Hide();
         frm.ShowDialog();
         this.Visible             = true;
         bll                      = new SalesBLL();
         dto                      = bll.Select();
         dataGridView1.DataSource = dto.Sales;
         CleanFilters();
     }
 }
コード例 #4
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (detail.SalesID == 0)
     {
         MessageBox.Show("Please select a sales from table");
     }
     else
     {
         DialogResult result = MessageBox.Show("Are you sure?", "Warning!!", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             if (bll.Delete(detail))
             {
                 MessageBox.Show("Sales was deleted");
                 bll = new SalesBLL();
                 dto = bll.Select();
                 dataGridView1.DataSource = dto.Sales;
                 CleanFilters();
             }
         }
     }
 }
コード例 #5
0
 private void FrmSalesList_Load(object sender, EventArgs e)
 {
     dto = bll.Select();
     dataGridView1.DataSource            = dto.Sales;
     dataGridView1.Columns[0].HeaderText = "Customer Name";
     dataGridView1.Columns[1].HeaderText = "Product Name";
     dataGridView1.Columns[2].HeaderText = "Category Name";
     dataGridView1.Columns[6].HeaderText = "Sales Amount";
     dataGridView1.Columns[7].HeaderText = "Price";
     dataGridView1.Columns[8].HeaderText = "Sales Date";
     dataGridView1.Columns[3].Visible    = false;
     dataGridView1.Columns[4].Visible    = false;
     dataGridView1.Columns[5].Visible    = false;
     dataGridView1.Columns[9].Visible    = false;
     dataGridView1.Columns[10].Visible   = false;
     dataGridView1.Columns[11].Visible   = false;
     dataGridView1.Columns[12].Visible   = false;
     dataGridView1.Columns[13].Visible   = false;
     cmbCategory.DataSource    = dto.Categories;
     cmbCategory.DisplayMember = "CategoryName";
     cmbCategory.ValueMember   = "ID";
     cmbCategory.SelectedIndex = -1;
 }
コード例 #6
0
ファイル: FrmSales.cs プロジェクト: Kyoungtaek/StockTracking
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (detail.ProductID == 0)
            {
                MessageBox.Show("Please select a product from product table");
            }
            else if (detail.CustomerID == 0)
            {
                MessageBox.Show("Please select a customer");
            }
            else if (detail.StockAmount < Convert.ToInt32(txtProductSalesAmount.Text))
            {
                MessageBox.Show("You have not enough product for sale");
            }
            else
            {
                detail.SalesAmount = Convert.ToInt32(txtProductSalesAmount.Text);
                detail.SalesDate   = DateTime.Today;

                if (bll.Insert(detail))
                {
                    MessageBox.Show("Sales was Added");
                    bll = new SalesBLL();
                    dto = bll.Select();
                    gridProduct.DataSource  = dto.Products;
                    gridCustomer.DataSource = dto.Customers;
                    comboFull             = false;
                    cbCategory.DataSource = dto.Categories;
                    if (dto.Products.Count > 0)
                    {
                        comboFull = true;
                    }
                    txtProductSalesAmount.Clear();
                }
            }
        }
コード例 #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtProductSalesAmount.Text.Trim() == "")
            {
                MessageBox.Show("Please fill the sales amount area");
            }

            else
            {
                if (!isUpdate)//Add
                {
                    if (detail.ProductID == 0)
                    {
                        MessageBox.Show("Please select a product from product table");
                    }
                    else if (detail.CustomerID == 0)
                    {
                        MessageBox.Show("Please select a customer from customer table");
                    }
                    else if (detail.StockAmount < Convert.ToInt32(txtProductSalesAmount.Text))
                    {
                        MessageBox.Show("You have bot enough product for sale");
                    }
                    else
                    {
                        detail.SalesAmount = Convert.ToInt32(txtProductSalesAmount.Text);
                        detail.SalesDate   = DateTime.Today;
                        if (bll.Insert(detail))
                        {
                            MessageBox.Show("Sales was added");
                            bll = new SalesBLL();
                            dto = bll.Select();
                            gridProduct.DataSource = dto.Products;
                            dto.Customers          = dto.Customers;
                            combofull = false;
                            cmbCategory.DataSource = dto.Categories;
                            if (dto.Products.Count > 0)
                            {
                                combofull = true;
                            }
                            txtProductSalesAmount.Clear();
                        }
                    }
                }
                else//Update
                {
                    if (detail.SalesAmount == Convert.ToInt32(txtProductSalesAmount.Text))
                    {
                        MessageBox.Show("There is no chnage");
                    }
                    else
                    {
                        int temp = detail.StockAmount + detail.SalesAmount;
                        if (temp < Convert.ToInt32(txtProductSalesAmount.Text))
                        {
                            MessageBox.Show("You have not enough product for sale");
                        }
                        else
                        {
                            detail.SalesAmount = Convert.ToInt32(txtProductSalesAmount.Text);
                            detail.StockAmount = temp - detail.SalesAmount;
                            if (bll.Update(detail))
                            {
                                MessageBox.Show("Sales was Updated");
                                this.Close();
                            }
                        }
                    }
                }
            }
        }
コード例 #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (detail.ProductID == 0)
            {
                MessageBox.Show("Please select a product");
            }
            else
            {
                if (!isUpdate)
                {
                    if (detail.CustomerID == 0)
                    {
                        MessageBox.Show("Please select a customer ID");
                    }
                    else if (detail.CustomerID == 0)
                    {
                        MessageBox.Show("Select a customer from the table");
                    }
                    else if (detail.StockAmount < Convert.ToInt32(txtProductStock.Text))
                    {
                        MessageBox.Show("Stock is not enough");
                    }
                    else
                    {
                        detail.SalesAmount = Convert.ToInt32(txtSalesAmount.Text);
                        detail.SalesDate   = DateTime.Today;

                        if (bll.Insert(detail))
                        {
                            MessageBox.Show("Sles was added");
                            bll = new SalesBLL();
                            dto = bll.Select();
                            GridProduct.DataSource = dto.Products;
                            combofull = false;
                            cmbCategory.DataSource = dto.Categories;
                            if (dto.Products.Count > 0)
                            {
                                combofull = true;
                            }
                            txtSalesAmount.Clear();
                        }
                    }
                }
                else
                {
                    if (detail.SalesAmount == Convert.ToInt32(txtSalesAmount.Text))
                    {
                        MessageBox.Show("There is not changes");
                    }
                    else
                    {
                        int temp = detail.StockAmount + detail.SalesAmount;
                        if (temp < Convert.ToInt32(txtSalesAmount.Text))
                        {
                            MessageBox.Show("You don have enoigh stock");
                        }
                        else
                        {
                            detail.SalesAmount = Convert.ToInt32(txtSalesAmount.Text);
                            detail.StockAmount = temp - detail.SalesAmount;
                            if (bll.Update(detail))
                            {
                                MessageBox.Show("Sales was updated");
                                this.Close();
                            }
                        }
                    }
                }
            }
        }