/// <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 } }
/// <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> /// 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(); } } }
/// <summary> /// Reads Prescription that have still gotta be collected /// </summary> public void ReadPrescriptionsFile() { ParentListHolder.FinalPrescriptionList.Clear(); //Resets XmlDocument PrescriptionFile = new XmlDocument(); PrescriptionFile.Load("CompletedPrescriptions.xml"); //Read XML file XmlNodeList Prescript = PrescriptionFile.GetElementsByTagName("Prescription"); //Creates a list of prescriptions int index = 0; foreach (XmlNode node in Prescript) //For every prescription in the list { string Name = node["Name"].InnerText; //get patient name string Doctor = node["Doctor"].InnerText; //get doc name string DateIssue = node["DateIssue"].InnerText; //get date issued string DateExpiry = node["DateExpiry"].InnerText; //get date expiry string ReadPrice = node["Price"].InnerText; //Get price string PharaName = node["Pharmacist"].InnerText; //Get pharmacist name string PresStatus = node["Completed"].InnerText; //get whether it has been completed 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.SetPharmacistName(PharaName); //set pharmacist name CurrentPrescript.SetPrice(ReadPrice); //set price CurrentPrescript.SetDateIssued(DateIssue); //set date issued CurrentPrescript.SetDateExpiry(DateExpiry); //set date expiry CurrentPrescript.SetCompleted(PresStatus); //set collected status foreach (XmlNode node2 in Items) //for all of the items { string NameItem = node2.InnerText; //get item name CurrentPrescript.AddItemNameList(NameItem); //add item to class string Number = node2.Attributes["Quantity"].InnerText; //get quantity CurrentPrescript.AddQuantity(Number); //add quantity to class } ParentListHolder.FinalPrescriptionList.Add(CurrentPrescript); //add class to class list index++; //next item } }
/// <summary> /// Read Prescriptions File XML /// </summary> public void ReadPrescriptionsFile() { XmlDocument PrescriptionFile = new XmlDocument(); PrescriptionFile.Load("CompletedPrescriptions.xml"); //Opens Prescriptions XML File XmlNodeList Prescript = PrescriptionFile.GetElementsByTagName("Prescription"); //Gets a List of Prescriptions int index = 0; //Prescription List Counter 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 Price = node["Price"].InnerText; //Get Price string DateIssue = node["DateIssue"].InnerText; //Get Date Issued string DateExpiry = node["DateExpiry"].InnerText; //Get Expiry Date string PharaName = node["Pharmacist"].InnerText; //Get Pharmacist Name string PresStatus = node["Completed"].InnerText; //Get Whether it was collect or not XmlNodeList Items = node.SelectNodes("Item"); //Create a List of Items Prescription CurrentPrescript = new Prescription(Name); //Create a New Class CurrentPrescript.SetDoctorName(Doctor); CurrentPrescript.SetPrice(Price); CurrentPrescript.SetPharmacistName(PharaName); CurrentPrescript.SetDateIssued(DateIssue); CurrentPrescript.SetDateExpiry(DateExpiry); CurrentPrescript.SetCompleted(PresStatus); foreach (XmlNode node2 in Items) //For Every Item in the list { string NameItem = node2.InnerText; //get Item Name CurrentPrescript.AddItemNameList(NameItem); string Number = node2.Attributes["Quantity"].InnerText; //Get Quantity CurrentPrescript.AddQuantity(Number); } PrescriptionsList.Add(CurrentPrescript); //Add Class to Class List index++; //Move to Next Prescription } }