private void button11_Click(object sender, EventArgs e) { try{ Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptSales rpt = new rptSales(); //The report you created. cmd = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); POS_DBDataSet myDS = new POS_DBDataSet(); //The DataSet you created. con = new SqlConnection(cs.DBConn); cmd.Connection = con; cmd.CommandText = "SELECT * from Customer,Invoice_Info where Customer.CustomerID=Invoice_Info.CustomerID and InvoiceDate Between @d1 and @d2 and PaymentDue > 0 order by InvoiceDate desc"; cmd.Parameters.Add("@d1", SqlDbType.DateTime, 30, "InvoiceDate").Value = DateTimePicker2.Value.Date; cmd.Parameters.Add("@d2", SqlDbType.DateTime, 30, "InvoiceDate").Value = DateTimePicker1.Value.Date; cmd.CommandType = CommandType.Text; myDA.SelectCommand = cmd; myDA.Fill(myDS, "Invoice_Info"); myDA.Fill(myDS, "Customer"); rpt.SetDataSource(myDS); frmSalesReport frm = new frmSalesReport(); frm.crystalReportViewer1.ReportSource = rpt; frm.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button10_Click(object sender, EventArgs e) { try { if (cmbCustomerName.Text == "") { MessageBox.Show("Please select customer name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbCustomerName.Focus(); return; } Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptSales rpt = new rptSales(); //The report you created. cmd = new SqlCommand(); SqlDataAdapter myDA = new SqlDataAdapter(); POS_DBDataSet myDS = new POS_DBDataSet(); //The DataSet you created. con = new SqlConnection(cs.DBConn); cmd.Connection = con; cmd.CommandText = "SELECT * from Customer,Invoice_Info where Customer.CustomerID=Invoice_Info.CustomerID and CustomerName='" + cmbCustomerName.Text + "' order by InvoiceDate desc"; cmd.CommandType = CommandType.Text; myDA.SelectCommand = cmd; myDA.Fill(myDS, "Invoice_Info"); myDA.Fill(myDS, "Customer"); rpt.SetDataSource(myDS); frmSalesReport frm = new frmSalesReport(); frm.crystalReportViewer1.ReportSource = rpt; frm.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }