Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. OleDbConnection Conn = new OleDbConnection(Program.ConnString);
  2. Conn.Open();
  3. OleDbCommand Cmd = new OleDbCommand();
  4. Cmd.Connection = Conn;
  5. DateTime StartDate = DateTime.Today.AddDays(-7);
  6. string strStart = StartDate.ToString("dd/MM/yyyy");
  7. DateTime EndDate = DateTime.Today;
  8. string strEnd = EndDate.ToString("dd/MM/yyyy");
  9. string SQL = "";
  10. if (list_all.Checked)
  11. {
  12. SQL = "SELECT StudentID, Forename, Surname, Class FROM Accounts ";
  13.  
  14. }
  15. else if (current_week.Checked)
  16. {
  17. SQL = "SELECT * FROM Transactions ";
  18. SQL += "WHERE TransDate BETWEEN #" + strStart + "# AND #" + strEnd + "# ";
  19. SQL += "GROUP BY TransType";
  20.  
  21.  
  22. }
  23. else if (this_weeks_totals.Checked)
  24. {
  25. SQL = "SELECT TransType, SUM(Amount) AS Total FROM Transactions ";
  26. SQL += "WHERE TransDate BETWEEN #" + strStart + "# AND #" + strEnd + "# ";
  27. SQL += "GROUP BY TransType";
  28.  
  29. }
  30. else if (particualr_account.Checked)
  31. {
  32. SQL = "SELECT TransDate, TransType, Amount FROM Transactions ";
  33. SQL += "WHERE StudentID='" + textBoxid.Text + "' ORDER BY TransDate";
  34. SQL += "GROUP BY TransType";
  35.  
  36. }
  37. Cmd.CommandText = SQL;
  38. OleDbDataAdapter da = new OleDbDataAdapter(Cmd);
  39. DataTable table = new DataTable();
  40. da.Fill(table);
  41. grid.DataSource = table;
  42. Conn.Close();
  43. grid.Show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement