Example #1
0
        private void btnDelete(object sender, EventArgs e)
        {
            //deleting record (customer).............
            var delCustomerProduct = new BusinessLayer.CustomerProduct(Convert.ToInt32(customerProductId.Text));
            int CusId = delCustomerProduct.CustomerId;
            int PrdId = delCustomerProduct.ProductId;

            delCustomerProduct.Delete();
            var delCustomer = new BusinessLayer.Customer(CusId);

            delCustomer.Delete();
            var delProduct = new BusinessLayer.Product(PrdId);

            delProduct.Delete();

            clearForm();
        }
Example #2
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();
        }
Example #3
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();
        }