Ejemplo n.º 1
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);
        }