/// <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 } }
/// <summary> /// Finish button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Complete_Click(object sender, EventArgs e) { double TotalPrice = 0; //Prescription total if (PrescriptionItemView.Items.Count > 0 && PharmaCombo.Text != null) //If Fields are filledin { for (int i = 0; i < PrescriptionItemView.Items.Count; i++) //for each of the items { #region Total Price string pricestring = PrescriptionItemView.Items[i].SubItems[2].Text.Substring(1); //get items price string quantitystring = PrescriptionItemView.Items[i].SubItems[1].Text; //get items quantity double price = double.Parse(pricestring); //Items Price int quantity = int.Parse(quantitystring); //Items Quantity price = price * quantity; //price is quantity times items price TotalPrice += price; //add the price to the total price #endregion DodgyBobStockControl.StockControl.DO("'" + PrescriptionItemView.Items[i].Text + "' consume " + quantity + " please"); //remove from stock } DodgyBobStockControl.StockControl.SAVE(); //Saves the stock update #region Saving the data to a class Prescription tempprescrip = new Prescription(PatientName); //create class if (Collecting.Checked == true) //if patient is collecting now { tempprescrip.SetCompleted("Completed"); //set status to completed } else { tempprescrip.SetCompleted("Not Completed"); //this means they are waiting } tempprescrip.SetDoctorName(DoctorName); //set doc name tempprescrip.SetPharmacistName(PharmaCombo.Text); //set pharmacist name tempprescrip.SetDateExpiry(DateExpiry.Text); //set date expiry tempprescrip.SetDateIssued(DateIssue.Text); //set date issued tempprescrip.SetPrice(TotalPrice.ToString()); //set price for (int i = 0; i < PrescriptionItemView.Items.Count; i++) //for every single item { string itemnamestring = PrescriptionItemView.Items[i].Text; //get item name string quantitystring = PrescriptionItemView.Items[i].SubItems[1].Text; //get quantity tempprescrip.ItemName.Add(itemnamestring); //add item name tempprescrip.Quantity.Add(quantitystring); //add quantity } ParentListHolder.FinalPrescriptionList.Add(tempprescrip); //add class to class list #endregion UpdatePrescriptionsToCollect(); // updates prescriptions XML file #region Tidying Up for (int i = 0; i < ToDoPrescriptList.Count; i++) //Removes the completed prescription from the old list { Prescription node = ToDoPrescriptList[i]; //get prescription class if (node.GetPatientName() == PatientName && node.GetDoctorName() == DoctorName && node.GetInstruction() == txtInstructions.Text) //check its the right one { ToDoPrescriptList.Remove(node); //remove it break; //leave loop } } WriteToDoPrescription(); //Re-Writes To Do Prescriptions without ToDoPrescriptList.Clear(); //Cleans the List PrescriptionList.Items.Clear(); //Reset items in list ReadToDoPrescriptionsFile(); //Reads the Prescriptions Back PrescriptionItemView.Items.Clear(); //Reset items in list txtInstructions.Text = ""; //set instruction to blank Collecting.Checked = false; //reset collecting variable SetPrice = 0.1; //Reset Fixed or Free #endregion if (File.Exists("CompletedPrescription.xml") == true) //if completed file exist { ReadPrescriptionsFile(); //read old one first } WritePrescription(); //write it out if (SetPrice != 0.1) //if price is a set one { TotalPrice = SetPrice; //set total price } ToPay Newform = new ToPay("£" + string.Format("{0:0.00}", TotalPrice)); //formats the price with two decimal places Newform.Show(); } else //if no prescription is selected { MessageBox.Show("No Prescription Selected"); //show error message } }