// Metoda dodająca wiersz w tabeli na podstawie podanego MoneyFlow private void AddMoneyFlowToDataGridRow(MoneyFlow mf) { MoneyFlow moneyFlow = new MoneyFlow(); DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell IdCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell AmountCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell TypeCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell NameCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell CategoryCell = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell DataCell = new DataGridViewTextBoxCell(); IdCell.Value = dataGridView1.Rows.Count + 1; AmountCell.Value = mf.Amount; NameCell.Value = mf.Name; CategoryCell.Value = mf.FlowCategory.Name; DataCell.Value = mf.Date; TypeCell.Value = mf.typ; row.Cells.Add(IdCell); row.Cells.Add(AmountCell); row.Cells.Add(TypeCell); row.Cells.Add(NameCell); row.Cells.Add(CategoryCell); row.Cells.Add(DataCell); row.Tag = mf; // W tagu zapisujemy referencje do wydatku dataGridView1.Rows.Add(row); }
// Metoda dodająca Nowy Flow private void btnNewIncome_Click(object sender, EventArgs e) { MoneyFlow mf = new MoneyFlow(); mf.Date = DateTime.Now; pocket.MoneyFlows.Add(mf); AddMoneyFlowToDataGridRow(mf); pocket.Serialize(); SetLabels(); }
public void Load() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("loginy\\" + Config.LoggedUser + "\\product.xml"); XmlNode mainNode = xmlDoc.GetElementsByTagName("MoneyFlows")[0]; foreach (XmlNode item in mainNode.ChildNodes) { MoneyFlow mf = new MoneyFlow(); mf.Amount = Convert.ToDouble(item.Attributes[0].Value); mf.typ = Convert.ToString(item.Attributes[1].Value); mf.Name = Convert.ToString(item.Attributes[2].Value); mf.Date = Convert.ToDateTime(item.Attributes[4].Value); mf.FlowCategory = Convert.ToInt32(item.Attributes[3].Value) == -1 ? null : Categories.categories[Convert.ToInt32(item.Attributes[3].Value)]; MoneyFlows.Add(mf); } }
// Show panel private void EditPanelShow(MoneyFlow mf) { if (mf.typ == "Wydatek") { radioButton2.Checked = true; } if (mf.typ == "Przychód") { radioButton1.Checked = true; } txtExpend.Text = Convert.ToString(mf.Amount); txtExpendName.Text = mf.Name; dateTimePickerExpend.Value = mf.Date; panel2.Visible = true; editedMoneyFlow = mf; comboBox1.Items.Clear(); foreach (Category item in Categories.categories) { comboBox1.Items.Add(item); } comboBox1.SelectedItem = mf.FlowCategory; }