private void button1_Click(object sender, EventArgs e) { SQLiteConnection Connect = new SQLiteConnection(@"Data Source=D:\4семестр\прПР\PaymentSystem\systemDb.db; Version=3;"); Connect.Open(); DataTable dTable = new DataTable(); string hours; string goods; string days; string sqlQuery; sqlQuery = string.Format("SELECT * FROM Records WHERE FIO=\"{0}\";", fioTB.Text); SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlQuery, Connect); adapter.Fill(dTable); if (dTable.Rows.Count > 0) { hours = dTable.Rows[0][2].ToString(); goods = dTable.Rows[0][3].ToString(); days = dTable.Rows[0][4].ToString(); } else { MessageBox.Show("There is no such employee"); return; } hours = (Convert.ToInt32(hours) + Convert.ToInt32(hoursTB.Text)).ToString(); goods = (Convert.ToInt32(goods) + Convert.ToInt32(goodsTB.Text)).ToString(); days = (Convert.ToInt32(days) + Convert.ToInt32(daysTB.Text)).ToString(); string updatecorect = "update Records set hoursWorked=\"" + hours + "\", goodsSold=\"" + goods + "\", lastVacation=\"" + days + "\" WHERE FIO=\"" + fioTB.Text + "\";"; SQLiteCommand updatec = new SQLiteCommand(updatecorect, Connect); updatec.ExecuteNonQuery(); string deleteStr = "DELETE FROM Reports WHERE report=\"" + reportTB.Text + "\";"; SQLiteCommand delete = new SQLiteCommand(deleteStr, Connect); delete.ExecuteNonQuery(); Connect.Close(); HighClassEmployeeMenu highRankMenu = new HighClassEmployeeMenu(); Hide(); highRankMenu.ShowDialog(); Close(); }
private void button1_Click(object sender, EventArgs e) { SQLiteConnection sql_con = new SQLiteConnection(@"Data Source=D:\4семестр\прПР\PaymentSystem\systemDb.db; Version=3;"); sql_con.Open(); string updatecorect = "update Reports set checked=\"true\", finished=\"false\" WHERE checked=\"false\";"; SQLiteCommand updatec = new SQLiteCommand(updatecorect, sql_con); updatec.ExecuteNonQuery(); sql_con.Close(); HighClassEmployeeMenu highRankMenu = new HighClassEmployeeMenu(); Hide(); highRankMenu.ShowDialog(); Close(); }
private void enterButton_Click(object sender, EventArgs e) { SQLiteConnection Connect = new SQLiteConnection(@"Data Source=D:\4семестр\прПР\PaymentSystem\systemDb.db; Version=3;"); Connect.Open(); DataTable dTable = new DataTable(); string login; string password; string sqlQuery; login = loginTextBox.Text; password = passwordTextBox.Text; if (login == "") { MessageBox.Show( "You have not entered a login", "Warning"); return; } if (password == "") { MessageBox.Show( "You have not entered a password", "Warning"); return; } sqlQuery = string.Format("SELECT * FROM User WHERE login=\"{0}\" AND password=\"{1}\";", login, password); SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlQuery, Connect); adapter.Fill(dTable); if (dTable.Rows.Count > 0) { User.id = dTable.Rows[0][0].ToString(); User.login = dTable.Rows[0][1].ToString(); User.password = dTable.Rows[0][2].ToString(); User.type = dTable.Rows[0][3].ToString(); } else { MessageBox.Show("No such user"); Connect.Close(); return; } Connect.Close(); switch (User.type) { case "1": LowClassEmployeeMenu lowRankMenu = new LowClassEmployeeMenu(); Hide(); lowRankMenu.ShowDialog(); Close(); break; case "2": AdministratorMenu adminMenu = new AdministratorMenu(); Hide(); adminMenu.ShowDialog(); Close(); break; case "3": HighClassEmployeeMenu highRankMenu = new HighClassEmployeeMenu(); Hide(); highRankMenu.ShowDialog(); Close(); break; default: AdministratorMenu menu = new AdministratorMenu(); Hide(); menu.ShowDialog(); Close(); break; } }