public void UpdateTotalPrice() { TotalPrice = CheckOutApp.CalculateTotalPrice(); lblPriceTotal.Text = CheckOutApp.CalculateTotalPrice().ToString(); //MessageBox.Show(CheckOutApp.CalculateTotalPrice().ToString()); this.Refresh(); }
private void Button2_Click(object sender, EventArgs e) { this.Dispose(); CheckOutApp.RemoveItem(this.Code); Item.CountCartItem(); CheckOut.Upd.Invoke(); }
public static void CountCartItem() { Console.WriteLine(CheckOutApp.TotalItems()); btnCheckOut.Text = "( " + CheckOutApp.TotalItems() + " ) Check Out"; Console.WriteLine(btnCheckOut.Text); btnCheckOut.Refresh(); }
private void BtnAddToCart_Click(object sender, EventArgs e) { if (btnCheckOut == null) { if (this.Parent.Parent.Parent.Parent is UserEnd) { UserEnd userEnd = this.Parent.Parent.Parent.Parent as UserEnd; Control[] controls = userEnd.Controls.Find("btnCheckOut", true);// as Button; if (controls.Length > 0) { if (controls[0] is Button) { btnCheckOut = controls[0] as Button; } } } } Console.WriteLine("ll"); CheckOutApp.AddItem(ItemID, Title, PriceTag); CountCartItem(); }
public static void InserOrdersDb(User user) { using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); SqlCommand cmd = new SqlCommand("Insert into orderTable values ( @userID, @bill, @status, @address, @mobile);", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@userID", user.UserName); cmd.Parameters.AddWithValue("@bill", (float)CheckOutApp.CalculateTotalPrice()); cmd.Parameters.AddWithValue("@status", 0); cmd.Parameters.AddWithValue("@address", user.Address); cmd.Parameters.AddWithValue("@mobile", user.Mobile); cmd.ExecuteNonQuery(); SqlCommand cmd2 = new SqlCommand("SELECT IDENT_CURRENT('orderTable')", con); int id = Convert.ToInt32(cmd2.ExecuteScalar()); cmd2 = new SqlCommand("Insert into notification values (@userID, @message, @notified);", con); cmd2.CommandType = CommandType.Text; cmd2.Parameters.AddWithValue("@userID", user.UserName); cmd2.Parameters.AddWithValue("@message", user.UserName + " has placed an order [" + id + "]"); cmd2.Parameters.AddWithValue("@notified", 0); cmd2.ExecuteNonQuery(); foreach (CartItemApp cartItemApp in CheckOutApp.itemApps) { SqlCommand cmd3 = new SqlCommand("Insert into orderExtension values ( @orderID, @itemCode, @quantity);", con); cmd3.CommandType = CommandType.Text; cmd3.Parameters.AddWithValue("@orderID", id); cmd3.Parameters.AddWithValue("@itemCode", Convert.ToInt32(cartItemApp.ItemCode)); cmd3.Parameters.AddWithValue("@quantity", cartItemApp.Quantity); cmd3.ExecuteNonQuery(); } con.Close(); Console.WriteLine("inserted orders"); } }
void StaticClear() { CheckOutApp.itemApps.Clear(); CheckOut.TotalPrice = 0; if (CheckOut.lblTotalPrice != null) { CheckOut.lblTotalPrice.Text = "0.00"; } if (Item.btnCheckOut != null) { Item.btnCheckOut = null; } btnCheckOut.Text = "( " + CheckOutApp.TotalItems() + " ) Check Out"; user = null; menuAllItems = null; personalInfo = null; checkOut = null; //CheckOut.clearCartDel.Invoke(); deliverySettings = null; }
public void UpdateCartButton() { if (btnCheckOut == null) { if (this.Parent.Parent is UserEnd) { UserEnd userEnd = this.Parent.Parent as UserEnd; Control[] controls = userEnd.Controls.Find("btnCheckOut", true);// as Button; if (controls.Length > 0) { if (controls[0] is Button) { btnCheckOut = controls[0] as Button; } } } } btnCheckOut.Text = "( " + CheckOutApp.TotalItems() + " ) Check Out"; }
private void BtnConfirmOrder_Click(object sender, EventArgs e) { CheckOutApp.PlaceOrder(user); BtnClearCart_Click(btnClearCart, new EventArgs()); userEnd.BtnAllItemsInvoke(); }