Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How do add price to a menu item

pollypollpollypoll Posts: 2Member
i have created the classes for the menu items and i cannot figure out how to get a price when someone someone order a pizza and a the toppings.I also cannot figure out how to store the pizza name,price and toppings when i click the submit order button.I am getting the pizza and prices from a database.

here is the pizza class
[code]


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;


namespace ItalianoLIB.BLL
{

public class Pizza
{

public string pizzaName { get; set; }
public string toppingName { get; set; }
public double toppingPrice { get; set; }
public double pizzaPrice { get; set; }



}
}

[/code]

here is the pizza menu form
[code]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;




namespace ItalianoWIN.PLL
{

public partial class PizzaMenu : Form
{
public string newPizzaName { get; set; }
public string newToppingName { get; set; }
public double newToppingPrice { get; set; }
public double newPizzaPrice { get; set; }

public PizzaMenu()
{

InitializeComponent();
}

private void Pizza_Load(object sender, EventArgs e)
{

//new connection from the DButils class
SqlConnection con = new SqlConnection(ItalianoLIB.DLL.DButils.CONSTR);
con.Open();

//fill Pizza type combo box
SqlDataAdapter da = new SqlDataAdapter("select * from pizza", con);
DataTable dt = new DataTable();
da.Fill(dt);

//adds the pizza name and price in the combo box
foreach (DataRow dr in dt.Rows)
{
cboPizzaType.Items.Add(dr["PizzaType"].ToString() + dr["PizzaPrice"].ToString());
}


//fill toppings listbox
SqlDataAdapter da2 = new SqlDataAdapter("select * from Topping",con);
DataTable dt2 = new DataTable();
da2.Fill(dt2);


for (int i = 0; i < dt2.Rows.Count; i++)
{
lstToppings.Items.Add(dt2.Rows[i]["ToppingName"]);
}



con.Close();


}

private void cboPizzaType_SelectedIndexChanged(object sender, EventArgs e)
{


}


private void lstToppings_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void bnPizOrd_Click(object sender, EventArgs e)
{



//Brings the user back to the main form
this.DialogResult = DialogResult.OK;
}

private void bnAddTop_Click(object sender, EventArgs e)
{


object obj = lstToppings.SelectedItem;
lstSelTop.Items.Add(obj);
lstToppings.Items.Remove(obj);

}

private void bnDelTop_Click(object sender, EventArgs e)
{
object obj = lstSelTop.SelectedItem;
lstToppings.Items.Add(obj);
lstSelTop.Items.Remove(obj);

}
}
}


[/code]
Sign In or Register to comment.