コード例 #1
0
 private void AdaugaClient_Load(object sender, EventArgs e)
 {
     if (DBRepositoriesManager.OpenAirCompanyDB() == false)
     {
         MessageBox.Show("Can't open AirCompanyDB");
         Close();
         return;
     }
 }
コード例 #2
0
        private void modificaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ModificaClient modificaClient;

            foreach (ListViewItem clientItem in lvClienti.SelectedItems)
            {
                modificaClient        = new ModificaClient();
                modificaClient.Client = clientItem.Tag as Persoana;
                if (modificaClient.ShowDialog(this) == DialogResult.OK)
                {
                    var comanda         = new SqlCommand();
                    var clientModificat = modificaClient.Client;
                    comanda.CommandText = "UPDATE CLIENTI SET NUME=@nume,PRENUME=@prenume,EMAIL=@email," +
                                          "CETATENIE=@cetatenie," +
                                          "DATA_NASTERE=@data_nastere,NUMAR_PASAPORT=@nr_pasaport,TELEFON=@telefon," +
                                          "CNP=@cnp,SEX=@sex " +
                                          "WHERE CNP=@cnp_cautat";

                    comanda.Parameters.Add("@nume", SqlDbType.VarChar).Value      = clientModificat.Nume;
                    comanda.Parameters.Add("@prenume", SqlDbType.VarChar).Value   = clientModificat.Prenume;
                    comanda.Parameters.Add("@email", SqlDbType.VarChar).Value     = clientModificat.Email;
                    comanda.Parameters.Add("@cetatenie", SqlDbType.VarChar).Value = clientModificat.Cetatenie;
                    comanda.Parameters.Add("@data_nastere", SqlDbType.Date).Value = clientModificat.DataNastere.
                                                                                    ToString("yyyy-MM-dd");
                    comanda.Parameters.Add("@nr_pasaport", SqlDbType.VarChar).Value = clientModificat.NumarPasaport;
                    comanda.Parameters.Add("@telefon", SqlDbType.VarChar).Value     = clientModificat.Telefon;
                    comanda.Parameters.Add("@cnp", SqlDbType.VarChar).Value         = clientModificat.CNP;
                    comanda.Parameters.Add("@sex", SqlDbType.VarChar).Value         = clientModificat.Sex;
                    comanda.Parameters.Add("@cnp_cautat", SqlDbType.VarChar).Value  =
                        (clientItem.Tag as Persoana).CNP;

                    if (DBRepositoriesManager.AirCompanyDBExecuteNonQuerry(comanda) == -1)
                    {
                        MessageBox.Show("Eroare la actualizarea datelor pentru clientul " + clientModificat.CNP);
                        continue;
                    }
                    else
                    {
                        clientItem.Tag = clientModificat;
                        clientItem.SubItems.Clear();
                        clientItem.Text = clientModificat.Nume;
                        clientItem.SubItems.Add(clientModificat.Prenume);
                        clientItem.SubItems.Add(clientModificat.Cetatenie);
                        clientItem.SubItems.Add(clientModificat.NumarPasaport);
                        clientItem.SubItems.Add(clientModificat.DataNastere.ToShortDateString());
                        clientItem.SubItems.Add(clientModificat.CNP);
                        clientItem.SubItems.Add(clientModificat.Sex);
                        clientItem.SubItems.Add(clientModificat.Telefon);
                        clientItem.SubItems.Add(clientModificat.Email);
                        lvClienti.Refresh();
                    }
                }
            }
        }
コード例 #3
0
        private void stergeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem clientItem in lvClienti.SelectedItems)
            {
                var command = new SqlCommand();
                command.CommandText = "DELETE FROM CLIENTI WHERE CNP=@cnp_de_sters";
                command.Parameters.Add("@cnp_de_sters", SqlDbType.VarChar).Value = (clientItem.Tag as Persoana).CNP;

                if (DBRepositoriesManager.AirCompanyDBExecuteNonQuerry(command) != -1)
                {
                    lvClienti.Items.Remove(clientItem);
                }
            }
            lvClienti.Refresh();
        }
コード例 #4
0
        private void btnAdauga_Click(object sender, EventArgs e)
        {
            var client = clientUserControl1.Persoana;

            if (client != null)
            {
                if (DBRepositoriesManager.AirCompanyDBExecuteNonQuerry("INSERT INTO CLIENTI" +
                                                                       "(NUME,PRENUME,EMAIL,CETATENIE,DATA_NASTERE,NUMAR_PASAPORT,TELEFON,CNP,SEX) VALUES"
                                                                       + "('" + @client.Nume + "','" + @client.Prenume + "','" + @client.Email + "','" +
                                                                       @client.Cetatenie + "','" +
                                                                       @client.DataNastere.ToString("yyyy-MM-dd") + "','" + @client.NumarPasaport + "','" +
                                                                       @client.Telefon + "','" +
                                                                       @client.CNP + "','" + @client.Sex + "')") == -1)
                {
                    MessageBox.Show("Eroare la adaugarea noului client in baza de date");
                }
            }
        }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
 public Persoana(string CNP)
 {
     this.CNP = CNP;
     if (DBRepositoriesManager.IsOpen)
     {
         var p = DBRepositoriesManager.AirCompanyDBGetPersoana(CNP);
         if (p != null)
         {
             Nume          = p.Nume;
             Prenume       = p.Prenume;
             Email         = p.Email;
             Cetatenie     = p.Cetatenie;
             DataNastere   = p.DataNastere;
             NumarPasaport = p.NumarPasaport;
             Telefon       = p.Telefon;
             CNP           = p.CNP;
             Sex           = p.Sex;
             EsteClient    = p.EsteClient;
         }
     }
 }
コード例 #7
0
 protected override void OnClosing(CancelEventArgs e)
 {
     DBRepositoriesManager.CloseAirCompanyDB();
     base.OnClosing(e);
 }
コード例 #8
0
 private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
 {
     DBRepositoriesManager.CloseAirCompanyDB();
 }
コード例 #9
0
        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();
        }