示例#1
0
        //*****************************************************************************************
        public EntryForm(PracticeForm child)
        {
            InitializeComponent();

            string workfile = MedicalSupplies.workFile;

            this.child = child;

            // the practice name will be displayed as a reminder to the operator
            this.practiceRichTextBox.Text = child.Text;
        }
示例#2
0
        //*****************************************************************************************

        private void fileMenuClose_Click(object sender, EventArgs e)
        {
            // identify the active child form, reset the appropriate flag, and close the form

            PracticeForm child = this.ActiveMdiChild as PracticeForm;

            if (child.Text == "Lake Dental Clinic")
            {
                dentalOpen = false;
            }

            if (child.Text == "Pickens Foot Clinic")
            {
                footOpen = false;
            }

            // close the child form
            child.Close();
        }
示例#3
0
        //*****************************************************************************************

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

            // identifying information about the subject file and active child window
            string workfile = MedicalSupplies.workFile;

            this.child = child;

            // get the index of the selected record from the form
            idx = child.inventoryListBx.SelectedIndex;

            // display the info in this form's richTextBoxes
            this.idRichTextBox.Text       = MedicalSupplies.theList[idx][0];
            this.nameRichTextBox.Text     = MedicalSupplies.theList[idx][1];
            this.qtyReqRichTextBox.Text   = MedicalSupplies.theList[idx][2];
            this.qtyRichTextBox.Text      = MedicalSupplies.theList[idx][3];
            this.practiceRichTextBox.Text = MedicalSupplies.theList[idx][4];
        }
示例#4
0
        //*****************************************************************************************
        public void Deleter()
        {
            // identify the active child form
            PracticeForm child = this.ActiveMdiChild as PracticeForm;

            // get the index of the selected record from the form
            int idx = child.inventoryListBx.SelectedIndex;

            // open the correct file and make a table of the records
            workFile = child.workFile;

            // create filestream object to get read access
            input = new FileStream(workFile, FileMode.Open, FileAccess.ReadWrite);

            // go to beginning of file
            input.Seek(0, SeekOrigin.Begin);

            // clear the list before each file opening
            theList.Clear();

            // deserialize and display in text box
            try
            {
                // iterate over filestream object input, opening a record and appending it to the list
                while (input.Position < input.Length)
                {
                    // get next Record from file
                    Record newRec = (Record)fileReader.Deserialize(input);
                    if (newRec == null)
                    {
                        continue;
                    }

                    // store Record values in temporary string array
                    values = new string[] { newRec.ID.ToString(), newRec.Name.ToString(),
                                                                  newRec.QtyReq.ToString(), newRec.Qty.ToString(), newRec.Practice.ToString() };

                    // add current iteration of values to theList
                    theList.Add(values);
                }
            }
            catch (IOException)
            {
                MessageBox.Show("oops.");
            }

            // Close the read/write stream and open an append stream
            input.Close();
            FileStream output = new FileStream(workFile, FileMode.Create, FileAccess.Write);

            // delete the item from theList and the child form's list box
            theList.RemoveAt(idx);
            child.getDelete(idx);

            // using fileMode Create, write the first record of the modified table to the file;
            // all other records will be serialized using Append

            Record temp = new Record();

            temp.ID       = int.Parse(theList[0][0]);
            temp.Name     = theList[0][1];
            temp.QtyReq   = int.Parse(theList[0][2]);
            temp.Qty      = int.Parse(theList[0][3]);
            temp.Practice = theList[0][4];

            BinaryFormatter writer = new BinaryFormatter();

            writer.Serialize(output, temp);

            // close output and open another filestream to Append the rest
            output.Close();
            output.Dispose();
            FileStream outputRest = new FileStream(workFile, FileMode.Append, FileAccess.Write);

            // write the rest of the file using Append, which doesn't overrwrite, buts adds to the end

            for (int i = 1; i < theList.Count(); i++) // i starts at 1 because zero is done above
            {
                Record tempo = new Record();
                tempo.ID       = int.Parse(theList[i][0]);
                tempo.Name     = theList[i][1];
                tempo.QtyReq   = int.Parse(theList[i][2]);
                tempo.Qty      = int.Parse(theList[i][3]);
                tempo.Practice = theList[i][4];
                writer.Serialize(outputRest, tempo);
            }
        }