Guest User

Untitled

a guest
Jan 19th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 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. dtb = GenerateBankStatement(dtb);
  44. reportViewer1.LocalReport.DataSources.Clear();
  45. ReportDataSource rpd = new ReportDataSource("DataSet1", dtb);
  46. reportViewer1.LocalReport.DataSources.Add(rpd);
  47. reportViewer1.RefreshReport();
  48. }
  49. }
  50.  
  51. private DataTable GenerateBankStatement(DataTable dt)
  52. {
  53. using (SqlConnection cn = new SqlConnection(constring))
  54. {
  55. try
  56. {
  57. string dateF = Convert.ToDateTime(dateFrom.Text).ToString("dd-MM-yyyy");
  58. string dateT = Convert.ToDateTime(dateTo.Text).ToString("dd-MM-yyyy");
  59. //SqlDataAdapter da = new SqlDataAdapter("SELECT [id] as id, [transaction_desc] as transaction_desc,[credit] as credit, [debit] as debit, [balance] as balance, [transaction_date] as transaction_date FROM transactions WHERE(accountNo1 = '" + accountNo1.Text + "') AND(transaction_date BETWEEN '" + dateF + "' AND '" + dateT + "')", cn);
  60. //SqlDataAdapter da = new SqlDataAdapter("SELECT [id] as id, [transaction_desc] as transaction_desc,[credit] as credit, [debit] as debit, [balance] as balance, [transaction_date] as transaction_date FROM transactions WHERE(accountNo1 = '" + accountNo1.Text + "')", cn);
  61. SqlDataAdapter da = new SqlDataAdapter("SELECT [fullname] as account_info.fullname, [accountNo] as account_info.accountNo, [ccy] as account_info.ccy, [address] as account_info.address, [id] as transactions.id, [transaction_desc] as transactions.transaction_desc, [credit] as transactions.credit, [debit] as transactions.debit, [balance] as transactions.balance, [transaction_date] as transactions.transaction_date FROM transactions CROSS JOIN account_info WHERE(account_info.accountNo = '" + accountNo1.Text + "') AND(transactions.transaction_date BETWEEN '" + dateF + "' AND '" + dateT + "')", cn);
  62. da.Fill(dt);
  63. }
  64. catch(Exception ex)
  65. {
  66. MessageBox.Show(ex.ToString());
  67. }
  68. }
  69. return dt;
  70. }
  71. }
  72. }
Add Comment
Please, Sign In to add comment