private void addButton_Click(object sender, EventArgs e) { if (itemComboBox.SelectedItem != null) { if (!string.IsNullOrEmpty(QuatityTextBox.Text)) { da = new DataAccess(); string sql = "SELECT Price FROM Menu WHERE MenuName='" + itemComboBox.SelectedItem.ToString() + "' "; SqlDataReader reader = da.GetData(sql); Menus m = new Menus(); while (reader.Read()) { m.Price = (int)reader["Price"]; } x = Convert.ToInt32(m.Price) * Convert.ToInt32(QuatityTextBox.Text); string text = itemComboBox.SelectedItem.ToString() + " " + QuatityTextBox.Text + " " + x + "taka"; orderListBox.Items.Add(text); itemComboBox.SelectedItem = null; QuatityTextBox.Clear(); Varriables.total(x); } else { MessageBox.Show("Please Select Quantity!"); } } else { MessageBox.Show("Please select an item!"); } }
private void totalButton_Click(object sender, EventArgs e) { int a = 0; string text = "_ _ _ _ _ _ _ _ _ _ _ _ _ "; string text2 = " Total = " + Varriables.total(a) + "TAKA"; orderListBox.Items.Add(text); orderListBox.Items.Add(text2); SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["HungerGamesDb"].ConnectionString); connection.Open(); string sql = "INSERT INTO Orders (EmployeeName, EmployeeId, Month, Price) VALUES ('" + nametextBox.Text + "','" + idtextBox.Text + "','" + dateTimePicker1.Text + "','" + Varriables.total(a) + "');"; SqlCommand cmd = new SqlCommand(sql, connection); cmd.ExecuteNonQuery(); MessageBox.Show("Your order has been placed"); }