Example #1
0
        private void Mgonjwa_List_Load(object sender, EventArgs e)
        {
            // populate the datagridview with nurse data
            MySqlCommand command = new MySqlCommand("SELECT * FROM `mgonjwa`");

            dataGridView2.ReadOnly = true;
            DataGridViewImageColumn piCol = new DataGridViewImageColumn();

            dataGridView2.RowTemplate.Height = 80;
            dataGridView2.DataSource         = sick.getMgonjwa(command);
            piCol.ImageLayout = DataGridViewImageCellLayout.Zoom;
            dataGridView2.AllowUserToAddRows = false;
        }
        private void buttonFind_Click(object sender, EventArgs e)
        {
            sick sick = new sick();

            //search nurse by id
            try
            {
                int          id      = Convert.ToInt32(textBoxID.Text);
                MySqlCommand command = new MySqlCommand("SELECT `id`, `First_Name`, `Last_Name`, `Gender`, `Date_Of_Birth`, `Phone_Number`, `Address`, `Picture`, `Country`, `City`, `Email`, `Passport`, `Disease`, `Doctors_Name` FROM `mgonjwa` WHERE `id`=" + id);


                DataTable table = sick.getMgonjwa(command);

                if (table.Rows.Count > 0)
                {
                    textBoxFirstName.Text = table.Rows[0]["First_Name"].ToString();
                    textBoxLastName.Text  = table.Rows[0]["Last_Name"].ToString();

                    //gender
                    if (table.Rows[0]["Gender"].ToString() == "Female")
                    {
                        radioButtonFemale.Checked = true;
                    }
                    else
                    {
                        radioButtonMale.Checked = true;
                    }
                    dateTimePicker1.Value   = (DateTime)table.Rows[0]["Date_Of_Birth"];
                    textBoxPhoneNumber.Text = table.Rows[0]["Phone_Number"].ToString();
                    textBoxAddress.Text     = table.Rows[0]["Address"].ToString();

                    //image
                    byte[]       pic     = (byte[])table.Rows[0]["Picture"];
                    MemoryStream picture = new MemoryStream(pic);
                    pictureBox1.Image = Image.FromStream(picture);

                    textBoxCountry.Text     = table.Rows[0]["Country"].ToString();
                    textBoxCity.Text        = table.Rows[0]["City"].ToString();
                    textBoxEmail.Text       = table.Rows[0]["Email"].ToString();
                    textBoxPassport.Text    = table.Rows[0]["Passport"].ToString();
                    textBoxDisease.Text     = table.Rows[0]["Disease"].ToString();
                    textBoxDoctorsName.Text = table.Rows[0]["Doctors_Name"].ToString();
                }
            }
            catch
            {
                MessageBox.Show("Enter a Valid Patient ID", "Invalid ID", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }