//update cart private void Button_Click(object sender, RoutedEventArgs e) { Cart objCart = new Cart(); OrderIngredientBL orderIngredientBL = new OrderIngredientBL(); try { //check null values objCart = CheckNulls(); bool result = orderIngredientBL.UpdateCartBL(objCart); if (result == true) { MessageBox.Show("Cart Updated!"); //clear data Clear(); //update the datagrid gridview_data(); } else { MessageBox.Show("Cart Not Updated!"); } } catch (RecipeIngredientSystemExceptions ex) { MessageBox.Show(ex.Message); } }
private void Orderbtn_Click(object sender, RoutedEventArgs e) { OrderCartIngredient orderAdded = new OrderCartIngredient(); OrderIngredientBL orderIngredientBL = new OrderIngredientBL(); try { string username = ""; //check null values if (!string.IsNullOrEmpty(txtusername.Text)) { username = txtusername.Text;//username textbox } orderAdded = CheckNullsforOrderAdd(); bool result = orderIngredientBL.AddOrderBL(orderAdded, username); if (result == true) { MessageBox.Show("Order Placed!"); this.Close(); ShippingDetails shipppingpage = new ShippingDetails(txtusername.Text); //redirect to shipping details page shipppingpage.Show(); } else { MessageBox.Show("Order not Placed!"); } } catch (RecipeIngredientSystemExceptions ex) { MessageBox.Show(ex.Message); } }
//Delete button private void Button_Click_1(object sender, RoutedEventArgs e) { Cart objCart = new Cart(); OrderIngredientBL orderIngredientBL = new OrderIngredientBL(); try { //check null values if (!string.IsNullOrEmpty(txtcartid.Text)) { objCart.CartId = Convert.ToInt32(txtcartid.Text); } //if cart contains data then only delete it if (objCart != null) { bool result = orderIngredientBL.DeleteCartBL(objCart); if (result == true) { MessageBox.Show("Cart Deleted!"); //Clear fields Clear(); //show the updated datagrid gridview_data(); } else { MessageBox.Show("Cart Not Deleted!"); } } } catch (RecipeIngredientSystemExceptions ex) { MessageBox.Show(ex.Message); } }
//show grid data public void gridview_data() { try { string username; //check null values if (!string.IsNullOrEmpty(txtusername.Text)) { //take username username = txtusername.Text; OrderIngredientBL orderIngredientBL = new OrderIngredientBL(); //get cart details of customer grid.ItemsSource = orderIngredientBL.GetCartBL(username); //OrderIngredientBL orderIngredientBL = new OrderIngredientBL(); decimal totalamount = orderIngredientBL.Totalamount(username); //calculate total amount txttamount.Text = totalamount.ToString(); //calculate gst txtgst1.Text = ((Convert.ToDecimal(txttamount.Text) * 18) / 100).ToString(); //calculate grand total including gst txtgtotal.Text = (Convert.ToDecimal(txttamount.Text) + Convert.ToDecimal(txtgst1.Text)).ToString(); } } catch (RecipeIngredientSystemExceptions ex) { MessageBox.Show(ex.Message); } }