Example #1
0
 /// <summary>
 /// sprema narudzbu u bazu s id specificnog racuna
 /// </summary>
 /// <param name="narudzba"></param>
 private void PohraniNarudzbu(Narudzbe narudzba)
 {
     using (var db = new Entities())
     {
         db.Narudzbes.Attach(narudzba);
         narudzba.RacunID = noviRacun.ID;
         db.SaveChanges();
     }
 }
        private void cbOdaberiNarudžbu_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbOdaberiNarudžbu.SelectedItem != null)
            {
                Narudzbe odabranaNarudzba = cbOdaberiNarudžbu.SelectedItem as Narudzbe;
                using (var db = new Entities())
                {
                    db.Narudzbes.Attach(odabranaNarudzba);
                    listaStavkiZaDgv = new BindingList <StavkeNarudzbe>(odabranaNarudzba.StavkeNarudzbes.ToList());
                }

                dgvPrikazNarudzba.DataSource = listaStavkiZaDgv;
                this.dgvPrikazNarudzba.Columns["Artikli"].Visible  = false;
                this.dgvPrikazNarudzba.Columns["Narudzbe"].Visible = false;
            }
        }
        /// <summary>
        /// Kreira novu narudžbu i otvara formu za unos stavki narudžbe
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMeni_Click(object sender, EventArgs e)
        {
            //napraviti narudžbu tu, i proslijediti u formu
            using (var db = new Entities())
            {
                Narudzbe narudzba = new Narudzbe
                {
                    RacunID    = null,
                    StolID     = idStola,
                    KorisnikID = poslaniKorisnikGlobal.ID, //inace bude id reg korisnika, kasnije promjeniti
                    Datum      = DateTime.Now
                };
                db.Narudzbes.Add(narudzba);
                db.SaveChanges();

                FrmDodajNarudžbu formaDodajNarudžbu = new FrmDodajNarudžbu(narudzba);
                formaDodajNarudžbu.ShowDialog();
            }
        }
Example #4
0
 public FrmDodajNarudžbu(Narudzbe novaNarudzba)
 {
     InitializeComponent();
     trenutnaNarudzba = novaNarudzba;
 }