Sie sind auf Seite 1von 3

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 DevExpress.Skins; using DevExpress.LookAndFeel; using DevExpress.UserSkins; using DevExpress.XtraEditors; namespace Eshoppingsystem { public partial class Form1 : XtraForm { double cost = 0; double tax = 0; double unitprice = 0; double quantity = 0; string productname = ""; double taxrate = 0.18; int sno = 0; double grandtotal = 0; double totalcost = 0; public Form1() { InitializeComponent(); InitGrid(); } BindingList<Person> gridDataList = new BindingList<Person>(); void InitGrid() { gridDataList.Add(new Person("John", "Smith")); gridDataList.Add(new Person("Gabriel", "Smith")); gridDataList.Add(new Person("Ashley", "Smith", "some comment")); gridDataList.Add(new Person("Adrian", "Smith", "some comment")); gridDataList.Add(new Person("Gabriella", "Smith", "some comment")); } private void productnamecomboBox_SelectedIndexChanged(object sender, Eve ntArgs e) { if (productnamecomboBox.SelectedIndex == 0) { unitpricetextBox.Text = "1500000"; } if (productnamecomboBox.SelectedIndex == 1) { unitpricetextBox.Text = "1200000"; } if (productnamecomboBox.SelectedIndex == 2) { unitpricetextBox.Text = "100000"; } if (productnamecomboBox.SelectedIndex == 3) {

unitpricetextBox.Text = "800000"; } if (productnamecomboBox.SelectedIndex == 4) { unitpricetextBox.Text = "200000"; } if (productnamecomboBox.SelectedIndex == 5) { unitpricetextBox.Text = "300000"; } } private void button1_Click(object sender, EventArgs e) { if (productnamecomboBox.SelectedItem == null) { MessageBox.Show("You must select a product name first"); productnamecomboBox.SelectedIndex = 0; } else if (quantitynumericUpDown.Value == 0) { MessageBox.Show("Please choose the quantiy of the selected produ ct"); quantitynumericUpDown.Value = 1; } else { costtextBox.Clear(); taxtextBox.Clear(); unitprice = Convert.ToDouble(unitpricetextBox.Text); quantity = Convert.ToDouble(quantitynumericUpDown.Value); cost = unitprice * quantity; costtextBox.Text = cost.ToString(); double ans = taxrate * cost; taxtextBox.Text = ans.ToString(); } } private void button2_Click(object sender, EventArgs e) { productname = productnamecomboBox.Text; unitprice = double.Parse(unitpricetextBox.Text); quantity = double.Parse(quantitynumericUpDown.Text); cost = double.Parse(costtextBox.Text); tax = double.Parse(taxtextBox.Text); sno++; totalcost = tax + cost; summarytextBox.AppendText("\n"); summarytextBox.AppendText(sno + "\t" + productname.ToString() + "\t\t\t" + unitprice.ToString() + "\t\t\t" + quantity.ToString() + "\t\t" + cost textBox.Text + "\t\t" + taxtextBox.Text + "\t\t" + totalcost); summarytextBox.AppendText("\n"); grandtotal += totalcost; } private void button3_Click(object sender, EventArgs e)

{ summarytextBox.Clear(); productnamecomboBox.SelectedIndex = -1; unitpricetextBox.Clear(); costtextBox.Clear(); quantitynumericUpDown.Value = 0; taxtextBox.Clear(); } private void Form1_Load(object sender, EventArgs e) { summarytextBox.Text = "SNo" + "\t" + "Product Name" + "\t\t" + "Unit Price" + "\t\t\t" + "Quantity" + "\t\t" + "Cost" + "\t\t" + "Tax" + "\t\t" + "T otal cost"; } private void button4_Click(object sender, EventArgs e) { SaveFileDialog filesaver = new SaveFileDialog(); filesaver.Title = "Chose the directory where you want to save your d ata"; filesaver.InitialDirectory = "F:\\"; filesaver.RestoreDirectory = true; filesaver.Filter = "All text files(*.txt)|*.txt|All word documents(* .docx)|*.docx|All Foxit software files(*.pdf)|*.pdf|All files(*.*)|*.*"; DialogResult filesave = filesaver.ShowDialog(); if (filesave == DialogResult.OK) { string filetobesaved = filesaver.FileName; } } private void button5_Click(object sender, EventArgs e) { summarytextBox.AppendText("The Grand total of your purchase is: " + grandtotal + "/=." + "\t" + "Thanks for shopping with us pleas come again"); } } }

Das könnte Ihnen auch gefallen