Example #1
0
        private void button19_Click(object sender, EventArgs e)
        {
            try
            {
                ISession s = DataLayer.GetSession();

                Patrola      p = s.Load <Patrola>(1);
                Objekat      o = s.Load <Objekat>(1);
                Intervencija i = new Intervencija();

                i.Datum   = DateTime.Now;
                i.Objekat = o;
                i.Patrola = p;
                i.Vreme   = "20:35H";
                i.Opis    = "Lagana prica";
                o.ImaoIntervencije.Add(i);
                p.ImalaIntervencije.Add(i);

                s.Save(i);
                s.Flush();

                s.Close();
            }


            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
            }
        }
        public static void DodajPatrolu(PatrolaView p)
        {
            try
            {
                ISession s       = DataLayer.GetSession();
                var      vodja   = s.Get <ObicanPolicajac>(p.Vodja.PolicajacId);
                var      partner = s.Get <ObicanPolicajac>(p.Partner.PolicajacId);
                var      vozilo  = s.Get <SluzbenoVozilo>(p.Vozilo.VoziloId);

                var patrola = new Patrola();

                patrola.Partner = partner;
                patrola.Vozilo  = vozilo;
                patrola.Vodja   = vodja;

                s.Save(patrola);
                s.Flush();
                s.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #3
0
        private void button9_Click(object sender, EventArgs e)
        {
            try
            {
                ISession s = DataLayer.GetSession();
                Patrola  p = s.Load <Patrola>(3);

                MessageBox.Show((p.PatrolaId).ToString());
                MessageBox.Show((p.Vozilo.Model));
                MessageBox.Show((p.Vodja.DatumSticanjaDiplome).ToString());
                MessageBox.Show((p.Partner.Jmbg).ToString());

                s.Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                Console.WriteLine(exception);
                throw;
            }
        }
 public PatrolaView(Patrola p)
 {
     PatrolaId = p.PatrolaId;
 }