Hi all,
I've got a problem which I can't solve by myself.
I have a Windows Form (
RepF
) which contains a Microsoft Report Viewer (
Report1.rdlc
) component.
Also, I have another Windows Form (
Principal
) where I fill in the information about the invoice, the system automatically generates the number of this invoice and insert it into the database (MySQL).
When I click over the button that stores these information into the database, the system shows me a window asking me if I want to print it. If I click
YES, the system opens the Windows Form
RepF
, sending the invoice number as a parameter to this Windows Form constructor.
public RepF(string invoiceNumber)
{
InitializeComponent();
_invoiceNumber = invoiceNumber;
}
After this, in the
RepF_Load
I initialize some
DataTables
and fill them with MySqlDataAdapters.
private void RepF_Load(object sender, EventArgs e)
{
this.reportViewer1.RefreshReport();
StreamReader stR = File.OpenText(filePath);
while (sLine != null)
{
sLine = stR.ReadLine();
if (sLine != null)
{ fileEntries.Add(sLine); }
}
_hostName = fileEntries[0].ToString();
_database = fileEntries[1].ToString();
_portNumber = fileEntries[2].ToString();
_userName = fileEntries[3].ToString();
_userPassword = fileEntries[4].ToString();
bdConn = new MySqlConnection("Server=" + _hostName + ";Port=" + _portNumber + ";Database=" + _database + ";Uid=" + _userName + ";Pwd=" + _userPassword + "; Connection Timeout = 3");
string teste = "Server=" + _hostName + ";Port=" + _portNumber + ";Database=" + _database + ";Uid=" + _userName + ";Pwd=" + _userPassword;
bdConn.Open();
MySqlCommand mscInvoiceDetails = new MySqlCommand("SELECT invoice_code, dt_invoice, total_value, observation FROM tb_invoices WHERE invoice_code = \'" + _invoiceNumber + "\';", bdConn);
MySqlCommand mscInvoiceDescriptionDetails = new MySqlCommand("SELECT detail_description, detail_value, ind_taxible FROM tb_doc_details WHERE tb_invoices_id_invoice = (SELECT id_invoice FROM tb_invoices WHERE invoice_code = \'" + _invoiceNumber + "\');", bdConn);
MySqlCommand mscClientDetails = new MySqlCommand("SELECT company_name, company_registration, address, corporate_name FROM tb_client WHERE id = (SELECT tb_client_id FROM tb_invoices WHERE invoice_code = \'" + _invoiceNumber + "\');", bdConn);
MySqlCommand mscPaymentTypeDetails = new MySqlCommand("SELECT payment_type_name, payment_type_description FROM tb_payment_type WHERE id = (SELECT tb_payment_type_id FROM tb_invoices WHERE invoice_code = \'" + _invoiceNumber + "\');", bdConn);
MySqlCommand mscDocumentTypeDetails = new MySqlCommand("SELECT doc_type_cd FROM tb_doc_type WHERE id_doc_type = (SELECT tb_doc_type_id_doc_type FROM tb_invoices WHERE invoice_code = \'" + _invoiceNumber + "\');", bdConn);
MySqlDataAdapter mscDAdtInvoiceDetails = new MySqlDataAdapter(mscInvoiceDetails);
mscDAdtInvoiceDetails.Fill(dtInvoiceDetails);
MySqlDataAdapter mscDAdtInvoiceDescriptionDetails = new MySqlDataAdapter(mscInvoiceDescriptionDetails);
mscDAdtInvoiceDescriptionDetails.Fill(dtInvoiceDescriptionDetails);
MySqlDataAdapter mscDAdtClientDetails = new MySqlDataAdapter(mscClientDetails);
mscDAdtClientDetails.Fill(dtClientDetails);
MySqlDataAdapter mscDAdtPaymentTypeDetails = new MySqlDataAdapter(mscPaymentTypeDetails);
mscDAdtPaymentTypeDetails.Fill(dtPaymentTypeDetails);
MySqlDataAdapter mscDAdtDocumentTypeDetails = new MySqlDataAdapter(mscDocumentTypeDetails);
mscDAdtDocumentTypeDetails.Fill(dtDocumentTypeDetails);
}
private void reportViewer1_Load(object sender, EventArgs e)
{
}
As you can see, I don't have a
DataSet
, as I am creating and populating my
DataTables
during the code execution, and, the Microsoft Report Viewer component is in this Windows Form (
RepF
) class.
This Windows Report Viewer has its report already configured (with text boxes and a table).
What I need to know is:
How can I use the data stored in those DataTables
in my report (Report1.rldc
), to see and print those information?
Notes:
1 - I am using Visual Studio Team System - C#
2 - I am not an experienced programmer
Thanks in advance! :)