public frmInfoTransaction(CTransaction info) { transaction = info; InitializeComponent(); lblSummary.Text = transaction.Summary; lblCreditAccount.Text = transaction.CreditAccount; lblDebitAccount.Text = transaction.DebitAccount; lblAmount.Text = transaction.CreditAmount == transaction.DebitAmount ? transaction.DebitAmount.ToString() + " " + transaction.DebitCurrency : transaction.CreditAmount + " " + transaction.CreditCurrency + "(" + transaction.DebitAmount + " " + transaction.DebitCurrency + ")"; switch (transaction.IconType) { case EMoneyFlowState.WithinSystem: tlpTransaction.BackColor = Color.Orange; break; case EMoneyFlowState.FlowIn: tlpTransaction.BackColor = Color.Green; break; case EMoneyFlowState.FlowOut: tlpTransaction.BackColor = Color.Red; break; default: break; } timer.Interval = 10000; timer.Start(); timer.Tick += Timer_Tick; }
private void btnSave_Click(object sender, EventArgs e) { bool CanSaveFlag = true; if (txtSummary.Text == "") { MessageBox.Show("Need a summary name"); CanSaveFlag = false; } if (txtCreditAmount.Text == "" || txtDebitAmount.Text == "") { MessageBox.Show("Amount incomplete"); CanSaveFlag = false; } if (CanSaveFlag) { CTransaction newTransaction = new CTransaction(); newTransaction.TagTime = curDate; newTransaction.Summary = txtSummary.Text; newTransaction.CreditAccount = cbxCredit.Text; newTransaction.CreditAmount = Convert.ToDouble(txtCreditAmount.Text); newTransaction.CreditCurrency = lblCreditCurrency.Text; newTransaction.DebitAccount = cbxDebit.Text; newTransaction.DebitAmount = Convert.ToDouble(txtDebitAmount.Text); newTransaction.DebitCurrency = lblDebitCurrency.Text; calculate C = new calculate(); newTransaction.IconType = C.MoneyInOrOut( G.glb.lstAccount.Find(o => o.AccountName == cbxDebit.Text).AccountType, G.glb.lstAccount.Find(o => o.AccountName == cbxCredit.Text).AccountType); G.glb.lstTransaction.Add(newTransaction); DrawLog(); Dispose(); } }
private void tsmConvert_Click(object sender, EventArgs e) { if (lsbBudget.SelectedItems != null) { DialogResult result = MessageBox.Show("Are you sure you want to convert?", "Convert", MessageBoxButtons.YesNo); switch (result) { case DialogResult.Yes: CTransaction convert = G.glb.lstBudget.Find(o => o.TagTime == curDate && o.Summary == lsbBudget.SelectedItem.ToString()); G.glb.lstTransaction.Add(convert); G.glb.lstBudget.RemoveAll(o => o.TagTime == curDate && o.Summary == lsbBudget.SelectedItem.ToString()); break; case DialogResult.No: break; default: break; } LoadBudget(); } }
public void CallInfoBudget(CTransaction info) { frmInfoTransaction frmInfoBudget = new frmInfoTransaction(info); frmInfoBudget.Show(); }
public void CallInfoTransaction(CTransaction info) { frmInfoTransaction frmInfoTransaction = new frmInfoTransaction(info); frmInfoTransaction.Show(); }
public void DrawEventController( PictureBox picMap, DateTime date, List <CEvent> events, List <CWorkOut> workOuts, List <CMedicine> medicines, List <CTransaction> transactions, List <CTransaction> budgets, List <CNote> notes) { int left = picMap.Width - 27 > 0 ? picMap.Width - 27 : 0; List <PictureBox> lstPicEvent = new List <PictureBox>(); List <CEvent> lstEvent = events.FindAll(o => o.TagTime.Date == date).ToList(); List <CWorkOut> lstWorkOut = workOuts.FindAll(o => o.TagTime.Date == date).ToList(); List <CMedicine> lstMedicine = medicines.FindAll(o => o.TagTime.Date == date).ToList(); List <CTransaction> lstTransaction = transactions.FindAll(o => o.TagTime.Date == date).ToList(); List <CTransaction> lstBudget = budgets.FindAll(o => o.TagTime.Date == date).ToList(); List <CNote> lstNote = notes.FindAll(o => o.TagTime.Date == date).ToList(); int acc = 0; for (int i = 0; i < lstEvent.Count; i++) { lstPicEvent.Add(new PictureBox()); CEvent eve = lstEvent[i]; if (lstEvent[i].EventState == EEventState.LogEvent) { lstPicEvent[i].Image = icon.iconEvent; } else if (lstEvent[i].EventState == EEventState.Succeed) { lstPicEvent[i].Image = icon.iconSucceedEvent; } else { lstPicEvent[i].Image = icon.iconFailedEvent; } lstPicEvent[i].Top = i * 30 + 3; lstPicEvent[i].Left = left; lstPicEvent[i].Width = 24; lstPicEvent[i].Height = 24; lstPicEvent[i].Click += (e, a) => CallInfoEvent(eve); picMap.Controls.Add(lstPicEvent[i]); } acc = acc + lstEvent.Count; for (int i = 0; i < lstWorkOut.Count; i++) { lstPicEvent.Add(new PictureBox()); CWorkOut workOut = lstWorkOut[i]; lstPicEvent[i + acc].Image = icon.iconFitness; lstPicEvent[i + acc].Top = (i + acc) * 30 + 3; lstPicEvent[i + acc].Left = left; lstPicEvent[i + acc].Width = 24; lstPicEvent[i + acc].Height = 24; lstPicEvent[i + acc].Click += (e, a) => CallInfoWorkOut(workOut); picMap.Controls.Add(lstPicEvent[i + acc]); } acc = acc + lstWorkOut.Count; for (int i = 0; i < lstMedicine.Count; i++) { lstPicEvent.Add(new PictureBox()); CMedicine medicine = lstMedicine[i]; lstPicEvent[i + acc].Image = icon.iconHealth; lstPicEvent[i + acc].Top = (i + acc) * 30 + 3; lstPicEvent[i + acc].Left = left; lstPicEvent[i + acc].Width = 24; lstPicEvent[i + acc].Height = 24; lstPicEvent[i + acc].Click += (e, a) => CallInfoMedicine(medicine); picMap.Controls.Add(lstPicEvent[i + acc]); } acc = acc + lstMedicine.Count; for (int i = 0; i < lstTransaction.Count; i++) { lstPicEvent.Add(new PictureBox()); CTransaction transaction = lstTransaction[i]; EMoneyFlowState MoneyFlowState = lstTransaction[i].IconType; switch (MoneyFlowState) { case EMoneyFlowState.WithinSystem: lstPicEvent[i + acc].Image = icon.iconMoneyWithin; break; case EMoneyFlowState.FlowIn: lstPicEvent[i + acc].Image = icon.iconMoneyIn; break; case EMoneyFlowState.FlowOut: lstPicEvent[i + acc].Image = icon.iconMoneyOut; break; default: break; } lstPicEvent[i + acc].Top = (i + acc) * 30 + 3; lstPicEvent[i + acc].Left = left; lstPicEvent[i + acc].Width = 24; lstPicEvent[i + acc].Height = 24; lstPicEvent[i + acc].Click += (e, a) => CallInfoTransaction(transaction); picMap.Controls.Add(lstPicEvent[i + acc]); } acc = acc + lstTransaction.Count; for (int i = 0; i < lstBudget.Count; i++) { lstPicEvent.Add(new PictureBox()); CTransaction transactionDue = lstBudget[i]; EMoneyFlowState MoneyFlowState = lstBudget[i].IconType; switch (MoneyFlowState) { case EMoneyFlowState.WithinSystem: lstPicEvent[i + acc].Image = icon.iconTransactionDueWithin; break; case EMoneyFlowState.FlowIn: lstPicEvent[i + acc].Image = icon.iconTransactionDueIn; break; case EMoneyFlowState.FlowOut: lstPicEvent[i + acc].Image = icon.iconTransactionDueOut; break; default: break; } lstPicEvent[i + acc].Top = (i + acc) * 30 + 3; lstPicEvent[i + acc].Left = left; lstPicEvent[i + acc].Width = 24; lstPicEvent[i + acc].Height = 24; lstPicEvent[i + acc].Click += (e, a) => CallInfoBudget(transactionDue); picMap.Controls.Add(lstPicEvent[i + acc]); } acc = acc + lstBudget.Count; for (int i = 0; i < lstNote.Count; i++) { lstPicEvent.Add(new PictureBox()); CNote note = lstNote[i]; if (lstNote[i].FinishedNote) { if (lstNote[i].LiteratureTitle != "") { lstPicEvent[i + acc].Image = icon.iconLiterature; } else { lstPicEvent[i + acc].Image = icon.iconNote; } } else { lstPicEvent[i + acc].Image = icon.iconWorkingNote; } lstPicEvent[i + acc].Top = (i + acc) * 30 + 3; lstPicEvent[i + acc].Left = left; lstPicEvent[i + acc].Width = 24; lstPicEvent[i + acc].Height = 24; lstPicEvent[i + acc].Click += (e, a) => CallInfoNote(note); picMap.Controls.Add(lstPicEvent[i + acc]); } acc = acc + lstNote.Count; }
private void btnSave_Click(object sender, EventArgs e) { bool CanSaveFlag = true; if (dtpPeriodEnd.Value < dtpPeriodStart.Value) { MessageBox.Show("End date can not earlier than start date"); CanSaveFlag = false; } if (txtSummary.Text == "") { MessageBox.Show("Need a summary name"); CanSaveFlag = false; } if (txtCreditAmount.Text == "" || txtDebitAmount.Text == "") { MessageBox.Show("Amount incomplete"); CanSaveFlag = false; } if (CanSaveFlag) { DateTime startDate = dtpPeriodStart.Value.Date; DateTime endDate = dtpPeriodEnd.Value.Date; for (DateTime day = startDate; day <= endDate; day = day.AddDays(1)) { bool IsSaveBudget = false; switch (day.DayOfWeek) { case DayOfWeek.Sunday: if (chkSu.Checked) { IsSaveBudget = true; } break; case DayOfWeek.Monday: if (chkMo.Checked) { IsSaveBudget = true; } break; case DayOfWeek.Tuesday: if (chkTu.Checked) { IsSaveBudget = true; } break; case DayOfWeek.Wednesday: if (chkWe.Checked) { IsSaveBudget = true; } break; case DayOfWeek.Thursday: if (chkTh.Checked) { IsSaveBudget = true; } break; case DayOfWeek.Friday: if (chkFr.Checked) { IsSaveBudget = true; } break; case DayOfWeek.Saturday: if (chkSa.Checked) { IsSaveBudget = true; } break; default: break; } if (IsSaveBudget) { CTransaction newBudget = new CTransaction(); newBudget.TagTime = day; newBudget.Summary = txtSummary.Text; newBudget.CreditAccount = cbxCredit.Text; newBudget.CreditAmount = Convert.ToDouble(txtCreditAmount.Text); newBudget.CreditCurrency = lblCreditCurrency.Text; newBudget.DebitAccount = cbxDebit.Text; newBudget.DebitAmount = Convert.ToDouble(txtDebitAmount.Text); newBudget.DebitCurrency = lblDebitCurrency.Text; calculate C = new calculate(); newBudget.IconType = C.MoneyInOrOut( G.glb.lstAccount.Find(o => o.AccountName == cbxDebit.Text).AccountType, G.glb.lstAccount.Find(o => o.AccountName == cbxCredit.Text).AccountType); G.glb.lstBudget.Add(newBudget); } } DrawLog(); Dispose(); } }