예제 #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            this.selectedEntry = this.appInstance.entries[e.RowIndex];

            this.libelleEdit.Text = this.selectedEntry.libelle;
            this.dateEdit.Text    = this.selectedEntry.date.ToShortDateString();
            this.montantEdit.Text = this.selectedEntry.amount + "";
            this.chargeEdit.Text  = this.selectedEntry.chargesPourcent + "";
        }
예제 #2
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (this.selectedEntry != null)
            {
                this.selectedEntry.libelle         = this.libelleEdit.Text;
                this.selectedEntry.date            = DateTime.Parse(this.dateEdit.Text);
                this.selectedEntry.amount          = float.Parse(this.montantEdit.Text);
                this.selectedEntry.chargesPourcent = float.Parse(this.chargeEdit.Text);

                this.selectedEntry = null;
            }
            else
            {
                ComptaEntry newEntry = null;
                if (this.chargeEdit.Text == "")
                {
                    newEntry = new ComptaEntry(
                        this.libelleEdit.Text,
                        DateTime.Parse(this.dateEdit.Text),
                        float.Parse(this.montantEdit.Text)
                        );
                }
                else
                {
                    newEntry = new ComptaEntry(
                        this.libelleEdit.Text,
                        DateTime.Parse(this.dateEdit.Text),
                        float.Parse(this.montantEdit.Text),
                        float.Parse(this.chargeEdit.Text)
                        );
                }

                this.appInstance.entries.Add(newEntry);
            }

            this.appInstance.saveEntriesInXml();
            this.refresh();
        }
예제 #3
0
        public void loadEntriesInXml()
        {
            if (File.Exists("entries.xml"))
            {
                System.Diagnostics.Debug.WriteLine("load from file");
                XmlDocument DocXml = new XmlDocument();
                DocXml.Load("entries.xml");
                XmlNode body = DocXml.SelectSingleNode("entries");

                foreach (XmlNode entryElement in body.ChildNodes)
                {
                    ComptaEntry comptaEntry = new ComptaEntry(
                        entryElement.ChildNodes[0].InnerText,
                        DateTime.Parse(entryElement.ChildNodes[1].InnerText),
                        float.Parse(entryElement.ChildNodes[2].InnerText),
                        float.Parse(entryElement.ChildNodes[3].InnerText)
                        );

                    this.entries.Add(comptaEntry);

                    //this.entries.Add(new ComptaEntry("Restant couveuse", DateTime.Now, 30.0f, 0.0f));
                }
            }
        }