public GimnasticarFilter getFilter()
        {
            if (!validateFilter())
                return null;

            GimnasticarFilter result = new GimnasticarFilter();
            if (txtRegBroj.Text.Trim() != String.Empty)
                result.RegBroj = RegistarskiBroj.Parse(txtRegBroj.Text);
            result.Ime = txtIme.Text.Trim();
            result.Prezime = txtPrezime.Text.Trim();
            if (txtGodRodj.Text.Trim() != String.Empty)
                result.GodRodj = int.Parse(txtGodRodj.Text);
            if (this.gimnastika == null)
            {
                if (cmbGimnastika.SelectedIndex == cmbGimnastika.Items.IndexOf(MSG))
                    result.Gimnastika = Gimnastika.MSG;
                else if (cmbGimnastika.SelectedIndex == cmbGimnastika.Items.IndexOf(ZSG))
                    result.Gimnastika = Gimnastika.ZSG;
            }
            else
                result.Gimnastika = this.gimnastika.Value;

            // NOTE: operator as vraca null ako sa leve strane nije objekt
            // odgovarajuceg tipa, ili je sa leve strane null
            result.Drzava = cmbDrzava.SelectedItem as Drzava;
            result.Kategorija = cmbKategorija.SelectedItem as KategorijaGimnasticara;
            result.Klub = cmbKlub.SelectedItem as Klub;

            return result;
        }
Exemple #2
0
        private void filterGimnasticarUserControl1_Filter(object sender, EventArgs e)
        {
            GimnasticarFilter flt = filterGimnasticarUserControl1.getFilter();

            if (flt != null)
            {
                filter(flt);
            }
        }
Exemple #3
0
        private void filter(GimnasticarFilter flt)
        {
            ISession session = null;

            try
            {
                using (session = NHibernateHelper.Instance.OpenSession())
                    using (session.BeginTransaction())
                    {
                        CurrentSessionContext.Bind(session);

                        IList <Gimnasticar> gimnasticari;
                        if (flt.isEmpty(true))
                        {
                            gimnasticari = DAOFactoryFactory.DAOFactory.GetGimnasticarDAO().FindAll();
                        }
                        else
                        {
                            gimnasticari = DAOFactoryFactory.DAOFactory.GetGimnasticarDAO().FindGimnasticari(
                                flt.Ime, flt.Prezime, flt.GodRodj, flt.Gimnastika, flt.Drzava, flt.Kategorija, flt.Klub);
                        }
                        SetItems(gimnasticari);
                        updateEntityCount();
                        dataGridViewUserControl1.Focus();
                    }
            }
            catch (Exception ex)
            {
                if (session != null && session.Transaction != null && session.Transaction.IsActive)
                {
                    session.Transaction.Rollback();
                }
                MessageDialogs.showError(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), this.Text);
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.Instance.SessionFactory);
            }
        }
Exemple #4
0
        public GimnasticarFilter getFilter()
        {
            if (!validateFilter())
            {
                return(null);
            }

            GimnasticarFilter result = new GimnasticarFilter();

            result.Ime     = txtIme.Text.Trim();
            result.Prezime = txtPrezime.Text.Trim();
            if (txtGodRodj.Text.Trim() != String.Empty)
            {
                result.GodRodj = int.Parse(txtGodRodj.Text);
            }
            if (this.gimnastika == null)
            {
                if (cmbGimnastika.SelectedIndex == cmbGimnastika.Items.IndexOf(MSG))
                {
                    result.Gimnastika = Gimnastika.MSG;
                }
                else if (cmbGimnastika.SelectedIndex == cmbGimnastika.Items.IndexOf(ZSG))
                {
                    result.Gimnastika = Gimnastika.ZSG;
                }
            }
            else
            {
                result.Gimnastika = this.gimnastika.Value;
            }

            // NOTE: operator as vraca null ako sa leve strane nije objekt
            // odgovarajuceg tipa, ili je sa leve strane null
            result.Drzava     = cmbDrzava.SelectedItem as Drzava;
            result.Kategorija = cmbKategorija.SelectedItem as KategorijaGimnasticara;
            result.Klub       = cmbKlub.SelectedItem as Klub;

            return(result);
        }