// button select the contact you want to edit from the list
        private void buttonSelectContact_Click(object sender, EventArgs e)
        {
            // open the form to select a contact from it
            Select_Contact_Form SelectContactF = new Select_Contact_Form();

            SelectContactF.ShowDialog();

            try
            {
                // get the contact id
                int contactId = Convert.ToInt32(SelectContactF.dataGridView1.CurrentRow.Cells[0].Value.ToString());

                CONTACT   contact = new CONTACT();
                DataTable table   = contact.GetContactById(contactId);

                textBoxContactId.Text       = table.Rows[0]["id"].ToString();
                textBoxFName.Text           = table.Rows[0]["fname"].ToString();
                textBoxLName.Text           = table.Rows[0]["lname"].ToString();
                comboBoxGroup.SelectedValue = table.Rows[0]["group_id"];
                textBoxPhone.Text           = table.Rows[0]["phone"].ToString();
                textBoxEmail.Text           = table.Rows[0]["email"].ToString();
                textBoxAddress.Text         = table.Rows[0]["address"].ToString();

                byte[]       pic     = (byte[])table.Rows[0]["pic"];
                MemoryStream picture = new MemoryStream(pic);
                pictureBoxContactImage.Image = Image.FromStream(picture);
            }
            catch (Exception)
            {
                // if no contact is selected
            }
        }
Exemplo n.º 2
0
        // button select contact to show a datagridview with contacts name and id to select one from it
        private void buttonSelectContact_Click(object sender, EventArgs e)
        {
            Select_Contact_Form SelectContactF = new Select_Contact_Form();

            SelectContactF.ShowDialog();

            try
            {
                TextBoxContactId.Text = SelectContactF.dataGridView1.CurrentRow.Cells[0].Value.ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("No Contact Selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }