コード例 #1
0
 private void BtnAdresa_Click(object sender, EventArgs e)
 {
     if (filled)
     {
         if (dataGridViewClienti.SelectedRows.Count > 0)
         {
             PartnerModel client = new PartnerModel();
             foreach (DataGridViewRow row in dataGridViewClienti.SelectedRows)
             {
                 client.ClientId  = Convert.ToInt32(row.Cells[0].Value.ToString());
                 client.Nume      = row.Cells[1].Value.ToString();
                 client.Prenume   = row.Cells[2].Value.ToString();
                 client.CodClient = row.Cells[3].Value.ToString();
                 client.Telefon   = row.Cells[4].Value.ToString();
                 client.Email     = row.Cells[5].Value.ToString();
                 AddressModel adresa = new AddressModel();
                 adresa.PartnerId = Convert.ToInt32(Convert.ToInt32(row.Cells[0].Value.ToString()));
                 EditClientAddressForm form = new EditClientAddressForm(adresa, client);
                 form.Show();
             }
         }
         else
         {
             MessageBox.Show("Selectati clientul pentru a vedea adresele!", "Status", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Lista clieti goala! Efectuati o cautare!", "Status", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }
コード例 #2
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            BLClients blClients = new BLClients();

            if (String.IsNullOrWhiteSpace(tbNume.Text))
            {
                errorProvider1.SetError(tbNume, "Camp obligatoriu!");
            }
            else if (String.IsNullOrWhiteSpace(tbPrenume.Text))
            {
                errorProvider1.SetError(tbPrenume, "Camp obligatoriu!");
            }
            else if (String.IsNullOrWhiteSpace(tbCod.Text))
            {
                errorProvider1.SetError(tbCod, "Camp obligatoriu!");
            }
            else if (String.IsNullOrWhiteSpace(tbTelefon.Text))
            {
                errorProvider1.SetError(tbTelefon, "Camp obligatoriu!");
            }
            else
            {
                PartnerModel clientNou = new PartnerModel();
                string       nume      = tbNume.Text;
                clientNou.Nume = nume;
                string prenume = tbPrenume.Text;
                clientNou.Prenume = prenume;
                string cod = tbCod.Text;
                clientNou.CodClient = cod;
                string tel = tbTelefon.Text;
                clientNou.Telefon = tel;
                string email = tbEmail.Text;
                clientNou.Email = email;
                blClients.InsertUser(nume, prenume, cod, tel, email, out bool status, out string error);
                MessageBox.Show(error, "Status", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                form.initializareDataGridView();
                DialogResult dialogResult = MessageBox.Show("Doriti sa adaugati si adresa pentru clientul introdus?", "Adresa Client", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    AddressModel adresa = new AddressModel();
                    adresa.PartnerId = blClients.SelectPartnerId(nume, prenume, cod);
                    EditClientAddressForm form = new EditClientAddressForm(adresa, clientNou);
                    form.Show();
                }
                else if (dialogResult == DialogResult.No)
                {
                    this.Hide();
                }
            }
        }