示例#1
0
文件: Form1.cs 项目: JakeARS/prog2014
        private void button1_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog() { Filter = "покупка|*.shopml" };
            var result = sfd.ShowDialog(this);
            if (result == DialogResult.OK)
            {
                var fileName = sfd.FileName;
                ShopData sd = new ShopData();
                var line = new ProductList();
                sd.Items = new List<ProductList>();
                if (checkBox1.Checked)
                    //pd.Items.Add(ProductType.Hol);
                    sd.Items.Add(new ProductList() { Type = ProductType.Hol, Quantity = (Int32) numericUpDown1.Value });
                if (checkBox2.Checked)
                    //pd.Items.Add(ProductType.Stir);
                    sd.Items.Add(new ProductList() { Type = ProductType.Stir, Quantity = (Int32)numericUpDown2.Value });
                if (checkBox3.Checked)
                    //pd.Items.Add(ProductLType.CVH);
                    sd.Items.Add(new ProductList() { Type = ProductType.CVH, Quantity = (Int32)numericUpDown3.Value });
                if (checkBox4.Checked)
                    //pd.Items.Add(ProductType.Plita);
                    sd.Items.Add(new ProductList() { Type = ProductType.Plita, Quantity = (Int32)numericUpDown4.Value });

                XmlSerializer xs = new XmlSerializer(typeof(ShopData));
                var fileStream = File.Create(fileName);
                xs.Serialize(fileStream, sd);
                fileStream.Close();
            }
        }
示例#2
0
文件: Form1.cs 项目: JakeARS/prog2014
 private void button4_Click(object sender, EventArgs e)
 {
     var pl = new ProductList
     {
         Hol = checkBox1.Checked,
         Stir = checkBox2.Checked,
         CVH = checkBox3.Checked,
         Plita = checkBox4.Checked,
         n1 = numericUpDown1.Value,
         n2 = numericUpDown2.Value,
         n3 = numericUpDown3.Value,
         n4 = numericUpDown4.Value,
         };
     if (listBox1.Items.Count < 1)
     {
         listBox1.Items.Add(pl);
     }
 }
示例#3
0
文件: Form1.cs 项目: Krudus/prog2014
 private void button4_Click(object sender, EventArgs e)
 {
     var pl = new ProductList
     {
         Chai = checkBox1.Checked,
         Kofe = checkBox2.Checked,
         Kola = checkBox3.Checked,
         Hleb = checkBox4.Checked,
         n1 = numericUpDown1.Value,
         n2 = numericUpDown2.Value,
         n3 = numericUpDown3.Value,
         n4 = numericUpDown4.Value,
         n5 = dateTimePicker3.Value,
         };
     if (listBox1.Items.Count < 1)
     {
         listBox1.Items.Add(pl);
     }
 }