private void StudentsListForm_Load(object sender, EventArgs e)
        {
            //ladowanie danych

            MySqlCommand command = new MySqlCommand("SELECT * FROM `students`");

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

            dataGridView1.RowTemplate.Height = 80;
            dataGridView1.DataSource         = studentClass.getStudents(command);
            gridViewImageColumn              = (DataGridViewImageColumn)dataGridView1.Columns[7];
            gridViewImageColumn.ImageLayout  = DataGridViewImageCellLayout.Stretch;
            dataGridView1.AllowUserToAddRows = false;
        }
Пример #2
0
        public void loadData(MySqlCommand command)
        {
            dataGridView1.ReadOnly = true;
            DataGridViewImageColumn gridViewImageColumn = new DataGridViewImageColumn();

            dataGridView1.RowTemplate.Height = 80;
            dataGridView1.DataSource         = studentClass.getStudents(command);
            gridViewImageColumn              = (DataGridViewImageColumn)dataGridView1.Columns[7];
            gridViewImageColumn.ImageLayout  = DataGridViewImageCellLayout.Stretch;
            dataGridView1.AllowUserToAddRows = false;
        }
        private void buttonFindStudent_Click(object sender, EventArgs e)
        {
            //przeszukiwanie

            try
            {
                int          id      = Convert.ToInt32(textBoxID.Text);
                MySqlCommand command = new MySqlCommand("SELECT `id`, `first_name`, `last_name`, `birthday`, `gender`, `phone`, `address`, `picture` FROM `students` WHERE `id` =" + id, db.getConnection);

                DataTable dataTable = studentClass.getStudents(command);

                if (dataTable.Rows.Count > 0)
                {
                    textBoxName.Text               = dataTable.Rows[0]["first_name"].ToString();
                    textBoxLastName.Text           = dataTable.Rows[0]["last_name"].ToString();
                    textBoxPhone.Text              = dataTable.Rows[0]["phone"].ToString();
                    textBoxAdres.Text              = dataTable.Rows[0]["address"].ToString();
                    dateTimePickerNewStudent.Value = (DateTime)dataTable.Rows[0]["birthday"];

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

                byte[]       picture = (byte[])dataTable.Rows[0]["picture"];
                MemoryStream pic     = new MemoryStream(picture);
                pictureBoxStudent.Image = Image.FromStream(pic);
            }catch
            {
                MessageBox.Show("Podaj poprawny numer ID", "Niepoprawny numer ID", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }