private BindingSource llenarCombo()
        {
            Clases.promotor prom  = new Clases.promotor();
            DataTable       table = new DataTable();

            table.Columns.Add("id");
            table.Columns.Add("nomnbre");
            table.Columns.Add("apellido");
            foreach (var item in prom.listarpromotor())
            {
                DataRow row = table.NewRow();
                row[0] = item.id_promotor;
                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);
        }
示例#2
0
        public List <promotor> listarpromotor()
        {
            List <promotor> promotor = new List <promotor>();

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

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

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    promotor tele = new promotor();
                    tele.id_promotor                 = dr.GetInt32(0);
                    tele.doc_iden                    = dr.GetString(1).Trim(new char[] { ' ' });
                    tele.nombre                      = dr.GetString(2).Trim(new char[] { ' ' });
                    tele.apellido                    = dr.GetString(3).Trim(new char[] { ' ' });
                    tele.telefono                    = dr.GetString(4).Trim(new char[] { ' ' });
                    tele.correo                      = dr.GetString(5).Trim(new char[] { ' ' });
                    tele.C_Locacion                  = new C_Locacion();
                    tele.C_Locacion.codigo           = dr.GetString(6).Trim(new char[] { ' ' });
                    tele.C_TipoDocumento             = new C_TipoDocumento();
                    tele.C_TipoDocumento.descripcion = dr.GetString(7).Trim(new char[] { ' ' });
                    tele.id_td       = dr.GetInt32(8);
                    tele.id_locacion = dr.GetInt32(9);
                    promotor.Add(tele);
                }
            }
            con.desconectar();
            return(promotor);
        }