コード例 #1
0
ファイル: frmNovaBolest.cs プロジェクト: Alokin7/PI
 //metoda za dodavanje nove životinje kojoj smo proslijedili objekt bolest
 private void dodajNovuBolest(Bolest novaBolest)
 {
     this.Validate();
     this.enciklopedijabolestiBindingSource.EndEdit();
     //dodavanje bolesti u bazu podataka
     this.enciklopedija_bolestiTableAdapter.Insert(novaBolest.Naziv, novaBolest.Opis);
 }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Bolest bolest = db.Bolests.Find(id);

            db.Bolests.Remove(bolest);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public void IzbrisiIzDijagnoze(Bolest bolest)
        {
            var stareBolesti = _view.Bolesti;

            //_view.Bolesti = stareBolesti.Remove(bolest;
            stareBolesti.Remove(bolest);
            _view.Bolesti = stareBolesti.Distinct().ToList();
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "BolestId,Naziv")] Bolest bolest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bolest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bolest));
 }
コード例 #5
0
        public ActionResult Create([Bind(Include = "BolestId,Naziv")] Bolest bolest)
        {
            if (ModelState.IsValid)
            {
                db.Bolests.Add(bolest);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bolest));
        }
コード例 #6
0
        public void DetaljiBolest(Bolest bolest)
        {
            BolestDetaljiForm detalji = new BolestDetaljiForm();

            detalji.Presenter = this;
            var dohvaceno = _unit.BolestiRepository.DohvatiPrekoIDSLijekovima(bolest.Id);

            detalji.Bolest = dohvaceno;
            //detalji.Bolest = bolest;
            detalji.Show();
        }
コード例 #7
0
        // GET: Bolests/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Bolest bolest = db.Bolests.Find(id);

            if (bolest == null)
            {
                return(HttpNotFound());
            }
            return(View(bolest));
        }
コード例 #8
0
ファイル: BolestController.cs プロジェクト: markomih/pharmacy
        // POST api/bolest
        public bool Post([FromBody] Bolest obj)
        {
            try
            {
                Configuration.Services.GetTraceWriter().Info(
                    Request, "ProductsController", "Get the list of products.");

                ServiceProvider.Get <BolestService>().Create(obj);
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
コード例 #9
0
ファイル: AddDiseaseForm.cs プロジェクト: markomih/pharmacy
        private void FillDiseaseArgs(Bolest bolest)
        {
            bolest.NazivBolesti = new NazivBolesti
            {
                LatinskiNaziv = textBoxLatinskiNaziv.Text,
                NarodniNaziv  = textBoxNarodniNaziv.Text
            };

            if (listBoxKontraindikacije.SelectedItem != null)
            {
                bolest.KontraindikacijaList = _parent.GetSelectedEntities(listBoxKontraindikacije)?
                                              .Select(ServiceProvider.Get <KontraindikacijaService>().Get).ToList();
            }

            if (listBoxLekovi.SelectedItem != null)
            {
                bolest.LekList = _parent.GetSelectedEntities(listBoxLekovi)?
                                 .Select(ServiceProvider.Get <LekService>().Get).ToList();
            }

            bolest.Opis = textBoxOpis.Text;
        }
コード例 #10
0
        public void UpdateBolest(Bolest b)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(_cs))
                {
                    conn.Open();
                    SqlCommand command = new SqlCommand("dbo.UpdateBolest", conn);
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.Add(new SqlParameter("@IDBolest", b.IDBolest));
                    command.Parameters.Add(new SqlParameter("@Naziv", b.NazivBolesti));
                    command.Parameters.Add(new SqlParameter("@GodinaOtkrica", b.GodinaOtkrica));
                    command.Parameters.Add(new SqlParameter("@OpasnostBolestiID", b.OpasnostID));

                    command.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #11
0
        public List <Bolest> GetBolest()
        {
            List <Bolest> lista = new List <Bolest>();

            try
            {
                using (SqlConnection Sqlcon = new SqlConnection(_cs))
                {
                    SqlCommand cmd = new SqlCommand("dbo.GetBolest", Sqlcon);

                    cmd.CommandType = CommandType.StoredProcedure;

                    Sqlcon.Open();

                    SqlDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        Bolest b = new Bolest();

                        b.IDBolest      = Convert.ToInt32(dr["IDBolest"]);
                        b.NazivBolesti  = dr["NazivBolesti"].ToString();
                        b.GodinaOtkrica = Convert.ToInt32(dr["GodinaOtkrica"]);
                        b.OpasnostID    = Convert.ToInt32(dr["OpasnostBolestiID"]);
                        b.Opasnost      = dr["Opasnost"].ToString();
                        lista.Add(b);
                    }
                    ;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(lista);
        }
コード例 #12
0
ファイル: AddDiseaseForm.cs プロジェクト: markomih/pharmacy
        private void AddNewDisease(object sender, EventArgs e)
        {
            var dialogResult = MessageBox.Show(Constants.CheckMessageBoxText, Constants.CheckMessageBoxText,
                                               MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            if (Add)
            {
                var obj = new Bolest();
                FillDiseaseArgs(obj);
                ServiceProvider.Get <BolestService>().Create(obj);
            }
            else
            {
                FillDiseaseArgs(Bolest);
                ServiceProvider.Get <BolestService>().Update(Bolest);
            }
            _parent.UpdateDiseaseGrid();
            Dispose();
        }
コード例 #13
0
 public void UpdateBolest(Bolest b)
 {
     new Repository().UpdateBolest(b);
 }
コード例 #14
0
 public void AddBolest(Bolest b)
 {
     new Repository().AddBolest(b);
 }
コード例 #15
0
ファイル: BolestController.cs プロジェクト: markomih/pharmacy
 // PUT api/bolest/5
 public void Put(int id, [FromBody] Bolest obj)
 {
     ServiceProvider.Get <BolestService>().Update(id, obj);
 }
コード例 #16
0
ファイル: AddDiseaseForm.cs プロジェクト: markomih/pharmacy
        public AddDiseaseForm(MainForm parent, Bolest bolest = null, bool add = true, bool details = false)
        {
            #region Initialize

            InitializeComponent();
            _parent = parent;
            Bolest  = bolest;
            Add     = add;

            #endregion

            #region Add handler

            listBoxKontraindikacije.DataSource = ServiceProvider.Get <KontraindikacijaService>().GetDataTable();
            listBoxLekovi.DataSource           = ServiceProvider.Get <LekService>().GetDataTable();

            listBoxKontraindikacije.DisplayMember = Constants.ConcatenatedField;
            listBoxLekovi.DisplayMember           = Constants.ConcatenatedField;

            #endregion

            if (add)
            {
                return;
            }

            #region Edit handler

            if (Bolest == null)
            {
                throw new Exception("Bolest == null => Bolest Add");
            }

            textBoxLatinskiNaziv.Text = bolest?.NazivBolesti?.LatinskiNaziv;
            textBoxNarodniNaziv.Text  = bolest?.NazivBolesti?.NarodniNaziv;

            buttonAdd.Text = Constants.ButtonEditText;

            var ids = (from Entity x in Bolest.KontraindikacijaList select x.Id).ToList();
            _parent.FillDefault(listBoxKontraindikacije, ids);


            ids = (from Entity x in Bolest.LekList select x.Id).ToList();
            _parent.FillDefault(listBoxLekovi, ids);


            textBoxOpis.Text = Bolest.Opis;

            #endregion

            #region details handler

            if (!details)
            {
                return;
            }

            _parent.DisableAll(this);
            tableLayoutPanel1.Controls.Remove(buttonAdd);

            labelSubject.Text = @"Detaljne informacije";
            #endregion
        }