protected void btnAgergar_Click(object sender, EventArgs e)
 {
     LoginBLL bl = new LoginBLL();
     User usuario = new User();
     usuario.UserName = txtUserName.Text;
     usuario.Password = txtPassword.Text;
     usuario.Name = txtUserName.Text;
     usuario.Email = txtEmail.Text;
     string correo = txtEmail.Text;
     string username = txtUserName.Text;
     if (bl.validarUsuarioUnico(username))
     {
         if (bl.validarCorreoUnico(correo))
         {
             if (txtPassword.Text == txtConfirmPassword.Text)
             {
                 bl.nuevoRegistro(usuario);
                 ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('Registro Agregado Exitosamente')", true);
             }
             else
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('Las contraseñas no coinciden')", true);
                 txtConfirmPassword.Text = "";
                 txtPassword.Text = "";
             }
         }
         else
         {
             ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('Este correo ya se utilizo')", true);
         }
     }
     else {
         ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('El userName ya se utilizo')", true);
     }
 }
Esempio n. 2
0
        protected void btnIngresar_Click(object sender, EventArgs e)
        {
            try
            {
                LoginBLL bl = new LoginBLL();
                string username;
                string password;
                username = txtUsuario.Text;
                password = txtPassword.Text;

                bl.consultarUserPorUsername(username, password);

                User user = new User();
                user = bl.consultarUserPorUsername(username, password).First();
                Session["User"] = user;
                Response.Redirect("~/Users/User_s.aspx");

            }
            catch (Exception ex)
            {

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + ex.Message + "')", true);
                //Session["User"] = null;

            }
        }
Esempio n. 3
0
        private void Login_Load(object sender, EventArgs e)
        {
            var Criar = new LoginBLL();

            Criar.CarregarCriarDB();
            //========================Função Lembrar-me========================
            if (Settings.Default.Password == "admin" && Settings.Default.Username == "admin")
            {
                txtSenha.Text     = Settings.Default.Password;
                txtUsuario.Text   = Settings.Default.Username;
                CBLembrar.Checked = true;
            }
            if (CBLembrar.Checked == false)
            {
                Settings.Default.Password = "";
                Settings.Default.Username = "";
                Settings.Default.Save();
            }
        }
Esempio n. 4
0
 protected void Button1_Click1(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         string youxiang = this.TextBox1.Text;
         string yhm      = this.TextBox2.Text;
         string mima     = this.TextBox3.Text;
         if (youxiang.Trim() == "")
         {
             Response.Write("<script>alert('邮箱不能为空')</script>");
         }
         else if (yhm.Trim() == "")
         {
             Response.Write("<script>alert('用户名不能为空')</script>");
         }
         else if (mima.Trim() == "")
         {
             Response.Write("<script>alert('密码不能为空')</script>");
         }
         else if (this.CheckBox1.Checked == false)
         {
             Response.Write("<script>alert('注册必须同意协议')</script>");
         }
         else
         {
             Model.Login zhuce = new Model.Login();
             zhuce.YHM          = yhm;
             zhuce.YouXiang     = youxiang;
             zhuce.MIMA         = mima;
             zhuce.Zhuceshijian = Convert.ToDateTime(DateTime.Now.ToString());
             zhuce.Userpic      = "touxiang_23.gif";
             if (LoginBLL.AddUser(zhuce))
             {
                 Response.Write("<script>alert('注册成功!')</script>");
                 Response.Redirect("登录.aspx");
             }
             else
             {
                 Response.Write("<script>alert('注册失败!')</script>");
             }
         }
     }
 }
Esempio n. 5
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            LoginBLL loginBLL = new LoginBLL();
            tblLogin login    = new tblLogin();

            login.Username = txtUserName.Text;
            login.Password = txtPassword.Text;
            if (loginBLL.getLogin(login).HasRows)
            {
                MessageBox.Show("Welcome", "Susscess", MessageBoxButtons.OK, MessageBoxIcon.None);
                frmStart frmStart = (frmStart)Application.OpenForms["frmStart"];
                frmStart.Hide();
                this.Hide();
            }
            else
            {
                DialogResult = MessageBox.Show("Khôngg được phép truy cập! ", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Esempio n. 6
0
        public JsonResult ValidateLogin(string PhoneNumber)
        {
            LoginBLL _loginBLL = new LoginBLL();

            Response _response = new Response();

            try
            {
                _response = _loginBLL.ValidateLogin(PhoneNumber);
                if (_response.Status)
                {
                    Session["UserName"] = Convert.ToString(_response.Data);
                }
            }
            catch (Exception ex)
            {
            }
            return(Json(_response, JsonRequestBehavior.AllowGet));
        }
Esempio n. 7
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            LoginBLL control    = new LoginBLL();
            var      existenoBD = control.checar(txtCampoUsuario.Text, txtCampoSenha.Text);

            if (existenoBD)
            {
                this.Hide();
                View.FrmMenu menu = new View.FrmMenu();
                menu.ShowDialog();
                this.Close();
                txtCampoUsuario.Clear();
                txtCampoSenha.Clear();
            }
            else
            {
                MessageBox.Show("Verificar Login e/ou Senha", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnAutenticar_Click(object sender, EventArgs e)
        {
            string        email    = txtUsuario.Text;
            string        senha    = txtSenha.Text;
            LoginResponse resposta = new LoginBLL().Autenticar(email, senha);

            if (!resposta.Sucesso)
            {
                MessageBox.Show(resposta.Mensagem);
            }
            else
            {
                FormMenu frm = new FormMenu();
                this.Hide();
                frm.ShowDialog();
                this.Show();
            }
            FormCleaner.Clear(this);
        }
        public string LoginIn(string name, string pwd)
        {
            StringBuilder sb    = new StringBuilder();
            LoginBLL      login = new LoginBLL();

            LiLanzModel.User u = login.LoginCheck(name, pwd);
            if (u.Userid > 0)
            {
                sb.Append("<?xml version=\"1.0\" encoding=\"gb2312\"?>");
                sb.Append(String.Format("<usr u_id=\"{0}\" u_name=\"{1}\" u_cname=\"{2}\">", u.Userid, u.Name, u.Cname));
                sb.Append("</usr>");

                return(sb.ToString());
            }
            else
            {
                return("");
            }
        }
Esempio n. 10
0
        public bool loginCheck(LoginBLL l)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconnstring);


            try
            {
                string sql = "Select * from Login where UserID=@UserID and Password=@Password";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@UserID", l.userid);
                cmd.Parameters.AddWithValue("@Password", l.password);

                SqlDataAdapter adapter = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable();

                adapter.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSuccess);
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LoginBLL bll = new LoginBLL();

            DAL.Login login = Session["LogedInUser"] as DAL.Login;
            if (login != null)
            {
                bll.SetLogin(login, 2);
                Session.Remove("LogedInUser");
                Session.Clear();
                Session.RemoveAll();
                GC.Collect();
                Response.Redirect("Login.aspx");
            }
            Session.Remove("LogedInUser");
            Session.Clear();
            Session.RemoveAll();
            GC.Collect();
            Response.Redirect("Login.aspx");
        }
Esempio n. 12
0
        //分页查询
        public ActionResult queryAll()
        {
            string       pageSize = Request.Params["pageSize"];
            string       pageNum  = Request.Params["pageNum"];
            List <Admin> list     = new LoginBLL().queryAll(Convert.ToInt32(pageSize), Convert.ToInt32(pageNum));
            var          alist    = list.Select(p => new
            {
                UserName   = p.UserName,             //账户名称
                UserCode   = p.UserCode,             //账户编号
                RealName   = p.RealName,             //真实名称
                Email      = p.Email,                //邮箱
                Mobile     = p.Mobile,               //电话
                Phone      = p.Phone,                //手机
                LoginCount = p.LoginCount,           //登录次数
                DepartNum  = p.SysDepart.DepartName, //部门名称
                RoleNum    = p.SysRole.RoleName      //角色名称
            }).ToList();

            return(Json(alist, JsonRequestBehavior.AllowGet));
        }
Esempio n. 13
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            usr_usuarios user = new usr_usuarios();

            user.usr_password = this.txtPasswor.Password.ToString();
            user.usr_nombre   = this.txtUser.Text;
            LoginBLL log     = new LoginBLL();
            var      retorno = log.login(user);

            if (retorno != null)
            {
                win_MenuPrincipal menu = new win_MenuPrincipal(user);
                menu.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Usuario o Contraseña invalidos.\n Intente de nuevo.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
        public bool loginCheck(LoginBLL log)
        {
            //Create a bool variable and  set its value to false
            bool success = false;

            using (SqlConnection con = new SqlConnection(myConnection))
            {
                try
                {
                    // Sql Query TO check LOgin
                    string sql = "SELECT * FROM tbl_user WHERE username=@username AND password=@password AND user_type=@user_type";
                    // SQL COMMAND TO PASS VALUE to THE query using SQL COMMAND
                    SqlCommand cmd = new SqlCommand(sql, con);
                    cmd.Parameters.AddWithValue("@username", log.userName);
                    cmd.Parameters.AddWithValue("@password", log.passWord);
                    cmd.Parameters.AddWithValue("@user_type", log.userType);
                    //we need SQL adapter to Temporary Show Data From DataBAse
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    //DataTable to Hold the data from the Sql Adapter temporarly into our DataTable
                    DataTable dt = new DataTable();
                    adapter.Fill(dt);
                    //check if the user is in our database
                    if (dt.Rows.Count > 0)
                    {
                        //Login Successful
                        success = true;
                    }
                    else
                    {
                        success = false;
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                return(success);
            }
        }
Esempio n. 15
0
 private void BtnUpdate_Click(object sender, EventArgs e)
 {
     if (txtUserID.Text == "")
     {
         MessageBox.Show("ID not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (txtFullName.Text == "" || txtDoB.Text == "" || txtContact.Text == "" || txtAddress.Text == "" || txtUser.Text == "" || txtPass.Text == "")
     {
         MessageBox.Show("Please Fill all the provided blanks!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         for (int i = 0; i < grdStaff.Rows.Count; i++)
         {
             if (grdStaff.Rows[i].Cells[5].Value.ToString() == txtUser.Text && grdStaff.Rows[i].Cells[0].Value.ToString() != txtUserID.Text)
             {
                 MessageBox.Show("Username already exists", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
         LoginBLL bll  = new LoginBLL();
         tblLogin user = new tblLogin();
         user.ID       = txtUserID.Text;
         user.FullName = txtFullName.Text;
         user.Age      = txtDoB.Text;
         user.Address  = txtAddress.Text;
         user.Contact  = txtContact.Text;
         user.Username = txtUser.Text;
         user.Password = txtPass.Text;
         bool result = bll.UpUserDAL(user);
         if (result == true)
         {
             MessageBox.Show("Update User successful!", "Success", MessageBoxButtons.OK);
             FrmStaffManage_Load(sender, e);
         }
         else
         {
             MessageBox.Show("Can't Update User", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Esempio n. 16
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Session["LoginAttempt"] = Convert.ToInt32(Session["LoginAttempt"]) + 1;
        if (LoginBLL.IsValidLogin(lblUserName.Text, txtPassword.Text))
        {
            Session["UserId"] = UserBLL.BLL_UserId(lblUserName.Text); // user email
            Response.Redirect("../User/UserData.aspx");               //the page to be opened on successful login
        }

        else //password not valid but username valid
        {
            if (Convert.ToInt32(Session["LoginAttempt"]) > 2)
            {
                Response.Redirect("IncorrectPassword.aspx?UserName="******"ReenterPassword.aspx?UserName=" + lblUserName.Text);
            }
        }
    }
Esempio n. 17
0
        protected void btSave_Click(object sender, EventArgs e)
        {
            Manage.Entity.Sys.User info = new Manage.Entity.Sys.User();
            info.PassWord = this.NewPassWord.Text;

            LoginInfo login = this.GetLoginInfo();

            login.PassWord = this.OldPassWord.Text;

            login = new LoginBLL().IsLogin(login);

            if (login == null)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myjs", "MSI('提示','原密码输入不正确!');", true);
                return;
            }
            info.UserID = login.UserID;
            BLLFactory.CreateBLL <UserManageBLL>().SetPassWord(info);

            ClientScript.RegisterStartupScript(this.GetType(), "myjs", "parent.closeAppWindow1();", true);
        }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Executar código para iniciar a página
                Session["usuario"] = "";
                LoginBLL objLoginBLL = new LoginBLL();
                List <DTO.Modulos.Seguranca.LoginDTO> listaLogin = objLoginBLL.obterTodos();

                cmbListaUsuarios.DataSource     = listaLogin;
                cmbListaUsuarios.DataTextField  = "nomeUsuario";
                cmbListaUsuarios.DataValueField = "id";

                cmbListaUsuarios.DataBind();
            }
            else
            {
                //Executar código de página carregada
                Session["usuario"] = txtNomeUsuario.Text;
            }
        }
Esempio n. 19
0
        private void btnAcessar_Click(object sender, EventArgs e)
        {
            loginDTO obj = new loginDTO();

            obj.prpUsuario = txtNome.Text;
            obj.prpSenha   = txtSenha.Text;

            string mensagem = LoginBLL.vldLogin(obj);

            if (mensagem == "true")
            {
                this.Hide();
                Projeto_DS.Home tela2 = new Projeto_DS.Home();
                tela2.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Usuario ou senha invalidos!", "ERRO", MessageBoxButtons.OK);
            }
        }
Esempio n. 20
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            string   usuario  = txtUsuario.Text.ToString();
            string   clave    = txtClave.Text.ToString();
            LoginBLL loginBLL = new LoginBLL();

            rolUsuario = loginBLL.validarUsuario(usuario, clave);
            if (rolUsuario != -2)
            {
                FrmMenuPrincipal menuPrin = new FrmMenuPrincipal();
                menuPrin.Visible = true;
                this.Visible     = false;
            }
            else
            {
                MessageBox.Show("Usuario o contraseña inválidos", "Error de Autenticación", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUsuario.Clear();
                txtClave.Clear();
                txtUsuario.Focus();
            }
        }
        protected void zhuceannui_Click(object sender, EventArgs e)
        {
            FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text, false);
            string name = this.TextBox1.Text;

            string mima = this.TextBox2.Text;

            if (name.Trim() != "" && mima.Trim() != "")
            {
                DataTable dt = LoginBLL.Select(name, mima);
                if (dt.Rows.Count > 0)
                {
                    Session["userid"] = dt.Rows[0][0];
                    Response.Redirect("首页.aspx");
                }
                else
                {
                    Response.Write("<script>alert('登录失败!用户名或密码错误!')</script>");
                }
            }
        }
Esempio n. 22
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string user  = txtUsuario.Text;
            string clave = txtClave.Text;

            LoginBLL oLoginBLL = new LoginBLL();

            if (oLoginBLL.validar(user, clave))
            {
                pnlErrorLogin.Visible = false;
                ControlUtils.openMdi(ParentForm, new Home(user));
                Close();
            }
            else
            {
                txtUsuario.Text = "";
                txtClave.Text   = "";
                txtUsuario.Focus();
                pnlErrorLogin.Visible = true;
            }
        }
Esempio n. 23
0
        public void TestLogin()
        {
            LoginBLL bll = new LoginBLL();
            bool     actualResult, expectedResult;

            bll._username = "******"; //Test Data
            bll._password = "******";   //Test Data
            DataTable dtCheck = bll.CheckLogin();

            expectedResult = true;
            if (dtCheck.Rows.Count > 0)
            {
                actualResult = true;
            }
            else
            {
                actualResult = false;
            }

            Assert.AreEqual(actualResult, expectedResult);
        }
Esempio n. 24
0
        /*-----------------
         * ----------------
         * Admin Controllers
         * ----------------------------------------------------------
         * ------------------*/
        public ActionResult AdminLanding(UserModel userModel)
        {
            // Must be admin to access view
            if (((LoginModel)Session["loginModel"]) != null && ((LoginModel)Session["loginModel"]).RoleIDFK == 1)
            {
                // Create the user objrct that will recieve the mapped object
                User user = new User();

                // create BLL object for login process
                LoginBLL login = new LoginBLL();

                // passed the mapped
                List <User> listUser = login.Login(user);

                return(View(listUser));
            }
            else
            {
                return(RedirectToAction("login", "home"));
            }
        }
 public LoginViewModel()
 {
     this.LoginBLL      = new LoginBLL();
     this.EntrarCommand = new Command(async() =>
     {
         try
         {
             await PopupNavigation.Instance.PushAsync(new PopupLoadingView(), false);
             int CodeUser = await LoginBLL.VerificaAutenticacao(email, senha);
             MessagingCenter.Send <string>(Convert.ToString(CodeUser), "EntrarCommand");
         }
         catch (CampoNullOrEmptyException ex)
         {
             MessasingCenterSendError(ex.Message);
         }
         catch (EmailInvalidoException ex)
         {
             LimparCampoEmail();
             LimparCampoSenha();
             MessasingCenterSendError(ex.Message);
         }
         catch (UsuarioNotFoundException ex)
         {
             LimparCampoSenha();
             MessasingCenterSendError(ex.Message);
         }
         catch (Exception ex)
         {
             MessasingCenterSendError(ex.Message);
         }
         finally
         {
             await PopupNavigation.Instance.PopAsync();
         }
     });
     this.CadastrarContaCommand = new Command(() =>
     {
         MessagingCenter.Send <string>("", "CadastrarContaCommand");
     });
 }
Esempio n. 26
0
        protected void btn_Login_Click(object sender, EventArgs e)
        {
            LoginBLL login   = new LoginBLL();
            string   account = this.txt_Account.Value;
            string   Pswd    = this.txt_Password.Value;

            userInfo = login.GetUserInfo(account);
            Info     = JsonHelper.EncodeJson(userInfo);
            string name = userInfo.Name;

            Response.Cookies["t"].Value          = name;
            Response.Cookies["clsaccount"].Value = account;
            string pswd = DES.Encrypt(Pswd);//密码加密

            Response.Cookies["clspassword"].Value = pswd;
            clspswd = pswd;
            Response.Cookies["clsaccount"].Expires  = DateTime.Now.AddDays(7);
            Response.Cookies["clspassword"].Expires = DateTime.Now.AddDays(7);
            Response.Cookies["t"].Expires           = DateTime.Now.AddDays(7);
            //将用户信息保存到Session
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "script", "SaveUerInfo()", true);
        }
Esempio n. 27
0
        internal static int SavePassword()
        {
            try
            {
                daUSER = new tblLOGINTableAdapter();
                dtUSER = new dbDSCMainDataSet.tblLOGINDataTable();

                daUSER.FillByUserName(dtUSER, UserInfo.UserName);
                drwUSER = dtUSER[0];

                drwUSER.UserName = UserInfo.UserName;
                drwUSER.Password = LoginBLL.EncryptPassword(UserInfo.Password);

                n = daUSER.Update(dtUSER);
                return(n);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Error: " + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(n);
            }
        }
Esempio n. 28
0
        protected void btLogin_Click(object sender, EventArgs e)
        {
            LoginBLL bll = BLLFactory.CreateBLL <LoginBLL>();

            LoginInfo loginUser = new LoginInfo();

            loginUser.LoginUserID = this.inputUserName.Text;
            loginUser.PassWord    = this.inputPassword.Text;

            loginUser = bll.IsLogin(loginUser);

            if (loginUser != null)
            {
                //用户名和密码输入正确
                Session["userInfo"] = loginUser;
                Response.Redirect("HDDefault.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myjs", "alert('用户名或密码不正确');", true);
            }
        }
Esempio n. 29
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         LoginBLL logBLL   = new LoginBLL();
         string   strError = "";
         if (txtMaNV.Text.Trim().Equals("") == true)
         {
             strError += "Mã nhân viên không được rỗng.";
         }
         if (txtPassword.Text.Trim().Equals("") == true)
         {
             strError += " Password không được rỗng.";
         }
         if (strError != "")
         {
             MessageBox.Show(strError, "Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             string strResult = logBLL.Login(txtMaNV.Text, txtPassword.Text);
             if (strResult == "404")
             {
                 MessageBox.Show("Mã nhân viên hoặc password không tồn tại.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 Variable.strMaNhanVien  = txtMaNV.Text;
                 Variable.strTenNhanVien = strResult;
                 Variable.strMatKhau     = txtPassword.Text;
                 LuuTaiKhoan();
                 FrmMain frmMain = new FrmMain();
                 frmMain.ShowDialog();
             }
         }
     }
     catch { }
 }
Esempio n. 30
0
        private void salvar(Login login)
        {
            try
            {
                if (txtUsuario.Text.Trim() == string.Empty || txtSenha.Text.Trim() == string.Empty || txtConfirmaSenha.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Informações obrigatórias não preenchidas", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (!(txtSenha.Text.Equals(txtConfirmaSenha.Text)))
                {
                    MessageBox.Show("Senhas não combinam, por favor digite novamente", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    LoginBLL loginBll = new LoginBLL();

                    login.nomeUsuario    = txtUsuario.Text;
                    login.senhaUsuario   = txtSenha.Text;
                    login.confirmarSenha = txtConfirmaSenha.Text;

                    loginBll.salvar(login);

                    MessageBox.Show("USUÁRIO cadastrado com sucesso", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    txtSenha.Clear();
                    txtConfirmaSenha.Clear();

                    Form_Login novo = new Form_Login();
                    novo.Visible = true;
                    this.Visible = false;
                }
            }

            catch (MySqlException erro)
            {
                MessageBox.Show("Usuário já existe \n" + erro.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 31
0
        public ActionResult Login(string username, string senha)
        {
            //string cookieValue = Cookie.Get("BudgShopTicket");
            //string[] dados = cookieValue.Split(',');
            //int id = int.Parse(dados[0]);
            //string tipo = dados[1];
            //if(tipo == "1")
            //{
            //
            //}
            //else
            //{
            //
            //}

            LoginBLL loginbll = new LoginBLL();

            try
            {
                dynamic objeto = loginbll.verificaLogin(username, senha);
                if (objeto.GetType() == typeof(Supermercado))
                {
                    Cookie.Set("BudgShopTicket", objeto.ID.ToString() + "," + "1");
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    Cookie.Set("BudgShopTicket", objeto.ID.ToString() + "," + "2");
                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch (Exception)
            {
                ViewBag.Erro = "Usuário e/ou senha inválidos";
            }

            return(View());
        }
        protected void btnAgergar_Click(object sender, EventArgs e)
        {
            LoginBLL bl      = new LoginBLL();
            User     usuario = new User();

            usuario.UserName = txtUserName.Text;
            usuario.Password = txtPassword.Text;
            usuario.Name     = txtUserName.Text;
            usuario.Email    = txtEmail.Text;
            string correo   = txtEmail.Text;
            string username = txtUserName.Text;

            if (bl.validarUsuarioUnico(username))
            {
                if (bl.validarCorreoUnico(correo))
                {
                    if (txtPassword.Text == txtConfirmPassword.Text)
                    {
                        bl.nuevoRegistro(usuario);
                        ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('Registro Agregado Exitosamente')", true);
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('Las contraseñas no coinciden')", true);
                        txtConfirmPassword.Text = "";
                        txtPassword.Text        = "";
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('Este correo ya se utilizo')", true);
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alerta", "alert('El userName ya se utilizo')", true);
            }
        }