Exemplo n.º 1
0
        private void btnIzaberiPrethTak_Click(object sender, EventArgs e)
        {
            OtvoriTakmicenjeForm form = null;
            DialogResult         result;

            try
            {
                form   = new OtvoriTakmicenjeForm(1, SelectedGimnastika);
                result = form.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }

            if (result != DialogResult.OK)
            {
                return;
            }

            copyFromTakmicenje = form.SelTakmicenja[0];
            txtPrethTak.Text   = copyFromTakmicenje.ToString();
            treeView1.Nodes.Clear();

            ISession session = null;

            try
            {
                using (session = NHibernateHelper.Instance.OpenSession())
                    using (session.BeginTransaction())
                    {
                        CurrentSessionContext.Bind(session);
                        svaRezTakmicenja = DAOFactoryFactory.DAOFactory.GetRezultatskoTakmicenjeDAO()
                                           .FindByTakmicenjeFetch_Tak1_Gimnasticari(copyFromTakmicenje.Id);

                        const string BEZVEZE = "__BEZVEZE__";

                        string   lastDescription = BEZVEZE;
                        TreeNode descNode        = null;
                        foreach (RezultatskoTakmicenje rt in svaRezTakmicenja)
                        {
                            if (rt.TakmicenjeDescription.Naziv != lastDescription)
                            {
                                lastDescription  = rt.TakmicenjeDescription.Naziv;
                                descNode         = treeView1.Nodes.Add(rt.TakmicenjeDescription.Naziv);
                                descNode.Checked = true;
                            }
                            TreeNode katNode = descNode.Nodes.Add(rt.Kategorija.Naziv);
                            katNode.Tag     = rt;
                            katNode.Checked = true;

                            List <GimnasticarUcesnik> gimnasticari = new List <GimnasticarUcesnik>(rt.Takmicenje1.Gimnasticari);
                            PropertyDescriptor        propDesc     =
                                TypeDescriptor.GetProperties(typeof(GimnasticarUcesnik))["KlubDrzava"];
                            gimnasticari.Sort(new SortComparer <GimnasticarUcesnik>(
                                                  propDesc, ListSortDirection.Ascending));

                            // nisam stavio String.Empty, za slucaj da neki gimnasticar nema ni klub ni drzavu
                            string   lastKlub = BEZVEZE;
                            TreeNode klubNode = null;

                            foreach (GimnasticarUcesnik g in gimnasticari)
                            {
                                if (g.KlubDrzava != lastKlub)
                                {
                                    lastKlub         = g.KlubDrzava;
                                    klubNode         = katNode.Nodes.Add(g.KlubDrzava);
                                    klubNode.Checked = true;
                                }
                                TreeNode gimNode = klubNode.Nodes.Add(g.ImeSrednjeImePrezimeDatumRodjenja);
                                gimNode.Tag     = g;
                                gimNode.Checked = true;
                            }
                        }
                        foreach (TreeNode n in treeView1.Nodes)
                        {
                            n.Expand();
                        }
                    }
            }
            catch (Exception ex)
            {
                if (session != null && session.Transaction != null && session.Transaction.IsActive)
                {
                    session.Transaction.Rollback();
                }
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.Instance.SessionFactory);
            }
        }
Exemplo n.º 2
0
        private void btnIzaberiPrvaDvaKola_Click(object sender, EventArgs e)
        {
            if (uzmiOsnovnePodatke)
            {
                return;
            }
            if (SelectedGimnastika == Gimnastika.Undefined)
            {
                MessageDialogs.showMessage("Unesite najpre gimnstiku", this.Text);
                return;
            }

            OtvoriTakmicenjeForm form = null;
            DialogResult         result;

            try
            {
                if (finaleKupa())
                {
                    form = new OtvoriTakmicenjeForm(2, SelectedGimnastika);
                }
                else if (zbirViseKola())
                {
                    form = new OtvoriTakmicenjeForm(2, MAX_KOLA, SelectedGimnastika);
                }
                result = form.ShowDialog();
            }
            catch (InfrastructureException ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }

            if (result != DialogResult.OK)
            {
                return;
            }

            if (finaleKupa() || zbirViseKola())
            {
                prethodnaKola.Clear();
                for (int i = 0; i < form.SelTakmicenja.Count; ++i)
                {
                    prethodnaKola.Add(form.SelTakmicenja[i]);
                }

                PropertyDescriptor[] propDesc = new PropertyDescriptor[] {
                    TypeDescriptor.GetProperties(typeof(Takmicenje))["Datum"]
                };
                ListSortDirection[] sortDir = new ListSortDirection[] {
                    ListSortDirection.Ascending
                };
                prethodnaKola.Sort(new SortComparer <Takmicenje>(propDesc, sortDir));

                listBox1.Items.Clear();
                for (int i = 0; i < prethodnaKola.Count; ++i)
                {
                    listBox1.Items.Add(prethodnaKola[i].Naziv);
                }
            }
        }
Exemplo n.º 3
0
        private void btnDodajIzPrethTak_Click(object sender, EventArgs e)
        {
            OtvoriTakmicenjeForm form = null;

            try
            {
                form = new OtvoriTakmicenjeForm(1, gimnastika);
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }

            IList <TakmicarskaKategorija> kategorije = null;
            ISession session = null;

            try
            {
                using (session = NHibernateHelper.Instance.OpenSession())
                    using (session.BeginTransaction())
                    {
                        CurrentSessionContext.Bind(session);
                        kategorije = DAOFactoryFactory.DAOFactory.GetTakmicarskaKategorijaDAO()
                                     .FindByTakmicenje(form.SelTakmicenja[0].Id);
                    }
            }
            catch (Exception ex)
            {
                if (session != null && session.Transaction != null && session.Transaction.IsActive)
                {
                    session.Transaction.Rollback();
                }
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.Instance.SessionFactory);
            }

            IList <string> kategorijeStr = new List <string>();

            foreach (TakmicarskaKategorija k in kategorije)
            {
                kategorijeStr.Add(k.Naziv);
            }
            IList <int> checkedItems = new List <int>();

            for (int i = 0; i < kategorijeStr.Count; ++i)
            {
                checkedItems.Add(i);
            }

            CheckListForm form2 = new CheckListForm(
                kategorijeStr, checkedItems, form.SelTakmicenja[0].ToString(), "Izaberite kategorije",
                true, "Izaberite kategorije", true);

            if (form2.ShowDialog() != DialogResult.OK)
            {
                return;
            }

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

                        IList <TakmicarskaKategorija> takKategorije = new List <TakmicarskaKategorija>();
                        int numAdded = 0;
                        foreach (int index in form2.CheckedIndices)
                        {
                            try
                            {
                                TakmicenjeService.addTakmicarskaKategorija(
                                    new TakmicarskaKategorija(kategorijeStr[index]), takmicenjeId);
                                ++numAdded;
                            }
                            catch (BusinessException)
                            {
                                // ignorisi
                            }
                        }
                        if (numAdded > 0)
                        {
                            Takmicenje t = DAOFactoryFactory.DAOFactory.GetTakmicenjeDAO().FindById(takmicenjeId);
                            t.LastModified = DateTime.Now;
                            session.Transaction.Commit();

                            // reload kategorije
                            setKategorije(DAOFactoryFactory.DAOFactory.GetTakmicarskaKategorijaDAO().FindByTakmicenje(takmicenjeId));
                        }
                    }
            }
            catch (Exception ex)
            {
                if (session != null && session.Transaction != null && session.Transaction.IsActive)
                {
                    session.Transaction.Rollback();
                }
                MessageDialogs.showMessage(ex.Message, this.Text);
                return;
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.Instance.SessionFactory);
            }
        }
Exemplo n.º 4
0
        private void mnOpen_Click(object sender, EventArgs e)
        {
            /*
            if (!OkToTrash())
                 return;

             OpenFileDialog ofd = new OpenFileDialog();
             ofd.Filter = strFilter;
             ofd.FileName = "*.txt";

             if (ofd.ShowDialog() == DialogResult.OK)
                 LoadFile(ofd.FileName);
             */

            if (!OkToTrash())
                return;
            try
            {
                OtvoriTakmicenjeForm form = new OtvoriTakmicenjeForm(takmicenjeId, false, 0, false);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    loadTakmicenje(form.Takmicenje);
                    loadBrojDecimalaUOpcije(form.Takmicenje);
                    Opcije.Instance.HeaderFooterInitialized = false;
                }
            }
            catch (InfrastructureException ex)
            {
                MessageDialogs.showError(ex.Message, strProgName);
            }
        }
Exemplo n.º 5
0
        private void btnIzaberiPrvaDvaKola_Click(object sender, EventArgs e)
        {
            OtvoriTakmicenjeForm form = null;
            DialogResult result;
            try
            {
                if (finaleKupa())
                    form = new OtvoriTakmicenjeForm(null, true, 2, false);
                else if (zbirViseKola())
                    form = new OtvoriTakmicenjeForm(null, true, MAX_KOLA, true);
                result = form.ShowDialog();
            }
            catch (InfrastructureException ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }

            if (result != DialogResult.OK)
                return;

            if (finaleKupa() || zbirViseKola())
            {
                prethodnaKola.Clear();
                for (int i = 0; i < form.SelTakmicenja.Count; ++i)
                    prethodnaKola.Add(form.SelTakmicenja[i]);

                PropertyDescriptor[] propDesc = new PropertyDescriptor[] {
                    TypeDescriptor.GetProperties(typeof(Takmicenje))["Datum"]
                };
                ListSortDirection[] sortDir = new ListSortDirection[] {
                    ListSortDirection.Ascending
                };
                prethodnaKola.Sort(new SortComparer<Takmicenje>(propDesc, sortDir));

                listBox1.Items.Clear();
                for (int i = 0; i < prethodnaKola.Count; ++i)
                    listBox1.Items.Add(prethodnaKola[i].Naziv);
            }
        }