コード例 #1
0
        private void dgContacts_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgContacts.Columns[e.ColumnIndex].Name == "Supprimer")
            {
                if (MessageBox.Show("Voulez vous supprimer ce contact ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    int id = int.Parse(dgContacts.CurrentRow.Cells[4].Value.ToString());
                    service.deleteContact(id);
                    loadData();
                }
            }

            if (dgContacts.Columns[e.ColumnIndex].Name == "modifier")
            {
                getId = int.Parse(dgContacts.CurrentRow.Cells[4].Value.ToString());

                selectedIndex = true;

                frmAjoutContact f = new frmAjoutContact();

                f.txtPrenom.Text = dgContacts.CurrentRow.Cells[6].Value.ToString();
                f.txtNom.Text    = dgContacts.CurrentRow.Cells[5].Value.ToString();
                f.txtCsp.Text    = dgContacts.CurrentRow.Cells[3].Value.ToString();
                f.cbbSexe.Text   = dgContacts.CurrentRow.Cells[7].Value.ToString();
                f.txtVille.Text  = dgContacts.CurrentRow.Cells[8].Value.ToString();

                f.Show();
            }
        }
コード例 #2
0
        private void btnAjouterContact_Click(object sender, EventArgs e)
        {
            frmAjoutContact f = new frmAjoutContact();

            f.Show();
        }