/// <summary>
 /// Returns true if this entries contains the same years as the entries of the given file
 /// If one file have one more or less year it returns false
 /// </summary>
 /// <param name="otherFile"></param>
 /// <returns></returns>
 public bool CheckYears(DataFile otherFile)
 {
     string[] allPossibleYearsOfThisFile     = this.GetYears();
     string[] allPossibleYearsOfTheOtherFile = otherFile.GetYears();
     if (allPossibleYearsOfThisFile.Length != allPossibleYearsOfTheOtherFile.Length)
     {
         return(false);
     }
     else
     {
         foreach (var year in allPossibleYearsOfThisFile)
         {
             if (!allPossibleYearsOfTheOtherFile.Contains(year))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 2
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (firstFile != null && secondFile != null)
     {
         if (firstFile.Entries.First().Station != secondFile.Entries.First().Station)
         {
             MessageBox.Show("Номера на станцията в единия файл не отговаря на номера на станцията в другият файл!" + Environment.NewLine + Environment.NewLine +
                             "ЗАБЕЛЕЖКА!" + Environment.NewLine + Environment.NewLine + "В двата файла, номера на станцията трябва да бъде един и същ!");
         }
         comboBox1.Items.Add(firstFile.Entries.First().Station);
         if (firstFile.CheckYears(secondFile))
         {
             comboBox2.Items.AddRange(firstFile.GetYears());
         }
         else
         {
             MessageBox.Show("Годините от двата файла не съвпадат.");
         }
     }
     else
     {
         MessageBox.Show("One or both files are empty. Please select the file and read the data first.");
     }
 }