Example #1
0
        //Extraer los datos de la vista
        public Usuario GetEntity()
        {
            Usuario us = new Usuario();

            if (Mnombre.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                us.Nombre = Mnombre.Text;
            }

            if (Mcontrasena.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                us.Contrasena = Mcontrasena.Text;
            }
            if (Mrol.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                Rol       = Mrol.SelectedValue;
                us.Id_rol = Convert.ToInt32(Rol);
            }
            us.Id_empleado = int.Parse(Idempleado.Value.ToString());
            us.Activo      = 1;

            return(us);
        }
Example #2
0
        public Empleado Modificar()
        {
            Empleado emp   = new Empleado();
            String   valor = Request.QueryString["id"];
            int      id    = int.Parse(valor);

            emp.Id_Empleado = id;

            if (Mnombre.ToString() == null)                     //valido los campos que no sean nulos
            {
                Mnombre.BorderColor = System.Drawing.Color.Red; //si son nulos, me tirara un error de validacion
            }
            else
            {
                emp.Nombre_Empleado = Mnombre.Text; //si son validos, me dejara enviar los datos a la base de datoa
            }
            if (Mapellido.ToString() == null)       //todo esto se hace para todos los campos del formulario
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                emp.Apellido = Mapellido.Text;
            }
            if (Mcedula.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                emp.Cedula = Mcedula.Text;
            }
            if (Mcargo.SelectedValue == null)//todo esto se hace para todos los campos del formulario
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                emp.Cargo = Mcargo.SelectedValue;
            }


            //  ord.Tipo_caso = Mtipocaso.SelectedValue;
            //ord.Tipo_orden = Mtipoorden.SelectedValue;
            //ord.Observaciones = Mobservaciones.Text;
            // ord.Baucher = Mbaucher.Text;
            // ord.No_orden = int.Parse(Mnoorden.Text);
            // ord.Estado = Mestado.SelectedValue;

            return(emp);
        }
Example #3
0
        protected void Iniciar_Sesion(object sender, EventArgs e)
        {
            string usuario = "a", contrasena = "b";

            //se declara una variable string para que reemplace los -- y ; y así evitar SQlInyection
            if (Mnombre.ToString() != null)
            {
                usuario = this.Mnombre.Text.Replace(";", "").Replace("--", "");
            }
            else
            {
                Response.Redirect("~/");
                //RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
                ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: Required(); ", true);
            }
            if (Mcontrasena.ToString() != null)
            {
                contrasena = this.Mcontrasena.Text.Replace(";", "").Replace("--", "");
            }
            else
            {
                Response.Redirect("~/");
                //RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
                ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: Required(); ", true);
            }

            //Se manda a llamar el metodo de autenticacion
            if (DTlogin.getInstance().Autenticar(usuario, contrasena) == true)
            {
                //Se verifica en la BD el Id_usuario
                DataTable tblUsuario = DTlogin.getInstance().prConsultaUsuario(usuario, contrasena);
                Session["Id_usuario"] = tblUsuario.Rows[0]["Id_usuario"].ToString();
                Session["Id_rol"]     = tblUsuario.Rows[0]["Id_rol"].ToString();
                Session["Activo"]     = tblUsuario.Rows[0]["Activo"].ToString();
                Response.Redirect("~/Views/Index");
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: ADD(); ", true);
            }
        }
Example #4
0
        public Empleado GetEntity()
        {
            Empleado emp = new Empleado();

            if (Mnombre.ToString() == null)                     //valido los campos que no sean nulos
            {
                Mnombre.BorderColor = System.Drawing.Color.Red; //si son nulos, me tirara un error de validacion
            }
            else
            {
                emp.Nombre_Empleado = Mnombre.Text; //si son validos, me dejara enviar los datos a la base de datoa
            }
            if (Mapellido.ToString() == null)       //todo esto se hace para todos los campos del formulario
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                emp.Apellido = Mapellido.Text;
            }
            if (Mcedula.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                emp.Cedula = Mcedula.Text;
            }
            if (Mcargo.SelectedValue == null)//todo esto se hace para todos los campos del formulario
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                emp.Cargo = Mcargo.SelectedValue;
            }



            return(emp);
        }
Example #5
0
        public Examen Modificar()
        {
            if (Mnombre.ToString() == null)
            {
                BorderStyle.Solid.ToString();
            }
            else
            {
                exam.nombre = Mnombre.Text;
            }
            if (Mprecio.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator3);
            }
            else
            {
                exam.precio_examen = Convert.ToDecimal(Mprecio.Text);
            }

            return(exam);
        }
Example #6
0
        public Usuario modificar()
        {
            Usuario usuario = new Usuario();
            String  valor   = Request.QueryString["id"];
            int     id      = int.Parse(valor);

            usuario.Id_usuario = id;

            if (Mnombre.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                usuario.Nombre = Mnombre.Text;
            }

            if (Mcontrasena.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                usuario.Contrasena = Mcontrasena.Text;
            }
            if (Mrol.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                Rol            = Mrol.SelectedValue;
                usuario.Id_rol = Convert.ToInt32(Rol);
            }
            usuario.Id_empleado = int.Parse(Idempleado.Value.ToString());
            usuario.Activo      = 1;

            return(usuario);
        }
        protected void Iniciar_Sesion(object sender, EventArgs e)
        {
            string usuario = "a", contrasena = "b";

            //se declara una variable string para que reemplace los -- y ; y así evitar SQlInyection
            if (Mnombre.ToString() != null)
            {
                usuario = this.Mnombre.Text.Replace(";", "").Replace("--", "");
            }
            else
            {
                Response.Redirect("~/");
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            if (Mcontrasena.ToString() != null)
            {
                contrasena = this.Mcontrasena.Text.Replace(";", "").Replace("--", "");
            }
            else
            {
                Response.Redirect("~/");
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }

            //Se manda a llamar el metodo de autenticacion
            if (DTlogin.getInstance().Autenticar(usuario, contrasena) == true)
            {
                //Se verifica en la BD el Id_usuario
                DataTable tblUsuario = DTlogin.getInstance().prConsultaUsuario(usuario, contrasena);
                Session["Id_usuario"] = tblUsuario.Rows[0]["Id_usuario"].ToString();
                Response.Redirect("~/Views/ViewLogin/Index");
            }
            else
            {
                Response.Write("<script>alert('El usuario o contraseña es invalido')</script)");
            }
        }
        public Usuario modificar()
        {
            Usuario usuario = new Usuario();
            String  valor   = Request.QueryString["id"];
            int     id      = int.Parse(valor);

            if (Mnombre.ToString() != null)
            {
                usuario.Nombre = Mnombre.Text;
            }

            if (Mcontrasena.ToString() != null)
            {
                usuario.Contrasena = Mcontrasena.Text;
            }

            if (Mrol.ToString() != null)
            {
                string Rol = Mrol.SelectedValue;
                us.Id_rol = Convert.ToInt32(Rol);
            }

            return(usuario);
        }
Example #9
0
        public Cliente GetEntity()
        {
            Cliente cli = new Cliente();

            // cli.Id_Cliente = int.Parse(id_cliente.ToString());
            if (Mnombre.ToString() == null)                     //valido los campos que no sean nulos
            {
                Mnombre.BorderColor = System.Drawing.Color.Red; //si son nulos, me tirara un error de validacion
            }
            else
            {
                cli.Nombres = Mnombre.Text;   //si son validos, me dejara enviar los datos a la base de datoa
            }
            if (Mapellido.ToString() == null) //todo esto se hace para todos los campos del formulario
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Apellidos = Mapellido.Text;
            }
            if (Mcedula.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Cedula = Mcedula.Text;
            }
            if (Mdepartamento.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Departamento = Mdepartamento.SelectedValue;
            }
            if (Mmunicipio.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Municipio = Mmunicipio.SelectedValue;
            }
            if (Msexo.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Sexo = Msexo.SelectedValue;
            }
            if (Mtelefono.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Telefono = int.Parse(Mtelefono.Text);
            }
            if (Mcorreo.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Correo = Mcorreo.Text;
            }
            if (Mdireccion.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Dirreccion = Mdireccion.Text;
            }
            return(cli);
        }
        public Cliente Modificar()
        {
            Cliente cli   = new Cliente();
            String  valor = Request.QueryString["id"];
            int     id    = int.Parse(valor);

            cli.Id_Cliente = id;
            if (Mnombre.ToString() == null)
            {
                BorderStyle.Solid.ToString();
            }
            else
            {
                cli.Nombres = Mnombre.Text;
            }
            if (Mapellido.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Apellidos = Mapellido.Text;
            }
            if (Mcedula.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Cedula = Mcedula.Text;
            }
            if (Mdepartamento.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Departamento = Mdepartamento.SelectedValue;
            }
            if (Mmunicipio.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Municipio = Mmunicipio.SelectedValue;
            }
            if (Msexo.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Sexo = Msexo.SelectedValue;
            }
            if (Mtelefono.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Telefono = int.Parse(Mtelefono.Text);
            }
            if (Mcorreo.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Correo = Mcorreo.Text;
            }
            if (Mdireccion.ToString() == null)
            {
                RegularExpressionValidator.GetValidationProperty(RequiredFieldValidator1);
            }
            else
            {
                cli.Dirreccion = Mdireccion.Text;
            }

            return(cli);
        }