Esempio n. 1
0
        /// <summary>
        /// Reads the Prescription Files and Loads them into classes
        /// </summary>
        public void ReadOldFile()
        {
            XmlDocument PrescriptionFile = new XmlDocument();

            PrescriptionFile.Load("Prescriptions.xml");                                    //Load Prescription File
            XmlNodeList Prescript = PrescriptionFile.GetElementsByTagName("Prescription"); //Get a List of Prescriptions

            foreach (XmlNode node in Prescript)                                            //For Each Prescription in the list
            {
                string       Name             = node["Name"].InnerText;                    //Get Patient Name
                string       Doctor           = node["Doctor"].InnerText;                  //Get Doctor Name
                string       instructions     = node["Instructions"].InnerText;            //Get Instructions
                XmlNodeList  Items            = node.SelectNodes("Item");                  //Creates a List of Items
                Prescription CurrentPrescript = new Prescription(Name);                    //Creates a New Class
                CurrentPrescript.SetDoctorName(Doctor);                                    //Sets Doctor name to the value read in
                CurrentPrescript.SetInstructions(instructions);                            //Sets Instructions to the value read in
                foreach (XmlNode node2 in Items)                                           //For each Item in the list
                {
                    string NameItem = node2.InnerText;                                     //Read Item Name
                    CurrentPrescript.AddItemNameList(NameItem);                            //Set Item Name
                    string Number = node2.Attributes["Quantity"].InnerText;                //Read Quantity
                    CurrentPrescript.AddQuantity(Number);                                  //Set Quantity
                }
                PrescriptList.Add(CurrentPrescript);                                       //Add Class to Class List
            }
        }
        /// <summary>
        /// Read Prescriptions to Complete XML
        /// </summary>
        public void ReadToDoPrescriptionsFile()
        {
            XmlDocument PrescriptionFile = new XmlDocument();

            PrescriptionFile.Load("Prescriptions.xml");                                    //Read XML file
            XmlNodeList Prescript = PrescriptionFile.GetElementsByTagName("Prescription"); //Get a List of Prescriptions
            int         index     = 0;

            foreach (XmlNode node in Prescript)                                 //For Every Prescription
            {
                string       Name             = node["Name"].InnerText;         //Get Patient Name
                string       Doctor           = node["Doctor"].InnerText;       //Get Doctor Name
                string       instructions     = node["Instructions"].InnerText; //Get Instructions
                XmlNodeList  Items            = node.SelectNodes("Item");       //Make a list of Items
                Prescription CurrentPrescript = new Prescription(Name);         //Create New CLass
                CurrentPrescript.SetDoctorName(Doctor);                         //Set Doc Name
                CurrentPrescript.SetInstructions(instructions);                 //Set Instructions
                foreach (XmlNode node2 in Items)                                //For each item in prescription
                {
                    string NameItem = node2.InnerText;                          //Get Item Name
                    CurrentPrescript.AddItemNameList(NameItem);                 //Add to Class
                    string Number = node2.Attributes["Quantity"].InnerText;     //Get Quantity
                    CurrentPrescript.AddQuantity(Number);                       //Add to CLass
                }
                ToDoPrescriptList.Add(CurrentPrescript);                        //Add Class to Class list
                PrescriptionList.Items.Add(CurrentPrescript.GetPatientName());  //Add to Complete List
                index++;                                                        //Next prescription
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Saves New Prescription File, Updates Stock and Cleans For a New Prescription
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Save_Click(object sender, EventArgs e)
 {
     if (txtPatientName.Text.Equals(""))                     //If there is Nothing in Patient Name Box
     {
         MessageBox.Show("Please Enter a Patient Name");     //Show Error Message
     }
     else if (DoctorsCombo.Text.Equals(""))                  //If there is Nothing in Doctor Drop Down
     {
         MessageBox.Show("Please Select a Doctor");          //Show Error Message
     }
     else if (ItemView.Items.Count == 0)                     //If there is Nothing in Items View
     {
         MessageBox.Show("No Items Have Been Selected");     //Show Error Message
     }
     else if (txtInstructions.Text.Equals(""))               //If there is Nothing in Instructions
     {
         MessageBox.Show("No Instructions have been typed"); //Show Error Message
     }
     else
     {
         bool allitemsinstock = true;                                                                                               //Flag for Items in Stock
         for (int i = 0; i < ItemView.Items.Count; i++)                                                                             //For Every Item
         {
             string quan = DodgyBobStockControl.StockControl.ASK("'" + ItemView.Items[i].SubItems[0].Text + "' stockcheck please"); //Check the Stock Available
             quan = quan.Substring(8);                                                                                              // Gets rid of "We Have "
             string[] tempvalues  = quan.Split(' ');                                                                                //Splits the string at " "'s
             int      quaninstock = int.Parse(tempvalues[0]);                                                                       //Gets the values before the space
             int      quantocheck = int.Parse(ItemView.Items[i].SubItems[1].Text);                                                  //Gets the amount of Items in the prescription
             if (quaninstock < quantocheck)                                                                                         //If we dont have enough items in stock
             {
                 MessageBox.Show("Pharmacy has not got enough items in stock");                                                     //Show Error Message
                 allitemsinstock = false;                                                                                           //Set the Flag
             }
         }
         if (allitemsinstock)                                                               //If we have enough items in stock
         {
             Prescription TempPrescriptionClass = new Prescription(txtPatientName.Text);    //Create a New Prescription Class
             TempPrescriptionClass.SetDoctorName(DoctorsCombo.Text);                        //Set Doctor Name
             TempPrescriptionClass.SetInstructions(txtInstructions.Text);                   //Set Instructions
             for (int i = 0; i < ItemView.Items.Count; i++)                                 //For Each Item
             {
                 TempPrescriptionClass.AddItemNameList(ItemView.Items[i].SubItems[0].Text); //Add Item Name to List
                 TempPrescriptionClass.AddQuantity(ItemView.Items[i].SubItems[1].Text);     //Add Quantity to List
             }
             PrescriptList.Add(TempPrescriptionClass);                                      //Add Class to Class List
             if (File.Exists(@"Prescriptions.xml") == true)                                 //Check If prescription file already exists
             {
                 ReadOldFile();                                                             //If So Read Old Values First
             }
             WritePrescription();                                                           //Write Out Everything
             MessageBox.Show("Prescription Saved");                                         //Tell User Prescription has been saved
             ResetForm();
         }
     }
 }