Пример #1
0
        private void loadUsersBtn_Click(object sender, EventArgs e)
        {
            AllUsersRepository userRepo = new AllUsersRepository();
            List <AllUsers>    ulist    = userRepo.GetAllUsers();

            this.userGridView1.DataSource = ulist;
        }
Пример #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();
            }
        }