Guest User

Untitled

a guest
Jan 19th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Configuration;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using Microsoft.Reporting.WinForms;
  13.  
  14. namespace TmpZ
  15. {
  16. public partial class BalanceSheet : Form
  17. {
  18. string constring = ConfigurationManager.ConnectionStrings["ConnData"].ConnectionString;
  19. public BalanceSheet()
  20. {
  21. InitializeComponent();
  22. }
  23.  
  24. private void BalanceSheet_Load(object sender, EventArgs e)
  25. {
  26.  
  27. }
  28.  
  29. private void reportViewer1_Load(object sender, EventArgs e)
  30. {
  31.  
  32. }
  33.  
  34. private void button1_Click(object sender, EventArgs e)
  35. {
  36. if (accountNo1.Text == "")
  37. {
  38. MessageBox.Show("Please Enter Account Number");
  39. }
  40. else
  41. {
  42. DataTable dtb = new DataTable();
  43. DataTable dtb2 = new DataTable();
  44. dtb2 = GetAddressInfo(dtb2);
  45. dtb = GenerateBankStatement(dtb);
  46. reportViewer1.LocalReport.DataSources.Clear();
  47. ReportDataSource rpd = new ReportDataSource("DataSet1", dtb);
  48. ReportDataSource rpd2 = new ReportDataSource("DataSet2", dtb2);
  49. reportViewer1.LocalReport.DataSources.Add(rpd);
  50. reportViewer1.LocalReport.DataSources.Add(rpd2);
  51. reportViewer1.RefreshReport();
  52. }
  53. }
  54.  
  55. private DataTable GetAddressInfo(DataTable dt)
  56. {
  57. using (SqlConnection cn = new SqlConnection(constring))
  58. {
  59. try
  60. {
  61. SqlDataAdapter da = new SqlDataAdapter("select fullname as [fullname], accountNo as [accountNo], ccy as [ccy] from account_info where accountNo = '" + accountNo1.Text + "'", cn);
  62. da.Fill(dt);
  63. }
  64. catch (Exception ex)
  65. {
  66. MessageBox.Show(ex.ToString());
  67. }
  68. }
  69. return dt;
  70. }
  71.  
  72. private DataTable GenerateBankStatement(DataTable dt)
  73. {
  74. using (SqlConnection cn = new SqlConnection(constring))
  75. {
  76. try
  77. {
  78. string dateF = Convert.ToDateTime(dateFrom.Text).ToString("dd-MM-yyyy");
  79. string dateT = Convert.ToDateTime(dateTo.Text).ToString("dd-MM-yyyy");
  80. SqlDataAdapter da = new SqlDataAdapter("SELECT account_info.fullname as [fullname], account_info.accountNo as [accountNo], account_info.ccy as [ccy], account_info.address as [address] , transactions.id as [id], transactions.transaction_desc as [transaction_desc], transactions.credit as [credit], transactions.debit as [debit], transactions.balance as [balance], transactions.transaction_date as [transaction_date] FROM transactions CROSS JOIN account_info WHERE(account_info.accountNo = '" + accountNo1.Text + "') AND(transactions.transaction_date BETWEEN '" + dateF + "' AND '" + dateT + "')", cn);
  81. da.Fill(dt);
  82. }
  83. catch(Exception ex)
  84. {
  85. MessageBox.Show(ex.ToString());
  86. }
  87. }
  88. return dt;
  89. }
  90. }
  91. }
Add Comment
Please, Sign In to add comment