Kishore Patel

Kishore Patel

  • NA
  • 10
  • 458

evaluate variable values ( manipulating variables and valu )

Jun 1 2020 9:53 AM
i have 2 tables
 
1. report table (with fields (cols))
col1, col2, col3, col4, col5, col6, col7
values in row 1
col1 = "trx_no"
col2 = "trx_date"
col3 = "quantity"
col4 = "rate"
col4 = "quantity * rate"
col6 = "tax"
col7 = "(quantity * rate)+tax"
 
2. transaction table (with fields (cols))
trx_no, trx_date, quantity, rate, tax
value in row 1
trx_no = "00001"
trx_date = "01/04/2020"
quantity = 20
rate = 150
tax = 540
value in row 2
trx_no = "00002"
trx_date = "05/04/2020"
quantity = 100
rate = 110
tax = 1980
  1. private void TData_Grid(string RMST)  
  2. {  
  3. if (SPDConn.State != ConnectionState.Open) // Connection can be {Open, Close, Broken, Connnecting, Executing, Fetching}  
  4. {  
  5. SPDConn.Close();  
  6. SPDConn.Open();  
  7. }  
  8. if (SPMConn.State != ConnectionState.Open) // Connection can be {Open, Close, Broken, Connnecting, Executing, Fetching}  
  9. {  
  10. SPMConn.Close();  
  11. SPMConn.Open();  
  12. }  
  13. string str1 = "select * from dbo.trxdat" + SPGlobal.spyear + " where cmp_code = '" + SPGlobal.spcmp_code + "' and trx_type = '" + RMST + "'";  
  14. SqlCommand mcmd = new SqlCommand(str1, SPDConn);  
  15. SqlDataReader mrdr = mcmd.ExecuteReader();  
  16. string trx_no;  
  17. DateTime trx_date;  
  18. decimal quantity, rate, tax;  
  19. while (mrdr.Read())  
  20. {  
  21. //transfering datatable to variables  
  22. trx_no = mrdr["trx_no"].ToString();  
  23. trx_date = (DateTime)mrdr["trx_date"];  
  24. quantity = (decimal)mrdr["quantity"];  
  25. rate = (decimal)mrdr["rate"];  
  26. tax = (decimal)mrdr["tax"];  
  27. Console.WriteLine(col1);  
  28. Console.WriteLine(col2);  
  29. Console.WriteLine(col3);  
  30. Console.WriteLine(col4);  
  31. Console.WriteLine(col5);  
  32. Console.WriteLine(col6);  
  33. Console.WriteLine(col7);  
  34. }  
  35. mrdr.Close();  
  36. }  
how do i manupulate col1, col2, col3, ...... so that at console i get
note : datatables won't change they are read only
 
"00001"
"01/04/2020"
20
150
3000
540
3540

Answers (1)