public override string ToString() { string m = String.Format("[OverdraftAccount:accountNumber={0},accountHolder={1},balance={2}]", AccountNumber, AccountHolder.ToString(), Balance); return(m); }
public static bool SaveToFile(AccountHolder ah) { SaveToDB(ah); String timeStamp = DateTime.Now.Millisecond.ToString(); File.WriteAllText(@"C:\Sandbox\AccountHolder" + timeStamp + ".dat", ah.ToString()); return(true); }
public static void SaveToDB(AccountHolder ah) { SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder { ConnectionString = @"Integrated Security=SSPI; Persist Security Info=False;Initial Catalog=AcmeBanking; Data Source=STUDENT03\SQLEXPRESS" }; using (SqlConnection conn = new SqlConnection(sb.ConnectionString)) { String cmdText = $@"insert into AcmeBanking.dbo.TransactionLog(name,details,TransactionDate) values('New Account', '{ah.ToString()}', getdate()); "; conn.Open(); SqlCommand cmd = new SqlCommand(cmdText, conn); cmd.ExecuteNonQuery(); conn.Close(); } }
public override string ToString() { return(accountNumber + " " + AccountHolder.ToString()); }