コード例 #1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Database for animal shelter |*.thisisadatabaseforanimalshelter";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    administration.Load(ofd.FileName);
                }
                catch (FileNotFoundException fileNotFoundException)
                {
                    MessageBox.Show(fileNotFoundException.Message);
                }
                catch (FileLoadException flException)
                {
                    MessageBox.Show(flException.Message);
                }
                catch (IOException ioException)
                {
                    MessageBox.Show(ioException.Message);
                }
                RedrawItemsInAnimalListBoxes();
            }
        }
コード例 #2
0
 private void btnLoad_Click(object sender, EventArgs e)
 {
     try
     {
         Administration.Load(fileName);
     }
     catch (ArgumentNullException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (ArgumentException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (PathTooLongException ex)
     {
         MessageBox.Show(ex.Message);
     }
     catch (FileNotFoundException ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         //update
     }
 }
コード例 #3
0
 private void btnLoad_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string loadPath = openFileDialog1.FileName;
         try
         {
             admin.Load(loadPath);
         }
         catch (FileNotFoundException)
         {
             MessageBox.Show("Vul een correcte bestandsnaam in");
         }
         catch (SerializationException)
         {
             MessageBox.Show("Kies een geldig bestand");
         }
     }
     updateListBoxes();
 }
コード例 #4
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            try
            {
                if (openFile.ShowDialog() == DialogResult.OK)
                {
                    string pathOfOpenFile = openFile.FileName;
                    administration.Load(pathOfOpenFile);
                    UpdateGUI();
                }
            }
            catch (ArgumentNullException arnull)
            {
                MessageBox.Show(arnull.Message);
            }
            catch (PathTooLongException pathlong)
            {
                MessageBox.Show(pathlong.Message);
            }
            catch (FileNotFoundException notfound)
            {
                MessageBox.Show(notfound.Message);
            }
            catch (ArgumentException argument)
            {
                MessageBox.Show(argument.Message);
            }
            catch (SerializationException serialize)
            {
                MessageBox.Show(serialize.Message);
            }
            catch (NullReferenceException refrence)
            {
                MessageBox.Show(refrence.Message);
            }
        }