private void button1_Click(object sender, EventArgs e) { AdminMenu adminMenu = new AdminMenu(); this.Hide(); adminMenu.ShowDialog(this);//Interface conversion function }
private void button1_Click(object sender, EventArgs e) { timer1.Enabled = true; HomePage homePage = new HomePage(textBox1.Text); //open the database connection DBConnect(); strsql = string.Format("insert into Voting(VoteName,Time,VoterLimit,CandidateNum,Statement) values('{0}','{1}','{2}','{3}',1)", textBox2.Text, textBox1.Text, comboBox1.Text, comboBox2.Text); MessageBox.Show(strsql); //show message command = new SqlCommand(strsql, mycon); //Specify the SQL statement to execute try { command.ExecuteScalar();//Loop the entire object MessageBox.Show("Save successful"); AdminMenu adminMenu = new AdminMenu(); this.Hide(); adminMenu.ShowDialog(this);//Interface conversion function } catch { MessageBox.Show("Save failed");//show message } finally { mycon.Close();//close the connection } }
private void button1_Click_1(object sender, EventArgs e) { AdminMenu adminMenu = new AdminMenu(); this.Hide(); adminMenu.ShowDialog(this); }
private void button1_Click(object sender, EventArgs e) { timer1.Enabled = true; HomePage homePage = new HomePage(textBox1.Text); DBConnect(); strsql = string.Format("insert into Voting(VoteName,Time,VoterLimit,CandidateNum,Statement) values('{0}','{1}','{2}','{3}',1)", textBox2.Text, textBox1.Text, comboBox1.Text, comboBox2.Text); MessageBox.Show(strsql); command = new SqlCommand(strsql, mycon); try { command.ExecuteScalar(); MessageBox.Show("Save successful"); AdminMenu adminMenu = new AdminMenu(); this.Hide(); adminMenu.ShowDialog(this); } catch { MessageBox.Show("Save failed"); } finally { mycon.Close(); } }
private void button2_Click(object sender, EventArgs e) { AdminMenu adminMenu = new AdminMenu(); this.Hide(); adminMenu.ShowDialog(this); timer1.Stop(); }
private void button1_Click(object sender, EventArgs e) { if (LoginInfo.CurrentUser.UserName == "admin1") { AdminMenu adminMenu = new AdminMenu(); this.Hide(); adminMenu.ShowDialog(this); } else { HomePage homePage = new HomePage(); this.Hide(); homePage.ShowDialog(this); } }
private void button1_Click(object sender, EventArgs e) { if (check() && DBConnect()) { if (VoterradioButton.Text == "Voter" && VoterradioButton.Checked) { strsql = string.Format("select count (*) from Voter where Name = '{0}' and Password = '******'", UserNametextBox.Text, PasswordBox.Text); command = new SqlCommand(strsql, mycon); try { int result = Convert.ToInt32(command.ExecuteScalar()); if (result > 0) { MessageBox.Show("successful login"); LoginInfo.CurrentUser.UserName = UserNametextBox.Text; HomePage HomePage = new HomePage(); this.Hide(); HomePage.ShowDialog(this); } else { MessageBox.Show("Login failed"); } } catch { MessageBox.Show("Sql error"); } } else if (AuditorradioButton.Text == "Auditor" && AuditorradioButton.Checked) { strsql = string.Format("select count (*) from Auditor where Name = '{0}' and Password = '******'", UserNametextBox.Text, PasswordBox.Text); command = new SqlCommand(strsql, mycon); try { int result = Convert.ToInt32(command.ExecuteScalar()); if (result > 0) { MessageBox.Show("successful login"); LoginInfo.CurrentUser.UserName = UserNametextBox.Text; AuditorChoose auditorMenu = new AuditorChoose(); this.Hide(); auditorMenu.ShowDialog(this); } else { MessageBox.Show("Login failed"); } } catch { MessageBox.Show("Sql error"); } } else if (AdminradioButton.Text == "Admin" && AdminradioButton.Checked) { strsql = string.Format("select count (*) from Admin where Name = '{0}' and Password = '******'", UserNametextBox.Text, PasswordBox.Text); command = new SqlCommand(strsql, mycon); try { int result = Convert.ToInt32(command.ExecuteScalar()); if (result > 0) { MessageBox.Show("successful login"); LoginInfo.CurrentUser.UserName = UserNametextBox.Text; AdminMenu adminmenu = new AdminMenu(); this.Hide(); adminmenu.ShowDialog(this); } else { MessageBox.Show("Login failed"); } } catch { MessageBox.Show("Sql error"); } } } }
private void button1_Click(object sender, EventArgs e) { if (check() && DBConnect()) //check the database connection { if (VoterradioButton.Text == "Voter" && VoterradioButton.Checked) //check the text is correct { strsql = string.Format("select count (*) from Voter where Name = '{0}' and Password = '******'", UserNametextBox.Text, PasswordBox.Text); command = new SqlCommand(strsql, mycon);//Specify the SQL statement to execute try { int result = Convert.ToInt32(command.ExecuteScalar()); if (result > 0) { MessageBox.Show("successful login"); //if username and password are correct, show successful login in the messagebox LoginInfo.CurrentUser.UserName = UserNametextBox.Text;//check the text correct HomePage HomePage = new HomePage(); this.Hide(); HomePage.ShowDialog(this); //Interface conversion function } else { MessageBox.Show("Login failed");//show results } } catch { MessageBox.Show("Sql error");//show results } } else if (AuditorradioButton.Text == "Auditor" && AuditorradioButton.Checked)//check the text are correct { strsql = string.Format("select count (*) from Auditor where Name = '{0}' and Password = '******'", UserNametextBox.Text, PasswordBox.Text); command = new SqlCommand(strsql, mycon); //Specify the SQL statement to execute try { int result = Convert.ToInt32(command.ExecuteScalar()); if (result > 0) { MessageBox.Show("successful login"); LoginInfo.CurrentUser.UserName = UserNametextBox.Text; AuditorChoose auditorMenu = new AuditorChoose(); this.Hide(); auditorMenu.ShowDialog(this); } else { MessageBox.Show("Login failed"); } } catch { MessageBox.Show("Sql error"); } } else if (AdminradioButton.Text == "Admin" && AdminradioButton.Checked) { strsql = string.Format("select count (*) from Admin where Name = '{0}' and Password = '******'", UserNametextBox.Text, PasswordBox.Text); command = new SqlCommand(strsql, mycon); //Specify the SQL statement to execute try { int result = Convert.ToInt32(command.ExecuteScalar()); if (result > 0) { MessageBox.Show("successful login"); LoginInfo.CurrentUser.UserName = UserNametextBox.Text; AdminMenu adminmenu = new AdminMenu(); this.Hide(); adminmenu.ShowDialog(this); } else { MessageBox.Show("Login failed"); } } catch { MessageBox.Show("Sql error"); } } } }