//Brisanje
        private void button4_Click(object sender, EventArgs e)
        {
            if (this.GridAlarmniSistem.SelectedRows.Count > 0)
            {
                int selectedIndex = this.GridAlarmniSistem.SelectedRows[0].Index;

                int rowID = int.Parse(GridAlarmniSistem[5, selectedIndex].Value.ToString());
                try
                {
                    ISession s = DataLayer.GetSession();

                    Entiteti.AlarmniSistem u = s.Load <Entiteti.AlarmniSistem>(rowID);

                    //brise se objekat iz baze ali ne i instanca objekta u memroiji
                    s.Delete(u);
                    //s.Delete("from Odeljenje");

                    s.Flush();
                    s.Close();
                    GridAlarmniSistem.Rows.RemoveAt(selectedIndex);
                }

                catch (Exception ec)
                {
                    MessageBox.Show(ec.Message);
                }
            }

            else
            {
                MessageBox.Show("Nije selektovana nijedna kolona.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 void dodajAlarm()
 {
     try
     {
         ISession s = DataLayer.GetSession();
         Entiteti.AlarmniSistem a = new Entiteti.AlarmniSistem()
         {
             SerijskiBroj      = int.Parse(textBox9.Text),
             DatumAtesta       = new DateTime(dateTimePicker8.Value.Year, dateTimePicker8.Value.Month, dateTimePicker8.Value.Day),
             DatumInstalacije  = new DateTime(dateTimePicker7.Value.Year, dateTimePicker7.Value.Month, dateTimePicker7.Value.Day),
             PocetniDatum      = new DateTime(dateTimePicker6.Value.Year, dateTimePicker6.Value.Month, dateTimePicker6.Value.Day),
             KrajnjiDatum      = new DateTime(dateTimePicker5.Value.Year, dateTimePicker5.Value.Month, dateTimePicker5.Value.Day),
             Opis              = textBox10.Text,
             Proizvodjac       = textBox8.Text,
             Model             = textBox7.Text,
             GodinaProizvodnje = int.Parse(textBox6.Text)
         };
         s.Save(a);
         s.Flush();
         s.Close();
         MessageBox.Show("alarm" + a.Opis + " dodat.");
         OsveziGrid();
         textBox6.Clear();
         textBox7.Clear();
         textBox8.Clear();
         textBox9.Clear();
         textBox10.Clear();
     }
     catch (Exception ec)
     {
         MessageBox.Show(ec.Message);
     }
 }