Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Configuration;
- using System.Data.SqlClient;
- using System.Data;
- /// <summary>
- /// Summary description for User
- /// </summary>
- public class Holder
- {
- public int Id { get; set; }
- public string Number { get; set; }
- public string Name { get; set; }
- public List<Account> Accounts { get; set; }
- public Holder()
- {
- //
- // TODO: Add constructor logic here
- //
- }
- public Holder(int id, string number, string name)
- {
- this.Id = id;
- this.Number = number;
- this.Name = name;
- }
- public Account GetAccounts()
- {
- string connString = ConfigurationManager.ConnectionStrings["labo3ConnString"].ConnectionString;
- using (SqlConnection conn = new SqlConnection(connString)) {
- SqlCommand cmd = new SqlCommand("select * from Accounts where = @id", conn);
- cmd.Parameters.Add("id", SqlDbType.Int).Value = 1;
- conn.Open();
- using (SqlDataReader reader = cmd.ExecuteReader()) {
- while (reader.Read()) {
- Account account = new Account();
- account.Id = reader.GetInt32(0);
- account.Number = reader.GetString(1);
- account.AccountType = (AccountType)Enum.Parse(typeof(AccountType), reader.GetString(2));
- account.Name = reader.GetString(3);
- account.Balance = reader.GetFloat(4);
- account.Maxdebit = reader.GetFloat(5);
- account.UserId = reader.GetInt32(6);
- Accounts.Add(account);
- }
- }
- }
- return new Account();
- }
- public static Holder GetUser(int id)
- {
- return new Holder();
- }
- }
Add Comment
Please, Sign In to add comment