C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2722
Number of posts: 5749

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How do add price to a menu item Posted by pollypoll on 19 Apr 2012 at 2:22 PM
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


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; }

      

    }
}



here is the pizza menu form

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);
          
        }
    }
}






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.