protected void Page_Load(object sender, EventArgs e) { BudgetSession S = BudgetSession.Get(this); if (S.Authenticated()) { Response.Redirect("Default.aspx"); return; } }
protected void Page_Load(object sender, EventArgs e) { ManageDataSession Data = ManageDataSession.Get(this); Data.State = ManageDataState.Main; BudgetSession S = BudgetSession.Get(this); if (S.Authenticated()) { S.LogOut(); } Response.Redirect("Login.aspx"); }
protected void Page_Load(object sender, EventArgs e) { BudgetSession S = BudgetSession.Get(this); if (S.Authenticated()) { navHome.Visible = true; navManageData.Visible = true; navExchange.Visible = true; navLogout.Visible = true; } else { navLogin.Visible = true; } }
protected void SignIn_Click(object sender, EventArgs e) { DAL DbDAL = new DAL(); BudgetSession S = BudgetSession.Get(this); if (!S.LogIn(DbDAL, inputUsername.Value, inputPassword.Value)) { labelError.InnerText = "Wrong username or password"; labelError.Visible = true; return; } if (S.Authenticated()) { Response.Redirect("Default.aspx"); return; } }
void GenerateExchangeTable(DAL DbDAL, Currency[] Currencies, BudgetSession S) { ListControl Lst = CreateListControl(); Tuple <Currency, float>[] Exchanges = Utils.GetExchange(S.ExchangeCurrency, Currencies); foreach (var Ex in Exchanges) { Lst.AddItem(string.Format("{0} - {1}", Ex.Item1.Code, Ex.Item2)); } TableRow Row = new TableRow(); TableCell Cell = new TableCell(); Cell.Controls.Add(Lst); Row.Cells.Add(Cell); DataTable.Rows.Add(Row); }
protected void Page_Load(object sender, EventArgs e) { BudgetSession S = BudgetSession.Get(this); if (!S.Authenticated()) { Response.Redirect("Login.aspx"); return; } ManageDataSession Data = ManageDataSession.Get(this); if (Data.SelectedCurrency == null) { DAL DbDAL = new DAL(); Data.SelectedCurrency = DbDAL.Select <Currency>().Where(C => C.Code == "HRK").First(); } HandleShowState(Data, Data.State); }
protected void Confirm_Click(object sender, EventArgs e) { ManageDataSession Data = ManageDataSession.Get(this); BudgetSession S = BudgetSession.Get(this); try { HandleStateConfirm(Data, S); } catch (DisplayException E) { labelError.Visible = true; labelError.InnerText = E.Message; return; } catch (Exception E) when(!Debugger.IsAttached) { labelError.Visible = true; labelError.InnerText = "Internal exception occured in HandleStateConfirm"; return; } Server.TransferRequest(Request.Url.AbsolutePath, false); }
protected void Page_Load(object sender, EventArgs e) { DbDAL = new DAL(); if (BudgetSession.GetUser(DbDAL, "admin") == null) { BudgetSession.CreateUser(DbDAL, "admin"); BudgetSession.ResetPassword(DbDAL, "admin", "root"); } BudgetSession S = BudgetSession.Get(this); if (!S.Authenticated()) { Response.Redirect("Login.aspx"); return; } CreateMonthLists(); Calculate(S.CurrentUser); }
protected void Page_Load(object sender, EventArgs e) { BudgetSession S = BudgetSession.Get(this); if (!S.Authenticated()) { Response.Redirect("Login.aspx"); return; } DAL DbDAL = new DAL(); Currency[] Currencies = DbDAL.Select <Currency>(new[] { new SQLiteParameter("@exchg", 1) }).ToArray(); if (S.ExchangeCurrency == null) { S.ExchangeCurrency = Currencies.Where(C => C.Code == "EUR").First(); } RefreshSelected(S); btnDropdown.Clear(); foreach (var Cur in Currencies) { btnDropdown.AddItem(new DropdownEntry(Cur.Code)); } btnDropdown.Bind(); GenerateExchangeTable(DbDAL, Currencies, S); btnDropdown.OnSelect += (Entry) => { S.ExchangeCurrency = Currencies.Where(C => C.Code == Entry.Name).First(); RefreshSelected(S); Server.TransferRequest(Request.Url.AbsolutePath, false); }; }
void HandleStateConfirm(ManageDataSession Data, BudgetSession S) { switch (Data.State) { case ManageDataState.Main: { MainRadioButton Next = GetMainRadioButton(Data); HandleShowState(Data, Next.NewState, true); return; } case ManageDataState.AddSingle: { if (!float.TryParse(inCurAmt.Value, out float Amt)) { throw new DisplayException("Could not parse currency amount"); } if (!DateTime.TryParse(dateBegin.Value, out DateTime Date)) { throw new DisplayException("Could not parse date"); } DAL DbDAL = new DAL(); Transaction T = new Transaction(S.CurrentUser, Date, Amt); T.Description = inComment.Value.Trim(); DbDAL.Insert(T); break; } case ManageDataState.AddMultiple: { if (!float.TryParse(inCurAmt.Value, out float Amt)) { throw new DisplayException("Could not parse currency amount"); } if (!DateTime.TryParse(dateBegin.Value, out DateTime From)) { throw new DisplayException("Could not parse From date"); } if (!DateTime.TryParse(dateEnd.Value, out DateTime To)) { throw new DisplayException("Could not parse To date"); } else { To = To.AddDays(1); } DAL DbDAL = new DAL(); while (From < To) { Transaction T = new Transaction(S.CurrentUser, From, Amt); T.Description = inComment.Value.Trim(); DbDAL.Insert(T); From = From.AddMonths(1); } break; } case ManageDataState.AddRepeating: break; case ManageDataState.AddMaestroPlus: { DAL DbDAL = new DAL(); MaestroPlusCalculator MaestroCalc = new MaestroPlusCalculator(DbDAL); int MonthCount = int.Parse(inMonthCount.Value); float Amt = float.Parse(inCurAmt.Value); DateTime From = DateTime.Parse(dateBegin.Value); string Comment = inComment.Value.Trim(); MaestroCalc.Calculate(MonthCount, Amt, out float OneTime, out float Monthly); MaestroEntry MaestroEntry = new MaestroEntry(); MaestroEntry.Description = Comment; DbDAL.Insert(MaestroEntry); Transaction TOneTime = new Transaction(S.CurrentUser, From, -OneTime); TOneTime.Description = "Maestro OneTime " + Comment; TOneTime.Maestro = MaestroEntry.ID; DbDAL.Insert(TOneTime); Transaction MaestroPayment = new Transaction(S.CurrentUser, From, Amt); MaestroPayment.Description = Comment; MaestroPayment.Maestro = MaestroEntry.ID; DbDAL.Insert(MaestroPayment); From = From.AddMonths(1); for (int i = 0; i < MonthCount; i++) { Transaction MaestroMonthly = new Transaction(S.CurrentUser, From, -Monthly); MaestroMonthly.Description = Comment; MaestroMonthly.Maestro = MaestroEntry.ID; DbDAL.Insert(MaestroMonthly); From = From.AddMonths(1); } break; } case ManageDataState.ManageMaestroPlus: break; default: throw new Exception("Invalid state " + Data.State); } }
void RefreshSelected(BudgetSession S) { inSelVal.Value = S.ExchangeCurrency.Code; }