Пример #1
0
        private void SaveUserLoginInfo()
        {
            var    userchoose = LoginMain.FindControl("UserChoose") as RadioButtonList;
            string UserType   = "";

            if (userchoose.SelectedIndex == 0)
            {
                UserType = "普通用户";
            }
            else if (userchoose.SelectedIndex == 1)
            {
                UserType = "医生用户";
            }
            else if (userchoose.SelectedIndex == 2)
            {
                UserType = "开发人员";
            }
            string LoginIP   = Request.UserHostAddress;
            string LoginName = LoginMain.UserName;
            string LoginTime = DateTime.Now.ToString();

            string        conString = WebConfigurationManager.ConnectionStrings["CDSSConnectionString"].ConnectionString;
            SqlConnection con       = new SqlConnection(conString);
            string        SqlStr    = "INSERT into UsersLogin (LoginTime,LoginName,UserType,LoginIP) " +
                                      "VALUES(@LoginTime,@LoginName,@UserType,@LoginIP)";;

            SqlCommand cmd = new SqlCommand(SqlStr, con);;

            cmd.Parameters.AddWithValue("@LoginTime", LoginTime);
            cmd.Parameters.AddWithValue("@LoginName", LoginName);
            cmd.Parameters.AddWithValue("@UserType", UserType);
            cmd.Parameters.AddWithValue("@LoginIP", LoginIP);
            con.Open();
            cmd.ExecuteNonQuery();
        }
Пример #2
0
        protected void ButtonLogin_Click(object sender, EventArgs e)
        {
            var  userchoose     = LoginMain.FindControl("UserChoose") as RadioButtonList;
            bool Authentication = false;

            if (userchoose.SelectedIndex == 0)
            {
                Authentication = SiteLevelCustomAuthenticationMethod(LoginMain.UserName, LoginMain.Password, "Commonuser");
            }
            else if (userchoose.SelectedIndex == 1)
            {
                Authentication = SiteLevelCustomAuthenticationMethod(LoginMain.UserName, LoginMain.Password, "Doctor");
            }
            else if (userchoose.SelectedIndex == 2)
            {
                Authentication = SiteLevelCustomAuthenticationMethod(LoginMain.UserName, LoginMain.Password, "Developer");
            }
            else
            {
                string MsgInfo = "请选择你的身份重新登录!";
                Response.Write("<script>window.alert('" + MsgInfo + "');</script>");
            }
            //e.Authenticated = Authenticated;
            if (Authentication == true)
            {
                Session["UserName"]  = LoginMain.UserName;
                Session["LoginTime"] = DateTime.Now.ToString();
                FormsAuthentication.SetAuthCookie(Session["UserName"].ToString(), createPersistentCookie: false);
                SaveUserLoginInfo();  //string ip = Request.UserHostAddress;
                if (Session["type"].ToString() == "Developer")
                {
                    Response.Redirect("~/DevelopersPage.aspx");
                }
                else if (Session["type"].ToString() == "Doctor")
                {
                    Response.Redirect("~/DoctorsPage.aspx");
                }
                else
                {
                    Response.Redirect("~/CommonUsersPage.aspx");
                }
            }
            else //如果登录失败就让用户重新登录
            {
                Session["UserName"]  = "";
                Session["type"]      = "";
                Session["LoginTime"] = "";
                string ErrorMessage = LoginErrorInfo + ",登录失败,请重新登录!";
                Response.Write("<script>window.alert('" + ErrorMessage + "');</script>");
                //Thread.Sleep(200);
                //Response.Redirect("~/Account/Login.aspx");
            }
        }
Пример #3
0
        protected void ButtonLogin_Click(object sender, EventArgs e)
        {
            var    userchoose     = LoginMain.FindControl("UserChoose") as RadioButtonList;
            string Authentication = "";

            if (userchoose.SelectedIndex == 0)
            {
                Authentication = SiteLevelCustomAuthenticationMethod(LoginMain.UserName, LoginMain.Password, "Commonuser");
            }
            else if (userchoose.SelectedIndex == 1)
            {
                Authentication = SiteLevelCustomAuthenticationMethod(LoginMain.UserName, LoginMain.Password, "Doctor");
            }
            else if (userchoose.SelectedIndex == 2)
            {
                Authentication = SiteLevelCustomAuthenticationMethod(LoginMain.UserName, LoginMain.Password, "Developer");
            }
            else
            {
                MessageBox.Show("请选择你的身份重新登录!");
            }
            //e.Authenticated = Authenticated;
            if (Authentication == "")  //登录成功
            {
                Session["UserName"] = LoginMain.UserName;
                FormsAuthentication.SetAuthCookie(Session["UserName"].ToString(), createPersistentCookie: false);
                if (Session["type"].ToString() == "Developer")
                {
                    Response.Redirect("~/DevelopersPage.aspx");
                }
                else if (Session["type"] == "Doctor")
                {
                    Response.Redirect("~/DoctorsPage.aspx");
                }
                else if (Session["type"] == "CommonUser")
                {
                    Response.Redirect("~/CommonUsersPage.aspx");
                }
            }
            else //如果登录失败就让用户重新登录
            {
                Session["type"]     = "";
                Session["UserName"] = "";
                string ErrorMessage = Authentication + ",登录失败!";
                //Response.Write("<script>window.alert('" + ErrorMessage + "');</script>");
                //LoginMain.FailureText = ErrorMessage;

                //this.LoginMain_LoginError(sender,e);
                //MessageBox.Show(ErrorMessage);
                Thread.Sleep(200);
                Response.Redirect("~/Account/Login.aspx");
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["IdConv"]))
            {
                Label lblNombreConvocatoria = (Label)LoginMain.FindControl("lblNombreConvocatoria");

                if (Request.QueryString["IdConv"].Equals("8809"))
                {
                    lblNombreConvocatoria.Text = Resources.ResourceConst.ConstPrimeraConvocatoria;
                }
                else if (Request.QueryString["IdConv"].Equals("9084"))
                {
                    lblNombreConvocatoria.Text = Resources.ResourceConst.ConstSegundaConvocatoria;
                }
            }
        }
Пример #5
0
        protected void LoginMain_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try
            {
                TextBox txtCapcha = (TextBox)LoginMain.FindControl("txtCapcha");

                if (Request.QueryString["IdConv"] == null || string.IsNullOrEmpty(Request.QueryString["IdConv"]))
                {
                    script = JQueryMensaje.ArmaMensaje("Error.", "No es una convocatoria valida, por favor ingrese con una convocatoria valida.", JQueryMensaje.TipoMensaje.Error);
                    ClientScript.RegisterClientScriptBlock(Page.GetType(), "abrirmodal", script, true);
                }
                else
                {
                    //Valida usuario y password
                    this.usuarioEntity = this.usuarioBusiness.ValidarUsuario(LoginMain.UserName, LoginMain.Password, Request.QueryString["IdConv"]);
                    if (!this.usuarioEntity.SeAutentica)
                    {
                        LoginMain.FailureText = "El nombre de usuario o el password no son validos, por favor verifique e intente nuevamente.";

                        script = JQueryMensaje.ArmaMensaje("Error.", "El nombre de usuario o el password no son validos, por favor verifique e intente nuevamente.", JQueryMensaje.TipoMensaje.Error);
                        ClientScript.RegisterClientScriptBlock(Page.GetType(), "abrirmodal", script, true);
                        return;
                    }
                }

                //VALIDACIÓN CÓDIGO CAPTHCHA
                if (txtCapcha.Text.ToUpper() != Session["Captcha"].ToString())
                {
                    LoginMain.FailureText = "El código de la imagen no corresponde.";
                    return;
                }

                this.usuarioEntity.Login          = LoginMain.UserName;
                this.usuarioEntity.Password       = LoginMain.Password;
                this.usuarioEntity.IdConvocatoria = Request.QueryString["IdConv"];
                Session["Usuario"] = this.usuarioEntity;

                FormsAuthentication.RedirectFromLoginPage(LoginMain.UserName, LoginMain.RememberMeSet);
                Response.Redirect("~/NivelFormacion/NivelFormacion.aspx", false);
            }
            catch (Exception ex)
            {
                script = JQueryMensaje.ArmaMensaje("Error.", ex.Message, JQueryMensaje.TipoMensaje.Error);
                ClientScript.RegisterClientScriptBlock(Page.GetType(), "abrirmodal", script, true);
            }
        }
Пример #6
0
        protected void LoginMain_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try
            {
                TextBox txtCapcha = (TextBox)LoginMain.FindControl("txtCapcha");

                //Valida usuario y password
                if (!this.usuarioBusiness.ValidarUsuarioIcetex(LoginMain.UserName, LoginMain.Password, ResourceConst.PathFileUsers))
                {
                    LoginMain.FailureText = "El nombre de usuario o el password no son validos por favor verifique e intente nuevamente.";
                    text = JQueryMensaje.ArmaMensaje("Error.", "El nombre de usuario o el password no son validos por favor verifique e intente nuevamente.", JQueryMensaje.TipoMensaje.Error);
                    ClientScript.RegisterClientScriptBlock(Page.GetType(), "abrirmodal", text, true);
                    return;
                }

                //VALIDACIÓN CÓDIGO CAPTHCHA
                if (txtCapcha.Text.ToUpper() != Session["Captcha"].ToString())
                {
                    text = JQueryMensaje.ArmaMensaje("Error.", "El código de la imagen no corresponde.", JQueryMensaje.TipoMensaje.Error);
                    ClientScript.RegisterClientScriptBlock(Page.GetType(), "abrirmodal", text, true);
                    return;
                }

                UsuarioIcetexEntity usuarioIcetexEntity = new UsuarioIcetexEntity()
                {
                    Login = LoginMain.UserName, Password = LoginMain.Password
                };
                Session["UsuarioIcetex"] = usuarioIcetexEntity;

                FormsAuthentication.RedirectFromLoginPage(LoginMain.UserName, LoginMain.RememberMeSet);
                Response.Redirect("~/Administracion/CalificarBeneficiario.aspx", false);
            }
            catch (Exception ex)
            {
                string script = JQueryMensaje.ArmaMensaje("Error.", ex.Message, JQueryMensaje.TipoMensaje.Error);
                ClientScript.RegisterClientScriptBlock(Page.GetType(), "abrirmodal", script, true);
            }
        }