コード例 #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 プロジェクト: Krudus/prog2014
        private void button1_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog() { Filter = "Заказ|*.internetshop" };
            var result = sfd.ShowDialog(this);
            if (result == DialogResult.OK)
            {
                var fileName = sfd.FileName;
                ShopData pd = new ShopData();
                pd.ItemType = new List<ShopType>();
                if (checkBox1.Checked)
                pd.ItemType.Add(ShopType.Bul);
                if (checkBox2.Checked)
                    pd.ItemType.Add(ShopType.Hleb);
                if (checkBox3.Checked)
                    pd.ItemType.Add(ShopType.Pon);
               if (checkBox4.Checked )
                    pd.ItemType.Contains(ShopType.Red);
               if( checkBox5.Checked)
                    pd.ItemType.Contains(ShopType.Chai);
               if( checkBox6.Checked )
                    pd.ItemType.Contains(ShopType.Kol);
               if( checkBox4.Checked)
                    pd.ItemType.Contains(ShopType.Red);
               if( checkBox5.Checked)
                    pd.ItemType.Contains(ShopType.Chai);
               if( checkBox6.Checked )
                    pd.ItemType.Contains(ShopType.Kol);
               if(     checkBox7.Checked )
                    pd.ItemType.Contains(ShopType.A);
             if   (   checkBox8.Checked )
                    pd.ItemType.Contains(ShopType.T);
            if(    checkBox9.Checked )
                    pd.ItemType.Contains(ShopType.Sh);

                XmlSerializer xs = new XmlSerializer(typeof(ShopData));
                var fileStream = File.Create(fileName);
                xs.Serialize(fileStream, pd);
                fileStream.Close();
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: JakeARS/prog2014
 private ShopData CreateShopData()
 {
     ShopData sd = new ShopData();
     sd.Items = new List<ProductList>();
     foreach (ProductList el in listBox1.Items)
     {
         sd.Items.Add(el);
     }
     return sd;
 }