如何在C#应用程序中更改此代码?

时间:2019-06-01 20:53:19

标签: c#

我在C#中有一个应用程序运行良好,但我想更改值  的
 组合框。  组合框的值是datapickertime,但我想捕捉  的价值  名为PRE_Fecha的数据库,其值为datetime并捕获所有  从此值开始的值。     值是:

PRE_Numero
CLI_DNI
DES_Codigo
PER_Codigo
PRE_Fecha
PRE_Importe 
PRE_TasaInteres
PRE_CantidadCuotas
PRE_Estado

代码是:

    //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 个答案:

没有答案