Exemplo n.º 1
0
        //One Event Handler to Open either the the Dental Clinic
        //or the Foot Clinic
        private void open_clinic_click(object sender, EventArgs e)
        {
            //sets the arguemnt sender as a item of toolstripmenu
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            string            tempfile;

            //If statement the will check the text of the item and select the correct
            //practice to open their file.

            if (item.Text == "Dental Clinics")
            {
                practice_name = "Lake Dental Clinic";
            }
            else
            {
                practice_name = "Jinkins Foot Clinic";
            }

            //Will pass the array list keeper to the open file to fill it
            //with the data
            tempfile = open_file(keeper);

            //creates the child form and gives it the practice name and the array list
            Child_Form child = new Child_Form(practice_name, keeper);

            child.file_name = tempfile;

            //sets the mdi parent to the main form
            child.MdiParent = this;

            //shows the child
            child.Show();
        }
Exemplo n.º 2
0
        //Purpose: To Have one event handler to control multiple menu options
        //Requires: The correct click
        //Returns:Nothing
        private void menuChoice_Click(object sender, EventArgs e)
        {
            //Creates a item from the tool strip menu item
            ToolStripMenuItem item = sender as ToolStripMenuItem;

            //creates a temp record
            Records temp;

            //Casts the active child form to the active child
            Child_Form active = (Child_Form)this.ActiveMdiChild;

            //If there is a active child
            //continue through the if statement
            if (active != null)
            {
                //shows the Insert form if Delete if not selected
                if (item.Text != "Delete")
                {
                    //shows the insert form dialog
                    Insert_form.ShowDialog();
                }
                //gets the record and sets it to temp
                temp = Insert_form.get_Record;

                //switch statement to control
                //which item was selected
                switch (item.Text)
                {
                //Will Insert the Record to the end of the
                //arrray list
                case "Insert":
                    active.Insert_Record(temp);
                    break;

                //Will Update the selected record
                case "Update":
                    active.updatelistbox(temp);
                    break;

                //Will delete the selected record
                //also will confirm if you want to delete the selected
                //record
                case "Delete":
                    if (MessageBox.Show("Are you sure you want to Delete", "Confirm",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        active.deleteitem();
                    }

                    break;

                default:
                    break;
                }
            }
        }