Ejemplo n.º 1
0
        private void btnUpdate(object sender, EventArgs e)
        {
            //it is a button which is updating data of customer and product.. we give cutomerProductId through it, customer and product change.
            var customerProduct = new BusinessLayer.CustomerProduct(Convert.ToInt32(customerProductId.Text));
            int cusId           = customerProduct.CustomerId;
            int prdId           = customerProduct.ProductId;
            var customer        = new BusinessLayer.Customer(cusId);

            customer.FirstName = firstName.Text;
            customer.LastName  = lastName.Text;
            customer.Save();
            var product = new BusinessLayer.Product(prdId);

            product.ProductName   = productName.Text;
            product.SaleCost      = Convert.ToInt32(saleCost.Text);
            product.WholesaleCost = Convert.ToInt32(wholeSaleCost.Text);
            product.Save();

            MessageBox.Show("Data Updated Successfully");
            clearForm();
        }
Ejemplo n.º 2
0
        private void btnAdd(object sender, EventArgs e)
        {
            // it is a button which is adding data into a database
            enterData();
            var customer  = new BusinessLayer.Customer();
            var product   = new BusinessLayer.Product();
            var purchases = new BusinessLayer.CustomerProduct();

            customer.FirstName = firstName.Text;
            customer.LastName  = lastName.Text;
            customer.Save();
            product.ProductName   = productName.Text;
            product.SaleCost      = Convert.ToDecimal(saleCost.Text);
            product.WholesaleCost = Convert.ToDecimal(wholeSaleCost.Text);
            product.Save();
            purchases.CustomerId = customer.CustomerId;
            purchases.ProductId  = product.ProductId;
            purchases.Save();

            MessageBox.Show("Data Updated Successfully");
            clearForm();
        }