private void Button_Click_Ok(object sender, RoutedEventArgs e)
        {
            if (tbDescriptionAnamnesis.Text == "" || tbDescriptionAnamnesis.Text == null || tbOpinionForAnamnesis.Text == "" || tbOpinionForAnamnesis.Text == null ||
                tbTypeAnamnesis.Text == "" || tbTypeAnamnesis.Text == null)
            {
                check_validation();
            }
            else
            {
                int id = mrd.anamControl.anamnesisService.anamnesisRepository.next_id;
                mrd.anamControl.anamnesisService.anamnesisRepository.next_id++;
                mrd.anamControl.CreateAnamnesis(mrd.lbuUsernamePatient.Content.ToString(), id,
                                                tbTypeAnamnesis.Text, tbDescriptionAnamnesis.Text, tbOpinionForAnamnesis.Text);

                for (int i = 0; i < lvDataBindingAnamnesis.Items.Count; i++)
                {
                    Model.Prescription prescription = (Model.Prescription)(lvDataBindingAnamnesis.Items[i]);
                    mrd.pc.CreatePrescription(id, mrd.pc.prescriptionService.prescriptionRepository.next_id,
                                              prescription.StartDatePrescription, prescription.EndDatePrescription, prescription.DescriptionPrescription,
                                              prescription.QuantityPrescription, prescription.drug.DrugName);
                }
                MessageBox.Show("Uspešno ste kreirali uput za doktora specijalistu!", "Uspešno izvršeno!", MessageBoxButton.OK, MessageBoxImage.Information);
                mrd.Load();
                this.Close();
            }
        }
        private void Button_Click_Ok(object sender, RoutedEventArgs e)
        {
            if (cbDrugAdd.Text == "" || tbDescriptionPrescription.Text == "" || tbDrugQuantity.Text == "" || tbEndDate.Text == "" ||
                tbStartDate.Text == "Select a date")
            {
                check_validation();
            }
            else
            {
                if (ac == null)
                {
                    mrd.pc.CreatePrescription(((Model.Anamnesis)mrd.lvDataBinding.SelectedItems[0]).AnamnesisId,
                                              int.Parse(lbDrugName.Content.ToString()), Convert.ToDateTime(tbStartDate.Text), Convert.ToDateTime(tbEndDate.Text),
                                              tbDescriptionPrescription.Text, int.Parse(tbDrugQuantity.Text), cbDrugAdd.Text);
                    mrd.full_uodate();
                }
                else
                {
                    Model.Prescription prescription = new Model.Prescription(int.Parse(lbDrugName.Content.ToString()),
                                                                             mrd.pc.prescriptionService.prescriptionRepository.next_id, Convert.ToDateTime(tbStartDate.Text),
                                                                             Convert.ToDateTime(tbEndDate.Text), tbDescriptionPrescription.Text, int.Parse(tbDrugQuantity.Text), cbDrugAdd.Text);

                    ac.lvDataBindingAnamnesis.Items.Add(prescription);
                }
                MessageBox.Show("Uspešno ste dodali recept!", "Uspešno izvršeno!", MessageBoxButton.OK, MessageBoxImage.Information);
                this.Close();
            }
        }
예제 #3
0
        public void CreatePrescription(int AnamId, int PresId, DateTime Start, DateTime End, String Description, int Quantity, String dr)
        {
            List <Model.Prescription> prescriptions = GetAllPrescriptions();

            Model.Prescription pr = new Model.Prescription(AnamId, PresId, Start, End, Description, Quantity, dr);
            prescriptions.Add(pr);
            prescriptionRepository.SavePrescription(prescriptions);
        }
예제 #4
0
        public List <Model.Prescription> LoadPrescription()
        {
            List <Model.Prescription> prescriptions = new List <Model.Prescription>();

            try
            {
                String       line;
                StreamReader sr = new StreamReader(FileLocation);

                while ((line = sr.ReadLine()) != null)
                {
                    Console.WriteLine(line);
                    string[] words = line.Split(',');


                    Model.Prescription pr = new Model.Prescription(int.Parse(words[0]), int.Parse(words[1]), Convert.ToDateTime(words[2]),
                                                                   Convert.ToDateTime(words[3]), words[4], int.Parse(words[5]), words[6]);


                    prescriptions.Add(pr);

                    next_id = pr.PrescriptionId;
                }
                next_id++;

                sr.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
            finally
            {
                Console.WriteLine("Executing finally block.");
            }

            return(prescriptions);
        }