Esempio n. 1
0
        public object Clone()
        {
            Candidat clona = (Candidat)this.MemberwiseClone();

            clona.cnp             = this.cnp;
            clona.cetatenie       = this.cetatenie;
            clona.nume            = this.nume;
            clona.initialaTatalui = this.initialaTatalui;
            clona.prenume         = this.prenume;
            clona.sex             = this.sex;
            clona.adresa          = this.adresa;
            clona.nrTelefon       = this.nrTelefon;
            clona.email           = this.email;
            return(clona);
        }
Esempio n. 2
0
        private void candidat_bt_Click(object sender, EventArgs e)
        {
            string cnp;
            string cetatenie;
            string nume;
            string initialaTatalui;
            string prenume;
            string sex;
            string adresa;
            string nrTelefon;
            string email;

            cnp             = cnp_tb.Text;
            cetatenie       = cetatenie_tb.Text;
            nume            = nume_tb.Text;
            initialaTatalui = initialaTatalui_tb.Text;
            prenume         = prenume_tb.Text;
            sex             = sex_cb.Text;
            adresa          = adresa_tb.Text;
            nrTelefon       = nrTelefon_tb.Text;
            email           = email_tb.Text;
            if (cnp.ToString().Length == 13 && adresa.Length > 5 && nrTelefon.Length == 10 && email.Length > 5)
            {
                Candidat        c          = new Candidat(cnp, cetatenie, nume, initialaTatalui, prenume, sex, adresa, nrTelefon, email);
                string          connString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = candidati.accdb";
                OleDbConnection conexiune  = new OleDbConnection(connString);
                OleDbCommand    candidat   = new OleDbCommand();
                candidat.Connection = conexiune;
                try
                {
                    conexiune.Open();
                    candidat.CommandText = "INSERT INTO candidati VALUES(?,?,?,?,?,?,?,?,?)";
                    candidat.Parameters.Add("cnp", OleDbType.Char, 14).Value             = cnp;
                    candidat.Parameters.Add("cetatenie", OleDbType.Char, 30).Value       = cetatenie;
                    candidat.Parameters.Add("nume", OleDbType.Char, 30).Value            = nume;
                    candidat.Parameters.Add("initiala_tatalui", OleDbType.Char, 3).Value = initialaTatalui;
                    candidat.Parameters.Add("prenume", OleDbType.Char, 30).Value         = prenume;
                    candidat.Parameters.Add("sex", OleDbType.Char, 10).Value             = sex;
                    candidat.Parameters.Add("adresa", OleDbType.Char, 60).Value          = adresa;
                    candidat.Parameters.Add("numar_telefon", OleDbType.Integer).Value    = nrTelefon;
                    candidat.Parameters.Add("email", OleDbType.Char, 40).Value           = email;
                    candidat.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    MessageBox.Show(c.ToString());
                    listaCandidat.Add(c);
                    conexiune.Close();
                    cnp_tb.Clear();
                    cetatenie_tb.Clear();
                    nume_tb.Clear();
                    initialaTatalui_tb.Clear();
                    prenume_tb.Clear();
                    adresa_tb.Clear();
                    nrTelefon_tb.Clear();
                    email_tb.Clear();
                }
            }
            else
            {
                MessageBox.Show("A fost detectata cel putin o eroare");
            }
        }