Example #1
0
        private BindingSource llenarCombo()
        {
            Clases.confirmador tele  = new Clases.confirmador();
            DataTable          table = new DataTable();

            table.Columns.Add("id");
            table.Columns.Add("nomnbre");
            table.Columns.Add("apellido");
            foreach (var item in tele.listarConfirmador())
            {
                DataRow row = table.NewRow();
                row[0] = item.id_confirmador;
                row[1] = item.nombre;
                row[2] = item.apellido;
                table.Rows.Add(row);
            }
            DataRowCollection rows = table.Rows;

            object[] cell;
            Dictionary <int, string> dic     = new Dictionary <int, string>();
            BindingSource            binding = new BindingSource();

            foreach (DataRow item in rows)
            {
                cell = item.ItemArray;

                dic.Add(Convert.ToInt32(cell[0]), cell[1].ToString() + " " + cell[2].ToString());

                cell = null;
            }

            binding.DataSource = dic;
            return(binding);
        }
Example #2
0
        public List <confirmador> listarConfirmador()
        {
            List <confirmador> confirmador = new List <confirmador>();

            if (con == null)
            {
                con = new conexion();
            }
            con.conectar();
            SqlCommand cmd = new SqlCommand("_sp_listarConfirmador", con.cnxn);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    confirmador conf = new confirmador();
                    conf.id_confirmador = dr.GetInt32(0);
                    conf.doc_iden       = dr.GetString(1).Trim(new char[] { ' ' });
                    conf.nombre         = dr.GetString(2).Trim(new char[] { ' ' });
                    conf.apellido       = dr.GetString(3).Trim(new char[] { ' ' });
                    conf.telefono       = dr.GetString(4).Trim(new char[] { ' ' });
                    conf.correo         = dr.GetString(5).Trim(new char[] { ' ' });


                    conf.C_TipoDocumento             = new C_TipoDocumento();
                    conf.C_TipoDocumento.descripcion = dr.GetString(6).Trim(new char[] { ' ' });
                    conf.id_td = dr.GetInt32(7);
                    // conf.codigo = dr.GetString(8).Trim(new char[] { ' ' });
                    confirmador.Add(conf);
                }
            }
            con.desconectar();
            return(confirmador);
        }