Ejemplo n.º 1
0
        private BindingSource llenarComboTO()
        {
            Clases.C_Telemarketing tele = new Clases.C_Telemarketing();
            DataTable table             = new DataTable();

            table.Columns.Add("id");
            table.Columns.Add("nomnbre");
            table.Columns.Add("apellido");
            foreach (var item in tele.listarTelemarketing())
            {
                DataRow row = table.NewRow();
                row[0] = item.id_telemarketing;
                row[1] = item.nombre;
                row[2] = item.codigo;
                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[2].ToString());

                cell = null;
            }

            binding.DataSource = dic;
            return(binding);
        }
Ejemplo n.º 2
0
        public List <C_Telemarketing> listarTelemarketing()
        {
            List <C_Telemarketing> telemarketing = new List <C_Telemarketing>();

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

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

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    C_Telemarketing tele = new C_Telemarketing();
                    tele.id_telemarketing = 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_TipoDocumento             = new C_TipoDocumento();
                    tele.C_TipoDocumento.descripcion = dr.GetString(6).Trim(new char[] { ' ' });
                    tele.id_td  = dr.GetInt32(7);
                    tele.codigo = dr.GetString(8).Trim(new char[] { ' ' });
                    telemarketing.Add(tele);
                }
            }
            con.desconectar();
            return(telemarketing);
        }