Esempio n. 1
0
 /// <summary>
 /// creates a new file to save.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void mnuFileNew_Click(object sender, EventArgs e)
 {
     try
     {
         if (estateManager.Count != 0)
         {
             DialogResult dialogResult = MessageBox.Show("Do you wish to save your list before creating a new one?"
                                                         , "Save work...", MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 if (file != null)
                 {
                     estateManager.BinarySerialize(file);
                 }
                 else
                 {
                     saveAs();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Esempio n. 2
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!saved)
            {
                saveAsToolStripMenuItem_Click(sender, e);
            }

            estateManager.BinarySerialize(fileName);
        }
Esempio n. 3
0
 private void MnuFileExit_Click(object sender, EventArgs e)
 {
     if (estateManager.Count != 0)
     {
         DialogResult dialogResult = MessageBox.Show("Do you wish to save your list before exiting?"
                                                     , "Save work...", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             if (currentFile != null)
             {
                 estateManager.BinarySerialize(currentFile);
             }
             else
             {
                 SaveAs();
             }
         }
     }
     Application.Exit();
 }
        public bool Save(Func <string> chooseFileName)
        {
            if (string.IsNullOrEmpty(chosenFileName))
            {
                chosenFileName = chooseFileName();
                if (chooseFileName == null)
                {
                    return(false);
                }
            }

            bool estateSave  = _estateManager.BinarySerialize(chosenFileName + ".estates");
            bool addressSave = _addressManager.BinarySerialize(chosenFileName + ".addresses");

            if (estateSave && addressSave)
            {
                UnsavedChanges = false;
                return(true);
            }
            return(false);
        }