예제 #1
0
        //Purpose: Creates a new file for a new practice and saves one record
        //from the user inside of it. It then opens a new form with the record.
        //Requires: object send, EventArgs e
        //Returns: nothing
        private void MedicalSupplies_FileNew(object sender, EventArgs e)
        {
            ArrayList       recordList = new ArrayList();
            BinaryFormatter writer     = new BinaryFormatter();
            string          fileName;

            //Inform User
            MessageBox.Show("Input a Record for New Practice", "New Practice Record",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);

            InsertForm inForm = new InsertForm(true);

            inForm.ShowDialog();

            Record rec = new Record(inForm.ItemID, inForm.ItemName, inForm.Practice,
                                    inForm.QtyReq, inForm.QtyHeld);

            fileName = inForm.Practice + ".Inv";
            recordList.Add(rec);

            //Open the new file with the new file name
            FileStream input = new FileStream(fileName,
                                              FileMode.OpenOrCreate, FileAccess.Write);

            writer.Serialize(input, rec);

            input.Close();

            //open child form for new file
            ChildForm newChild = new ChildForm(recordList, fileName);

            newChild.MdiParent = this;
            newChild.Show();
        }// MedicalSupplies_FileNew
예제 #2
0
        }//end MedicalSupplies_Delete

        private void MedicalSupplies_Update(object sender, EventArgs e)
        {
            ChildForm activeChild = this.ActiveMdiChild as ChildForm;

            if (activeChild != null)
            {
                InsertForm updateForm = new InsertForm(false);
                updateForm.Text = "Update Record";

                updateForm.ShowDialog();

                Record rec = new Record(updateForm.ItemID, updateForm.ItemName, "",
                                        updateForm.QtyReq, updateForm.QtyHeld);

                //update the record on active child form
                activeChild.updateRecord(rec);
            }
        }//MedicalSupplies_Update
예제 #3
0
        }// end  MedicalSupplies_Exit

        private void MedicalSupplies_Insert(object sender, EventArgs e)
        {
            InsertForm inForm      = new InsertForm(false);
            ChildForm  activeChild = this.ActiveMdiChild as ChildForm;

            if (activeChild != null)
            {
                //Opens the Insert form
                inForm.ShowDialog();

                //if the insert form wasn't canceled, store the new record data in
                //a record and pass it to the active child
                if (!inForm.Canceled)
                {
                    Record rec = new Record(inForm.ItemID, inForm.ItemName, "",
                                            inForm.QtyReq, inForm.QtyHeld);

                    //insert the new record to the list
                    activeChild.insertToList(rec);
                }
            }
        }//end MedicalSupplies_Insert