Пример #1
0
        public void SaveRule()
        {
            var dal = new DAL();
            var bonds = dal.GetList();
            if (bonds.Count == 0)
            {
                const string message = @"You do not have any bonds to Save, thus I am unable "
                    + @" to save any bonds. Please add some bonds before Saving";
                MessageBox.Show(message);
                return;
            }

            var dlg = new SaveFileDialog { FileName = "Prize Bond Manager",
                DefaultExt = ".pbm", Filter = @"Prize Bond Manager Files (.pbm)|*.pbm" };

            // Show save file dialog box
            var result = dlg.ShowDialog();

            // Process save file dialog box results
            if (result == DialogResult.OK)
            {
                // Save document
                string filename = dlg.FileName;
                var serializer = new Serializer();
                var objectToSerialize = new ObjectToSerialize { Bonds = bonds };
                serializer.SerializeObject(filename, objectToSerialize);
            }
        }
Пример #2
0
 private void LoadBonds()
 {
     var dal = new DAL();
     List<Bond> bonds = dal.GetList();
     dataGridView1.DataSource = bonds;
 }