private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (mCoyoteDBEntities1 context = new mCoyoteDBEntities1())
                {
                    Customer customer = new Customer()
                    {
                        custFirstName = txtFirstName.Text,
                        custLastName = txtLastName.Text,
                        custAddress = txtAddress.Text,
                        custEmail = txtEmail.Text,
                        custPhone = txtPhone.Text
                    };

                    context.Customers.Add(customer);
                    context.SaveChanges();
                    this.Close();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("You must enter a value for each item");
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            using (mCoyoteDBEntities1 context = new mCoyoteDBEntities1())
            {
                Product product = context.Products.FirstOrDefault(c => c.Id == myId);

                product.prodName = txtProdName.Text;
                product.prodCode = txtProdCode.Text;
                product.prodPrice = decimal.Parse(txtProdPrice.Text);

                context.SaveChanges();
                this.Close();

            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            using (mCoyoteDBEntities1 context = new mCoyoteDBEntities1())
            {
                Customer customer = context.Customers.FirstOrDefault(c => c.Id == myId);

                customer.custFirstName = txtFirstName.Text;
                customer.custLastName = txtLastName.Text;
                customer.custAddress = txtAddress.Text;
                customer.custEmail = txtEmail.Text;
                customer.custPhone = txtPhone.Text;

                context.SaveChanges();
                this.Close();

            }
        }
Beispiel #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (mCoyoteDBEntities1 context = new mCoyoteDBEntities1())
                {
                    Product product = new Product()
                    {
                        prodName = txtProdName.Text,
                        prodCode = txtProdCode.Text,
                        prodPrice = decimal.Parse(txtProdPrice.Text)

                    };

                    context.Products.Add(product);
                    context.SaveChanges();
                    this.Close();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("You must enter a value for each item");
            }
        }
Beispiel #5
0
        private void buttonCashTend_Click(object sender, EventArgs e)
        {
            double cashTendered = 0;

            if (myTyped != "")
            {
                cashTendered = double.Parse(myTyped) / 100;

                if (cashTendered >= ((runningTotal * discountRate)))
                {
                    rtfReceipt.AppendText("-----------\n" + "Cash tendered:\t \t" + cashTendered.ToString("C") + "\n");
                    if (taxRate != 0.00)
                    {
                        rtfReceipt.AppendText("Change:\t \t\t" + (cashTendered - ((runningTotal + tax) - (runningTotal * discountRate))).ToString("C") + "\n");
                    }
                    else
                    {
                        rtfReceipt.AppendText("Change:\t \t\t" + (cashTendered - (runningTotal * discountRate)).ToString("C") + "\n");
                    }
                }
                else
                {
                    MessageBox.Show("Cash Tendered must be more than total.");
                    cashTendered = 0;
                }
                using (mCoyoteDBEntities1 context = new mCoyoteDBEntities1())
                {
                    Transaction transaction = new Transaction()
                    {
                        Id = transId,
                        transDate = DateTime.Now,
                        transGrossTotal = decimal.Parse(runningTotal.ToString()),
                        transDiscount = decimal.Parse(discount.ToString()),
                        transTax = decimal.Parse(tax.ToString()),
                        transNetTotal = decimal.Parse(finalTotal.ToString())
                    };

                    context.Transactions.Add(transaction);
                    context.SaveChanges();
                    transId = 0;
                    runningTotal = 0;
                    tax = 0;
                    myItems.Clear();
                }
            }
        }
Beispiel #6
0
        private void btnDeleteProduct_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Are you sure you want to delete this product?",
                "Delete product", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dialog == DialogResult.Yes)
            {
                using (mCoyoteDBEntities1 context = new mCoyoteDBEntities1())
                {
                    Product product = new Product();

                    foreach (DataGridViewRow row in this.dtgProducts.SelectedRows)
                    {
                        Product prod = row.DataBoundItem as Product;
                        if (prod != null)
                        {
                            Product prod_to_delete = context.Products.Single(c => c.Id == prod.Id);
                            context.Products.Remove(prod_to_delete);
                        }
                    }

                    context.SaveChanges();
                    loadProductDatagrid();
                }
            }
        }
Beispiel #7
0
        private void btnDeleteCustomer_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Are you sure you want to delete this customer?",
                "Delete Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dialog == DialogResult.Yes)
            {
                using (mCoyoteDBEntities1 context = new mCoyoteDBEntities1())
                {
                    Customer customer = new Customer();

                    foreach (DataGridViewRow row in this.dtgCustomers.SelectedRows)
                    {
                        Customer cust = row.DataBoundItem as Customer;
                        if (cust != null)
                        {
                            Customer cust_to_delete = context.Customers.Single(c => c.Id == cust.Id);
                            context.Customers.Remove(cust_to_delete);
                        }
                    }

                    context.SaveChanges();
                    loadCustomerDatagrid();
                }

            }
        }