/// <summary> /// Function to generate bill again the current pateint. /// Also saves the selected medicines against this bill. /// </summary> /// <param name="Curent Patient ID"></param> /// <param name="Array of Medicines IDs"></param> private void generateBill(int savedPatientID, int[] medIDs) { var bill = new Bill(); bill.BillAmount = this.billAmount; bill.BillDate = datePickerAppointment.Value; bill.PatientID = savedPatientID; var billform = new BillForm(txtPatName.Text, billAmount, datePickerAppointment.Value.ToString()); if (billform.ShowDialog() == DialogResult.Yes) { bill.BillStatus = true; } else { bill.BillStatus = false; } int savedBillID = processPatient.SaveBill(bill); //Save bill-medicines data. BillMedicine billMedicine; foreach (var item in medIDs) { billMedicine = new BillMedicine() { BilIID = savedBillID, MedicineID = item }; processPatient.BillToMedicines(billMedicine); } }
public void BillToMedicines(BillMedicine billMedicine) { using (context = new MedicalStore_dbEntities()) { context.BillMedicines.Add(billMedicine); context.SaveChanges(); } }