예제 #1
0
        // Save the current file*******************************************************************

        private void fileMenuSave_Click(object sender, EventArgs e)
        {
            // First, check to see if child forms are open. If so, ask if want to save.
            PracticeForm child = this.ActiveMdiChild as PracticeForm;

            if (child != null) // don't try to save what doesn't exist
            {
                DialogResult notSoFast = MessageBox.Show("Do you want to save changes?",
                                                         "SAVE CHANGES", MessageBoxButtons.YesNo);

                if (notSoFast == DialogResult.Yes) // save
                {
                    child.writeFile();
                }
                else // don't want to save...
                {
                    Application.Exit();
                }
            }
        }
예제 #2
0
        // provide capability to edit existing inventory entries***********************************

        private void editMenuUpdate_Click(object sender, EventArgs e)
        {
            // Identify the active child; it will be passed to the EntryForm
            PracticeForm child = this.ActiveMdiChild as PracticeForm;

            //create a new EntryForm, passing child and bool update = true
            EntryForm Entry = new EntryForm(child, true);

            // This try / catch is necessary in case the user clicks "update" with no record selected.
            try
            {
                Entry.Controls.RemoveAt(2); // the insert button won't be visible; update only
                Entry.Text = "Update inventory item";
                Entry.ShowDialog();
            }
            catch (ArgumentOutOfRangeException)
            {
                // The exception is handled by the EntryForm.
            }
        }
예제 #3
0
        // Parameterized constructor for specific clinic type and update option********************

        public EntryForm(PracticeForm child, bool update)
        {
            InitializeComponent();

            string workfile = MedicalSupplies.workFile; // identifies the input file

            this.child = child;

            // the practice name will be displayed as a reminder to the operator
            this.practiceRichTextBox.Text = child.Text;

            // if boolean update is true, display the selected record in this form's
            // rich text boxesfor editing
            if (update == true)
            {
                // get the index of the selected line
                idx = child.inventoryListBx.SelectedIndex;

                try // make sure a record is selected; can't update null object
                {
                    // read the line as a string
                    line = child.inventoryListBx.Items[idx].ToString();

                    // parse the (tab separated) string to display elements in the appropriate rich
                    // text box
                    string[] split = line.Split('\t');

                    // display the indexed elements of 'split' in the text boxes
                    this.idRichTextBox.Text     = split[0];
                    this.nameRichTextBox.Text   = split[1];
                    this.qtyReqRichTextBox.Text = split[2];
                    this.qtyRichTextBox.Text    = split[3];
                }

                catch (ArgumentOutOfRangeException)
                {
                    MessageBox.Show("Please select a record to update.");
                    this.Close();
                }
            }
        }
예제 #4
0
        // for closing practice forms**************************************************************

        private void fileMenuClose_Click(object sender, EventArgs e)
        {
            // identify the active child form
            PracticeForm child = this.ActiveMdiChild as PracticeForm;

            DialogResult notSoFast = MessageBox.Show("Do you want to save changes?",
                                                     "SAVE CHANGES", MessageBoxButtons.YesNo);

            if (notSoFast == DialogResult.Yes) // save and exit
            {
                try                            // can't close and save a null file
                {
                    // call the active child form to serialize the newly edited file
                    child.writeFile();

                    // reset the window open boolean variable
                    if (child.Text == "Lake Dental Clinic")
                    {
                        dentalOpen = false;
                    }
                    if (child.Text == "Pickens Foot Clinic")
                    {
                        footOpen = false;
                    }

                    // close the child form
                    child.Close();
                }

                catch (NullReferenceException)
                {
                    MessageBox.Show("There's no file open.");
                }
            }
            else // don't want to save...
            {
                this.Close();
            }
        }
예제 #5
0
        // for deleting entries********************************************************************

        private void editMenuDelete_Click(object sender, EventArgs e)
        {
            // identify the active child form
            PracticeForm child = this.ActiveMdiChild as PracticeForm;

            // verify user's intent
            DialogResult waitAminute = MessageBox.Show("Delete the selected record?",
                                                       "CONFIRM DELETION", MessageBoxButtons.YesNo);

            if (waitAminute == DialogResult.Yes)
            {
                // get the index of the selected record from the form
                int idx = child.inventoryListBx.SelectedIndex;

                // delete the selected line from the child's list box
                child.getDelete(idx);
            }
            else // don't want to delete
            {
                // no action necessary
            }
        }