Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ng = new NGcliente();
            //creamos los objetos de la biblioteca de datos;
            cli = new Cliente();
            Mcedula.MaxLength = 16;

            String valor = Request.QueryString["id"];   //obtenemos el id que le pasamos a travez de la url
            int    id    = int.Parse(valor);            //parseamos el valorm, para obtenerlo un int;

            cli.Id_Cliente = id;                        //le asignamos ese id a la propiedad id_cliente;
            this.registro  = ng.ListarClientePorId(id); //usamos el metodo de la clase dtcliente para buscar el cliente por el id

            if (!IsPostBack)
            {
                //en esta parte se carga el dropdownlist
                Mdepartamento.DataSource = ng.ListarDepartamento();//aqui le paso mi consulta que esta en la clase dtdepartamento
                Mdepartamento.DataBind();

                Mmunicipio.DataSource = ng.ListarMunicipio();
                Mmunicipio.DataBind();

                ListItem li = new ListItem("SELECCIONE", "0"); //creamos una lista, para agregar el seleccione
                Mdepartamento.Items.Insert(0, li);             //agregamis el seleccione en la posicion uno
                Mmunicipio.Items.Insert(0, li);
                Mmunicipio.Enabled = false;
            }

            Id_cliente.Value = valor; //le pasamos el valor del id a este hidden por si de un error, no perder el id y volver a cargar la pagina con esos datos;
            if (registro.Read())      //validamos
            {
                this.cli.Nombres = this.registro["Nombre"].ToString();
                cli.Apellidos    = this.registro["Apellido"].ToString();
                cli.Cedula       = this.registro["Cedula"].ToString();
                cli.Departamento = this.registro["Id_Departamento"].ToString();
                cli.Municipio    = this.registro["Id_Municipio"].ToString();
                cli.Dirreccion   = this.registro["Direccion"].ToString();
                cli.Sexo         = this.registro["sexo"].ToString();
                cli.Telefono     = int.Parse(this.registro["Num_Telefono"].ToString());
                this.cli.Correo  = this.registro["Email"].ToString();
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Creacion de los objetos
            cli = new Cliente();
            NGcliente ng = new NGcliente();

            //Obtener id del cliente
            String valor = Request.QueryString["id"];
            int    id    = int.Parse(valor);

            cli.Id_Cliente = id;

            //Cargar el Combobox de departamento
            Mdepartamento.DataSource = ng.ListarDepartamento();            //aqui le paso mi consulta que esta en la clase dtdepartamento
            Mdepartamento.DataBind();

            //Cargar el Combobox de municipio
            Mmunicipio.DataSource = ng.ListarMunicipio();
            Mmunicipio.DataBind();

            //Lamamos al metodo buscar cliente por id
            registro         = ng.ListarClientePorId(id);
            Id_cliente.Value = valor;

            //Comenzamos a recorer el sqldatareader
            if (registro.Read())
            {
                //seteamos los datos de los campos de ese cliente
                this.cli.Nombres = this.registro["Nombre"].ToString();
                cli.Apellidos    = this.registro["Apellido"].ToString();
                cli.Cedula       = this.registro["Cedula"].ToString();
                cli.Departamento = this.registro["Id_Departamento"].ToString();
                cli.Dirreccion   = this.registro["Direccion"].ToString();
                cli.Municipio    = this.registro["Id_Municipio"].ToString();
                cli.Sexo         = this.registro["Sexo"].ToString();
                cli.Telefono     = int.Parse(this.registro["Num_Telefono"].ToString());
                cli.Correo       = this.registro["Email"].ToString();
            }
        }