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); } }
private void signInButton_Click(object sender, EventArgs e) { databaseConnection database = new databaseConnection(); MySqlDataAdapter adapter = new MySqlDataAdapter(); DataTable table = new DataTable(); MySqlCommand command = new MySqlCommand("SELECT * FROM `authorization` WHERE " + "`login`= @usn AND `password` = @pass", database.getConnection); command.Parameters.Add("@usn", MySqlDbType.VarChar).Value = textBoxLogin.Text; command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = textBoxPass.Text; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count > 0) { MessageBox.Show("Добро пожаловать eSchool", "Спасибо что выбрали нас", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Не правильный логин или пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }