private void AdaugaClient_Load(object sender, EventArgs e) { if (DBRepositoriesManager.OpenAirCompanyDB() == false) { MessageBox.Show("Can't open AirCompanyDB"); Close(); return; } }
private void GestioneazaClienti_Load(object sender, EventArgs e) { if (DBRepositoriesManager.OpenAirCompanyDB() == false) { MessageBox.Show("Eroare la deschiderea bazei de date"); Close(); return; } var DbReader = DBRepositoriesManager.AirCompanyDBExecuteReader("SELECT * from CLIENTI"); if (DbReader == null) { MessageBox.Show("Eroare la citirea datelor din baza de date"); Close(); return; } using (DbReader) { while (DbReader.Read()) { var client = new Persoana(DbReader["NUME"].ToString(), DbReader["PRENUME"].ToString(), DbReader["EMAIL"].ToString(), DbReader["CETATENIE"].ToString(), ((DateTime)DbReader["DATA_NASTERE"]), DbReader["NUMAR_PASAPORT"].ToString(), DbReader["TELEFON"].ToString(), DbReader["CNP"].ToString(), DbReader["SEX"].ToString()); var ClientItem = new ListViewItem(client.Nume); ClientItem.SubItems.Add(client.Prenume); ClientItem.SubItems.Add(client.Cetatenie); ClientItem.SubItems.Add(client.NumarPasaport); ClientItem.SubItems.Add(client.DataNastere.ToShortDateString()); ClientItem.SubItems.Add(client.CNP); ClientItem.SubItems.Add(client.Sex); ClientItem.SubItems.Add(client.Telefon); ClientItem.SubItems.Add(client.Email); ClientItem.Tag = client; lvClienti.Items.Add(ClientItem); } } foreach (ColumnHeader column in lvClienti.Columns) { column.Width = -1; } }
public void CitesteRuteXML() { if (!DBRepositoriesManager.OpenAirCompanyDB()) { System.Windows.Forms.MessageBox.Show("Eroare la deschiderea bazei de date", "Eroare deschidere baza de date", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } XmlDocument document = new XmlDocument(); try { document.Load(@Properties.Settings.Default.SerializationFilesPath + "RuteAeriene.xml"); } catch (FileNotFoundException) { System.Windows.Forms.MessageBox.Show("Unnable to open rute.xml"); return; } this.rute.Clear(); RutaAeriana ruta; Hashtable TabelaRezervari; SortedDictionary <DateTime, SortedDictionary <Zbor, Hashtable> > DicInfoRute; DateTime data; SortedDictionary <Zbor, Hashtable> DicZboruri; //nivelul cu rute foreach (XmlNode rutaNode in document.DocumentElement.ChildNodes) { //alocare dictionar pentru ruta DicInfoRute = new SortedDictionary <DateTime, SortedDictionary <Zbor, Hashtable> >(); //alocare ruta ruta = new RutaAeriana(new Aeroport(rutaNode.Attributes["numeAeropDec"]?.InnerText, rutaNode.Attributes["orasDec"]?.InnerText, rutaNode.Attributes["taraDec"]?.InnerText, rutaNode.Attributes["codIATAAeropDec"]?.InnerText, rutaNode.Attributes["codICAOAeropDec"]?.InnerText), new Aeroport(rutaNode.Attributes["numeAeropAter"]?.InnerText, rutaNode.Attributes["orasAter"]?.InnerText, rutaNode.Attributes["taraAter"]?.InnerText, rutaNode.Attributes["codIATAAeropAter"]?.InnerText, rutaNode.Attributes["codICAOAeropAter"]?.InnerText)); //nivelul cu zboruri pentru o data anumita foreach (XmlNode dataNode in rutaNode.ChildNodes) { //alocare data data = DateTime.ParseExact(dataNode.Attributes["data"]?.InnerText, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); DicZboruri = new SortedDictionary <Zbor, Hashtable>(); //nivelul cu zboruri foreach (XmlNode zborNode in dataNode.ChildNodes) { //alocam tabela de rezervari pentru zborul curent TabelaRezervari = new Hashtable(); Zbor zbor = new Zbor(DateTime.ParseExact(zborNode.Attributes["dataPlecare"]?.InnerText, "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture) , DateTime.ParseExact(zborNode.Attributes["dataSosire"]?.InnerText, "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture) , float.Parse(zborNode.Attributes["cost"]?.InnerText), int.Parse(zborNode.Attributes["nrLocuriDisponibile"]?.InnerText)); zbor.NumarLocuri = int.Parse(zborNode.Attributes["nrLocuriTotal"]?.InnerText); foreach (XmlNode rezervareNode in zborNode.ChildNodes) { var rezervare = new Rezervare( ruta, zbor, int.Parse(rezervareNode.Attributes["nrBilete"]?.InnerText), //new Persoana(rezervareNode.Attributes["persoana"]?.InnerText)); DBRepositoriesManager.AirCompanyDBGetPersoana(rezervareNode.Attributes["persoana"]?.InnerText)); TabelaRezervari.Add(rezervare.Rezervant.CNP, rezervare); } DicZboruri.Add(zbor, TabelaRezervari); } DicInfoRute.Add(data, DicZboruri); } //adauga ruta cu dictionarul ei in Rutele Companiei this.rute.Add(ruta, DicInfoRute); } DBRepositoriesManager.CloseAirCompanyDB(); }