Wednesday, March 20, 2013

C#2012 :Lunch Order Billing Menu

Lunch Order Calculator in C# 2012:




Use this file in .cs file
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OSU_Lunch_Order
{
    public partial class frmHamburger : Form
    {
        //Global Decleration
        decimal Subtotal;
        decimal Tax = 0.0775m;
        decimal OrderTotal;
       

        public frmHamburger()
        {
            InitializeComponent();
        }
       

        //Events for Check-Changed
        private void Addons_CheckedChanged(object sender, EventArgs e)
        {
            if (rdoHamburger.Checked)
            {
                //Displays label in the checkbox - Text Change
                grpAddon.Text = "Add-on items($.75/each";
                chk1.Text = "Lettuce, tomato, and onions";
                chk2.Text = "Mayonnaise and mustard";
                chk3.Text = "French fries";

                // Remove the Checkbox
                chk1.Checked = false;
                chk2.Checked = false;
                chk3.Checked = false;

                //Clears the Subtotal, Tax and Order Total
                txtOrderTotal.Clear();
                txtSubtotal.Clear();
                txtTax.Clear();

            }
            else if (rdoPizza.Checked)
            {
                //Labels for Checkbox
                grpAddon.Text = "Add-on items($.50/each)";
                chk1.Text = "Pepproni";
                chk2.Text = "Sausage";
                chk3.Text = "Olives";

                // Removes the Checkbox
                chk1.Checked = false;
                chk2.Checked = false;
                chk3.Checked = false;

                //Clears the Subtotal, Tax and Order Total
                txtOrderTotal.Clear();
                txtSubtotal.Clear();
                txtTax.Clear();
            }
            else if (rdoSalad.Checked)
            {
                //Labels for Checkbox
                grpAddon.Text = "Add-on items($.25/each";
                chk1.Text = "Croutons";
                chk2.Text = "Bacon bits";
                chk3.Text = "Bread sticks";

                //Removes the checkbox
                chk1.Checked = false;
                chk2.Checked = false;
                chk3.Checked = false;

                //Clears the Subtotal, Tax and Order Total
                txtOrderTotal.Clear();
                txtSubtotal.Clear();
                txtTax.Clear();
            }
            txtOrderTotal.Clear();
            txtSubtotal.Clear();
            txtTax.Clear();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
          

            string message = "Thank You for Using Our Service!\n Would You Like use our service again?";
            DialogResult button =
                MessageBox.Show(message, "Dear Customer",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Information);

            if (button == DialogResult.No)
            {
                this.Close();
            }
            if (button == DialogResult.Yes)
            {
                MessageBox.Show("Thank You!! \n We Hope you will come Soon!", "Greeting Message");
                this.Close();
            }
        }
        // Codes for Buttons
        private void btnOrder_Click(object sender, EventArgs e)
        {
            decimal add = 0m;
            if (chk1.Checked)
            {
                add++;
            }
            if (chk2.Checked)
            {
                add++;
            }
            if (chk3.Checked)
            {
                add++;
            }
            if (rdoHamburger.Checked)
            {
                decimal Hamburger = Convert.ToDecimal(rdoHamburger.Checked);
                Hamburger = 6.95m;

                Subtotal = Hamburger + (add *.75m);
                Tax = Subtotal * 0.0775m;
                OrderTotal = Tax + Subtotal;

                txtSubtotal.Text = Subtotal.ToString("c");
                txtTax.Text = Tax.ToString("c");
                txtOrderTotal.Text = OrderTotal.ToString("c");

            }
            else if (rdoPizza.Checked)
            {

                decimal Pizza = Convert.ToDecimal(rdoPizza.Checked);
                Pizza = 5.95m;

                Subtotal = Pizza + (add * .50m);

                Tax = Subtotal * 0.00775m;

                OrderTotal = Tax + Subtotal;

                txtSubtotal.Text = Subtotal.ToString("c");
                txtTax.Text = Tax.ToString("c");
                txtOrderTotal.Text = OrderTotal.ToString("c");


            }
            else if (rdoSalad.Checked)
            {

                decimal salad = Convert.ToDecimal(rdoSalad.Checked);
                salad = 4.95m;

                Subtotal = salad + (add * .25m);

                Tax = Subtotal * 0.0775m;
                OrderTotal = Tax + Subtotal;
                txtSubtotal.Text = Subtotal.ToString("c");
                txtTax.Text = Tax.ToString("c");
                txtOrderTotal.Text = OrderTotal.ToString("c");
            }
        }

      

 
    }
 
}

--use this file in designer.cs file:

namespace OSU_Lunch_Order
{
    partial class frmHamburger
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.grpCourse = new System.Windows.Forms.GroupBox();
            this.rdoSalad = new System.Windows.Forms.RadioButton();
            this.rdoPizza = new System.Windows.Forms.RadioButton();
            this.rdoHamburger = new System.Windows.Forms.RadioButton();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.txtOrderTotal = new System.Windows.Forms.TextBox();
            this.txtTax = new System.Windows.Forms.TextBox();
            this.txtSubtotal = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.btnOrder = new System.Windows.Forms.Button();
            this.btnExit = new System.Windows.Forms.Button();
            this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
            this.grpAddon = new System.Windows.Forms.GroupBox();
            this.chk3 = new System.Windows.Forms.CheckBox();
            this.chk2 = new System.Windows.Forms.CheckBox();
            this.chk1 = new System.Windows.Forms.CheckBox();
            this.grpCourse.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.grpAddon.SuspendLayout();
            this.SuspendLayout();
            //
            // grpCourse
            //
            this.grpCourse.Controls.Add(this.rdoSalad);
            this.grpCourse.Controls.Add(this.rdoPizza);
            this.grpCourse.Controls.Add(this.rdoHamburger);
            this.grpCourse.Location = new System.Drawing.Point(13, 13);
            this.grpCourse.Name = "grpCourse";
            this.grpCourse.Size = new System.Drawing.Size(143, 98);
            this.grpCourse.TabIndex = 0;
            this.grpCourse.TabStop = false;
            this.grpCourse.Text = "Main Course";
            //
            // rdoSalad
            //
            this.rdoSalad.AutoSize = true;
            this.rdoSalad.Location = new System.Drawing.Point(20, 68);
            this.rdoSalad.Name = "rdoSalad";
            this.rdoSalad.Size = new System.Drawing.Size(88, 17);
            this.rdoSalad.TabIndex = 2;
            this.rdoSalad.Text = "Salad - $4.95";
            this.rdoSalad.UseVisualStyleBackColor = true;
            this.rdoSalad.CheckedChanged += new System.EventHandler(this.Addons_CheckedChanged);
            //
            // rdoPizza
            //
            this.rdoPizza.AutoSize = true;
            this.rdoPizza.Location = new System.Drawing.Point(20, 44);
            this.rdoPizza.Name = "rdoPizza";
            this.rdoPizza.Size = new System.Drawing.Size(86, 17);
            this.rdoPizza.TabIndex = 1;
            this.rdoPizza.Text = "Pizza - $5.95";
            this.rdoPizza.UseVisualStyleBackColor = true;
            this.rdoPizza.CheckedChanged += new System.EventHandler(this.Addons_CheckedChanged);
            //
            // rdoHamburger
            //
            this.rdoHamburger.AutoSize = true;
            this.rdoHamburger.Location = new System.Drawing.Point(20, 20);
            this.rdoHamburger.Name = "rdoHamburger";
            this.rdoHamburger.Size = new System.Drawing.Size(110, 17);
            this.rdoHamburger.TabIndex = 0;
            this.rdoHamburger.TabStop = true;
            this.rdoHamburger.Text = "Hamburger -$6.95";
            this.rdoHamburger.UseVisualStyleBackColor = true;
            this.rdoHamburger.CheckedChanged += new System.EventHandler(this.Addons_CheckedChanged);
            //
            // groupBox2
            //
            this.groupBox2.Controls.Add(this.txtOrderTotal);
            this.groupBox2.Controls.Add(this.txtTax);
            this.groupBox2.Controls.Add(this.txtSubtotal);
            this.groupBox2.Controls.Add(this.label3);
            this.groupBox2.Controls.Add(this.label2);
            this.groupBox2.Controls.Add(this.label1);
            this.groupBox2.Location = new System.Drawing.Point(13, 146);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(221, 113);
            this.groupBox2.TabIndex = 1;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Order Total";
            //
            // txtOrderTotal
            //
            this.txtOrderTotal.Location = new System.Drawing.Point(100, 72);
            this.txtOrderTotal.Name = "txtOrderTotal";
            this.txtOrderTotal.ReadOnly = true;
            this.txtOrderTotal.Size = new System.Drawing.Size(100, 20);
            this.txtOrderTotal.TabIndex = 5;
            //
            // txtTax
            //
            this.txtTax.Location = new System.Drawing.Point(100, 50);
            this.txtTax.Name = "txtTax";
            this.txtTax.ReadOnly = true;
            this.txtTax.Size = new System.Drawing.Size(100, 20);
            this.txtTax.TabIndex = 4;
            //
            // txtSubtotal
            //
            this.txtSubtotal.Location = new System.Drawing.Point(100, 27);
            this.txtSubtotal.Name = "txtSubtotal";
            this.txtSubtotal.ReadOnly = true;
            this.txtSubtotal.Size = new System.Drawing.Size(100, 20);
            this.txtSubtotal.TabIndex = 3;
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(17, 80);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(63, 13);
            this.label3.TabIndex = 2;
            this.label3.Text = "Order Total:";
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(20, 58);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(63, 13);
            this.label2.TabIndex = 1;
            this.label2.Text = "Tax(7.75%):";
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(20, 35);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(49, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Subtotal:";
            //
            // btnOrder
            //
            this.btnOrder.Location = new System.Drawing.Point(259, 146);
            this.btnOrder.Name = "btnOrder";
            this.btnOrder.Size = new System.Drawing.Size(105, 28);
            this.btnOrder.TabIndex = 2;
            this.btnOrder.Text = "Place Order";
            this.btnOrder.UseVisualStyleBackColor = true;
            this.btnOrder.Click += new System.EventHandler(this.btnOrder_Click);
            //
            // btnExit
            //
            this.btnExit.Location = new System.Drawing.Point(259, 214);
            this.btnExit.Name = "btnExit";
            this.btnExit.Size = new System.Drawing.Size(105, 24);
            this.btnExit.TabIndex = 3;
            this.btnExit.Text = "Exit";
            this.btnExit.UseVisualStyleBackColor = true;
            this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
            //
            // grpAddon
            //
            this.grpAddon.Controls.Add(this.chk3);
            this.grpAddon.Controls.Add(this.chk2);
            this.grpAddon.Controls.Add(this.chk1);
            this.grpAddon.Location = new System.Drawing.Point(173, 13);
            this.grpAddon.Name = "grpAddon";
            this.grpAddon.Size = new System.Drawing.Size(200, 100);
            this.grpAddon.TabIndex = 4;
            this.grpAddon.TabStop = false;
            this.grpAddon.Text = "Add-on items";
            //
            // chk3
            //
            this.chk3.AutoSize = true;
            this.chk3.Location = new System.Drawing.Point(7, 68);
            this.chk3.Name = "chk3";
            this.chk3.Size = new System.Drawing.Size(15, 14);
            this.chk3.TabIndex = 2;
            this.chk3.UseVisualStyleBackColor = true;
            //
            // chk2
            //
            this.chk2.AutoSize = true;
            this.chk2.Location = new System.Drawing.Point(7, 44);
            this.chk2.Name = "chk2";
            this.chk2.Size = new System.Drawing.Size(15, 14);
            this.chk2.TabIndex = 1;
            this.chk2.UseVisualStyleBackColor = true;
            //
            // chk1
            //
            this.chk1.AutoSize = true;
            this.chk1.Location = new System.Drawing.Point(7, 20);
            this.chk1.Name = "chk1";
            this.chk1.Size = new System.Drawing.Size(15, 14);
            this.chk1.TabIndex = 0;
            this.chk1.UseVisualStyleBackColor = true;
            //
            // frmHamburger
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(376, 260);
            this.Controls.Add(this.grpAddon);
            this.Controls.Add(this.btnExit);
            this.Controls.Add(this.btnOrder);
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.grpCourse);
            this.Name = "frmHamburger";
            this.Text = "  Lunch Order";
            this.grpCourse.ResumeLayout(false);
            this.grpCourse.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.grpAddon.ResumeLayout(false);
            this.grpAddon.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.GroupBox grpCourse;
        private System.Windows.Forms.RadioButton rdoSalad;
        private System.Windows.Forms.RadioButton rdoPizza;
        private System.Windows.Forms.RadioButton rdoHamburger;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.TextBox txtOrderTotal;
        private System.Windows.Forms.TextBox txtTax;
        private System.Windows.Forms.TextBox txtSubtotal;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button btnOrder;
        private System.Windows.Forms.Button btnExit;
        private System.Windows.Forms.PageSetupDialog pageSetupDialog1;
        private System.Windows.Forms.GroupBox grpAddon;
        private System.Windows.Forms.CheckBox chk3;
        private System.Windows.Forms.CheckBox chk2;
        private System.Windows.Forms.CheckBox chk1;
    }
}


----Thank you! Enjoy the code!

2 comments: