Exemplo n.º 1
0
        public ActionResult Login(string id)
        {
            if (!String.IsNullOrEmpty(id))
            {
                RedirectToAction("Index", "LeaveApprove");
            }
            var viewModels = new LoginModel.MyViewModel
            {
                Memos  = db.GetMemos(),
                Charts = db.GetCharts(),
                Newss  = db.GetNews(),
                p2k3s  = db.Getp2k3s()
            };

            return(View(viewModels));
        }
Exemplo n.º 2
0
        public ActionResult Login(KMI_INTRANET.Models.LoginModel.MyViewModel model)
        {
            if (ModelState.IsValid)
                {
                    if (model.IsValid(model.UserName, model.Password))
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                        Session["USER"] = model.UserName;
                        string connectionString = "Data Source=HRMSDEV;user id=PERSON;password=PERSON;Unicode=True;";

                        using (OracleConnection connection = new OracleConnection(connectionString))
                        {
                            OracleCommand cmd = new OracleCommand();
                            cmd.CommandText = "select t.nickname from person.CTM_EMPLOYEE_MASTER_TAB t where t.emp_id='" + Session["USER"] + "'";
                            cmd.CommandType = CommandType.Text;
                            cmd.Connection = connection;

                            connection.Open();
                            using (OracleDataReader rdr = cmd.ExecuteReader())
                            {
                                rdr.Read();
                                if (DBNull.Value.Equals(rdr.GetString(0)))
                                {
                                    Session["fullname"] = "-";
                                }
                                else
                                {
                                    Session["fullname"] = rdr.GetString(0);
                                }

                            }
                            connection.Close();
                            OracleCommand cmd1 = new OracleCommand();
                            cmd1.CommandText = "select t.LEV,t.autorized from person.KMIINTRANET_USER t where t.USERNAME='******'";
                            cmd1.CommandType = CommandType.Text;
                            cmd1.Connection = connection;

                            connection.Open();
                            using (OracleDataReader rdr1 = cmd1.ExecuteReader())
                            {
                                rdr1.Read();
                                if (rdr1.GetString(0) == "")
                                {
                                    Session["UserSecurity"] = "-";
                                }
                                else
                                {
                                    Session["UserSecurity"] = rdr1.GetString(0);
                                }

                                if (rdr1.GetString(0) == "USER")
                                {
                                    Session["Autorized"] = "";
                                }
                                else
                                {
                                    Session["Autorized"] = rdr1.GetString(1);
                                }

                            }
                            connection.Close();
                            //if (!String.IsNullOrEmpty(id))
                            //{
                            //    string param1 = this.Request.QueryString["param.1"];
                            //    string param2 = this.Request.QueryString["param.2"];
                            //    Redirect(Url.Action("Index", "LeaveApprove") + "?id=" + id);
                            //}
                            //else
                            //{
                                //return RedirectToAction("Index", "Home");
                            //}
                            string returnUrl = Request.QueryString["ReturnUrl"];
                                if (!String.IsNullOrEmpty(returnUrl))
                                {
                                    return Redirect(returnUrl);
                                }
                                else
                                {
                                    return RedirectToAction("Index", "Home");
                                }

                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "The user name or password incorrect.");
                    }

            }
                var viewModels = new LoginModel.MyViewModel
                {
                    Memos = db.GetMemos(),
                    Charts = db.GetCharts(),
                    Newss = db.GetNews(),
                    p2k3s = db.Getp2k3s()
                };
                return View(viewModels);
        }
Exemplo n.º 3
0
 public ActionResult Login(string id)
 {
     if (!String.IsNullOrEmpty(id))
     {
          RedirectToAction("Index", "LeaveApprove");
     }
     var viewModels = new LoginModel.MyViewModel
     {
         Memos = db.GetMemos(),
         Charts = db.GetCharts(),
         Newss = db.GetNews(),
         p2k3s = db.Getp2k3s()
     };
     return View(viewModels);
 }
Exemplo n.º 4
0
        public ActionResult Login(KMI_INTRANET.Models.LoginModel.MyViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.IsValid(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    Session["USER"] = model.UserName;
                    string connectionString = "Data Source=HRMSDEV;user id=PERSON;password=PERSON;Unicode=True;";

                    using (OracleConnection connection = new OracleConnection(connectionString))
                    {
                        OracleCommand cmd = new OracleCommand();
                        cmd.CommandText = "select t.nickname from person.CTM_EMPLOYEE_MASTER_TAB t where t.emp_id='" + Session["USER"] + "'";
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = connection;

                        connection.Open();
                        using (OracleDataReader rdr = cmd.ExecuteReader())
                        {
                            rdr.Read();
                            if (DBNull.Value.Equals(rdr.GetString(0)))
                            {
                                Session["fullname"] = "-";
                            }
                            else
                            {
                                Session["fullname"] = rdr.GetString(0);
                            }
                        }
                        connection.Close();
                        OracleCommand cmd1 = new OracleCommand();
                        cmd1.CommandText = "select t.LEV,t.autorized from person.KMIINTRANET_USER t where t.USERNAME='******'";
                        cmd1.CommandType = CommandType.Text;
                        cmd1.Connection  = connection;

                        connection.Open();
                        using (OracleDataReader rdr1 = cmd1.ExecuteReader())
                        {
                            rdr1.Read();
                            if (rdr1.GetString(0) == "")
                            {
                                Session["UserSecurity"] = "-";
                            }
                            else
                            {
                                Session["UserSecurity"] = rdr1.GetString(0);
                            }

                            if (rdr1.GetString(0) == "USER")
                            {
                                Session["Autorized"] = "";
                            }
                            else
                            {
                                Session["Autorized"] = rdr1.GetString(1);
                            }
                        }
                        connection.Close();
                        //if (!String.IsNullOrEmpty(id))
                        //{
                        //    string param1 = this.Request.QueryString["param.1"];
                        //    string param2 = this.Request.QueryString["param.2"];
                        //    Redirect(Url.Action("Index", "LeaveApprove") + "?id=" + id);
                        //}
                        //else
                        //{
                        //return RedirectToAction("Index", "Home");
                        //}
                        string returnUrl = Request.QueryString["ReturnUrl"];
                        if (!String.IsNullOrEmpty(returnUrl))
                        {
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password incorrect.");
                }
            }
            var viewModels = new LoginModel.MyViewModel
            {
                Memos  = db.GetMemos(),
                Charts = db.GetCharts(),
                Newss  = db.GetNews(),
                p2k3s  = db.Getp2k3s()
            };

            return(View(viewModels));
        }