Exemplo n.º 1
0
 private void zapiszToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (filePath != "")
     {
         WriterToFile.Write(filePath);
     }
     else
     {
         zapiszJakoToolStripMenuItem_Click(sender, e);
     }
 }
Exemplo n.º 2
0
        private void zapiszJakoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                SetTimetableProperties();
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Syntax error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            try
            {
                ValidationBeforeSave();
            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show(ex.Message, "Syntax error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            //saveFileDialog.InitialDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location;
            saveFileDialog.Filter           = "Plik rozkładu ISDR (*.roz)|*.roz";
            saveFileDialog.Title            = "Zapis do pliku...";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.ShowDialog();
            if (saveFileDialog.FileName != "")
            {
                try
                {
                    WriterToFile.Write(saveFileDialog.FileName);
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message, "Write to file error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }