// METHOD TO PERFORM WHEN THE FORM LOAD private void ShoppingCartUI_Load(object sender, EventArgs e) { // Open the connection Conn.OpenConnection(); ResProd.GetAllProduct(); this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span); this.dataGridView2.DataSource = ResCart.GetAllCart(); // Close the connection Conn.CloseConnection(); }
// METHOD TO REMOVE FROM CART private void button5_Click(object sender, EventArgs e) { if (CartID > 0) { // Method to remove from the Cart table ResCart.RemoveCart(CartID); // Method to Populate the Cart Data Grid View this.dataGridView2.DataSource = ResCart.GetAllCart(); MessageBox.Show("Cart Item Deleted Successfully"); } else { MessageBox.Show("Invalid Details"); } }
// METHOD TO REMOVE FROM PRODUCT private void button3_Click(object sender, EventArgs e) { if (ID > 0) { // Method to remove from the Product table ResProd.RemoveProduct(ID); // Method to Populate the Data Grid View this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span); this.dataGridView2.DataSource = ResCart.GetAllCart(); MessageBox.Show("Product Deleted Successfully"); } else { MessageBox.Show("Invalid Details"); } }
// METHOD TO ADD TO CART private void button4_Click(object sender, EventArgs e) { try { // Method to add to the Cart table ResCart.AddCart(ID, (int)numericUpDown1.Value); // Method to Populate the Data Grid View this.dataGridView2.DataSource = ResCart.GetAllCart(); MessageBox.Show("Product Added to Cart Successfully"); } catch (Exception ex) { MessageBox.Show("Invalid Product Details"); } // Change the Numeric Value back to default 1; numericUpDown1.Value = 1; }