Exemplo n.º 1
0
        protected override void requiredFieldsAndFormatValidation(Notification notification)
        {
            SifraGrupe dummy;

            if (txtSifra.Text.Trim() == String.Empty)
            {
                notification.RegisterMessage("Sifra", "Sifra grupe je obavezan.");
            }
            else if (!SifraGrupe.TryParse(txtSifra.Text, out dummy))
            {
                notification.RegisterMessage(
                    "Sifra", String.Format("Neispravan format za sifru grupe. Sifra " +
                                           "grupe mora da zapocne sa brojem, i moze da sadrzi " +
                                           "maksimalno {0} znakova.", Grupa.SIFRA_MAX_LENGTH));
            }

            if (txtNaziv.Text.Trim() == String.Empty)
            {
                notification.RegisterMessage(
                    "Naziv", "Naziv grupe je obavezan.");
            }

            if (SelectedFinCelina == null && finansijskeCeline.Count > 0)
            {
                notification.RegisterMessage(
                    "FinansijskaCelina", "Finansijska celina je obavezna.");
            }
        }
Exemplo n.º 2
0
        protected override void saveOriginalData(DomainObject entity)
        {
            Grupa g = (Grupa)entity;

            oldSifra = g.Sifra;
            oldNaziv = g.Naziv;
            oldImaGodisnjuClanarinu = g.ImaGodisnjuClanarinu;
        }
Exemplo n.º 3
0
        public virtual List <ReportGrupa> getAktivniClanoviPoGrupamaReportGrupe(DateTime from, DateTime to,
                                                                                List <Grupa> grupe, IDictionary <SifraGrupe, int> duplikati)
        {
            from = from.Date;
            to   = to.Date.AddDays(1);
            try
            {
                string query       = @"
SELECT u.grupa_id, g.broj_grupe, g.podgrupa, g.naziv, Sum(u.iznos), Count(*)
FROM uplate u INNER JOIN grupe g
	ON u.grupa_id = g.grupa_id
WHERE (u.datum_vreme_uplate BETWEEN '{0}' AND '{1}')
{2}
GROUP BY u.grupa_id, g.broj_grupe, g.podgrupa, g.naziv
ORDER BY g.broj_grupe, g.podgrupa
";
                bool   filterGrupe = grupe != null && grupe.Count > 0;
                string filter      = String.Empty;
                if (filterGrupe)
                {
                    filter = " AND " + Util.getGrupeFilter(grupe, "g", "grupa_id");
                }
                query = String.Format(query, from.ToString("yyyy-MM-dd"), to.ToString("yyyy-MM-dd"), filter);

                ISQLQuery          q       = Session.CreateSQLQuery(query);
                IList <object[]>   result  = q.List <object[]>();
                List <ReportGrupa> result2 = new List <ReportGrupa>();
                foreach (object[] row in result)
                {
                    int     grupa_id    = (int)row[0];
                    int     brojGrupe   = (int)row[1];
                    string  podgrupa    = (string)row[2];
                    string  nazivGrupe  = (string)row[3];
                    decimal ukupanIznos = (decimal)row[4];
                    int     brojClanova = (int)row[5];
                    string  sifra       = brojGrupe + podgrupa;

                    SifraGrupe sifraGrupe = new SifraGrupe(sifra);
                    if (duplikati.ContainsKey(sifraGrupe))
                    {
                        brojClanova -= duplikati[sifraGrupe];
                    }

                    object[] data = new object[] { new SifraGrupe(sifra), nazivGrupe,
                                                   ukupanIznos };
                    result2.Add(new ReportGrupa(data, brojClanova));
                }
                return(result2);
            }
            catch (HibernateException ex)
            {
                string message = String.Format(
                    "{0} \n\n{1}", Strings.DatabaseAccessExceptionMessage, ex.Message);
                throw new InfrastructureException(message, ex);
            }
        }
Exemplo n.º 4
0
        protected override void updateEntityFromUI(DomainObject entity)
        {
            Grupa g = (Grupa)entity;

            g.Sifra                = SifraGrupe.Parse(txtSifra.Text.Trim());
            g.Naziv                = txtNaziv.Text.Trim();
            g.Kategorija           = SelectedKategorija;
            g.FinansijskaCelina    = SelectedFinCelina;
            g.ImaGodisnjuClanarinu = chbImaGodisnjuClanarinu.Checked;
        }
Exemplo n.º 5
0
 private Grupa findGrupa(SifraGrupe sifra)
 {
     foreach (Grupa g in grupe)
     {
         if (g.Sifra == sifra)
         {
             return(g);
         }
     }
     return(null);
 }
Exemplo n.º 6
0
        public MesecnaClanarinaDialog(Nullable <int> entityId, SifraGrupe pocetnaSifraGrupe)
        {
            if (entityId != null)
            {
                throw new ArgumentException("CenaDialog radi samo u add modu.");
            }

            InitializeComponent();
            this.pocetnaSifraGrupe = pocetnaSifraGrupe;
            initialize(entityId, true);
        }
Exemplo n.º 7
0
 private MesecnaClanarina findClanarina(SifraGrupe grupa)
 {
     foreach (MesecnaClanarina mc in entities)
     {
         if (mc.Grupa.Sifra == grupa)
         {
             return(mc);
         }
     }
     return(null);
 }
Exemplo n.º 8
0
        private void txtSifraGrupe_TextChanged(object sender, System.EventArgs e)
        {
            SifraGrupe sifra;

            if (SifraGrupe.TryParse(txtSifraGrupe.Text.Trim(), out sifra))
            {
                SelectedGrupa = findGrupa(sifra);
            }
            else
            {
                SelectedGrupa = null;
            }
        }
Exemplo n.º 9
0
        protected override EntityDetailForm createEntityDetailForm(Nullable <int> entityId)
        {
            MesecnaClanarina mc    = (MesecnaClanarina)getSelectedEntity();
            SifraGrupe       sifra = null;

            if (mc != null)
            {
                sifra = mc.Grupa.Sifra;
            }
            else if (rbtGrupa.Checked && SelectedGrupa != null)
            {
                sifra = SelectedGrupa.Sifra;
            }
            return(new MesecnaClanarinaDialog(entityId, sifra));
        }
Exemplo n.º 10
0
 public virtual bool existsGrupaSifra(SifraGrupe sifra)
 {
     try
     {
         IQuery q = Session.CreateQuery(@"select count(*)
                                          from Grupa g
                                          where g.Sifra.BrojGrupe = :grupa
                                          and g.Sifra.Podgrupa = :podgrupa");
         q.SetInt32("grupa", sifra.BrojGrupe);
         q.SetString("podgrupa", sifra.Podgrupa);
         return((long)q.UniqueResult() > 0);
     }
     catch (HibernateException ex)
     {
         string message = String.Format(
             "{0} \n\n{1}", Strings.DatabaseAccessExceptionMessage, ex.Message);
         throw new InfrastructureException(message, ex);
     }
 }
Exemplo n.º 11
0
        public virtual List <object[]> getAktivniClanoviPoGrupamaReportItems(DateTime from, DateTime to, List <Grupa> grupe,
                                                                             IDictionary <int, Mesto> mestaMap, IDictionary <SifraGrupe, int> duplikati)
        {
            from = from.Date;
            to   = to.Date.AddDays(1);
            try
            {
                string query       = @"
SELECT
    c.broj, c.ime, c.prezime, c.datum_rodjenja, c.adresa, c.mesto_id,
    g.broj_grupe, g.podgrupa
FROM grupe g INNER JOIN (uplate u INNER JOIN clanovi c
	ON u.clan_id = c.clan_id)
	ON g.grupa_id = u.grupa_id
WHERE
    (u.datum_vreme_uplate BETWEEN '{0}' AND '{1}')
{2}
ORDER BY
    g.broj_grupe, g.podgrupa, c.prezime, c.ime, c.broj
";
                bool   filterGrupe = grupe != null && grupe.Count > 0;
                string filter      = String.Empty;
                if (filterGrupe)
                {
                    filter = " AND " + Util.getGrupeFilter(grupe, "g", "grupa_id");
                }
                query = String.Format(query, from.ToString("yyyy-MM-dd"), to.ToString("yyyy-MM-dd"), filter);

                ISQLQuery        q       = Session.CreateSQLQuery(query);
                IList <object[]> result  = q.List <object[]>();
                List <object[]>  result2 = new List <object[]>();

                int    prevBroj  = -1;
                string prevSifra = "bezveze";

                foreach (object[] row in result)
                {
                    int    broj    = (int)row[0];
                    string ime     = (string)row[1];
                    string prezime = (string)row[2];

                    Nullable <DateTime> datumRodjenja = null;
                    if (row[3] != null)
                    {
                        datumRodjenja = (DateTime)row[3];
                    }

                    string adresa = (string)row[4];

                    Nullable <int> mesto_id = null;
                    string         mesto    = String.Empty;
                    if (row[5] != null)
                    {
                        mesto_id = (int)row[5];
                        mesto    = mestaMap[mesto_id.Value].Naziv;
                    }

                    string sifra = (int)row[6] + (string)row[7];

                    if (broj != prevBroj || sifra != prevSifra)
                    {
                        string clan = Clan.formatPrezimeImeDatumRodjAdresaMesto(
                            prezime, ime, datumRodjenja, adresa, mesto);
                        result2.Add(new object[] { clan });
                    }
                    else
                    {
                        SifraGrupe sifraGrupe = new SifraGrupe(sifra);
                        if (duplikati.ContainsKey(sifraGrupe))
                        {
                            duplikati[sifraGrupe]++;
                        }
                        else
                        {
                            duplikati.Add(sifraGrupe, 1);
                        }
                    }
                    prevBroj  = broj;
                    prevSifra = sifra;
                }
                return(result2);
            }
            catch (HibernateException ex)
            {
                string message = String.Format(
                    "{0} \n\n{1}", Strings.DatabaseAccessExceptionMessage, ex.Message);
                throw new InfrastructureException(message, ex);
            }
        }