示例#1
0
文件: Form1.cs 项目: 1extra/prog2015
 public ProductData WORK()
 {
     var a = new ProductData();
     a.description = textBox1.Text;
     foreach (IngrData ed in listBox1.Items)
     {
        a.Spisok.Add(ed);
     }
     return a;
 }
示例#2
0
 private void Initfoods()
 {
     var pdName = GetProductName();
     if (pdName != null && System.IO.File.Exists(pdName))
     {
         var file = System.IO.File.OpenRead(pdName);
         var xs = new XmlSerializer(typeof(ProductData));
         pd = (ProductData)xs.Deserialize(file);
         file.Close();
     }
     else
     {
         pd = new ProductData();
     }
 }
示例#3
0
文件: Form1.cs 项目: 1extra/prog2015
        private void button1_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog() { Title = "Сохранение данных", Filter = "Рецепт|*.rcp" };
            var result = sfd.ShowDialog(this);
            if (result != DialogResult.OK)
                return;

            var pd = new ProductData()
            {
                description = textBox1.Text,
            };

            foreach (IngrData ed in listBox1.Items)
            {
                pd.Spisok.Add(ed);
            }

            var xs = new XmlSerializer(typeof(ProductData));
            var file = File.Create(sfd.FileName);
            xs.Serialize(file, pd);
            file.Close();
        }