Transfer date value from Form1 to class c# windows form . net

Asked

Viewed 230 times

1

I’m working with windows form . net c# but I don’t have much practice and would like a help...

I have a calendar component in a Form1 and after running the application, a date is selected which is stored in a var. So far so good. I created a class as shown below: In this Class I need to receive the value of the chosen date in Form1 and I don’t know how to do it...

Form1

private void btnBuscar_Click(object sender, EventArgs e)
{
    if (validaPeriodo() == true)
    {
        btnValidar.Enabled = true;
        btnGerar.Enabled = false;
        btnVisualizarFalha.Enabled = false;

        NewDb openDb = new NewDb();
        DataTable resultado = new DataTable();

        using (MySqlConnection db = openDb.AbrirConexaoMySql())
        {
            try
            {
                db.Open();


                if (CESDI.SelectedTab.Text == "CESDI")
                {
                    MySqlCommand sqlCommand = MamData.MySql.CESDI.SelectCESDI(db, dtaDataInicio.Text, dtaDataFinal.Text);
                    txtNAtos.Text = MamData.MySql.CESDI.SelectAtosCesdi(db, dtaDataInicio.Text, dtaDataFinal.Text);
                    inicializarGrids(sqlCommand, gridCESDI);
                }
            }
        }
    }
}

Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using MamData;
using System.Net;
using Comunicacao.Dal;

using System.Data;
using System.ComponentModel;
using MySql.Data.MySqlClient;


namespace Comunicacao.XML.CENSEC
{
    public class GeraSEFAZ
    {
        public static string dataInicial;
        public static string dataFinal;

        static public string geraXmlSEFAZ(List<DataGridViewRow> registros)
        {
        }
    }
}
  • Dude, improve your question, it got badly formatted in relation to the code and also the code is incomplete and kind of confusing.

1 answer

1

To use date you will have to work with DateTime. I don’t see how to work the date in your code just with String.

For example:

DateTime dataInicio = DateTime.Now; //Usando a data atual

Browser other questions tagged

You are not signed in. Login or sign up in order to post.