private void Form2_Load(object sender, EventArgs e) { //загрузили список сотрудников m_dbConn = new SQLiteConnection("Data Source=" + dbFileName + ";Version=3;"); m_sqlCmd = new SQLiteCommand(); m_dbConn.Open(); m_sqlCmd.Connection = m_dbConn; Insert_DGV.Add_worker(dataGridView1, m_dbConn);//вставка всех сотрудников в DGV1 }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { if (m_dbConn.State == ConnectionState.Closed) { m_dbConn.Open(); m_sqlCmd.Connection = m_dbConn; } string Id_work = dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString(); Insert_DGV.Add_worker(dataGridView2, m_dbConn, Id_work, textBox4); }
private void button1_Click(object sender, EventArgs e) { m_dbConn = new SQLiteConnection("Data Source=" + dbFileName + ";Version=3;"); m_sqlCmd = new SQLiteCommand(); if (m_dbConn.State == ConnectionState.Closed) { m_dbConn.Open(); } m_sqlCmd.Connection = m_dbConn; m_sqlCmd.CommandText = "INSERT INTO worker(name, date_nachalo, group_worker , rate)" + "VALUES(@name, @date_nachalo, @group_worker, @rate);"; m_sqlCmd.Parameters.AddWithValue("@name", textBox1.Text); m_sqlCmd.Parameters.AddWithValue("@date_nachalo", dateTimePicker1.Value.ToString("yyyy-MM-dd")); m_sqlCmd.Parameters.AddWithValue("@group_worker", comboBox1.Text); m_sqlCmd.Parameters.AddWithValue("@rate", textBox2.Text); m_sqlCmd.ExecuteNonQuery(); MessageBox.Show("Сотрудник добавлен"); Insert_DGV.Add_worker(dataGridView1, m_dbConn); this.Close(); }
private void Form3_Load(object sender, EventArgs e) { m_dbConn = new SQLiteConnection("Data Source=" + dbFileName + ";Version=3;"); m_sqlCmd = new SQLiteCommand(); if (m_dbConn.State == ConnectionState.Closed) { m_dbConn.Open(); } m_sqlCmd.Connection = m_dbConn; Insert_DGV.Add_worker(dataGridView1, m_dbConn);//вставка всех сотрудников в DGV1 if (m_dbConn.State == ConnectionState.Closed) { m_dbConn.Open(); } string sqlExpression = "SELECT id_worker FROM worker where name ='" + textBox_from_main.Text + "'"; SQLiteCommand command = new SQLiteCommand(sqlExpression, m_dbConn); object result = command.ExecuteScalar(); string Id_work = Convert.ToString(result); Insert_DGV.Add_worker(dataGridView2, m_dbConn, Id_work, textBox6); }