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);
                }
            }
        }