private void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Програма за артикли (*.atk)|*.atk"; openFileDialog.Title = "Отвори ја програмата"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(FileName, FileMode.Open)) { IFormatter formater = new BinaryFormatter(); SaveDoc = (SaveDoc)formater.Deserialize(fileStream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }
public Form1() { InitializeComponent(); SaveDoc = new SaveDoc(); Category category = new Category("Алат", 1); category.AddProduct(new Product("Клешта", 10)); lbKategorii.Items.Add(category); Category category2 = new Category("Електричен алат", 2); category2.AddProduct(new Product("Бруска", 15)); lbKategorii.Items.Add(category2); loadCategory(); }
private void newToolStripButton_Click(object sender, EventArgs e) { SaveDoc = new SaveDoc(); Invalidate(true); }