Ejemplo n.º 1
0
        private void gvBills_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                pictureBox1.Enabled = false;
                pictureBox2.Enabled = false;
                btnEdit.Enabled = true;

                int billsID = int.Parse(gvBills.Rows[e.RowIndex].Cells["colBillsID"].Value.ToString());
                Bill bills = new Bill();
                BLLBills bllBills = new BLLBills();
                bills = bllBills.GetBillsById(billsID);

                if (gvBills.Columns[e.ColumnIndex].Name == "colBillsDeleted")
                {
                    if (MessageBox.Show("Are you sure to delete: " + gvBills.Rows[e.RowIndex].Cells["colBillsId"].Value.ToString(), "Message", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        bllBills.Deleted(bills);
                        LoadGridBills();
                        gvProductsToBills.Rows.Clear();
                        return;
                    }
                }

                gvProductsToBills.Rows.Clear();
                foreach (BillDetail billsDetail in bills.BillDetails)
                {
                    Product product = new Product();
                    BLLProduct productBLL = new BLLProduct();
                    product = productBLL.GetProductById(billsDetail.ProductId);

                    gvProductsToBills.Rows.Add(product.ProductId, product.ProductName, billsDetail.RealPrice, billsDetail.Amounts, billsDetail.Sum, Properties.Resources.DeleteRed);
                }

                lbTotal.Text = bills.Total.ToString();
            }
        }
Ejemplo n.º 2
0
        private void gvProducts_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                int productId = int.Parse(gvProducts.Rows[e.RowIndex].Cells["colProductId"].Value.ToString());
                int rowIndex = -1;

                Product product = new Product();
                BLLProduct productBLL = new BLLProduct();
                product = productBLL.GetProductById(productId);

                if (TestExistsProductInBills(gvProductsToBills, productId, ref rowIndex))
                {
                    gvProductsToBills.Rows[rowIndex].Cells["colAmounts"].Value = int.Parse(gvProductsToBills.Rows[rowIndex].Cells["colAmounts"].Value.ToString()) + 1;
                    gvProductsToBills.Rows[rowIndex].Cells["colTotal"].Value = float.Parse(gvProductsToBills.Rows[rowIndex].Cells["colTotal"].Value.ToString()) + product.OriginalPrice;
                }
                else
                {
                    gvProductsToBills.Rows.Add(product.ProductId, product.ProductName, product.OriginalPrice, 1, product.OriginalPrice, Properties.Resources.DeleteRed);
                }

                lbTotal.Text = SumTotal().ToString();
            }
        }
Ejemplo n.º 3
0
 private void cboCategories_SelectedIndexChanged(object sender, EventArgs e)
 {
     BLLProduct productBLL = new BLLProduct();
     gvProducts.DataSource = productBLL.GetProductByCategoryId(int.Parse(cboCategories.SelectedValue.ToString()));
 }
Ejemplo n.º 4
0
        private void gvProducts_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                int productId = int.Parse(gvProducts.Rows[e.RowIndex].Cells["colProductId"].Value.ToString());
                Product product = new Product();
                BLLProduct productBLL = new BLLProduct();
                product = productBLL.GetProductById(productId);

                lbName.Text = product.ProductName;
                lbPrice.Text = product.OriginalPrice.ToString();
                lbUnit.Text = product.ProductUnit;
                lbDescription.Text = product.Description;
            }
        }