예제 #1
0
        private void studentsListForm_Load(object sender, EventArgs e)
        {
            MySqlCommand command = new MySqlCommand("SELECT * FROM `student` ORDER BY `last_name`");

            dataGridView1.ReadOnly = true;
            DataGridViewImageColumn picCol = new DataGridViewImageColumn();

            dataGridView1.RowTemplate.Height = 80;
            dataGridView1.DataSource         = student.getStudents(command);
            picCol             = (DataGridViewImageColumn)dataGridView1.Columns[8];
            picCol.ImageLayout = DataGridViewImageCellLayout.Stretch;
            dataGridView1.AllowUserToAddRows = false;
        }
예제 #2
0
        public void fillGrid(MySqlCommand command)
        {
            dataGridView1.ReadOnly = true;
            DataGridViewImageColumn picCol = new DataGridViewImageColumn();

            dataGridView1.RowTemplate.Height = 80;
            dataGridView1.DataSource         = student.getStudents(command);

            picCol             = (DataGridViewImageColumn)dataGridView1.Columns[8];
            picCol.ImageLayout = DataGridViewImageCellLayout.Stretch;

            dataGridView1.AllowUserToAddRows = false;
        }
예제 #3
0
        private void buttonFind_Click(object sender, EventArgs e)
        {
            try
            {
                int          id      = Convert.ToInt32(textBoxID.Text);
                MySqlCommand command = new MySqlCommand("SELECT `id`, `first_name`, `last_name`, `clasa`, `birthdate`, `gender`, `phone`, `address`, `picture` FROM `student` WHERE `id`=" + id);

                DataTable table = student.getStudents(command);

                if (table.Rows.Count > 0)
                {
                    textBoxPrenume.Text = table.Rows[0]["first_name"].ToString();
                    textBoxNume.Text    = table.Rows[0]["last_name"].ToString();
                    comboBoxClasa.Text  = table.Rows[0]["clasa"].ToString();
                    textBoxTelefon.Text = table.Rows[0]["phone"].ToString();
                    textBoxAdresa.Text  = table.Rows[0]["address"].ToString();

                    dateTimePicker1.Value = (DateTime)table.Rows[0]["birthdate"];

                    if (table.Rows[0]["gender"].ToString() == "Female")
                    {
                        radioButtonFemale.Checked = true;
                    }
                    else
                    {
                        radioButtonMale.Checked = true;
                    }

                    byte[]       pic     = (byte[])table.Rows[0]["picture"];
                    MemoryStream picture = new MemoryStream(pic);
                    pictureBoxStudentImage.Image = Image.FromStream(picture);
                }
                else
                {
                    MessageBox.Show("Introduceți un ID valid", "ID invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBoxPrenume.Text          = "Prenume";
                    textBoxNume.Text             = "Nume";
                    textBoxTelefon.Text          = "Telefon";
                    comboBoxClasa.Text           = "";
                    textBoxAdresa.Text           = "Adresă";
                    dateTimePicker1.Value        = DateTime.Now;
                    pictureBoxStudentImage.Image = null;
                }
            }
            catch
            {
            }
        }