I have an application in c# is doing well but I wanna change the value of the
combobox. the value to the combobox is a datapickertime but I wanna catch the value of the database, called PRE_Fecha that value is datetime and catch all values starting off this value. The values are:

PRE_Numero
CLI_DNI
DES_Codigo
PER_Codigo
PRE_Fecha
PRE_Importe 
PRE_TasaInteres
PRE_CantidadCuotas
PRE_Estado

The code is :

    //Vistas or Views

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using ClasesBase;

     namespace Vistas

     {
     public partial class FrmListarPrestamoPorFecha : Form
     {
    public FrmListarPrestamoPorFecha()
    {
        InitializeComponent();
    }


    private void btnAceptar_Click(object sender, EventArgs e)
    {
        Prestamo oPrestamo = new Prestamo();


        oPrestamo.Pre_fecha = dateTimePickerFecha.Value; //Here i wanna catch the value PRE_Fecha, starting here i wanna call all the values of database

        DialogResult respuesta = MessageBox.Show("CONFIRMAR NUEVO PRESTAMO ? ", " ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

        {

            MessageBox.Show("NUEVO DESTINO " + "\n\n" + "NÂș DESTINO : " + TrabajarPrestamo.TraerIdPrestamo() + "\n");

            this.Close();


        }

    }        

    private void FrmListarPrestamoPorFecha_Load(object sender, EventArgs e)
    {
        dgvListadoPrestamos.DataSource = TrabajarPrestamo.traerPrestamos();          


    }

    private void btnCancelar_Click(object sender, EventArgs e)
    {
        this.Close();
    }
   }
  }
   //ClaseBase This is the class how i called in the view top

    public static DataTable traerPrestamos()
    {
        //Conexion 
        SqlConnection cnn = new SqlConnection(ClasesBase.Properties.Settings.Default.conex);

        //Comando de consulta
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "select * from Prestamo"; //HEre i call all the values of the database
        cmd.CommandType = System.Data.CommandType.Text;
        cmd.Connection = cnn;

        //Creo la tabla vacia
        DataTable tabla = new DataTable();

        //Creo el adaptador en base al comando cmd
        SqlDataAdapter da = new SqlDataAdapter(cmd);

        //Lleno la tabla con los datos de la base de datos
        da.Fill(tabla);

        //Devuelvo la tabla
        return tabla;

    }
    //This are the values of the database
    PRE_Numero
    CLI_DNI
    DES_Codigo
    PER_Codigo
    PRE_Fecha
    PRE_Importe 
    PRE_TasaInteres
    PRE_CantidadCuotas
    PRE_Estado

0 Answers