public ProductData WORK() { var a = new ProductData(); a.description = textBox1.Text; foreach (IngrData ed in listBox1.Items) { a.Spisok.Add(ed); } return a; }
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(); } }
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(); }