示例#1
0
        private void mainScreen_loginBtn_Click(object sender, EventArgs e)
        {
            String txtUsername = mainScreen_username.Text;
            String txtPassword = mainScreen_password.Text;

            //try
            //{

            // modify it to your server and db name
            if (txtUsername == "admin" && txtPassword == "admin")
            {
                adminForm AdminPage = new adminForm();
                AdminPage.ShowDialog();
            }
            else
            {
                string        checkCredentials = "Select * from Trainee Where UserName = '******' and Pass = '******'";
                SqlCommand    CheckTrainee     = new SqlCommand(checkCredentials, Program.dbconnection);
                SqlDataReader TraineeData      = CheckTrainee.ExecuteReader();


                if (TraineeData.HasRows)
                {
                    MessageBox.Show("Successful Trainee Login !");
                    TraineeData.Read();
                    UserId = TraineeData.GetInt32(0);
                    TraineeData.Close();
                    Console.WriteLine(UserId.ToString());
                    userForm objuserForm = new userForm();
                    this.Hide();
                    objuserForm.Show();
                }
                else
                {
                    TraineeData.Close();
                    string        checkCredentialsTrainer = "Select * from Trainer Where UserName = '******' and Password = '******'";
                    SqlCommand    CheckTrainer            = new SqlCommand(checkCredentialsTrainer, Program.dbconnection);
                    SqlDataReader TrainerData             = CheckTrainer.ExecuteReader();
                    if (TrainerData.HasRows)
                    {
                        TrainerData.Read();
                        UserId = TrainerData.GetInt32(0);
                        TrainerData.Close();
                        trainerForm objuserForm = new trainerForm();
                        this.Hide();
                        objuserForm.Show();
                    }
                    else
                    {
                        TrainerData.Close();
                        MessageBox.Show("Check your username and password \n");
                    }
                }
            }

            //}
            // catch (Exception Ex)
            //{
            //  MessageBox.Show(Ex.Message);
            //}
        }
示例#2
0
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            adminForm af = new adminForm();

            af.ShowDialog();
        }