protected void Page_Load(object sender, EventArgs e)
        {
            //creamos los objetos de la biblioteca de datos;
            this.dtcliente   = new DTcliente();
            dtdepartamento   = new DTdepartamento();
            this.dtmunicipio = new DTmunicipio();
            cli = new Cliente();

            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  = dtcliente.getClienteporid(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     = dtdepartamento.listardepartamento(); //aqui le paso mi consulta que esta en la clase dtdepartamento
                Mdepartamento.DataTextField  = "Departamento";                      //le paso el texto del items
                Mdepartamento.DataValueField = "Id_departamento";                   //le paso el id de cada items
                Mdepartamento.DataBind();

                Mmunicipio.DataSource     = dtmunicipio.listarmunicipio();
                Mmunicipio.DataTextField  = "Municipio";
                Mmunicipio.DataValueField = "Id_Municipio";
                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();
                //le seteamos los valores que obtenemos del cliente;
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Creacion de los objetos
            this.dtcliente   = new DTcliente();
            dtdepartamento   = new DTdepartamento();
            cli              = new Cliente();
            this.dtmunicipio = new DTmunicipio();

            //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     = dtdepartamento.listardepartamento(); //aqui le paso mi consulta que esta en la clase dtdepartamento
            Mdepartamento.DataTextField  = "Departamento";                      //le paso el texto del items
            Mdepartamento.DataValueField = "Id_departamento";                   //le paso el id de cada items
            Mdepartamento.DataBind();

            //Cargar el Combobox de municipio
            Mmunicipio.DataSource     = dtmunicipio.listarmunicipio();
            Mmunicipio.DataTextField  = "Municipio";
            Mmunicipio.DataValueField = "Id_Municipio";
            Mmunicipio.DataBind();

            //Lamamos al metodo buscar cliente por id
            this.registro    = dtcliente.getClienteporid(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());
                this.cli.Correo  = this.registro["Email"].ToString();
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.dtcliente      = new DTcliente();
            this.dtdepartamento = new DTdepartamento();
            this.dtmunicipio    = new DTmunicipio();
            this.clientes       = this.dtcliente.listarCliente();
            if (!IsPostBack)
            {
                //en esta parte se carga el dropdownlist
                Mdepartamento.DataSource     = dtdepartamento.listardepartamento(); //aqui le paso mi consulta que esta en la clase dtdepartamento
                Mdepartamento.DataTextField  = "Departamento";                      //le paso el texto del items
                Mdepartamento.DataValueField = "Id_departamento";                   //le paso el id de cada items
                Mdepartamento.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;
            }
        }
Exemplo n.º 4
0
 public SqlDataReader ListarDepartamento()
 {
     return(DTdepartamento.getInstance().listardepartamento());
 }