views:

246

answers:

0

this is my code .This is an application for generating reports in c# using crystal reports

private void button3_Click(object sender, EventArgs e)
{
        con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Documents and Settings/techsoft/My Documents/Database.accdb;Persist Security Info=False");
        con.Open();
        OleDbCommand cmm = new OleDbCommand("select * from Table3", con);
        OleDbDataReader drr;
        drr = cmm.ExecuteReader();
        drr.Read();
        CrystalReport1 cry = new CrystalReport1();
        string[] aa;
        int i;
        string a = textBox1.Text;(e.g 11/26/2009,11/27/2009,11/26/2009-11/27/2009)
        aa = a.Split(',');
        int  j = aa.Length;
        for (i = 0; i < j; i++)
        {
            if (textBox1.Text == "")
            {
                crystalReportViewer1.SelectionFormula = "{Table3.logindate}='" + textBox1.Text + "'and {Table3.id}='" + textBox2.Text + "'";
                MessageBox.Show("Date is Mandatory");
                goto Label89;
            }
            else if (textBox2.Text == "")
            {
                if (aa[i].Length == 21)
                {
                    string range;
                    range = aa[i].ToString();
                    string range1 = range.Substring(0, 10);
                    string range2 = range.Substring(11, 10);
                    crystalReportViewer1.SelectionFormula = "{Table3.logindate} >= '" + range1 + "'" + " and {Table3.logindate} <= '" + range2 + "'";


                }

              else 
                {

                    crystalReportViewer1.SelectionFormula = "({Table3.logindate}  = '" + aa[i] + "')";


                }


            }
            else if ((textBox1.Text != "") && (textBox2.Text != ""))
            {
                crystalReportViewer1.SelectionFormula = "{Table3.logindate}='" + textBox1.Text + "'and{Table3.id}='" + textBox2.Text + "'";

            }

            crystalReportViewer1.ReportSource = cry;   
       Label89: int y;
        }
}

here i am using multiline textbox i want to select a report by giving many different dates in a textbox at a time here i am getting reports only for the date which i have entered atlast. plz give me a solution