private void btnSubmit_Click(object sender, EventArgs e) { Transaction obTransaction = new Transaction(); obTransaction.TransactionID = PublicFunction.EncryptPassword(DateTime.Now.ToString()); obTransaction.Action = (int)actionID; obTransaction.Amount = (int)numericUpDown_Amount.Value; obTransaction.Reason = txtReason.Text; obTransaction.Time = dateTimePicker_Time.Value; Data obData = PublicVariables.listData.Find(ob => ob.Year == obTransaction.Time.Year); if (obData == null) { obData = new Data(); obData.Year = obTransaction.Time.Year; List<Transaction> listTransaction = new List<Transaction>(); listTransaction.Add(obTransaction); obData.Transactions = listTransaction; PublicFunction.WriteData(obData.Year, obData); } else { obData.Transactions.Add(obTransaction); PublicFunction.WriteData(obData.Year, obData); } this.Hide(); }
public Data(Data p_Data) { Year = p_Data.Year; Transactions = p_Data.Transactions; }
private void LoadData() { Data obData = null; for (int i = 0; i < PublicVariables.listData.Count; i++) { if (PublicVariables.listData[i].Year == Year) obData = new Data(PublicVariables.listData[i]); } List<Transaction> listTransSource = new List<Transaction>(); List<Transaction> listTransSourceOpening = new List<Transaction>(); int Amount = 0; int OpeningAmount = 0; if (obData != null) { if (DataType == Ultity.DataType.Day) { listTransSource = obData.Transactions.FindAll(ob => ob.Time.Day == Day && ob.Time.Month == Month); listTransSourceOpening = obData.Transactions.FindAll(ob => ob.Time < new DateTime(Year, Month, Day)); } else if (DataType == Ultity.DataType.Month) { listTransSource = obData.Transactions.FindAll(ob => ob.Time.Month == Month); listTransSourceOpening = obData.Transactions.FindAll(ob => ob.Time < new DateTime(Year, Month, 1)); } else { listTransSource = obData.Transactions; listTransSourceOpening = obData.Transactions.FindAll(ob => ob.Time < new DateTime(Year, 1, 1)); } } for (int i = Ultity.YearStart; i < Year; i++) { Data obDataOpening = new Data(PublicVariables.listData[i]); if (obDataOpening != null) { listTransSourceOpening.AddRange(obDataOpening.Transactions); } } dataGridView_Main.DataSource = listTransSource.FindAll(ob => { bool flag = false; if (isDeposit && (ob.Action == (int)Ultity.Action.Deposit)) flag = true; else if (isWithdraw && (ob.Action == (int)Ultity.Action.Withdraw)) flag = true; else if (isLend && (ob.Action == (int)Ultity.Action.Lend)) flag = true; else if (isBorrow && (ob.Action == (int)Ultity.Action.Borrow)) flag = true; return flag; }); listTransSource.ForEach(ob => { if (ob.Action == (int)Ultity.Action.Deposit || ob.Action == (int)Ultity.Action.Borrow) Amount += ob.Amount; else Amount -= ob.Amount; }); listTransSourceOpening.ForEach(ob => { if (ob.Action == (int)Ultity.Action.Deposit || ob.Action == (int)Ultity.Action.Borrow) OpeningAmount += ob.Amount; else OpeningAmount -= ob.Amount; }); lblAmount.Text = Amount.ToString("N0"); lblOpeningAmount.Text = OpeningAmount.ToString("N0"); lblClosingAmount.Text = (OpeningAmount + Amount).ToString("N0"); LoadCultureDataGrid(); }
public static bool WriteData(int p_Year, Data p_Data) { return WriteObjectToXmlUpgraded(p_Year + ".mmd", p_Data); }