private void button1_Click(object sender, EventArgs e) { string temp; if (user.Checked) { temp = "user"; } else { temp = "admin"; } SQLiteConnection scn = new SQLiteConnection(@"data source = main.db"); scn.Open(); SQLiteCommand sq = new SQLiteCommand("select count(password) from " + temp + " where password = '******' and username = '******'", scn); int num = Convert.ToInt32(sq.ExecuteScalar()); scn.Close(); if (num == 0) { MessageBox.Show("Invalid Password or Username", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (num == 1) { Main main = new Main(); if (temp == "admin") { Admin = true; main.newAdminUser.Enabled = true; } else { Admin = false; } if (Properties.Settings.Default.first == true) { ProductKey ProductKey = new ProductKey(); ProductKey.Show(); } else { main.Show(); this.Hide(); } } }
private void timer1_Tick(object sender, EventArgs e) { if (sec == 2) { if (Properties.Settings.Default.first == true) { ProductKey ProductKey = new ProductKey(); ProductKey.Show(); } else { Sqlite.LoadCompany(); Sqlite.LoadHeaderDataSet(); StartPage startpage = new StartPage(); startpage.username.Items.Insert(0, "--Select Username--"); startpage.username.SelectedIndex = 0; try { SQLiteConnection scn = new SQLiteConnection(@"data source = main.db"); scn.Open(); SQLiteCommand sq; sq = new SQLiteCommand("select * from user", scn); SQLiteDataReader dr = sq.ExecuteReader(); //int id = 1; while (dr.Read()) { startpage.username.Items.Add(dr["username"]); } scn.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } startpage.Show(); } timer1.Enabled = false; this.Hide(); } else { sec++; } }