suhel jamadar

suhel jamadar

  • NA
  • 133
  • 11.2k

RDLC report filter by date, & Customer wise

May 14 2020 5:14 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using Microsoft.Reporting.WinForms;
namespace WindowsFormsApp2
{
public partial class SalesReport : Form
{
public SalesReport()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\kolhapur_it\Documents\Data.mdf;Integrated Security=True;Connect Timeout=30");
SqlCommand cmd;
SqlDataAdapter sda;
private void SalesReport_Load(object sender, EventArgs e)
{
con.Open();
string sql = "select * from CustIn ";
cmd = new SqlCommand(sql, con);
sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
comboBox1.DisplayMember = "CustName";
comboBox1.DataSource = dt;
comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
con.Close();
this.reportViewer1.RefreshReport();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\kolhapur_it\Documents\Data.mdf;Integrated Security=True;Connect Timeout=30");
con.Open();
string sql = "select * from Sale ";
cmd = new SqlCommand(sql, con);
sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
ReportDataSource rds = new ReportDataSource("DataSet1", dt);
reportViewer1.LocalReport.ReportPath = @"E:\poulatry\WindowsFormsApp2\SalesR.rdlc";
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.RefreshReport();
con.Close();
}
public void fillcombobox()
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\kolhapur_it\Documents\Data.mdf;Integrated Security=True;Connect Timeout=30");
string sql = "select * from CompIn ";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader myreader;
try
{
con.Open();
myreader = cmd.ExecuteReader();
while (myreader.Read())
{
string cname = myreader.GetString(1);
comboBox1.Items.Add(cname);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}

Answers (5)