Searching crystal reports in C#

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Windows.Forms;  
  9. using System.Data.OleDb;  
  10. namespace SakshiHospital  
  11. {  
  12.     public partial class DebitRpt: Form  
  13.     {  
  14.         public DebitRpt()   
  15.         {  
  16.             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);  
  17.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;  
  18.             this.ClientSize = new System.Drawing.Size(721, 439);  
  19.             this.Name = "Cry_Report";  
  20.             this.Text = "Cry_Report";  
  21.             this.Load += new System.EventHandler(this.DebitRpt_Load);  
  22.             this.ResumeLayout(false);  
  23.             this.SuspendLayout();  
  24.             InitializeComponent();  
  25.         }  
  26.         private void DebitRpt_Load(object sender, EventArgs e) {}  
  27.         private void btnSearch_Click(object sender, EventArgs e)  
  28.         {  
  29.             try   
  30.             {  
  31.                 // string bill_no = "B_00" + txtbillno.Text;  
  32.                 DataSet ds = new DataSet();  
  33.                 // con = new OleDbConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString);  
  34.                 OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=ClientMgmtDb1.accdb;");  
  35.                 con.Open();  
  36.                 OleDbDataAdapter da = new OleDbDataAdapter();  
  37.                 // if(txtbillno.Text.Trim().Length==0)  
  38.                 if (txtdebitnote.Text != "")   
  39.                 {  
  40.                     // MessageBox.Show("Enter Bill number");  
  41.                     da = new OleDbDataAdapter("select ID,NAME,Debit_Number,Date,Address,PO_Number,PO_Date,Narat,Quantity,Rate,Total_price,amount FROM Debit_Mst where Debit_Number='" + txtdebitnote.Text.Trim() + "'", con);  
  42.                 }  
  43.                 da.Fill(ds, "Debit");  
  44.                 if (ds.Tables.Count > 0)   
  45.                 {  
  46.                     Debitrptcr cr = new Debitrptcr();  
  47.                     // Bill2 cr = new Bill2();  
  48.                     cr.SetDataSource(ds.Tables[0]);  
  49.                     this.crystalReportViewer1.ReportSource = cr;  
  50.                     this.crystalReportViewer1.Show();  
  51.                     //// }  
  52.                 }  
  53.                 con.Close();  
  54.             } catch (OleDbException s)  
  55.             {  
  56.                 MessageBox.Show("Server Problem...");  
  57.             }  
  58.         }  
  59.         private void txtdebitnote_TextChanged(object sender, EventArgs e) {  
  60.             txtdebitnote.BackColor = System.Drawing.Color.Aquamarine;  
  61.             this.AcceptButton = btnSearch;  
  62.         }  
  63.     }  
  64. }