private void button1_Click(object sender, EventArgs e)
        {
            AdminHomeForm admin = new AdminHomeForm();

            admin.Show();
            this.Hide();
        }
示例#2
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            string uname = this.userTextBox1.Text;
            string upass = this.passTextBox2.Text;
            //Console.WriteLine("user: "******"pass: "******"SELECT * from AllUsers WHERE Username = '******' and Password = '******'";
            DataTable tbl         = dt.dbConnect(query);
            string    designation = "";

            try
            {
                userId      = Convert.ToInt32(tbl.Rows[0]["UserId"]);
                designation = tbl.Rows[0]["UserType"].ToString();
            }catch (Exception er)
            {
                MessageBox.Show("Wrong Password or Username");
            }
            //Console.WriteLine(designation);

            if (tbl.Rows.Count == 1)
            {
                if (designation.Equals("Admin"))
                {
                    AdminHomeForm aform = new AdminHomeForm(userId);
                    aform.Show();
                    this.Hide();
                }
                else if (designation.Equals("Employee"))
                {
                    EmployeeForm aform = new EmployeeForm(userId);
                    aform.Show();
                    this.Hide();
                }
                else if (designation.Equals("Passenger"))
                {
                    PassengerForm aform = new PassengerForm(userId);
                    aform.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Unknown User");
                }
            }
            else
            {
                passWLabel.Text = "Wrong User or Password.";
                userTextBox1.Clear();
                passTextBox2.Clear();
            }
        }
        private void loginBtn_Click(object sender, EventArgs e)
        {
            string uname = this.userTextBox1.Text.ToString();
            string upass = this.passTextBox2.Text.ToString();

            Console.WriteLine("user: "******"pass: "******"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Dell\Documents\Github\AirlineApplication\airline.mdf;Integrated Security=True;Connect Timeout=30");

            /*string query = "SELECT * from Admin WHERE Username = '******' and Password = '******'";
             * SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon);
             * DataTable tbl = new DataTable();
             * sda.Fill(tbl);*/



            if (admin.Checked == true)
            {
                string         query = "SELECT * from Admin WHERE Username = '******' and Password = '******'";
                SqlDataAdapter sda   = new SqlDataAdapter(query, sqlcon);
                DataTable      tbl   = new DataTable();
                sda.Fill(tbl);

                if (tbl.Rows.Count == 1)
                {
                    AdminHomeForm aform = new AdminHomeForm();
                    aform.Show();
                    this.Hide();
                }
                else
                {
                    passWLabel.Text = "Wrong User or Password.";
                    userTextBox1.Clear();
                    passTextBox2.Clear();
                }
            }
            else if (employeeRbtn.Checked == true)
            {
                string         query = "SELECT * from Employee WHERE Username = '******' and Password = '******'";
                SqlDataAdapter sda   = new SqlDataAdapter(query, sqlcon);
                DataTable      tbl   = new DataTable();
                sda.Fill(tbl);

                if (tbl.Rows.Count == 1)
                {
                    EmployeeForm eform = new EmployeeForm();
                    eform.Show();
                    this.Hide();
                }
                else
                {
                    passWLabel.Text = "Wrong User or Password.";
                    userTextBox1.Clear();
                    passTextBox2.Clear();
                }
            }
            else
            {
                string         query = "SELECT * from Passengers WHERE UserName = '******' and Password = '******'";
                SqlDataAdapter sda   = new SqlDataAdapter(query, sqlcon);
                DataTable      tbl   = new DataTable();
                sda.Fill(tbl);

                if (tbl.Rows.Count == 1)
                {
                    PassengerForm pform = new PassengerForm();
                    pform.Show();
                    this.Hide();
                }
                else
                {
                    passWLabel.Text = "Wrong User or Password.";
                    userTextBox1.Clear();
                    passTextBox2.Clear();
                }
            }
        }