Пример #1
0
        private void LoadClienti()
        {
            var query = "SELECT * FROM Clienti";

            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                var command = new SQLiteCommand(query, connection);
                connection.Open();

                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        long   id           = (long)reader["ID"];
                        string nume         = (string)reader["Nume"];
                        string prenume      = (string)reader["Prenume"];
                        string telefon      = (string)reader["Telefon"];
                        string adresa       = (string)reader["Adresa"];
                        string serieBuletin = (string)reader["SerieBuletin"];
                        string dataNasterii = (string)reader["DataNasterii"];
                        String cnp          = reader["CNP"].ToString();

                        long.TryParse(cnp, out long CNP);

                        Clienti local = new Clienti(id, nume, prenume, adresa, CNP, serieBuletin, dataNasterii, telefon);
                        listaClienti.Add(local);
                    }
                }
            }
        }
Пример #2
0
        private void AddClient(Clienti clienti)
        {
            string sql = "INSERT INTO Clienti(Nume, Prenume, Adresa, SerieBuletin,CNP,Telefon,DataNasterii) "
                         + " VALUES(@nume,@prenume,@adresa,@telefon,@cnp,@serieBuletin,@dataNasterii);" + " SELECT last_insert_rowid();";

            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                var command = new SQLiteCommand(sql, connection);
                command.Parameters.AddWithValue("@nume", clienti.Nume);
                command.Parameters.AddWithValue("@prenume", clienti.Prenume);
                command.Parameters.AddWithValue("@adresa", clienti.Adresa);
                command.Parameters.AddWithValue("@telefon", clienti.Telefon);
                command.Parameters.AddWithValue("@cnp", clienti.CNP);
                command.Parameters.AddWithValue("@serieBuletin", clienti.SerieBuletin);
                command.Parameters.AddWithValue("@dataNasterii", clienti.DataNasterii);

                connection.Open();
                long id = (long)command.ExecuteScalar();
                clienti.ID = id;

                try
                {
                    listaClienti.Add(clienti);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #3
0
 private void btAsigurare_Click(object sender, EventArgs e)
 {
     if (lvClienti.CheckedItems.Count != 1)
     {
         MessageBox.Show("Va rugam sa bifati doar o inregistrare", "Avertisment");
     }
     else
     {
         Clienti       client    = listaClienti.ElementAt(lvClienti.CheckedIndices[0]);
         AsigurareForm asigurare = new AsigurareForm(client);
         asigurare.ShowDialog();
     }
 }
Пример #4
0
 private void btLBEdit_Click(object sender, EventArgs e)
 {
     if (listBox.SelectedItems.Count != 0)
     {
         local               = listaClienti.ElementAt(listBox.SelectedIndices[0]);
         uc1.tbNume.Text     = local.Nume;
         tbPrenume.Text      = local.Prenume;
         tbAdresa.Text       = local.Adresa;
         tbTelefon.Text      = local.Telefon;
         tbCNP.Text          = local.CNP.ToString();
         dtpNastere.Text     = local.DataNasterii;
         tbSerieBuletin.Text = local.SerieBuletin;
     }
 }
Пример #5
0
        private void btSalveaza_Click(object sender, EventArgs e)
        {
            int.TryParse(tbNrNod.Text, out int loc);
            Clienti local = localList.ElementAt(loc - 1);

            local.Adresa       = tbAdresa.Text;
            local.Nume         = tbNume.Text;
            local.Prenume      = tbPrenume.Text;
            local.SerieBuletin = tbSerieBuletin.Text;
            local.Telefon      = tbTelefon.Text;
            long.TryParse(tbCNP.Text, out long CNP);
            local.CNP = CNP;

            populareTV();
        }
Пример #6
0
 public int CompareTo(object obj)
 {
     if (obj == null)
     {
         return(-1);
     }
     else
     {
         Clienti persoana = obj as Clienti;
         if (persoana.Nume != null)
         {
             return(this.Nume.CompareTo(persoana.Nume));
         }
         else
         {
             throw new ArgumentException("Object ul nu este client");
         }
     }
 }
Пример #7
0
        public object Clone()
        {
            Clienti c = new Clienti();

            c.Nume           = this.Nume;
            c.Prenume        = this.Prenume;
            c.SerieBuletin   = this.SerieBuletin;
            c.DataNasterii   = this.DataNasterii;
            c.CNP            = this.CNP;
            c.Telefon        = this.Telefon;
            c.listaAsigurari = new List <Asigurari>();
            c.Adresa         = this.Adresa;
            foreach (Asigurari each in this.listaAsigurari)
            {
                c.listaAsigurari.Add(each);
            }

            return(c);
        }
Пример #8
0
        private void panel1_DragDrop(object sender, DragEventArgs e)
        {
            string[] filePath = e.Data.GetData(DataFormats.FileDrop, false) as string[];

            foreach (String path in filePath)
            {
                string[] content = File.ReadAllLines(path);

                localList.Clear();
                foreach (String line in content)
                {
                    string[] token = line.Split(new String[] { "  |  " }, StringSplitOptions.None);

                    Clienti local = new Clienti();

                    local.Nume         = token[0];
                    local.Prenume      = token[1];
                    local.SerieBuletin = token[2];
                    local.Telefon      = token[3];
                    local.Adresa       = token[4];
                    long.TryParse(token[5], out long cnp);
                    local.CNP          = cnp;
                    local.DataNasterii = token[6];


                    localList.Add(local);
                }
                dataGridView1.Rows.Clear();
                foreach (Clienti each in localList)
                {
                    dataGridView1.Rows.Add(new String[] {
                        each.Nume,
                        each.Prenume,
                        each.Adresa,
                        each.Telefon,
                        each.CNP.ToString(),
                        each.SerieBuletin,
                        each.DataNasterii
                    });
                }
            }
        }
Пример #9
0
        private void btAdauga_Click(object sender, EventArgs e)
        {
            bool OK = true;

            foreach (Clienti each in listaClienti)
            {
                if (each.CNP.ToString() == tbCNP.Text)
                {
                    OK = false;
                }
            }
            if (OK == true)
            {
                String nume        = uc1.tbNume.Text;
                String prenume     = tbPrenume.Text;
                String adresa      = tbAdresa.Text;
                String serieBuletn = tbSerieBuletin.Text;
                long.TryParse(tbCNP.Text, out long CNP);
                String telefon      = tbTelefon.Text;
                String dataNasterii = dtpNastere.Text;

                Clienti local  = new Clienti(nume, prenume, adresa, CNP, serieBuletn, dataNasterii, telefon);
                var     op     = new Operation();
                var     dition = new Addition();

                local.add += op.OnOperation;
                local.add += dition.OnOperation;

                local.OnOperation();

                //listaClienti.Add(local);
                AddClient(local);
                populareLV();
            }
            else
            {
                MessageBox.Show("Clientul exista deja in lista", "Avertisment");
            }
        }
Пример #10
0
        private void btEditare_Click(object sender, EventArgs e)
        {
            if (lvClienti.CheckedItems.Count != 1)
            {
                MessageBox.Show("Va rugam sa bifati doar o inregistrare", "Avertisment");
            }
            else
            {
                bool OK = false;
                while (OK == false)
                {
                    Clienti            client  = listaClienti.ElementAt(lvClienti.CheckedIndices[0]);
                    EditareClientiForm editare = new EditareClientiForm(client);
                    editare.ShowDialog();
                    OK = true;
                    foreach (Clienti each in listaClienti)
                    {
                        if (each != client)
                        {
                            if (each.CNP == client.CNP)
                            {
                                OK = false;
                            }
                        }
                    }

                    if (OK == true)
                    {
                        populareLV();
                    }
                    else
                    {
                        MessageBox.Show("CNP identic cu al altui client, va rugam modificati", "Avertisment");
                    }
                }
            }
        }
Пример #11
0
 public AsigurareForm(Clienti c)
 {
     InitializeComponent();
     local = c;
     populareListViewAsigurari();
 }
Пример #12
0
 public EditareClientiForm(Clienti c)
 {
     InitializeComponent();
     local = c;
 }
Пример #13
0
 public void OnOperation(Clienti clienti)
 {
     Console.WriteLine("Clientul " + clienti.ID + " " + clienti.Nume + " " + clienti.Prenume + " a fost asigurat\n");
 }
Пример #14
0
 public void OnOperation(Clienti clienti)
 {
     Console.WriteLine("Clientul " + clienti.Nume + " " + clienti.Prenume + " se asigura");
     Console.WriteLine("Please wait...");
     Thread.Sleep(3000);
 }