void fillTeacherKeyCombo() { iTeacherTableDB iTeacher = new iTeacherTableDB(); MySqlCommand command = new MySqlCommand("SELECT * FROM `iteacher`"); comboBoxfkT.DataSource = iTeacher.getTeachers(command); comboBoxfkT.DisplayMember = "id"; comboBoxfkT.ValueMember = "id"; comboBoxfkT.SelectedItem = null; this.comboBoxfkT.DropDownStyle = ComboBoxStyle.DropDownList; }
public void fillGrid(MySqlCommand command) { //тут список учителей будет DataGridViewImageColumn picCol = new DataGridViewImageColumn(); dataGridView1.RowTemplate.Height = 155; dataGridView1.DataSource = iTeacher.getTeachers(command); //11 колонка для изображения picCol = (DataGridViewImageColumn)dataGridView1.Columns[9]; picCol.ImageLayout = DataGridViewImageCellLayout.Stretch; //Показываю кол-во учителей labelTotalTeachers.Text = "Общая количество учителей: " + dataGridView1.Rows.Count; }
private void listTeacherForm_Load(object sender, EventArgs e) { //тут список учителей будет MySqlCommand command = new MySqlCommand("SELECT * FROM `iteacher`"); dataGridView1.ReadOnly = true; DataGridViewImageColumn picCol = new DataGridViewImageColumn(); dataGridView1.RowTemplate.Height = 150; dataGridView1.DataSource = iTeacher.getTeachers(command); //11 колонка для изображения picCol = (DataGridViewImageColumn)dataGridView1.Columns[11]; picCol.ImageLayout = DataGridViewImageCellLayout.Stretch; dataGridView1.AllowUserToAddRows = false; }
private void buttonFind_Click(object sender, EventArgs e) { try { int id = Convert.ToInt32(textBoxID.Text); databaseConnection db = new databaseConnection(); MySql.Data.MySqlClient.MySqlCommand command = new MySqlCommand("SELECT `id`, `surName`, `name`, `patronymic`, `gender`, `birthDate`, `address`, `mail`, `mobile`, `login`, `pass`, `teacherPic` FROM `iteacher` WHERE `id`=" + id, db.getConnection); DataTable table = iTeacher.getTeachers(command); if (table.Rows.Count > 0) { textBoxID.Text = table.Rows[0]["id"].ToString(); textBoxSname.Text = table.Rows[0]["surName"].ToString(); textBoxName.Text = table.Rows[0]["name"].ToString(); textBoxPname.Text = table.Rows[0]["patronymic"].ToString(); //пол if (table.Rows[0]["gender"].ToString() == "Female") { radioButtonFemale.Checked = true; } else { radioButtonMale.Checked = true; } dateTimePicker1.Value = (DateTime)table.Rows[0]["birthDate"]; textBoxAddress.Text = table.Rows[0]["address"].ToString(); textBoxMail.Text = table.Rows[0]["mail"].ToString(); textBoxMobile.Text = table.Rows[0]["mobile"].ToString(); textBoxLogin.Text = table.Rows[0]["login"].ToString(); textBoxPassword.Text = table.Rows[0]["pass"].ToString(); //тут его фотка byte[] pic = (byte[])table.Rows[0]["teacherPic"]; MemoryStream picture = new MemoryStream(pic); pictureBoxTeacherImage.Image = Image.FromStream(picture); } else { MessageBox.Show("Извините но такой код в нашей базе нету", "Ошибка в поисках", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show("Извините но такой код в нашей базе нету", "Ошибка в поисках", MessageBoxButtons.OK, MessageBoxIcon.Error); } }