private void tsmiSaveSheduleToFile_Click(object sender, EventArgs e) { SaveFileDialog frmSave = new SaveFileDialog(); frmSave.FileName = "расписание.xml"; frmSave.Filter = "(*.xml)|*.xml"; if (frmSave.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { ScheduleSerializer.SaveData(frmSave.FileName, Schedule); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } }
private void tsmiOpenSheduleFromFile_Click(object sender, EventArgs e) { OpenFileDialog frmOpen = new OpenFileDialog(); frmOpen.DefaultExt = "xml"; frmOpen.Filter = "(*.xml)|*.xml"; if (frmOpen.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { Schedule = ScheduleSerializer.ReadData(frmOpen.FileName); if (Schedule != null) { Schedule.Employments.Clear(); } UpdateTableShedule(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (dgvSchedule.ColumnCount <= 0) { cmbView.Enabled = false; } else { cmbView.Enabled = true; } } }