Esempio n. 1
0
 public void SaveExecute()
 {
     if (String.IsNullOrEmpty(Date.ToString()) || String.IsNullOrEmpty(Hours.ToString()) || String.IsNullOrEmpty(Description) || Hours == 0)
     {
         MessageBox.Show("Please fill all fields.", "Notification");
     }
     else
     {
         try
         {
             MessageBoxResult result = MessageBox.Show("Are you sure you want to save the report?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
             if (result == MessageBoxResult.Yes)
             {
                 string       source = string.Format(@"../../Maintenance{0}.txt", Maintenance.MaintenanceId);
                 StreamWriter str    = new StreamWriter(source, true);
                 string       output = "[" + Date + "][" + Hours + "][" + Description + "]";
                 str.WriteLine(output);
                 str.Close();
                 MessageBox.Show("Report is saved.", "Notification", MessageBoxButton.OK);
                 reportView.Close();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
 /// <summary>
 /// This method invokes a methods for adding report.
 /// </summary>
 public void SaveExecute()
 {
     try
     {
         reports.AddReport(report);
         addReportView.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }