private void ChangeBalance(Enums.AccountType aType, decimal funds) { if (aType is Enums.AccountType.Checking) { _checking += funds; } else if (aType is Enums.AccountType.Savings) { _savings += funds; } }
public void Deposit(Enums.AccountType AccountType, T money, User client) { invoke = client.ChangeUserBalance; transactions.Add(money); if (AccountType is Enums.AccountType.Savings) { invoke(AccountType, decimal.Parse(money.ToString())); } else if (AccountType is Enums.AccountType.Checking) { invoke(AccountType, decimal.Parse(money.ToString())); } }
public void ConvertFromDBObject(IDBObject obj) { if (!(obj is DB_Account)) { return; } DB_Account acc = obj as DB_Account; this.ID = Guid.Parse(acc.ID); this.IsActive = acc.IsActive; this.IsOffBudget = acc.IsOffBudget; this.Name = acc.Name; this.Note = acc.Note; Enums.AccountType type = Enums.AccountType.None; Enum.TryParse <Enums.AccountType>(acc.Type, out type); this.Type = type; DataHelper.AddItem(this); }
public static void Handle(byte[] Data, SocketClient Client) { Client.Crypto = new Cryptographer(); Client.Crypto.Decrypt(ref Data); ushort PacketID = BitConverter.ToUInt16(Data, 2); if (PacketID == 1051) { string Account = System.Text.ASCIIEncoding.ASCII.GetString(Data, 4, 16).Replace("\0", ""); byte[] PassBytes = new byte[16]; Buffer.BlockCopy(Data, 20, PassBytes, 0, 16); string Password = RC5.Decrypt(PassBytes); DataTable DT = Program.AccountDB.GetDataTable("SELECT `uid`, `type` FROM `userinfo` WHERE `username`='" + Account + "' AND `password`='" + Password + "'"); if (DT.Rows.Count == 1) { DataRow dr = DT.Rows[0]; uint UID = Convert.ToUInt32(dr.ItemArray[0]); Enums.AccountType AcctType = (Enums.AccountType)Convert.ToByte(dr.ItemArray[1]); if (AcctType == Enums.AccountType.BannedAccount) { Client.Send(Packets.ToSend.AuthResponse(Enums.AuthResponseType.Banned, UID)); } else { string date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; Program.AccountDB.ExecuteNonQuery("INSERT INTO `login_tokens` (`PlayerUID`, `Date`) VALUES ('" + UID + "', '" + date + "')"); Client.Send(Packets.ToSend.AuthResponse(Enums.AuthResponseType.Successful, UID)); } } else { Client.Send(Packets.ToSend.AuthResponse(Enums.AuthResponseType.WrongPass, 0)); } } Client.Disconnect(); }
private static void BuildAccountRows(IEnumerable <Account> accounts, List <ForecastRow> retList, Enums.AccountType accntType) { retList.Add(BuildHeader1(accntType.ToDescription())); foreach (var account in accounts) { //Build rows decimal currentBal = GetCurrentBalance(account); decimal plusMonth1 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(1)) + currentBal; decimal plusMonth2 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(2)) + plusMonth1; decimal plusMonth3 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(3)) + plusMonth2; decimal plusMonth4 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(4)) + plusMonth3; decimal plusMonth5 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(5)) + plusMonth4; decimal plusMonth6 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(6)) + plusMonth5; decimal plusMonth7 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(7)) + plusMonth6; decimal plusMonth8 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(8)) + plusMonth7; decimal plusMonth9 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(9)) + plusMonth8; decimal plusMonth10 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(10)) + plusMonth9; decimal plusMonth11 = GetMonthAccountProjection(account, DateTime.Now.AddMonths(11)) + plusMonth10; decimal plusYear1 = GetMonthAccountProjection(account, DateTime.Now.AddYears(1)) + plusMonth11; decimal plusYear2 = GetMonthAccountProjection(account, DateTime.Now.AddYears(2)) + GetYearAccountProjections(account, 2); decimal plusYear3 = GetMonthAccountProjection(account, DateTime.Now.AddYears(3)) + GetYearAccountProjections(account, 3);; retList.Add((new ForecastRow() { AccountName = account.Name, AccountType = account.AccountType.ToDescription(), MonthCurrent = currentBal.ToString(CultureInfo.CurrentCulture), Month1 = plusMonth1.ToString(), Month2 = plusMonth2.ToString(), Month3 = plusMonth3.ToString(), Month4 = plusMonth4.ToString(), Month5 = plusMonth5.ToString(), Month6 = plusMonth6.ToString(), Year1 = plusYear1.ToString(), Year2 = plusYear2.ToString(), Year3 = plusYear3.ToString() } )); #region old //PrimaryContext db = new PrimaryContext(); ////Calculate current balance //decimal curentBal = GetCurrentBalance(account); ////Calculate monthly change //decimal monthDelta = GetMonthlyDelta(account); ////Collect Allocation change events -- Not yet implimented //IEnumerable<AllocationChange> allocationChangeList = db.ChangeEvents.OfType<AllocationChange>().Where(x => x.Allocation.AccountId == account.Id); ////Collect Account change events //IEnumerable<AccountChange> accountChangeList = db.ChangeEvents.OfType<AccountChange>().Where(x => x.AccountId == account.Id); ////Build Projections //Dictionary<int, decimal> forecast = BuildAccountProjections(retList, accountChangeList, curentBal, monthDelta); //retList.Add(new ForecastRow(Enums.TableRowType.expense, account.Name, forecast[0].ToString(), // forecast[1].ToString(), forecast[2].ToString(), // forecast[3].ToString(), forecast[4].ToString(), forecast[5].ToString(), forecast[6].ToString(), // forecast[7].ToString(), forecast[8].ToString(), forecast[9].ToString())); #endregion } }
// Balance changing methods; public void ChangeUserBalance(Enums.AccountType CheckOrSave, decimal sentFunds) { ChangeBalance(CheckOrSave, sentFunds); }