Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. private DataSet GetData()
  2. {
  3.  
  4. string select = "SELECT DISTINCT OrganisationId,OrganisationName,StaffId,StaffName,Department,Position,TaxIdNumber, SessionId,Month,Year,BasicSalary,TransAllowance,UtilityAllowance," +
  5. "HousingAllowance,Gratuities,Pension,(TaxExempts + MonthlyTaxDue) AS TotalDeduction,(GrossIncome - (TaxExempts + MonthlyTaxDue)) AS NetPay,OtherStatutoryDeductions,TaxExempts,MonthlyTaxDue,YearlyTaxdue, " +
  6. "GrossIncome FROM IncomeTax WHERE (OrganisationId = @OrganisationId AND Month = @Month AND Year = @Year) GROUP BY StaffID";
  7. using (SQLiteConnection con = new SQLiteConnection(connstring))
  8. {
  9. using (SQLiteCommand cmd = new SQLiteCommand(select))
  10. {
  11. using (SQLiteDataAdapter sda = new SQLiteDataAdapter())
  12. {
  13. cmd.Connection = con;
  14. sda.SelectCommand = cmd;
  15. cmd.CommandType = CommandType.Text;
  16. cmd.CommandTimeout = 9000000;
  17. cmd.Parameters.Add("@OrganisationId", DbType.String, 50).Value = txtOrgId.Text.ToUpper();
  18. cmd.Parameters.Add("@StaffId", DbType.String, 50).Value = txtStaffId.Text.ToUpper();
  19. cmd.Parameters.Add("@Month", DbType.String, 50).Value = cboMonthSearch.SelectedItem.ToString().ToUpper();
  20. cmd.Parameters.Add("@Year", DbType.String, 50).Value = cboYearSearch.SelectedItem.ToString().ToUpper();
  21. DataSet dsCustomers = new DataSet1();
  22.  
  23. sda.Fill(dsCustomers, "After2011PaySlip");
  24.  
  25. if (dsCustomers.Tables[4].Rows.Count == 0)
  26. {
  27. reportViewer1.Visible = false;
  28. MessageBox.Show("Records not found!");
  29. }
  30. else
  31. {
  32. reportViewer1.Visible = true;
  33. }
  34. return dsCustomers;
  35.  
  36. }
  37. }
  38. }
  39. }
  40.  
  41. private void btnSearch_Click(object sender, EventArgs e)
  42. {
  43. try
  44. {
  45. DataSet dsCustomers = GetData();
  46. ReportDataSource datasource = new ReportDataSource("DataSet1", dsCustomers.Tables[4]);
  47. this.reportViewer1.LocalReport.DataSources.Clear();
  48. reportViewer1.ProcessingMode = ProcessingMode.Local;
  49. // the ReportPath is relative to the page displaying the ReportViewer
  50. reportViewer1.LocalReport.ReportPath =
  51. "After2011PaySlipReport.rdlc";
  52.  
  53. this.reportViewer1.LocalReport.DataSources.Add(datasource);
  54. this.reportViewer1.RefreshReport();
  55. }
  56. catch(Exception ex)
  57. {
  58. MessageBox.Show(ex.Message);
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement