コード例 #1
0
ファイル: Form1.cs プロジェクト: Mahmoudc/JournalRecorder
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FillItemListBox();
            frmAddDetails details = new frmAddDetails();

            details.ShowDialog();
            JournalRecord item = null;

            item = details.item;
            if (!details.cancel)
            {
                lbList.Items.Add(item.category);
                lists.Add(item);
                file.SaveItems(lists, true);
            }
        }
コード例 #2
0
ファイル: InvItemDB.cs プロジェクト: Mahmoudc/JournalRecorder
        public List <JournalRecord> GetItems(bool firstFile)
        {
            // create the list
            List <JournalRecord> items = new List <JournalRecord>();

            // create the XmlReaderSettings object
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;
            settings.IgnoreComments   = true;

            // create the XmlReader object

            XmlReader xmlIn = XmlReader.Create(Path, settings);

            // read past all nodes to the first Book node
            if (xmlIn.ReadToDescendant("Journal"))
            {
                // create one Product object for each Product node
                do
                {
                    JournalRecord list = new JournalRecord();
                    xmlIn.ReadStartElement("Journal");
                    if (firstFile)
                    {
                        list.category = xmlIn.ReadElementContentAsString();
                    }
                    if (!firstFile)
                    {
                        list.date    = xmlIn.ReadElementContentAsString();
                        list.journal = xmlIn.ReadElementContentAsString();
                    }
                    items.Add(list);
                }while (xmlIn.ReadToNextSibling("Journal"));
            }

            // close the XmlReader object
            xmlIn.Close();

            return(items);
        }
コード例 #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FillItemListBox();
            frmExpandDetails details = new frmExpandDetails();

            details.ShowDialog();
            JournalRecord item     = null;
            string        fileData = "/" + details.txtJournal.Text + ".docx";
            //If you want to open a file you'd use the selected item text to find document
            FileStream   file       = new FileStream(folder + fileData, FileMode.Create);
            StreamWriter outputFile = new StreamWriter(file);

            outputFile.Close();
            item = details.item;
            if (!details.cancel)
            {
                lbList.Items.Add(item.displayText());
                lists.Add(item);
                secondFile.SaveItems(lists, false);
            }
        }