Exemple #1
0
        private void Print_Click(object sender, EventArgs e)
        {
            printDoc.PrinterSettings.PrinterName = cmbxPrinter.Text;
            if (printDoc.PrinterSettings.IsValid)
            {
                try
                {
                    printDoc.PrinterSettings.PrintFileName = szDocName;//check this: there's bound to be a bug here (disallowed characters in filename)
                    printDoc.DocumentName = szDocName;
                }
                catch
                {
                    printDoc.PrinterSettings.PrintFileName = "PrintFileName";
                    printDoc.DocumentName = "PrintFileName";
                }
                printDoc.PrinterSettings.PrintRange = PrintRange.AllPages;

                StatusBarMessages.SetStatusBarMessageAction("Printing...");
                printDoc.Print();
                StatusBarMessages.SetStatusBarMessageAction("Done printing");
                Close();
            }
            else
            {
                MessageBox.Show("Printer does not exist");
                return;
            }
        }
Exemple #2
0
 private void MenuItemRefresh_Click(object sender, EventArgs e)
 {
     if (FILTER != null)
     {
         SortTreeView(FILTER);
         StatusBarMessages.SetStatusBarMessageAction("Refreshed treeview");
     }
 }
Exemple #3
0
        private void DeleteTreeNode(TreeNode treeNodeSelected)
        {
            try
            {
                if (treeNodeSelected.Name == "PARENTNODE")//the selected node is a parentNode
                {
                    if (MessageBox.Show("Do you want to delete this parent node [" + treeNodeSelected.Text + "]" +
                                        " and all its children?\n(NB: This action cannot be undone.)",
                                        "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        foreach (TreeNode child in treeNodeSelected.Nodes)//close tabpage if possible
                        {
                            CloseTabPage(child.Name);
                            RecentlyOpenedDocs.DeleteSermonFromID(int.Parse(child.Name));
                            Sermon.DeleteSermon(int.Parse(child.Name));
                        }
                        if (int.TryParse(treeNodeSelected.Name, out int id))
                        {
                            CloseTabPage(treeNodeSelected.Name);
                            RecentlyOpenedDocs.DeleteSermonFromID(int.Parse(treeNodeSelected.Name));
                            Sermon.DeleteSermon(int.Parse(treeNodeSelected.Name));
                        }
                        treeNodeSelected.Remove();
                    }
                }
                else//i.e. the selected node is not a parent node
                {
                    TreeNode parentNode = treeNodeSelected.Parent;

                    if (treeNodeSelected.Name != null)
                    {
                        if (MessageBox.Show("Do you want to delete this node [" + treeNodeSelected.Text + "]" +
                                            "?\n(NB: This action cannot be undone.)",
                                            "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            CloseTabPage(treeNodeSelected.Name);//close tabpage if possible
                            treeNodeSelected.Remove();
                            RecentlyOpenedDocs.DeleteSermonFromID(int.Parse(treeNodeSelected.Name));
                            Sermon.DeleteSermon(int.Parse(treeNodeSelected.Name));
                            StatusBarMessages.SetStatusBarMessageAction("Deleted " + treeNodeSelected.Text);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Could not access node data.\nPlease try again.", "Failed to delete!");
                    }
                    if (parentNode.GetNodeCount(false) == 0)
                    {
                        parentNode.Remove();
                    }
                }
            }
            catch
            {
                MessageBox.Show("Kindly specify the node to be deleted.");
            }
        }
Exemple #4
0
 private void MenuitemTheme_Click(object sender, EventArgs e)
 {
     if (FILTER != "Theme")
     {
         FILTER = "Theme";
         SortTreeView(FILTER);
         StatusBarMessages.SetStatusBarMessageAction("Sorted by Theme");
     }
 }
Exemple #5
0
        private void MenuItemDeleteAll_Click(object sender, EventArgs e)
        {
            DialogResult userChoice = MessageBox.Show("This option is going to delete every record in your library. Do you wish to continue?\n(NB: This action cannot be undone.)", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (userChoice == DialogResult.Yes)
            {
                try
                {
                    foreach (TreeNode tnParentNode in Nodes)
                    {
                        foreach (TreeNode tnChildNode in tnParentNode.Nodes)
                        {
                            try
                            {
                                string szRemoved = tnChildNode.Name;
                                CloseTabPage(szRemoved);//close tabpage if possible
                                Sermon.DeleteSermon(int.Parse(szRemoved));
                                RecentlyOpenedDocs.DeleteSermonFromID(int.Parse(szRemoved));
                            }
                            catch {; }
                        }
                    }
                    Nodes.Clear();
                    Sort();
                    if (Nodes.Count != 0)
                    {
                        MessageBox.Show("An error was encountered in deleting some nodes. Please try again.");
                        StatusBarMessages.SetStatusBarMessageAction("Partial deletion");
                    }
                    else
                    {
                        StatusBarMessages.SetStatusBarMessageAction("Deleted all stored sermons");
                    }
                }
                catch {; }
            }
        }
Exemple #6
0
        private void SaveTypedData()
        {
            try
            {
                DateTime datetime = dtPicker.Value;

                int series;
                try
                {
                    if (!int.TryParse(cmbxSeries.SelectedValue.ToString(), out series))
                    {
                        series = 0;
                    }
                }
                catch
                {
                    series = 0;
                }

                string venue;
                if (string.IsNullOrEmpty(txbVenue_Name.Text))
                {
                    venue = "NOT SET";
                }
                if (txbVenue_Name.Text == txbVenue_Name.Watermark)
                {
                    venue = "NOT SET";
                }
                else
                {
                    venue = txbVenue_Name.Text;
                }

                string town;
                if (string.IsNullOrEmpty(txbVenue_Town.Text))
                {
                    town = "NOT SET";
                }
                if (txbVenue_Town.Text == txbVenue_Town.Watermark)
                {
                    town = "NOT SET";
                }
                else
                {
                    town = txbVenue_Town.Text;
                }

                string activity;
                if (string.IsNullOrEmpty(txbVenue_Activity.Text))
                {
                    activity = "NOT SET";
                }
                if (txbVenue_Activity.Text == txbVenue_Activity.Watermark)
                {
                    activity = "NOT SET";
                }
                else
                {
                    activity = txbVenue_Activity.Text;
                }

                string speaker;
                if (string.IsNullOrEmpty(txbSpeakerName.Text))
                {
                    speaker = "NOT SET";
                }
                if (txbSpeakerName.Text == txbSpeakerName.Watermark)
                {
                    speaker = "NOT SET";
                }
                else
                {
                    speaker = txbSpeakerName.Text;
                }

                string keytext;
                if (string.IsNullOrEmpty(txbKeyText.Text))
                {
                    keytext = "NOT SET";
                }
                if (txbKeyText.Text == txbKeyText.Watermark)
                {
                    keytext = "NOT SET";
                }
                else
                {
                    keytext = txbKeyText.Text;
                }

                string hymn;
                if (string.IsNullOrEmpty(txbHymn.Text))
                {
                    hymn = "NOT SET";
                }
                if (txbHymn.Text == txbHymn.Watermark)
                {
                    hymn = "NOT SET";
                }
                else
                {
                    hymn = txbHymn.Text;
                }

                string title;
                if (string.IsNullOrEmpty(txbTitle.Text))
                {
                    title = "NOT SET";
                }
                if (txbTitle.Text == txbTitle.Watermark)
                {
                    title = "NOT SET";
                }
                else
                {
                    title = txbTitle.Text;
                }

                string theme;
                if (string.IsNullOrEmpty(txbTheme.Text))
                {
                    theme = "NOT SET";
                }
                if (txbTheme.Text == txbTheme.Watermark)
                {
                    theme = "NOT SET";
                }
                else
                {
                    theme = txbTheme.Text;
                }

                string content = rtbContent.Rtf;

                StatusBarMessages.SetStatusBarMessageAction("Saving " + title);

                if (isEdited == false)//new sermon
                {
                    Sermon sermon = new Sermon(0, series, datetime, venue, town, activity, speaker, keytext, hymn, title, theme, content);

                    string[] arraySubItems = Sermon.ComponentsToString(sermon);
                    if (Sermon.WriteSermon(arraySubItems) == 1)//sermon inserted successfully
                    {
                        AppEngine.Database.Sermon dummy = new AppEngine.Database.Sermon()
                        {
                            Activity    = sermon.Activity,
                            Content     = sermon.Content,
                            DateCreated = sermon.DateCreated,
                            Hymn        = sermon.Hymn,
                            KeyText     = sermon.KeyText,
                            Speaker     = sermon.Speaker,
                            Title       = sermon.Title,
                            Theme       = sermon.Theme,
                            Town        = sermon.Town,
                            Venue       = sermon.Venue
                        };
                        if (dummy.Exists(dummy))
                        {
                            sermon.Id = dummy.Id;
                            parentForm.tabControl.TabPages.Remove(parentForm.tabControl.SelectedTab);
                            parentForm.AddNewTabPage(SermonReader.DisplayStoredSermon(Sermon.ComponentsToString(sermon)));
                            treeViewEx.AddNewTreeNode(dummy.Title, dummy.Id.ToString());
                        }
                    }
                    else
                    {
                        MessageBox.Show("Document not added.\nPlease try again.");
                    }
                }
                else//edited sermon: use existing ID
                {
                    Sermon   sermon        = new Sermon(editedID, series, datetime, venue, town, activity, speaker, keytext, hymn, title, theme, content);
                    string[] arraySubItems = Sermon.ComponentsToString(sermon);
                    arraySubItems[iID] = editedID.ToString();
                    Sermon.OverwriteSermon(arraySubItems);
                    parentForm.tabControl.TabPages.Remove(parentForm.tabControl.SelectedTab);
                    parentForm.AddNewTabPage(SermonReader.DisplayStoredSermon(arraySubItems));
                }
                StatusBarMessages.SetStatusBarMessageAction("Saved " + title);
            }
            catch
            {
                StatusBarMessages.SetStatusBarMessageAction("Error saving " + txbTitle.Text);
            }
        }
Exemple #7
0
 private void Abort_Click(object sender, EventArgs e)
 {
     Close();
     StatusBarMessages.SetStatusBarMessageAction("Printing cancelled");
 }