Exemplo n.º 1
0
        private void Btn_Click(object sender, EventArgs e)
        {
            Button currentButton = (Button)sender;

            TblProduct selectedProduct = (TblProduct)currentButton.Tag;

            tempTable.Rows.Add(selectedProduct.ProductID, selectedProduct.Description, String.Format("{0:C}", selectedProduct.Price));
            ChosenItemsDataGridView.DataSource = tempTable;
            ChosenProductsList.Add(selectedProduct);

            totalToPay       += selectedProduct.Price;
            lblTotal.Visible  = true;
            removeAll.Visible = true;
            lblTotal.Text     = String.Format("Total to Pay: {0:C}", totalToPay);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            using (Coffee_ProjectEntities cpe = new Coffee_ProjectEntities())
            {
                TblProduct newProduct = new TblProduct()
                {
                    Description = txtDescription.Text,
                    Price       = Convert.ToDecimal(txtPrice.Text),
                    Image       = imageBytes,
                    ProductType = (int)cmbCategory.SelectedValue
                };

                cpe.TblProducts.Add(newProduct);
                cpe.SaveChanges();
                lblSaving.Visible = false;
                MessageBox.Show("Item Saved Successfully", "Item Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }