public static int AirCompanyDBAddRezervant(Persoana persoana) { if (DBConnection.State == System.Data.ConnectionState.Open) { DBCommand.CommandText = "INSERT INTO REZERVANTI" + "(NUME,PRENUME,EMAIL,CETATENIE,DATA_NASTERE,NUMAR_PASAPORT,TELEFON,CNP,SEX) VALUES" + "('" + persoana.Nume + "','" + persoana.Prenume + "','" + persoana.Email + "','" + persoana.Cetatenie + "','" + persoana.DataNastere.ToString("yyyy-MM-dd") + "','" + persoana.NumarPasaport + "','" + persoana.Telefon + "','" + persoana.CNP + "','" + persoana.Sex + "')"; DBCommand.Connection = DBConnection; try { return(DBCommand.ExecuteNonQuery()); } catch (Exception ex) { File.AppendAllText(SQLExeptionsFile.FullName, Environment.NewLine + DateTime.Now.ToString() + Environment.NewLine + ex.Message, Encoding.Unicode); return(-1); } } return(-1); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (this.GetType() != obj.GetType()) { return(false); } if (ReferenceEquals(this, obj)) { return(true); } if (this.GetHashCode() != obj.GetHashCode()) { return(false); } Persoana persoana = obj as Persoana; return(Nume.Equals(persoana.Nume) && Prenume.Equals(persoana.Prenume) && Email.Equals(persoana.Email) && Cetatenie.Equals(persoana.Cetatenie) && DataNastere.Equals(persoana.DataNastere) && NumarPasaport.Equals(persoana.NumarPasaport) && Telefon.Equals(persoana.Telefon) && CNP.Equals(persoana.CNP) && Sex.Equals(persoana.Sex)); }
public int CompareTo(object obj) { if (obj == null) { return(1); } Persoana persoana = obj as Persoana; if (persoana != null) { var compData = DataNastere.CompareTo(persoana.DataNastere); if (compData == 0) { return(CNP.CompareTo(persoana.CNP)); } else { return(compData); } } else { throw new ArgumentException("Object is not a " + this.GetType()); } }
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { if (Clipboard.ContainsData(Persoana.FormatClipboard)) { Persoana = (Persoana)Clipboard.GetData(Persoana.FormatClipboard); } }
public Rezervare(RutaAeriana ruta, ZborBasic zbor, int nrBilete, Persoana persoana) { RutaAeriana = ruta; Zbor = zbor; NumarBilete = nrBilete; Rezervant = persoana; }
public Persoana(Persoana p) { 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; }
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 static Persoana AirCompanyDBGetPersoana(string CNP) { if (DBConnection.State == System.Data.ConnectionState.Open) { try { Persoana p; SqlCommand commandClienti = new SqlCommand(); commandClienti.Connection = DBConnection; commandClienti.CommandText = "SELECT * FROM CLIENTI WHERE CNP='" + CNP + "'"; //commandClienti.Parameters.Add("@cnp_cautatGetPers", SqlDbType.VarChar).Value = CNP; using (var readerClient = commandClienti.ExecuteReader()) { if (readerClient.HasRows) { readerClient.Read(); p = new Persoana(); p.Nume = readerClient["NUME"].ToString(); p.Prenume = readerClient["PRENUME"].ToString(); p.Email = readerClient["EMAIL"].ToString(); p.Cetatenie = readerClient["CETATENIE"].ToString(); p.DataNastere = (DateTime)readerClient["DATA_NASTERE"]; p.NumarPasaport = readerClient["NUMAR_PASAPORT"].ToString(); p.Telefon = readerClient["TELEFON"].ToString(); p.CNP = readerClient["CNP"].ToString(); p.Sex = readerClient["SEX"].ToString(); p.EsteClient = true; return(p); } } SqlCommand rezCommand = new SqlCommand(); rezCommand.Connection = DBConnection; rezCommand.CommandText = "SELECT * FROM REZERVANTI WHERE CNP=@cnp_cautat"; rezCommand.Parameters.Add("@cnp_cautat", SqlDbType.VarChar).Value = CNP; using (var readerRezervant = rezCommand.ExecuteReader()) { if (readerRezervant.HasRows == false) { return(null); } else { readerRezervant.Read(); p = new Persoana(); p.Nume = readerRezervant["NUME"].ToString(); p.Prenume = readerRezervant["PRENUME"].ToString(); p.Email = readerRezervant["EMAIL"].ToString(); p.Cetatenie = readerRezervant["CETATENIE"].ToString(); p.DataNastere = (DateTime)readerRezervant["DATA_NASTERE"]; p.NumarPasaport = readerRezervant["NUMAR_PASAPORT"].ToString(); p.Telefon = readerRezervant["TELEFON"].ToString(); p.CNP = readerRezervant["CNP"].ToString(); p.Sex = readerRezervant["SEX"].ToString(); p.EsteClient = false; return(p); } } } catch (Exception ex) { File.AppendAllText(SQLExeptionsFile.FullName, Environment.NewLine + DateTime.Now.ToString() + Environment.NewLine + ex.Message, Encoding.Unicode); throw ex; } } else { System.Windows.Forms.MessageBox.Show("Eroare la citirea persoanei din baza de date", "Baza de date nu a fost deschisa", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); throw new Exception("Baza de date nu a fost deschisa"); } }