Example #1
0
        public MainWindow()
        {
            InitializeComponent();
            CompanieAeriana.NumeFisierSerializare = "CompanieAeriana.txt";
            if (File.Exists(Properties.Settings.Default.SerializationFilesPath + CompanieAeriana.NumeFisierSerializare))
            {
                AirMoldova = CompanieAeriana.Deserialize();
            }
            else
            {
                AirMoldova = new CompanieAeriana("Air", "Chisinau", "0789856356", "*****@*****.**");
            }
            AirMoldova.GraphRute = new AdjacencyGraph <Aeroport, Edge <Aeroport> >();
            ThreadPool.SetMaxThreads(2, 2);
            ThreadPool.QueueUserWorkItem(obj => { Aeroport.LoadAeroporturi(); });
            ThreadPool.QueueUserWorkItem(obj => { AirMoldova.DeserializeazaDiscounturi(); });
            LoadRoutes();

            CurrentMainWindow = this;
            //Action LoadAeropAsync = new Action(Aeroport.LoadAeroporturi);
            //LoadAeropAsync.BeginInvoke(new AsyncCallback(result =>
            //{
            //    (result.AsyncState as Action).EndInvoke(result);

            //}), LoadAeropAsync);
        }
        public static CompanieAeriana Deserialize()
        {
            IFormatter      formatter       = new BinaryFormatter();
            FileStream      s               = new FileStream(Properties.Settings.Default.SerializationFilesPath + NumeFisierSerializare, FileMode.Open);
            CompanieAeriana companieAeriana = (CompanieAeriana)formatter.Deserialize(s);

            s.Close();
            return(companieAeriana);
        }
Example #3
0
 public StergeRuta(CompanieAeriana companieAeriana)
 {
     InitializeComponent();
     this.companie = companieAeriana;
     if (companie.Rute.Count > 0)
     {
         foreach (var ruta in companie.Rute)
         {
             cbRute.Items.Add(ruta.Key);
         }
         cbRute.SelectedIndex = 0;
     }
 }
 public ModificaRuta(CompanieAeriana companieAeriana)
 {
     InitializeComponent();
     this.companie        = companieAeriana;
     cbRute.DataSource    = companie.Rute.Keys.ToList();
     rbModifAerop.Checked = true;
     try
     {
         //this.BackgroundImage = new Bitmap(@"C:\Users\dimar\source\repos\Proiect_PAW\Proiect_PAW\Resources\Images\AirPlaneTakeOff.jpg");
         //this.BackgroundImage = new Bitmap(@"‪C:\Users\dimar\Downloads\Document.png");
     }
     catch
     {
         File.WriteAllText("debug.txt", "Unnable to open image C:\\Users\\dimar\\Downloads\\Document.png");
     }
 }
Example #5
0
 public DateCompanie(CompanieAeriana companie)
 {
     InitializeComponent();
     this.companie = companie;
     InitFields();
 }
 public ConfigurareDiscounts(CompanieAeriana companieAeriana)
 {
     InitializeComponent();
     this.companie = companieAeriana;
     InitDiscountTree();
 }
        private void btnModifica_Click(object sender, EventArgs e)
        {
            if (rbModifAerop.Checked == true)
            {
                var rutaModificata = dateRutaUsrControl1.GetRutaAeriana();
                if (companie.Rute.ContainsKey(rutaModificata))
                {
                    MessageBox.Show("Această rută modificată este deja deservită de către companie",
                                    "Eroare modificare rută", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                RutaAeriana rutaVeche;
                if ((rutaVeche = cbRute.SelectedItem as RutaAeriana) != null &&
                    companie.Rute[rutaVeche].Count == 0)
                {
                    //ruta veche o avem deja
                    SortedDictionary <DateTime, SortedDictionary <Zbor, Hashtable> > zboruriVechi = null;
                    try
                    {
                        zboruriVechi = companie.Rute[rutaVeche];
                    }
                    catch (KeyNotFoundException ex)
                    { File.WriteAllText("debug.txt", ex.Message); }
                    //stergem ruta veche din dictionar
                    companie.Rute.Remove(rutaVeche);
                    //introducem ruta modificata
                    companie.AdaugaRuta(rutaModificata, zboruriVechi);
                    //reactulizam data sources
                    cbRute.DataSource = null;
                    cbRute.Items.Clear();
                    cbRute.DataSource = companie.Rute.Keys.ToList();
                }
                else
                {
                    MessageBox.Show("Această rută nu poate fi modificată,deoarece pentru dinsa deja au fost " +
                                    "înregistrate zboruri,pentru care la rîndul lor au fost înregistrate rezervări",
                                    "Eroare modificare rută", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (rbModifZboruri.Checked == true)
            {
                var zborModificat = adaugaZboruriUsrControl1.GetZbor();
                if (zborModificat != null)
                {
                    cbRute.Enabled       = false;
                    cbDateZbor.Enabled   = false;
                    cbZboruri.Enabled    = false;
                    rbModifAerop.Enabled = false;
                    btnCancel.Enabled    = false;

                    RutaAeriana rutaAeriana = cbRute.SelectedItem as RutaAeriana;

                    try
                    {
                        if (companie.Rute[rutaAeriana]
                            [CompanieAeriana.ExtractDate(zborModificat.TimpDecolare)].
                            ContainsKey(zborModificat))
                        {
                            MessageBox.Show("Aceast zbor deja există în cadrul acestei rute",
                                            "Eroare modificare zbor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            btnModifica.Enabled = false;

                            cbRute.Enabled       = true;
                            cbDateZbor.Enabled   = true;
                            cbZboruri.Enabled    = true;
                            rbModifAerop.Enabled = true;
                            btnCancel.Enabled    = true;

                            return;
                        }
                    }
                    catch (KeyNotFoundException)
                    {
                        //daca data nu a fost gasita atunci sigur asa ruta nu exista in dictionar
                    }
                    //datele vechi
                    var zborVechi   = cbZboruri.SelectedItem as Zbor;
                    var rezervVechi = companie.Rute[rutaAeriana]
                                      [CompanieAeriana.ExtractDate(zborVechi.TimpDecolare)][zborVechi];
                    companie.Rute[rutaAeriana]
                    [CompanieAeriana.ExtractDate(zborVechi.TimpDecolare)].Remove(zborVechi);
                    //modificare date vechi
                    zborVechi.TimpAterizare = zborModificat.TimpAterizare;
                    zborVechi.TimpDecolare  = zborModificat.TimpDecolare;
                    //reinserare date noi
                    companie.AdaugaZbor(rutaAeriana, zborVechi, rezervVechi);
                    //reactualizare data sources
                    try
                    {
                        cbDateZbor.DataSource = null;
                        cbDateZbor.Items.Clear();
                        cbZboruri.DataSource = null;
                        cbZboruri.Items.Clear();


                        cbDateZbor.DataSource = companie.Rute[rutaAeriana].Keys.ToList();
                        cbZboruri.DataSource  = companie.Rute[rutaAeriana]
                                                [(DateTime)cbDateZbor.SelectedItem].Keys.ToList();
                    }
                    catch { }
                    btnModifica.Enabled = false;
                    adaugaZboruriUsrControl1.dateAterizare.Enabled = false;
                    adaugaZboruriUsrControl1.dateDecolare.Enabled  = false;

                    cbRute.Enabled       = true;
                    cbDateZbor.Enabled   = true;
                    cbZboruri.Enabled    = true;
                    rbModifAerop.Enabled = true;
                    btnCancel.Enabled    = true;
                }
            }
        }
 public AdaugaRuta(CompanieAeriana companie)
 {
     InitializeComponent();
     this.companie = companie;
 }