コード例 #1
0
        public void Sort()
        {
            List <ClassGenericFlight> sortableList = new List <ClassGenericFlight>(MyGenericFlights);

            sortableList.Sort();

            for (int i = 0; i < sortableList.Count; i++)
            {
                MyGenericFlights.Move(MyGenericFlights.IndexOf(sortableList[i]), i);
            }
        }
コード例 #2
0
 private void Import_Gen_Click(object sender, RoutedEventArgs e)
 {
     #region OpenFileDialog
     Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
     dlg.FileName         = MyUtil.Code + "_Flight";       // Default file name
     dlg.DefaultExt       = ".txt";                        // Default file extension
     dlg.Filter           = "Text documents (.txt)|*.txt"; // Filter files by extension
     dlg.InitialDirectory = MyManager.WorkPlace;
     Nullable <bool> result = dlg.ShowDialog();
     if (result == true)
     {
         MyGenericFlights = ClassSerializable.ReadFile <ClassGenericFlight>(dlg.FileName);
     }
     Sort();
     List <ClassGenericFlight> tmp = new List <ClassGenericFlight>();
     foreach (ClassGenericFlight item in MyGenericFlights)
     {
         if (item.Code == null)
         {
             item.Code = MyUtil.Code;
         }
         else if (!item.Code.Equals(MyUtil.Code))
         {
             tmp.Add(item);
         }
     }
     foreach (ClassGenericFlight item in tmp)
     {
         MyGenericFlights.Remove(item);
     }
     if (MyGenericFlights.Count == 0)
     {
         MessageBox.Show("No generic flight found for this company !", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     Datagrid_Generic.DataContext = MyGenericFlights;
     #endregion
 }
コード例 #3
0
 private void Delete_GenericFlight_Click(object sender, RoutedEventArgs e)
 {
     if (Datagrid_Generic.SelectedIndex == -1)
     {
         MessageBox.Show("Select at least a generic flight !", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else
     {
         try
         {
             List <ClassGenericFlight> tmp = new List <ClassGenericFlight>();
             foreach (ClassGenericFlight item in Datagrid_Generic.SelectedItems)
             {
                 tmp.Add(item);
             }
             foreach (ClassGenericFlight item in tmp)
             {
                 MyGenericFlights.Remove(item);
             }
             Datagrid_Generic.DataContext = MyGenericFlights;
         }
         catch (Exception) { }
     }
 }