private void UpdateLek()
        {
            SelektovaniLek.Sifra       = Convert.ToInt32(SifraTb.Text);
            SelektovaniLek.Naziv       = NazivTb.Text as string;
            SelektovaniLek.Kolicina    = Convert.ToInt32(KolicinaTb.Text);
            SelektovaniLek.RokTrajanja = (DateTime)RokTb.SelectedDate;
            SelektovaniLek.Tip         = TipTb.SelectedItem as string;
            SelektovaniLek.Proizvodjac = ProizvodjacTb.Text as string;
            SelektovaniLek.Sastav      = (List <string>)listBox2.ItemsSource;


            Drug newDrug = new Drug();

            newDrug.Name           = SelektovaniLek.Naziv;
            newDrug.Id             = SelektovaniLek.Sifra;
            newDrug.Quantity       = SelektovaniLek.Kolicina;
            newDrug.ExpirationDate = SelektovaniLek.RokTrajanja;
            newDrug.Producer       = SelektovaniLek.Proizvodjac;
            List <DrugType> types = dt.ViewDrugTypes();

            foreach (DrugType d in types)
            {
                if (SelektovaniLek.Tip.Equals(d.Type))
                {
                    newDrug.drugType = d;
                }
            }
            List <Ingredient> myIngredients = new List <Ingredient>();
            List <Ingredient> ingredients   = dt.ViewIngridients();

            foreach (Ingredient i in ingredients)
            {
                foreach (string s in newIngredients)
                {
                    if (s.Equals(i.Name))
                    {
                        myIngredients.Add(i);
                    }
                }
            }

            newDrug.ingredient = myIngredients;

            dc.EditConfirmedDrug(newDrug);
            List <Therapy> tt = new List <Therapy>();

            tt = tc.ViewTherapyByDrug(newDrug.Id);
            foreach (Therapy t in tt)
            {
                t.drug = newDrug;
                tc.EditTherapy(t);
            }
            dc.EditUnconfirmedDrug(newDrug);
        }
Exemple #2
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(txtDrug.Text))
            {
                MessageBox.Show("Morate selektovati lijek u tabeli koji želite propisati.", "Upozorenje!",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                txtDrug.Focus();
                return;
            }
            else if (String.IsNullOrEmpty(txtbox2.Text))
            {
                MessageBox.Show("Morate unijeti tok bolesti na prethodnom tabu.", "Upozorenje!",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                txtbox2.Clear();
                txtbox2.Focus();
                return;
            }


            drugSelected.Quantity = --drugQuantity;
            dcon.EditConfirmedDrug(drugSelected);

            List <Drug> drugs = new List <Drug>();

            drugs = dcon.ViewConfirmedDrugs();

            List <DrugDTO> dDTOs = new List <DrugDTO>();

            foreach (Drug d in drugs)
            {
                DrugDTO dDTO = new DrugDTO();
                dDTO.Id       = d.Id;
                dDTO.Name     = d.Name;
                dDTO.Quantity = d.Quantity;
                dDTO.drugType = d.drugType.Type;

                dDTOs.Add(dDTO);
            }

            DataGrid3.ItemsSource = dDTOs;

            if (String.IsNullOrEmpty(txtbox2.Text))
            {
                MessageBox.Show("Morate unijeti tok bolesti.", "Upozorenje!",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                txtbox2.Clear();
                txtbox2.Focus();
                return;
            }
            else if (String.IsNullOrEmpty(txtbox3.Text))
            {
                MessageBox.Show("Morate unijeti terapiju", "Upozorenje!",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                txtbox3.Clear();
                txtbox3.Focus();
                return;
            }
            try
            {
                string date      = txtbox1.Text;
                string disease   = txtbox2.Text;
                string therapy11 = txtbox3.Text;

                PatientCard pc = new PatientCard();
                string[]    ss = showName.Text.Split(' ');
                pc = ap.ViewPatientCard(ss[ss.Length - 1]);
                string mh = pc.MedicalHistory;

                pc.MedicalHistory = mh + date + ":" + disease + ":" + therapy11 + ";";

                ap.EditPatientCard(pc);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            ScheduleExaminaton win = new ScheduleExaminaton();

            win.Show();

            txtbox2.Clear();
            txtbox3.Clear();

            drugSelCell = -1;
        }