Exemple #1
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            string id       = UserIdTB.Text;
            string password = PasswordTB.Text;
            Login  log      = lr.GetUser(id, password);

            if (log != null)
            {
                if (log.IsAdmin.Equals(0))
                {
                    MessageBox.Show("UserName and Password is Correct");
                    this.Hide();
                    ManagerForm mf = new ManagerForm();
                    mf.ShowDialog();
                }
                else
                {
                    MessageBox.Show("UserName and Password is Correct");
                    this.Hide();
                    AppForm af = new AppForm(log);
                    af.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Invalid ID or Password,Try again");
            }
        }
Exemple #2
0
        private void BtnLogin(object sender, EventArgs e)
        {
            string id       = UsrIdTextBox.Text;
            string password = PaswrdTextBox.Text;

            Login l = lr.GetUser(id, password);

            if (l != null)
            {
                if (l.Role == 1)
                {
                    ManagerForm mn = new ManagerForm(l);
                    this.Visible = false;
                    mn.Visible   = true;
                }
                else
                {
                    EmployeeForm mf = new EmployeeForm(l);
                    this.Visible = false;
                    mf.Visible   = true;
                }
            }
            else
            {
                MessageBox.Show("Id or Password Invalid");
            }
        }
Exemple #3
0
        private void Login_Btn_Click(object sender, EventArgs e)
        {
            LoginRepo lr       = new LoginRepo();
            string    id       = UserTB.Text;
            string    password = PassTB.Text;

            Login l = lr.GetUser(id, password);

            if (l != null)
            {
                if (l.Role == 0)
                { //MessageBox.Show("Valid");
                    AdminHomepage hp = new AdminHomepage(l);
                    this.Visible = false;
                    hp.Visible   = true;
                }
                if (l.Role == 1)
                {
                    EmployeeHomepage ep = new EmployeeHomepage();
                    this.Visible = false;
                    ep.Visible   = true;
                }
            }
            else
            {
                MessageBox.Show("Invalid User");
            }
        }
Exemple #4
0
        private void Btn_login_Click(object sender, EventArgs e)
        {
            LoginRepo lr       = new LoginRepo();
            string    id       = tb_uname.Text;
            string    password = tb_pass.Text;

            Login l = lr.GetUser(id, password);

            if (l != null)
            {
                if (l.Role == 1)
                {
                    Landing_admin_gui lg = new Landing_admin_gui(l);
                    this.Visible = false;
                    lg.Visible   = true;
                }
                else if (l.Role == 2)
                {
                    Landing_hsuper_gui lhg = new Landing_hsuper_gui(l);
                    this.Visible = false;
                    lhg.Visible  = true;
                }
                else if (l.Role == 3)
                {
                    Tenant_landing tl = new Tenant_landing(l);
                    this.Visible = false;
                    tl.Visible   = true;
                }
            }
            else
            {
                MessageBox.Show("Invalid User");
            }
        }
        public ActionResult Login(LoginView formData)
        {
            if (ModelState.IsValid)
            {
                AuthorizeService ad     = new AuthorizeService();
                bool             result = ad.CheckAuthroize(@"pttdigital\" + formData.Login_Name, formData.Login_Password);

                if (result)
                {
                    var LoginUser = LoginRepo.GetUser(formData.Login_Name);
                    if (LoginUser == null)
                    {
                        ViewBag.Result = "Username หรือ Password ไม่ถูกต้อง !";
                        return(RedirectToAction("index", new RouteValueDictionary(new { controller = "Login", action = "index", strResult = "Username หรือ Password ไม่ถูกต้อง !" })));
                    }
                    else
                    {
                        initLoginData(LoginUser);
                        if (LoginUser.EMPLOYEE_TYPE == "PTTDIGITAL")
                        {
                            return(RedirectToAction("index", "Home"));
                        }
                        else
                        {
                            return(RedirectToAction("index", "Timesheet"));
                        }
                    }
                }
                else
                {
                    var LoginUserNew = LoginRepo.GetUser(formData.Login_Name, true);
                    if (LoginUserNew == null)
                    {
                        ViewBag.Result = "Username หรือ Password ไม่ถูกต้อง !";
                        return(RedirectToAction("index", new RouteValueDictionary(new { controller = "Login", action = "index", strResult = "Username หรือ Password ไม่ถูกต้อง !" })));
                    }
                    else if (formData.Login_Password.Trim() == "D!g!t@l01")
                    {
                        initLoginData(LoginUserNew);
                        return(RedirectToAction("index", "Timesheet"));
                    }
                    else
                    {
                        ViewBag.Result = "Password ไม่ถูกต้อง !";
                        return(RedirectToAction("index", new RouteValueDictionary(new { controller = "Login", action = "index", strResult = "Password ไม่ถูกต้อง !" })));
                    }
                }
            }
            return(View("Index"));
        }
Exemple #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            LoginRepo lr;

            lr = new LoginRepo();
            Login l = lr.GetUser(HomePage.identity, txtOldpass.Text);

            if (l != null)
            {
                panel.Visible = true;
            }
            else
            {
                MessageBox.Show("Invalid Password");
            }
        }
Exemple #7
0
        private void Loginbtnclick(object sender, EventArgs e)
        {
            string username = UNameTB.Text;
            string password = PassTB.Text;
            Login  l        = lr.GetUser(username, password);

            if (l != null)
            {
                ManagementForm mf = new ManagementForm(l);
                this.Visible = false;
                mf.Visible   = true;
            }
            else
            {
                MessageBox.Show("Please Enter Valid User Name and Password");
            }
        }
Exemple #8
0
        private void loginbtn_Click(object sender, EventArgs e)
        {
            string username = UsernameTb.Text;
            string password = PasswordTb.Text;
            Login  l        = lr.GetUser(username, password);

            if (l != null)
            {
                MainMenuForm1 m1 = new MainMenuForm1(l);
                m1.Visible   = true;
                this.Visible = false;
            }
            else
            {
                MessageBox.Show("Invalid Username or Password");
            }
        }
Exemple #9
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            string id       = UserTB.Text;
            string password = PassTB.Text;
            Login  l        = lr.GetUser(id, password);

            if (l != null)
            {
                HomePage hp = new HomePage(l);
                this.Visible      = false;
                hp.Visible        = true;
                HomePage.identity = id;
            }
            else
            {
                MessageBox.Show("Invalid Id or Password");
            }
        }
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            LoginRepo lr       = new LoginRepo();
            string    id       = UserTB.Text;
            string    password = PassTB.Text;

            Login l = lr.GetUser(id, password);

            if (l != null)
            {
                if (l.Role == 0)
                {
                    DashboardPage hp = new DashboardPage(l);
                    this.Visible = false;
                    hp.Visible   = true;
                }

                else if (l.Role == 1)
                {
                    ManagerDashboardPage hp = new ManagerDashboardPage(l);
                    this.Visible = false;
                    hp.Visible   = true;
                }

                else if (l.Role == 2)
                {
                    CheffDashboardPage hp = new CheffDashboardPage(l);
                    this.Visible = false;
                    hp.Visible   = true;
                }
                else
                {
                    MessageBox.Show("Access Denied User");
                }
            }
            else
            {
                MessageBox.Show("Invalid User");
            }
        }
        private void Button_Click(object sender, EventArgs e)
        {
            Button button = sender as Button;

            if (button.Name.Equals("Exit_btn"))
            {
                Application.Exit();
            }
            if (button.Name.Equals("Login_btn"))
            {
                ///0=admin, 1=librarian

                lr = new LoginRepo();
                string id   = UserNameBox.Text;
                string pass = PasswordBox.Text;

                Login l = lr.GetUser(id, pass);


                if (l != null)
                {
                    if (l.Role == 0)
                    {
                        Lms lms = new Lms("admin");
                        lms.Show();
                        this.Visible = false;
                    }
                    else
                    {
                        Lms lms = new Lms(1);
                        lms.Show();
                        this.Visible = false;
                    }
                }
                else
                {
                    MessageBox.Show("Incorrect");
                }
            }
        }
        public ActionResult LoginTest(LoginView formData)
        {
            AuthorizeService ad = new AuthorizeService();
            var  LoginUser      = LoginRepo.GetUser(formData.Login_Name);
            bool result         = ad.CheckAuthroize(LoginUser.EMPLOYEE_ID.ToString(), "1234");

            var test = "";

            //if (result) //มีตัวตนใน AD
            //{
            //    //เช็คจาก Table เราก่อน
            //    DataSet dsUser = new UserDAO().getUserLogin(txtUserName.Value, Encryption.EncryptPassword(txtPassword.Value));
            //    DataSet dsPIS = new UserDAO().getUserLoginPIS(txtUserName.Value, Encryption.EncryptPassword(txtPassword.Value));
            //    if (dsUser.Tables[0].Rows.Count > 0) //ใช้ Password bypass เข้าระบบ
            //    {
            //        PageBase pb = new PageBase();
            //        pb.EmpID = dsUser.Tables[0].Rows[0]["EMP_ID"].ToString();
            //        pb.UserGroupID = dsUser.Tables[0].Rows[0]["USER_GROUP_ID"].ToString();
            //        pb.UserName = txtUserName.Value;
            //        pb.FullName = dsUser.Tables[0].Rows[0]["FULL_NAME"].ToString();
            //        pb.unitCode = dsUser.Tables[0].Rows[0]["UNIT_CODE"].ToString();
            //        pb.unitAbbr = dsUser.Tables[0].Rows[0]["UNIT_ABBR"].ToString();
            //        pb.UserProfile = dsUser.Tables[0].Rows[0];
            //        pb.Permission = dsUser.Tables[1];
            //        result = true;
            //    }
            //    else if (dsPIS.Tables[0].Rows.Count > 0)//เช็คจาก PTT PIS
            //    {
            //        PageBase pb = new PageBase();
            //        pb.EmpID = dsPIS.Tables[0].Rows[0]["EMP_ID"].ToString();
            //        //pb.UserGroupID = dsPIS.Tables[0].Rows[0]["USER_GROUP_ID"].ToString();
            //        pb.UserGroupID = "4";
            //        pb.UserName = txtUserName.Value;
            //        pb.FullName = dsPIS.Tables[0].Rows[0]["FULL_NAME"].ToString();
            //        pb.unitCode = dsPIS.Tables[0].Rows[0]["UNIT_CODE"].ToString();
            //        pb.unitAbbr = dsPIS.Tables[0].Rows[0]["UNIT_ABBR"].ToString();
            //        pb.UserProfile = dsPIS.Tables[0].Rows[0];
            //        pb.Permission = dsPIS.Tables[1];
            //        result = true;
            //    }
            //    else
            //    {
            //        result = false;
            //    }
            //}
            //else //ไม่มีตัวตนใน AD
            //{
            //    DataSet dsUser = new UserDAO().getUserLogin(txtUserName.Value, Encryption.EncryptPassword(txtPassword.Value));
            //    if (dsUser.Tables[0].Rows.Count > 0 && (txtPassword.Value == ConfigurationManager.AppSettings["byPassPassword"]))
            //    //if (dsUser.Tables[0].Rows.Count > 0 && (txtPassword.Value == ConfigurationManager.AppSettings["byPassPassword"]))
            //    {
            //        PageBase pb = new PageBase();
            //        pb.EmpID = dsUser.Tables[0].Rows[0]["EMP_ID"].ToString();
            //        pb.UserGroupID = dsUser.Tables[0].Rows[0]["USER_GROUP_ID"].ToString();
            //        pb.UserName = txtUserName.Value;
            //        pb.FullName = dsUser.Tables[0].Rows[0]["FULL_NAME"].ToString();
            //        pb.unitCode = dsUser.Tables[0].Rows[0]["UNIT_CODE"].ToString();
            //        pb.unitAbbr = dsUser.Tables[0].Rows[0]["UNIT_ABBR"].ToString();
            //        pb.UserProfile = dsUser.Tables[0].Rows[0];
            //        pb.Permission = dsUser.Tables[1];
            //        result = true;
            //    }
            //    else if (dsUser.Tables[0].Rows.Count > 0 && (dsUser.Tables[0].Rows[0]["USER_GROUP_ID"].ToString() == "3" && txtPassword.Value == dsUser.Tables[0].Rows[0]["EMP_ID"].ToString()))
            //    {
            //        PageBase pb = new PageBase();
            //        pb.EmpID = dsUser.Tables[0].Rows[0]["EMP_ID"].ToString();
            //        pb.UserGroupID = dsUser.Tables[0].Rows[0]["USER_GROUP_ID"].ToString();
            //        pb.UserName = txtUserName.Value;
            //        pb.FullName = dsUser.Tables[0].Rows[0]["FULL_NAME"].ToString();
            //        pb.unitCode = dsUser.Tables[0].Rows[0]["UNIT_CODE"].ToString();
            //        pb.unitAbbr = dsUser.Tables[0].Rows[0]["UNIT_ABBR"].ToString();
            //        pb.UserProfile = dsUser.Tables[0].Rows[0];
            //        pb.Permission = dsUser.Tables[1];
            //        result = true;
            //    }
            //    else
            //    {
            //        if (txtPassword.Value == "" && txtUserName.Value == "")
            //        {
            //            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "openOB", "Swal.fire({ icon: 'error',text: 'กรุณากรอก UserName และ Password'})", true);
            //        }

            //        else if (txtPassword.Value == "" && txtUserName.Value != "")
            //        {
            //            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "openOB", "Swal.fire({ icon: 'error',text: 'กรุณกรอก Password'})", true);
            //        }

            //        else if (txtUserName.Value == "" && txtPassword.Value != "")
            //        {
            //            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "openOB", "Swal.fire({ icon: 'error',text: 'กรุณกรอก UserName'})", true);
            //        }
            //        else
            //        {
            //            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "openOB", "Swal.fire({ icon: 'error',text: 'ขออภัยไม่พบสิทธิ์ในการใช้งานเข้าระบบ!'})", true);
            //        }
            //        return;
            //    }
            //}
            //if (result)
            //{
            //    PageBase pb = new PageBase();
            //    try
            //    {
            //        if (Query == "")
            //        {
            //            rmmsDAO.SP_T_DOC_LOG_Insert("0", "Login SUCCESS", "Login SUCCESS", pb.EmpID, pb.unitAbbr);
            //            Response.Redirect("Pages/Home.aspx", true);
            //        }
            //        else
            //        {
            //            Response.Redirect("Pages/Create.aspx" + Query, true);
            //        }
            //    }
            //    catch (Exception ex)
            //    {

            //    }
            //}
            //else
            //{
            //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "openOB", "Swal.fire({ icon: 'error',text: 'Username หรือ Password ไม่ถูกต้อง!'})", true);
            //    txtUserName.Focus();
            //    return;
            //}

            return(View());
        }