Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Logic.connection con = new Logic.connection();

            con.Select("Select * from [Userss] where userName='******' and userPassword='******'");
            DataTable dt = new DataTable();

            con.sda.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                int roleId = int.Parse(dt.Rows[0][3].ToString());
                // string name = dt.Rows[0][4].ToString();
                int userId = int.Parse(dt.Rows[0][0].ToString());
                con.Insert("INSERT INTO UserLoginTimeLog(userId,userLoginTime)VALUES  ('" + userId + "','" + DateTime.Now.ToString("MM-dd-yyyy h:mm:ss tt") + "')");



                if (roleId == 1 || roleId == 2 || roleId == 3)
                {
                    this.Hide();
                    MAIN mainForm = new MAIN(userId);
                    mainForm.Show();
                }
                else if (roleId == 4 || roleId == 5)
                {
                    this.Hide();
                    UserMain mainForm = new UserMain(userId);
                    mainForm.Show();
                }
                else
                {
                    MessageBox.Show("Invalid Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #2
0
        public UserMain(int userId)
        {
            InitializeComponent();
            Logic.connection con = new Logic.connection();
            this.uid = userId;
            con.Select("SELECT Userss.userName, UserRoles.role FROM UserRoles INNER JOIN Userss ON Userss.roleId=UserRoles.roleId where userId='" + uid + "'");
            DataTable dt = new DataTable();

            con.sda.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                // lblUserName.Text = dt.Rows[0]["userName"].ToString();
                // label6.Text = dt.Rows[0]["role"].ToString();
            }
        }