Guest User

Untitled

a guest
Jan 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Configuration;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8.  
  9. /// <summary>
  10. /// Summary description for User
  11. /// </summary>
  12. public class Holder
  13. {
  14. public int Id { get; set; }
  15. public string Number { get; set; }
  16. public string Name { get; set; }
  17. public List<Account> Accounts { get; set; }
  18.  
  19. public Holder()
  20. {
  21. //
  22. // TODO: Add constructor logic here
  23. //
  24. }
  25.  
  26. public Holder(int id, string number, string name)
  27. {
  28. this.Id = id;
  29. this.Number = number;
  30. this.Name = name;
  31. }
  32.  
  33. public Account GetAccounts()
  34. {
  35. string connString = ConfigurationManager.ConnectionStrings["labo3ConnString"].ConnectionString;
  36. using (SqlConnection conn = new SqlConnection(connString)) {
  37.  
  38. SqlCommand cmd = new SqlCommand("select * from Accounts where = @id", conn);
  39. cmd.Parameters.Add("id", SqlDbType.Int).Value = 1;
  40. conn.Open();
  41. using (SqlDataReader reader = cmd.ExecuteReader()) {
  42. while (reader.Read()) {
  43. Account account = new Account();
  44. account.Id = reader.GetInt32(0);
  45. account.Number = reader.GetString(1);
  46. account.AccountType = (AccountType)Enum.Parse(typeof(AccountType), reader.GetString(2));
  47. account.Name = reader.GetString(3);
  48. account.Balance = reader.GetFloat(4);
  49. account.Maxdebit = reader.GetFloat(5);
  50. account.UserId = reader.GetInt32(6);
  51. Accounts.Add(account);
  52. }
  53. }
  54. }
  55.  
  56. return new Account();
  57. }
  58.  
  59. public static Holder GetUser(int id)
  60. {
  61.  
  62.  
  63. return new Holder();
  64. }
  65. }
Add Comment
Please, Sign In to add comment