private void dgvProducts_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                productEL.Productid = Convert.ToInt32(dgvProducts.SelectedRows[0].Cells["PRODUCT ID"].Value);

                if (CheckIfHasDuplicate(productEL.Productid))
                {
                    InsertItemToCart(Convert.ToInt32(dgvCart.SelectedRows[0].Cells["QTY"].Value), "EDIT");
                }
                else
                {
                    productEL = productBL.Select(productEL);

                    if (productEL.Stocks != 0)
                    {
                        InsertItemToCart(1, "ADD");
                    }
                    else
                    {
                        MessageBox.Show("NO STOCKS");
                    }
                }
            }
        }
        private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 | e.ColumnIndex == 1)
            {
                productEL.Productid = Convert.ToInt32(dgv.SelectedRows[0].Cells["PRODUCT ID"].Value);
            }

            if (e.ColumnIndex == 0)
            {
                s             = "EDIT";
                lblTitle.Text = "UPDATE CATEGORY";
                ShowForm(true);

                productEL             = productBL.Select(productEL);
                categoryEL.Categoryid = productEL.Categoryid;
                categoryEL            = categoryBL.Select(categoryEL);

                txtProductName.Text      = productEL.Productname;
                cbCategory.SelectedIndex = cbCategory.FindString(categoryEL.Category);
                txtDescription.Text      = productEL.Description;
                txtPrice.Text            = productEL.Price.ToString();
                txtStocks.Text           = productEL.Stocks.ToString();
            }
            else if (e.ColumnIndex == 1)
            {
                DialogResult dialogResult = MessageBox.Show("ARE YOU SURE TO DELETE THIS SELECTED ITEM?", "DELETING", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    ShowResult(productBL.Delete(productEL));
                }
            }
        }
示例#3
0
        public EL.Registrations.products Select(EL.Registrations.products productEL)
        {
            var dt = Helper.executeQuery("select * from products where productid = '" + productEL.Productid + "'");

            if (dt.Rows.Count > 0)
            {
                productEL.Productid   = Convert.ToInt32(dt.Rows[0]["productid"].ToString());
                productEL.Categoryid  = Convert.ToInt32(dt.Rows[0]["categoryid"].ToString());
                productEL.Productname = dt.Rows[0]["productname"].ToString();
                productEL.Description = dt.Rows[0]["description"].ToString();
                productEL.Price       = Convert.ToSingle(dt.Rows[0]["price"].ToString());
                productEL.Stocks      = Convert.ToInt32(dt.Rows[0]["stocks"].ToString());
                return(productEL);
            }
            else
            {
                return(null);
            }
        }
        private void ResetForm()
        {
            lblTotalItems.ResetText();
            lblTotalAmount.ResetText();
            dgvCart.Rows.Clear();
            lblNameAndNumber.ResetText();

            CalculateCart();

            txtSearchCustomers.ResetText();
            txtSearchProducts.ResetText();

            PopulateDGVCustomers();
            PopulateDGVProducts();

            customerEL              = new EL.Registrations.customers();
            productEL               = new EL.Registrations.products();
            transactionEL           = new EL.Transactions.transactions();
            productsintransactionEL = new EL.Transactions.productsintransactions();
        }
示例#5
0
 public bool Delete(EL.Registrations.products productEL)
 {
     return(Helper.executeNonQueryBool("delete from products where productid = '" + productEL.Productid + "'"));
 }
示例#6
0
 public bool Update(EL.Registrations.products productEL)
 {
     productEL.Productname = MySql.Data.MySqlClient.MySqlHelper.EscapeString(productEL.Productname);
     productEL.Description = MySql.Data.MySqlClient.MySqlHelper.EscapeString(productEL.Description);
     return(Helper.executeNonQueryBool("update products set categoryid = '" + productEL.Categoryid + "', productname = '" + productEL.Productname + "', description = '" + productEL.Description + "', price = '" + productEL.Price + "', stocks = '" + productEL.Stocks + "' where productid = '" + productEL.Productid + "'"));
 }
示例#7
0
 public long Insert(EL.Registrations.products productEL)
 {
     productEL.Productname = MySql.Data.MySqlClient.MySqlHelper.EscapeString(productEL.Productname);
     productEL.Description = MySql.Data.MySqlClient.MySqlHelper.EscapeString(productEL.Description);
     return(Helper.executeNonQueryLong("insert into products (categoryid, productname, description, price, stocks) values ('" + productEL.Categoryid + "', '" + productEL.Productname + "', '" + productEL.Description + "', '" + productEL.Price + "', '" + productEL.Stocks + "')"));
 }
        private void lblPay_Click(object sender, EventArgs e)
        {
            if (customerEL.Customerid > 0)
            {
                if (dgvCart.RowCount > 0)
                {
                    string value = "0";
                    if (methods.InputBox("ENTER AMOUNT TENDERED", "AMOUNT:", ref value) == DialogResult.OK)
                    {
                        amounttendered = Convert.ToSingle(value);

                        if (amounttendered >= totalamount)
                        {
                            changeamount = amounttendered - totalamount;

                            transactionEL.Customerid          = customerEL.Customerid;
                            transactionEL.Transactiondatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            transactionEL.Totalamount         = totalamount;
                            transactionEL.Amounttendered      = amounttendered;
                            transactionEL.ChangeAmount        = changeamount;
                            transactionEL.Isvoid = 0;


                            if ((transactionEL.Transactionid = Convert.ToInt32(transactionBL.Insert(transactionEL))) > 0)
                            {
                                bool bol = true;
                                foreach (DataGridViewRow row in dgvCart.Rows)
                                {
                                    productsintransactionEL.Transactionid = transactionEL.Transactionid;
                                    productsintransactionEL.Productid     = Convert.ToInt32(row.Cells["productid"].Value);
                                    productsintransactionEL.Soldprice     = Convert.ToSingle(row.Cells["PRICE"].Value);
                                    productsintransactionEL.Quantity      = Convert.ToInt32(row.Cells["QTY"].Value);
                                    productsintransactionEL.Amount        = Convert.ToSingle(row.Cells["PRICE"].Value) * Convert.ToInt32(row.Cells["QTY"].Value);

                                    if (productsintransactionBL.Insert(productsintransactionEL) <= 0)
                                    {
                                        bol = false;
                                    }
                                    else
                                    {
                                        productEL.Productid = productsintransactionEL.Productid;
                                        productEL           = productBL.Select(productEL);
                                        productEL.Stocks    = productEL.Stocks - productsintransactionEL.Quantity;
                                        productBL.Update(productEL);
                                    }
                                }

                                if (bol)
                                {
                                    MessageBox.Show("TRANSACTION ID " + transactionEL.Transactionid + " IS SUCCESSFULLY SAVED \n CHANGE IS " + methods.ConvertToMoneyFormat(changeamount));
                                    ResetForm();
                                }
                                else
                                {
                                    MessageBox.Show("ERROR");
                                }
                            }
                            else
                            {
                                MessageBox.Show("ERROR");
                            }
                        }
                        else
                        {
                            MessageBox.Show("AMOUNT TENDERED IS INSUFFICIENT OF " + methods.ConvertToMoneyFormat(totalamount - amounttendered));
                        }
                    }
                }
                else
                {
                    MessageBox.Show("NO PRODUCTS IN THE CART");
                }
            }
            else
            {
                MessageBox.Show("PLEASE ADD CUSTOMER");
            }
        }
 public bool Delete(EL.Registrations.products productEL)
 {
     return(productDL.Delete(productEL));
 }
示例#10
0
 public bool Update(EL.Registrations.products productEL)
 {
     return(productDL.Update(productEL));
 }
示例#11
0
 public long Insert(EL.Registrations.products productEL)
 {
     return(productDL.Insert(productEL));
 }
示例#12
0
 public EL.Registrations.products Select(EL.Registrations.products productEL)
 {
     return(productDL.Select(productEL));
 }