コード例 #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
ファイル: HomeController.cs プロジェクト: 1extra/prog2015
 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();
        }