public bool Autenticar_Usuario(ref Cls_Usuario_DAL Obj_Usuario_DAL, string Correo, string clave)
        {
            Cls_BD_BLL Obj_BD_BLL = new Cls_BD_BLL();
            Cls_BD_DAL Obj_BD_DAL = new Cls_BD_DAL();

            Obj_BD_DAL.SNomTabla  = "Usuarios";
            Obj_BD_DAL.SSentencia = "SP_CONSULTAR_USUARIOS";//  Necesito que devuelva

            Obj_BD_BLL.Crear_DT_Parametros(ref Obj_BD_DAL);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@Correo", "4", Correo); // 4 es varchar
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@Clave", "4", clave);   // 4 es varchar

            //Obj_BD_BLL.Exec_DataAdapter(ref Obj_BD_DAL);

            if (Obj_BD_DAL.SMsjError == string.Empty)
            {
                Obj_Usuario_DAL.SMsj_Error = string.Empty;
                Obj_Usuario_DAL.Ds         = Obj_BD_DAL.DS;
                if (Obj_Usuario_DAL.Ds.Tables.Contains(Correo) && Obj_Usuario_DAL.Ds.Tables.Contains(clave))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                Obj_Usuario_DAL.SMsj_Error = Obj_BD_DAL.SMsjError;
                Obj_Usuario_DAL.Ds         = null;
                return(false);
            }
        }
Пример #2
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     if (txtusuario.Value.Trim().Equals(string.Empty) || txtcontrasena.Value.Trim().Equals(string.Empty) || DropDownTUsuarios.SelectedIndex == 0)
     {
         //se agrega el label que indique lo que no hay datos
         lblGuardar.InnerText = "Debe ingresar datos";
         lblGuardar.Visible   = true;
     }
     else
     {
         lblGuardar.Visible = false;
         if (!txtcontrasena.Value.Trim().Equals(string.Empty))
         {
             Cls_Usuario_BLL Obj_Usuario_BLL = new Cls_Usuario_BLL();
             Obj_Usuarios_DAL             = new Cls_Usuario_DAL();
             Obj_Usuarios_DAL.SIdUsuario  = txtusuario.Value.ToString();
             Obj_Usuarios_DAL.SIdPersona  = DropDownTUsuarios.Value;
             Obj_Usuarios_DAL.SContrasena = txtcontrasena.Value.Trim();
             Obj_Usuario_BLL.Encripta(ref Obj_Usuarios_DAL);
             if ((BD)Session["tipo"] == BD.Actualizar)
             {
                 Obj_Usuario_BLL.crudUsuario(ref Obj_Usuarios_DAL, BD.Actualizar);
             }
             else if ((BD)Session["tipo"] == BD.Insertar)
             {
                 Obj_Usuario_BLL.crudUsuario(ref Obj_Usuarios_DAL, BD.Insertar);
             }
         }
         Response.Redirect(pantallaMantenimiento, true);
     }
 }
Пример #3
0
 public void Encripta(ref Cls_Usuario_DAL Obj_Usuario_DAL)
 {
     try
     {
         byte[]          inputBytes = Encoding.ASCII.GetBytes(Obj_Usuario_DAL.SContrasena);
         byte[]          encripted;
         RijndaelManaged cripto = new RijndaelManaged();
         using (MemoryStream ms = new MemoryStream(inputBytes.Length))
         {
             using (CryptoStream objCryptoStream = new CryptoStream(ms, cripto.CreateEncryptor(Clave, IV), CryptoStreamMode.Write))
             {
                 objCryptoStream.Write(inputBytes, 0, inputBytes.Length);
                 objCryptoStream.FlushFinalBlock();
                 objCryptoStream.Close();
             }
             encripted = ms.ToArray();
         }
         Obj_Usuario_DAL.SContrasena = Convert.ToBase64String(encripted);
         Obj_Usuario_DAL.sMsjError   = string.Empty;
     }
     catch (Exception ex)
     {
         Obj_Usuario_DAL.sMsjError = ex.Message.ToString();
     }
 }
        private void Login(char tipo)
        {
            Cls_Persona_DAL Obj_Persona_DAL  = new Cls_Persona_DAL();
            Cls_Usuario_DAL Obj_Usuarios_DAL = new Cls_Usuario_DAL();
            Cls_Usuario_BLL Obj_Usuarios_BLL = new Cls_Usuario_BLL();

            Obj_Usuarios_DAL.SIdPersona  = this.uname.Value;
            Obj_Usuarios_DAL.SContrasena = this.psw.Value;
            Obj_Usuarios_BLL.Encripta(ref Obj_Usuarios_DAL);
            Obj_Usuarios_BLL.Login(ref Obj_Usuarios_DAL);

            if (Obj_Usuarios_DAL.DS.Tables[0].Rows.Count > 0)
            {
                Obj_Persona_DAL.bIdRol  = Convert.ToByte(Obj_Usuarios_DAL.DS.Tables[0].Rows[0][1]);
                Obj_Persona_DAL.sNombre = Obj_Usuarios_DAL.DS.Tables[0].Rows[0][0].ToString();
                Session["Login"]        = Obj_Persona_DAL;

                if (Obj_Persona_DAL.bIdRol == 1)
                {
                    Response.Redirect(sistemaMantenimiento, false);
                }
                else
                {
                    Response.Redirect(sistemaCliente, false);
                }
            }
            else
            {
                Response.Write("<script>window.alert('Usuario No se puede Registrar o ya se encuentra registrado');</script>");
            }
        }
        public void Modificar_Usuarios(ref Cls_Usuario_DAL Obj_Usuario_DAL, String Correo)
        {
            Cls_BD_BLL Obj_BD_BLL = new Cls_BD_BLL();
            Cls_BD_DAL Obj_BD_DAL = new Cls_BD_DAL();

            Obj_BD_DAL.SNomTabla  = "";
            Obj_BD_DAL.SSentencia = "SP_ACTUALIZAR_Usr_Usuario";

            Obj_BD_BLL.Crear_DT_Parametros(ref Obj_BD_DAL);

            Obj_BD_DAL.Dt_Parametros.Rows.Add("@vc_nombreUsuario", "4", Obj_Usuario_DAL.SNombre);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@vc_cedulaUsuario", "4", Obj_Usuario_DAL.SNotas);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@vc_telefonoUsuario", "4", Obj_Usuario_DAL.STelefono);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@vc_correoUsuario", "4", Correo);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@vc_claveUsuario", "4", Obj_Usuario_DAL.SClave);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@b_activoUsuario", "3", Obj_Usuario_DAL.BNotificaciones);


            Obj_BD_BLL.Exec_NonQuery(ref Obj_BD_DAL);

            if (Obj_BD_DAL.SMsjError == string.Empty)
            {
                Obj_Usuario_DAL.SMsj_Error = string.Empty;
                Obj_Usuario_DAL.BEstAX     = true;
                Obj_Usuario_DAL.SAX        = "U";
            }
            else
            {
                Obj_Usuario_DAL.SMsj_Error = Obj_BD_DAL.SMsjError;
                Obj_Usuario_DAL.BEstAX     = false;
                Obj_Usuario_DAL.SAX        = "U";
            }
        }
Пример #6
0
        private void BindGrid()
        {
            //Se instancia objeto
            Obj_Usuario_DAL = new Cls_Usuario_DAL();

            if (this.txtFiltrar.Value == string.Empty)//listar
            {
                //llamado metodo listar estados
                Obj_Usuario_BLL.crudUsuario(ref Obj_Usuario_DAL, BD.Listar);
            }
            else
            {
                Obj_Usuario_DAL.SIdUsuario = this.txtFiltrar.Value;
                //llamado metodo listar estados
                Obj_Usuario_BLL.crudUsuario(ref Obj_Usuario_DAL, BD.Filtrar);
            }

            if (Obj_Usuario_DAL.sMsjError == string.Empty)
            {
                //Carga de Grid con DataSet instanciado en DAL
                this.UsuariosGridView.DataSource = Obj_Usuario_DAL.DS.Tables[0];
                this.UsuariosGridView.DataBind();
            }
            else
            {
                this.errorMensaje.InnerHtml = "Se presento un error a la hora de listar Usuarios.";
                this.BindGrid();
            }
        }
        public void Insertar_Usuarios(ref Cls_Usuario_DAL Obj_Usuario_DAL)
        {
            Cls_BD_BLL Obj_BD_BLL = new Cls_BD_BLL();
            Cls_BD_DAL Obj_BD_DAL = new Cls_BD_DAL();

            Obj_BD_DAL.SNomTabla  = "";
            Obj_BD_DAL.SSentencia = "SP_INSERTAR_USUARIO1";

            Obj_BD_BLL.Crear_DT_Parametros(ref Obj_BD_DAL);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@Nombre", "4", Obj_Usuario_DAL.SNombre);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@Notas", "4", Obj_Usuario_DAL.SNotas);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@Telefono", "4", Obj_Usuario_DAL.STelefono);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@Correo", "4", Obj_Usuario_DAL.SCorreo);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@Clave", "4", Obj_Usuario_DAL.SClave);
            Obj_BD_DAL.Dt_Parametros.Rows.Add("@Notificaciones", "3", Obj_Usuario_DAL.BNotificaciones);



            Obj_BD_BLL.Exec_NonQuery(ref Obj_BD_DAL);

            if (Obj_BD_DAL.SMsjError == string.Empty)
            {
                Obj_Usuario_DAL.SMsj_Error = string.Empty;
                Obj_Usuario_DAL.BEstAX     = true;
                Obj_Usuario_DAL.SAX        = "U";
            }
            else
            {
                Obj_Usuario_DAL.SMsj_Error = Obj_BD_DAL.SMsjError;
                Obj_Usuario_DAL.BEstAX     = false;
                Obj_Usuario_DAL.SAX        = "I";
            }
        }
Пример #8
0
        protected void btnEliminar_Click(object sender, EventArgs e)
        {
            if (vFiltra)
            {
                Obj_Usuario_DAL = new Cls_Usuario_DAL();

                //Recorre Grid buscando chk
                foreach (GridViewRow row in UsuariosGridView.Rows)
                {
                    //busca el la fila
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        //si esta checkeado instancia las propiedades del objeto
                        CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox);
                        if (chkRow.Checked)
                        {
                            Obj_Usuario_DAL.SIdUsuario = row.Cells[0].Text;
                            //llamado metodo eliminar estados
                            Obj_Usuario_BLL.crudUsuario(ref Obj_Usuario_DAL, BD.Eliminar);// eliminar estados
                        }
                    }
                }
                if (Obj_Usuario_DAL.sMsjError == string.Empty)
                {
                    this.errorMensaje.InnerHtml = "Usuario Eliminado con exito.";
                    this.BindGrid();
                }
                else
                {
                    this.errorMensaje.InnerHtml = "Se presento un error a la hora de Eliminar Usuario.";
                    this.BindGrid();
                }
            }
        }
Пример #9
0
        public void crudUsuario(ref Cls_Usuario_DAL Obj_Usuario_DAL, BD Accion)
        {
            // Se instancia el Objeto de CatalogosMantenimientosClient (WCF)
            CatalogosMantenimientosClient Obj_Usuario_Client = new CatalogosMantenimientosClient();

            try
            {
                // Se abre la conexion al servicio
                Obj_Usuario_Client.Open();
                // Se cargan trae el DataTable y se carga al Obj_Estado_DAL
                string sMsjError = string.Empty;
                switch (Accion)
                {
                case BD.Actualizar:
                    Obj_Usuario_Client.actualizarUsuario(Obj_Usuario_DAL.SIdUsuario, Obj_Usuario_DAL.SIdPersona, Obj_Usuario_DAL.SContrasena, ref sMsjError);
                    break;

                case BD.Eliminar:
                    Obj_Usuario_Client.eliminarUsuario(Obj_Usuario_DAL.SIdUsuario, ref sMsjError);
                    break;

                case BD.Filtrar:
                    Obj_Usuario_DAL.DS.Tables.Add(Obj_Usuario_Client.filtrarUsuario(Obj_Usuario_DAL.SIdUsuario, Obj_Usuario_DAL.SIdPersona, Obj_Usuario_DAL.SContrasena, ref sMsjError));
                    break;

                case BD.Insertar:
                    Obj_Usuario_Client.insertarUsuario(Obj_Usuario_DAL.SIdUsuario, Obj_Usuario_DAL.SIdPersona, Obj_Usuario_DAL.SContrasena, ref sMsjError);
                    break;

                case BD.Listar:
                    Obj_Usuario_DAL.DS.Tables.Add(Obj_Usuario_Client.listarUsuario(ref sMsjError));
                    break;

                case BD.FiltrarVista:
                    Obj_Usuario_DAL.DS.Tables.Add(Obj_Usuario_Client.filtrarUsuario(Obj_Usuario_DAL.SIdUsuario, Obj_Usuario_DAL.SIdPersona, Obj_Usuario_DAL.SContrasena, ref sMsjError));
                    break;

                default:
                    break;
                }
                Obj_Usuario_DAL.sMsjError = sMsjError;
            }
            catch (Exception ex)
            {
                Obj_Usuario_DAL.sMsjError = ex.Message.ToString();
            }
            finally
            {
                if (Obj_Usuario_Client.State == System.ServiceModel.CommunicationState.Opened)
                {
                    Obj_Usuario_Client.Close();
                }
            }
        }
        protected void Registrarse(object sender, EventArgs e)
        {
            Cls_Persona_DAL Obj_Persona_DAL = new Cls_Persona_DAL();
            Cls_Persona_BLL Obj_Persona_BLL = new Cls_Persona_BLL();

            Obj_Persona_DAL.sIdPersona = this.cedulaRG.Value.ToString().Trim();
            Obj_Persona_DAL.sNombre    = this.nombreRG.Value.ToString().Trim();
            Obj_Persona_DAL.sDireccion = this.direccionRG.Value.ToString().Trim();
            Obj_Persona_DAL.bIdRol     = (byte)Rol.Cliente;

            Obj_Persona_BLL.crudPersona(ref Obj_Persona_DAL, BD.Insertar);

            Cls_Telefonos_DAL Obj_Telefonos_DAL = new Cls_Telefonos_DAL();
            Cls_Telefono_BLL  Obj_Telefonos_BLL = new Cls_Telefono_BLL();

            Obj_Telefonos_DAL.sTelefono  = this.telefonoRG.Value.ToString().Trim();
            Obj_Telefonos_DAL.sIdPersona = this.cedulaRG.Value.ToString().Trim();
            Obj_Telefonos_BLL.crudTelefono(ref Obj_Telefonos_DAL, BD.Insertar);//   insertar

            Cls_Correos_DAL Obj_Correo_DAL = new Cls_Correos_DAL();
            Cls_Correos_BLL Obj_Correo_BLL = new Cls_Correos_BLL();

            Obj_Correo_DAL.sIdPersona = this.cedulaRG.Value.ToString().Trim();
            Obj_Correo_DAL.sCorreo    = this.emailRG.Value.ToString().Trim();
            Obj_Correo_BLL.crudCorreos(ref Obj_Correo_DAL, BD.Insertar);//  insertar


            Cls_Clientes_DAL Obj_Cliente_DAL = new Cls_Clientes_DAL();
            Cls_Clientes_BLL Obj_Cliente_BLL = new Cls_Clientes_BLL();

            Obj_Cliente_DAL.sIdPersona     = this.cedulaRG.Value.ToString().Trim();
            Obj_Cliente_DAL.bIdTipoCliente = (byte)Cliente.Socio;
            Obj_Cliente_BLL.crudCliente(ref Obj_Cliente_DAL, BD.Insertar);


            Cls_Usuario_DAL Obj_Usuario_DAL = new Cls_Usuario_DAL();
            Cls_Usuario_BLL Obj_Usuario_BLL = new Cls_Usuario_BLL();

            Obj_Usuario_DAL.SIdUsuario  = this.cedulaRG.Value.ToString().Trim();
            Obj_Usuario_DAL.SIdPersona  = this.cedulaRG.Value.ToString().Trim();
            Obj_Usuario_DAL.SContrasena = this.passwordRG.Value.ToString().Trim();
            Obj_Usuario_BLL.Encripta(ref Obj_Usuario_DAL);
            Obj_Usuario_BLL.crudUsuario(ref Obj_Usuario_DAL, BD.Insertar);


            Obj_Persona_DAL.sIdPersona = this.cedulaRG.Value.ToString().Trim();
            Obj_Persona_BLL.crudPersona(ref Obj_Persona_DAL, BD.Filtrar);

            Session["Login"] = Obj_Persona_DAL;
            Server.Transfer("IndexCliente.aspx");
        }
Пример #11
0
 public void Login(ref Cls_Usuario_DAL Obj_Usuario_DAL)
 {
     try
     {
         // Se instancia el Objeto de CatalogosMantenimientosClient (WCF)
         CatalogosMantenimientosClient Obj_Usuario_Client = new CatalogosMantenimientosClient();
         // Se cargan trae el DataTable
         string sMsjError = string.Empty;
         Obj_Usuario_DAL.DS.Tables.Add(Obj_Usuario_Client.Login(Obj_Usuario_DAL.SIdPersona, Obj_Usuario_DAL.SContrasena, ref sMsjError));
         Obj_Usuario_Client.Close();
         Obj_Usuario_DAL.sMsjError = sMsjError;
     }
     catch (Exception ex)
     {
         Obj_Usuario_DAL.sMsjError = ex.Message.ToString();
     }
 }
Пример #12
0
        private void validaPassword()
        {
            Cls_Usuario_DAL Obj_Usuarios_DAL = new Cls_Usuario_DAL();
            Cls_Usuario_BLL Obj_Usuarios_BLL = new Cls_Usuario_BLL();

            Cls_Persona_DAL persona = (Cls_Persona_DAL)Session["Login"];


            if (passwordRG.Value != string.Empty)
            {
                Obj_Usuarios_DAL.SIdPersona  = this.cedulaRG.Value;
                Obj_Usuarios_DAL.SContrasena = this.passwordRG.Value;
                Obj_Usuarios_BLL.Encripta(ref Obj_Usuarios_DAL);
                Obj_Usuarios_BLL.Login(ref Obj_Usuarios_DAL);

                if (Obj_Usuarios_DAL.DS.Tables[0].Rows[0][0].ToString() == persona.sNombre)
                {
                    validacion = true;
                }
            }
        }
Пример #13
0
        public string Modificar_Usuario(string Correo, string Clave, string Nombre, string Notas, string Telefono, bool Notificaciones)
        {
            Cls_Usuario_DAL Obj_Usuario_DAL = new Cls_Usuario_DAL();
            Cls_Usuario_BLL Obj_Usuario_BLL = new Cls_Usuario_BLL();

            Obj_Usuario_DAL.SCorreo         = Correo;
            Obj_Usuario_DAL.SClave          = Clave;
            Obj_Usuario_DAL.SNombre         = Nombre;
            Obj_Usuario_DAL.SNotas          = Notas;
            Obj_Usuario_DAL.STelefono       = Telefono;
            Obj_Usuario_DAL.BNotificaciones = Notificaciones;
            Obj_Usuario_BLL.Modificar_Usuarios(ref Obj_Usuario_DAL, Correo);

            if (Obj_Usuario_DAL.SMsj_Error == string.Empty)
            {
                return("Usuario Modificado");
            }
            else
            {
                return("Error de conexion");
            }
        }
Пример #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         LlenarDDL();
         if ((BD)Session["tipo"] == BD.Actualizar)
         {
             Obj_Usuarios_DAL           = (Cls_Usuario_DAL)Session["Usuario"];
             mantenimiento.InnerHtml    = "Modificacion de Usuario";
             txtusuario.Disabled        = true;
             txtusuario.Value           = Obj_Usuarios_DAL.SIdUsuario.ToString();
             DropDownTUsuarios.Disabled = true;
             DropDownTUsuarios.Value    = Obj_Usuarios_DAL.SIdPersona;
         }
         else if ((BD)Session["tipo"] == BD.Insertar)
         {
             mantenimiento.InnerHtml         = "Nuevos de Usuario";
             txtusuario.Value                = string.Empty;
             DropDownTUsuarios.SelectedIndex = 0;
             txtcontrasena.Value             = string.Empty;
         }
     }
 }
        public bool Recuperar_Clave_Usuarios(ref Cls_Usuario_DAL Obj_Usuario_DAL)
        {
            Cls_BD_BLL Obj_BD_BLL = new Cls_BD_BLL();
            Cls_BD_DAL Obj_BD_DAL = new Cls_BD_DAL();

            Obj_BD_DAL.SNomTabla  = "Usuarios";
            Obj_BD_DAL.SSentencia = "SP_LISTAR_CORREOS";

            //Obj_BD_BLL.Exec_DataAdapter(ref Obj_BD_DAL);

            if (Obj_BD_DAL.SMsjError == string.Empty)
            {
                Obj_Usuario_DAL.SMsj_Error = string.Empty;
                Obj_Usuario_DAL.Ds         = Obj_BD_DAL.DS;
                return(true);
            }
            else
            {
                Obj_Usuario_DAL.SMsj_Error = Obj_BD_DAL.SMsjError;
                Obj_Usuario_DAL.Ds         = null;
                return(false);
            }
        }
Пример #16
0
 protected void btnEditar_Click(object sender, EventArgs e)
 {
     //Recorre Grid buscando chk
     foreach (GridViewRow row in UsuariosGridView.Rows)
     {
         //busca el la fila
         if (row.RowType == DataControlRowType.DataRow)
         {
             //si esta checkeado instancia las propiedades del objeto
             if ((row.Cells[0].FindControl("chkRow") as CheckBox).Checked)
             {
                 //Secion tipo Editar
                 Session["tipo"] = BD.Actualizar;
                 //Se instancia objeto
                 Obj_Usuario_DAL            = new Cls_Usuario_DAL();
                 Obj_Usuario_DAL.SIdUsuario = row.Cells[0].Text.Trim();
                 Obj_Usuario_DAL.SIdPersona = row.Cells[1].Text.Trim();
                 //Sesion estado lleva el objeto
                 Session["Usuario"] = Obj_Usuario_DAL;
                 Response.Redirect(pantallaMantenimiento, false);
             }
         }
     }
 }
Пример #17
0
 public void Desencripta(ref Cls_Usuario_DAL Obj_Usuario_DAL)
 {
     try
     {
         byte[]          inputBytes  = Convert.FromBase64String(Obj_Usuario_DAL.SContrasena);
         byte[]          resultBytes = new byte[inputBytes.Length];
         RijndaelManaged cripto      = new RijndaelManaged();
         using (MemoryStream ms = new MemoryStream(inputBytes))
         {
             using (CryptoStream objCryptoStream = new CryptoStream(ms, cripto.CreateDecryptor(Clave, IV), CryptoStreamMode.Read))
             {
                 using (StreamReader sr = new StreamReader(objCryptoStream, true))
                 {
                     Obj_Usuario_DAL.SContrasena = sr.ReadToEnd();
                 }
             }
         }
         Obj_Usuario_DAL.sMsjError = string.Empty;
     }
     catch (Exception ex)
     {
         Obj_Usuario_DAL.sMsjError = ex.Message.ToString();
     }
 }