private void Add()

        {
            if (this.txtPassword.Text != this.txtConfirmPassword.Text)
            {
                this.lblError.Text = "la Contraseña y la confirmación debe de ser Iguales";
                return;
            }


            Crypt _crypt = new Crypt();

            _password = _crypt.MD5(txtPassword.Text);


            FContext = new FacturadorEntities1();
            try
            {
                // ObjUsuario = FContext.TblUsuarios.Single(Usuario => Usuario.Username == txtUserName.Text && Usuario.Password == txtpassword.Text );

                var ObjUsuario = FContext.TblUsuarios.FirstOrDefault(Usuario => Usuario.CorreoElectronico == txtEmail.Text);

                if (ObjUsuario != null)
                {
                    var _usr = FContext.TblUsuarios.FirstOrDefault(usr => usr.CorreoElectronico == txtEmail.Text && usr.Password == _password);

                    if (_usr != null)
                    {
                        lblError.Text = "El Correo Ya existe: ";
                        lnkRecuperarPassword.Visible = true;
                    }
                }
                else
                {
                    tblCliente cliente = new tblCliente();

                    cliente.Nombre            = this.txtNombre.Text.ToUpper();
                    cliente.Empresa           = this.txtEmpresa.Text.ToUpper();
                    cliente.CorreoElectronico = this.txtEmail.Text;
                    cliente.FechaCreacion     = DateTime.Now;
                    cliente.Telefono          = this.txtTelefono.Text;
                    cliente.Password          = _password;
                    FContext.AddTotblClientes(cliente);

                    FContext.SaveChanges();
                    Session["IdCliente"] = cliente.pkClienteid;
                    CrearEmisor();
                    CreaUsuario();


                    Response.Redirect("listEmisores.aspx");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private void Add()
        {
            Crypt _crypt = new Crypt();

            _password = _crypt.MD5(this.txtPassword.Text);


            FContext = new FacturadorEntities1();
            try
            {
                var ObjUsuario = FContext.TblUsuarios.FirstOrDefault(Usuario => Usuario.CorreoElectronico == txtEmail.Text);

                if (ObjUsuario != null)
                {
                    //var _usr = FContext.TblUsuarios.FirstOrDefault(usr => usr.CorreoElectronico == txtEmail.Text && usr.Password == _password);

                    //if (_usr != null)
                    //{
                    lblError.Text = "El Correo Ya existe: ";
                    lnkRecuperarPassword.Visible = true;

                    //}
                }
                else
                {
                    tblCliente cliente = new tblCliente();

                    cliente.Nombre            = this.txtNombre.Text.ToUpper();
                    cliente.Empresa           = this.txtEmpresa.Text.ToUpper();
                    cliente.CorreoElectronico = this.txtEmail.Text;
                    cliente.FechaCreacion     = DateTime.Now;
                    cliente.Telefono          = this.txtTelefono.Text;
                    cliente.Password          = _password;
                    FContext.AddTotblClientes(cliente);

                    FContext.SaveChanges();
                    Session["IdCliente"] = cliente.pkClienteid;
                    CrearEmisor();
                    CreaUsuario();


                    Response.Redirect("Desktop.aspx");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }