public void initialize() { try { using (ISession session = NHibernateHelper.OpenSession()) using (session.BeginTransaction()) { CurrentSessionContext.Bind(session); if (vezbaId == null) { OsnovniPodaciVezbeForm f = new OsnovniPodaciVezbeForm(); if (f.ShowDialog() == DialogResult.OK) { vezba = new Vezba(); vezba.Gimnasticar = f.Gimnasticar; vezba.Sprava = f.Sprava; vezba.Pravilo = f.Pravilo; vezba.Naziv = f.Naziv; view.Vezba = vezba; view.updateUI(); existsInDatabase = false; modified = false; view.setCaption(getCaption()); view.Initialized = true; } else { view.Initialized = false; } } else { vezba = DAOFactoryFactory.DAOFactory.GetVezbaDAO().FindById(vezbaId.Value); vezba.sortirajElementeByRedBroj(); saveOrigData(vezba); view.Vezba = vezba; view.updateUI(); existsInDatabase = true; modified = false; view.setCaption(getCaption()); if (vezba.Elementi.Count > 0) { view.selectElementCell(1, 0); } view.Initialized = true; // TODO: Treba hvatati database izuzetke i postaviti initalized na false } } } finally { CurrentSessionContext.Unbind(NHibernateHelper.SessionFactory); } }
public void initialize() { try { using (ISession session = NHibernateHelper.OpenSession()) using (session.BeginTransaction()) { CurrentSessionContext.Bind(session); if (vezbaId == null) { OsnovniPodaciVezbeForm f = new OsnovniPodaciVezbeForm(); if (f.ShowDialog() == DialogResult.OK) { vezba = new Vezba(); vezba.Gimnasticar = f.Gimnasticar; vezba.Sprava = f.Sprava; vezba.Pravilo = f.Pravilo; vezba.Naziv = f.Naziv; view.Vezba = vezba; view.updateUI(); existsInDatabase = false; modified = false; view.setCaption(getCaption()); view.Initialized = true; } else { view.Initialized = false; } } else { vezba = DAOFactoryFactory.DAOFactory.GetVezbaDAO().FindById(vezbaId.Value); vezba.sortirajElementeByRedBroj(); saveOrigData(vezba); view.Vezba = vezba; view.updateUI(); existsInDatabase = true; modified = false; view.setCaption(getCaption()); if (vezba.Elementi.Count > 0) view.selectElementCell(1, 0); view.Initialized = true; // TODO: Treba hvatati database izuzetke i postaviti initalized na false } } } finally { CurrentSessionContext.Unbind(NHibernateHelper.SessionFactory); } }