public Boolean isUserExists() { DB db = new DB(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("select * " + "from adres where company_id = @uL", db.getConnection()); command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = textBox1_ind.Text; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count > 0) { MessageBox.Show("Имя занято"); return(true); } else { return(false); } }
private void buttonRegister_Click(object sender, EventArgs e) { DateTime dt1 = dateTimePicker1.Value; DateTime dt2 = dateTimePicker2.Value; if (textBox1_ind.Text.Contains(' ') || textBox1_obl.Text.Contains(' ')) { MessageBox.Show("Введите корректные значения"); return; } else if (textBox1_ind.Text == "id сотрудника" || textBox1_obl.Text == "id документа") { MessageBox.Show("Введите данные"); return; } DB db = new DB(); MySqlCommand command = new MySqlCommand("INSERT INTO `oborot`.`HISTORY` (`Дата_Получения`, `SOTRUDNIK_id`, `DOKUMENT_id`," + " `Дата_Отправки`)" + " VALUES (@otch, @name, @surname, @pol)", db.getConnection()); command.Parameters.Add("@name", MySqlDbType.VarChar).Value = textBox1_ind.Text; command.Parameters.Add("@surname", MySqlDbType.VarChar).Value = textBox1_obl.Text; command.Parameters.Add("@otch", MySqlDbType.Date).Value = dt1; command.Parameters.Add("@pol", MySqlDbType.Date).Value = dt2; db.openConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Запись добавлена"); } else { MessageBox.Show("Запись не добавлена"); } db.closeConnection(); }
public Boolean isExistsDoc() { DB db = new DB(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("select * " + "from work_user_doc where doc_id = @uL", db.getConnection()); command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = textBox2.Text; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count > 0) { return(false); } else { MessageBox.Show("Документ не принят в работу"); return(true); } }
public Boolean isUserExists() { DB db = new DB(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("select * from gotov_doc where `doc_id` = @uL", db.getConnection()); command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = textBox2.Text; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count > 0) { MessageBox.Show("Документ занят"); return(true); } else { return(false); } }
private void buttonRegister_Click(object sender, EventArgs e) { if (textBox1.Text.Contains(' ') || textBox2.Text.Contains(' ') || textBox3.Text.Contains(' ')) { MessageBox.Show("Введите корректные значения"); return; } else if (textBox1.Text == "Время входа" || textBox2.Text == "Время выхода" || textBox2.Text == "Логин пользователя") { MessageBox.Show("Введите данные"); return; } DB db = new DB(); MySqlCommand command1 = new MySqlCommand("INSERT INTO session " + "SET `Вход` = @vh, `Выход` = @vhd," + " users_id = (SELECT id FROM users WHERE `Логин` = @log)", db.getConnection()); command1.Parameters.Add("@vh", MySqlDbType.VarChar).Value = textBox1.Text; command1.Parameters.Add("@vhd", MySqlDbType.VarChar).Value = textBox2.Text; command1.Parameters.Add("@log", MySqlDbType.VarChar).Value = textBox3.Text; db.openConnection(); if (command1.ExecuteNonQuery() == 1) { MessageBox.Show("Запись добавлена"); } else { MessageBox.Show("Запись не добавлена"); } db.closeConnection(); }