private List <UplataClanarine> getUplate(Clan c)
        {
            if (c == null || c.Broj == CitacKartica.TEST_KARTICA_BROJ)
            {
                return(new List <UplataClanarine>());
            }

            List <UplataClanarine> uplate = null;

            try
            {
                using (ISession session = NHibernateHelper.Instance.OpenSession())
                    using (session.BeginTransaction())
                    {
                        CurrentSessionContext.Bind(session);
                        UplataClanarineDAO uplataClanarineDAO = DAOFactoryFactory.DAOFactory.GetUplataClanarineDAO();
                        uplate = new List <UplataClanarine>(uplataClanarineDAO.findUplate(c));
                    }
            }
            catch (Exception ex)
            {
                MessageDialogs.showMessage(ex.Message, "Uplata clanarine");
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.Instance.SessionFactory);
            }

            if (uplate == null)
            {
                uplate = new List <UplataClanarine>();
            }
            Util.sortByVaziOdDesc(uplate);
            return(uplate);
        }
Example #2
0
        private List <object> loadUplateForInterval(DateTime from, DateTime to)
        {
            UplataClanarineDAO uplataClanarineDAO = DAOFactoryFactory.DAOFactory.GetUplataClanarineDAO();

            return(new List <UplataClanarine>(uplataClanarineDAO.findUplate(from, to)).ConvertAll <object>(
                       delegate(UplataClanarine u)
            {
                return u;
            }));
        }
Example #3
0
        private List <object> loadUplateForClan(Clan c)
        {
            if (c == null)
            {
                return(new List <object>());
            }

            UplataClanarineDAO uplataClanarineDAO = DAOFactoryFactory.DAOFactory.GetUplataClanarineDAO();

            return(new List <UplataClanarine>(uplataClanarineDAO.findUplate(c)).ConvertAll <object>(
                       delegate(UplataClanarine u)
            {
                return u;
            }));
        }
Example #4
0
        private List <UplataClanarine> loadUplate(Clan c)
        {
            if (c == null)
            {
                return(new List <UplataClanarine>());
            }

            UplataClanarineDAO     uplataClanarineDAO = DAOFactoryFactory.DAOFactory.GetUplataClanarineDAO();
            List <UplataClanarine> result             = new List <UplataClanarine>(uplataClanarineDAO.findUplate(c));

            if (result == null)
            {
                result = new List <UplataClanarine>();
            }
            Util.sortByVaziOdDesc(result);
            return(result);
        }
        public void Init()
        {
            initDate = DateTime.Now;
            try
            {
                using (ISession session = NHibernateHelper.Instance.OpenSession())
                    using (session.BeginTransaction())
                    {
                        // TODO3: Proveri da li ovde treba koristiti CurrentSessionContext ako nije JedinstenProgram
                        CurrentSessionContext.Bind(session);

                        clanoviSaKarticom = new Dictionary <int, Clan>();
                        foreach (Clan clan in DAOFactoryFactory.DAOFactory.GetClanDAO().findClanoviSaKarticom())
                        {
                            clanoviSaKarticom.Add(clan.BrojKartice.Value, clan);
                        }

                        GrupaDAO      grupaDAO = DAOFactoryFactory.DAOFactory.GetGrupaDAO();
                        IList <Grupa> godisnjaClanarinaGrupe = grupaDAO.findGodisnjaClanarina();
                        if (godisnjaClanarinaGrupe.Count == 0)
                        {
                            // TODO3: Da li je potrebna ova provera? Ako se grupe sa godisnjom clanarinom zadaju
                            // u programu, trebalo bi da je dozvoljeno da ne bude zadata nijedna grupa.
                            MessageDialogs.showMessage("Ne mogu da pronadjem grupu za godisnju clanarinu", "Greska");
                        }

                        prethodneUplate = new Dictionary <int, List <UplataClanarine> >();
                        DateTime now  = DateTime.Now;
                        DateTime from = now.AddMonths(-6);

                        // Kao krajnji datum za uplate se uzima sledeci mesec zbog sledece situacije: Dolazi potpuno novi clan
                        // (prvi put se upisuje u sokolsko drustvo), i placa clanarinu za sledeci mesec (da pocinje od
                        // sledeceg meseca da vezba). Tada je jedina uplate koja postoji uplata za sledeci mesec (i treba
                        // da svetli zeleno, i da se grupa za tu uplatu prikazije na ekranu, i da se ta grupa veze za
                        // DolazakNaTrening).
                        DateTime sledeciMesec = now.AddMonths(1);

                        UplataClanarineDAO uplataClanarineDAO = DAOFactoryFactory.DAOFactory.GetUplataClanarineDAO();
                        foreach (UplataClanarine u in uplataClanarineDAO.findUplateVaziOd(from, sledeciMesec))
                        {
                            foreach (Grupa g in godisnjaClanarinaGrupe)
                            {
                                if (g.Id == u.Grupa.Id)
                                {
                                    continue;
                                }
                            }
                            // Ako ne postoji uplata za ovaj mesec ali postoji uplata za sledeci mesec, ta uplata ce biti
                            // stavljena u prethodneUplate. Ta uplata ce biti izabrana u metodu findUplata zato sto
                            // findUplata sortira prethodne uplate opadajuce po datumu vazenja.
                            if (prethodneUplate.ContainsKey(u.Clan.Id))
                            {
                                prethodneUplate[u.Clan.Id].Add(u);
                            }
                            else
                            {
                                List <UplataClanarine> uplate = new List <UplataClanarine>();
                                uplate.Add(u);
                                prethodneUplate.Add(u.Clan.Id, uplate);
                            }
                        }

                        uplateGodisnjaClanarina = new Dictionary <int, UplataClanarine>();
                        if (godisnjaClanarinaGrupe.Count > 0)
                        {
                            DateTime firstDateTimeInYear = new DateTime(DateTime.Now.Year, 1, 1, 0, 0, 0);
                            DateTime lastDateTimeInYear  = new DateTime(DateTime.Now.Year + 1, 1, 1, 0, 0, 0).AddSeconds(-1);
                            foreach (UplataClanarine u in uplataClanarineDAO.findUplate(godisnjaClanarinaGrupe,
                                                                                        firstDateTimeInYear, lastDateTimeInYear))
                            {
                                if (!uplateGodisnjaClanarina.ContainsKey(u.Clan.Id))
                                {
                                    uplateGodisnjaClanarina.Add(u.Clan.Id, u);
                                }
                            }
                        }

                        uplateGodisnjaClanarinaPrethGod = new Dictionary <int, UplataClanarine>();
                        if (godisnjaClanarinaGrupe.Count > 0)
                        {
                            DateTime firstDateTimeInYear = new DateTime(DateTime.Now.Year - 1, 1, 1, 0, 0, 0);
                            DateTime lastDateTimeInYear  = new DateTime(DateTime.Now.Year, 1, 1, 0, 0, 0).AddSeconds(-1);
                            foreach (UplataClanarine u in uplataClanarineDAO.findUplate(godisnjaClanarinaGrupe,
                                                                                        firstDateTimeInYear, lastDateTimeInYear))
                            {
                                if (!uplateGodisnjaClanarinaPrethGod.ContainsKey(u.Clan.Id))
                                {
                                    uplateGodisnjaClanarinaPrethGod.Add(u.Clan.Id, u);
                                }
                            }
                        }

                        DateTime                 pocetakDana     = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                        DateTime                 sutra           = pocetakDana.AddDays(1);
                        DateTime                 krajDana        = new DateTime(sutra.Year, sutra.Month, sutra.Day, 0, 0, 0).AddSeconds(-1);
                        DolazakNaTreningDAO      dolazakDAO      = DAOFactoryFactory.DAOFactory.GetDolazakNaTreningDAO();
                        IList <DolazakNaTrening> danasnjiDolasci =
                            DAOFactoryFactory.DAOFactory.GetDolazakNaTreningDAO().getDolazakNaTrening(pocetakDana, krajDana);
                        danasnjaOcitavanja = new HashedSet();
                        foreach (DolazakNaTrening d in danasnjiDolasci)
                        {
                            danasnjaOcitavanja.Add(d.Clan.Id);
                        }
                    }
            }
            catch (Exception ex)
            {
                MessageDialogs.showMessage(ex.Message, "Citac kartica");
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.Instance.SessionFactory);
            }
        }
Example #6
0
 private void loadUplate(List <Clan> duplikati)
 {
     dictUplate = new Dictionary <int, List <UplataClanarine> >();
     for (int i = 0; i < duplikati.Count; ++i)
     {
         Clan c = duplikati[i];
         if (c == null)
         {
             continue;
         }
         if (!dictUplate.ContainsKey(c.Id))
         {
             UplataClanarineDAO     uplataClanarineDAO = DAOFactoryFactory.DAOFactory.GetUplataClanarineDAO();
             List <UplataClanarine> uplate             = new List <UplataClanarine>(uplataClanarineDAO.findUplate(c));
             if (uplate == null)
             {
                 uplate = new List <UplataClanarine>();
             }
             Util.sortByVaziOdDesc(uplate);
             dictUplate.Add(c.Id, uplate);
         }
         else
         {
             throw new Exception("Greska");
         }
     }
     return;
 }