Beispiel #1
0
        private void checkBusinessRulesOnUpdate(Element e)
        {
            Notification notification = new Notification();
            ElementDAO   elementDAO   = DAOFactoryFactory.DAOFactory.GetElementDAO();

            if (e.Sprava != oldSprava || e.Naziv != oldNaziv)
            {
                if (e.Naziv != "" && elementDAO.postojiElement(e.Sprava, e.Naziv))
                {
                    notification.RegisterMessage("Naziv", "Element sa datim nazivom vec postoji.");
                    throw new BusinessException(notification);
                }
            }
            if (e.Sprava != oldSprava || e.EngleskiNaziv != oldEngleskiNaziv)
            {
                if (e.EngleskiNaziv != "" &&
                    elementDAO.postojiElementEng(e.Sprava, e.EngleskiNaziv))
                {
                    notification.RegisterMessage("EngleskiNaziv", "Element sa datim engleskim nazivom vec postoji.");
                    throw new BusinessException(notification);
                }
            }
            if (e.Sprava != oldSprava || e.NazivPoGimnasticaru != oldNazivPoGimnasticaru)
            {
                if (e.NazivPoGimnasticaru != "" &&
                    elementDAO.postojiElementGim(e.Sprava, e.NazivPoGimnasticaru))
                {
                    notification.RegisterMessage("NazivPoGimnasticaru", "Element sa datim nazivom po gimnasticaru vec postoji.");
                    throw new BusinessException(notification);
                }
            }
            if (e.IsTablicniElement)
            {
                if (e.Sprava != oldSprava ||
                    e.Grupa != oldGrupa ||
                    e.Tezina != oldTezina ||
                    e.Broj != oldBroj ||
                    e.PodBroj != oldPodBroj)
                {
                    if (elementDAO.postojiElement(e.Sprava, e.Grupa,
                                                  e.Broj, e.PodBroj))
                    {
                        notification.RegisterMessage("Grupa", "Vec postoji element sa datim brojem za datu spravu i grupu.");
                        throw new BusinessException(notification);
                    }
                }
            }
        }
Beispiel #2
0
        private void checkBusinessRulesOnAdd(Element e)
        {
            // TODO: Nek bude moguce da dva tablicna elementa iste sprave, grupe,
            // tezine i broja, a razlicitog podbroja imaju isti naziv (promeni ovo i
            // kod checkUpdate)

            Notification notification = new Notification();
            ElementDAO   elementDAO   = DAOFactoryFactory.DAOFactory.GetElementDAO();

            if (e.Naziv != "" &&
                elementDAO.postojiElement(e.Sprava, e.Naziv))
            {
                notification.RegisterMessage("Naziv", "Element sa datim nazivom vec postoji.");
                throw new BusinessException(notification);
            }
            if (e.EngleskiNaziv != "" &&
                elementDAO.postojiElementEng(e.Sprava, e.EngleskiNaziv))
            {
                notification.RegisterMessage("EngleskiNaziv", "Element sa datim engleskim nazivom vec postoji.");
                throw new BusinessException(notification);
            }
            if (e.NazivPoGimnasticaru != "" &&
                elementDAO.postojiElementGim(e.Sprava, e.NazivPoGimnasticaru))
            {
                notification.RegisterMessage("NazivPoGimnasticaru", "Element sa datim nazivom po gimnasticaru vec postoji.");
                throw new BusinessException(notification);
            }
            if (e.IsTablicniElement)
            {
                if (elementDAO.postojiElement(e.Sprava, e.Grupa,
                                              e.Broj, e.PodBroj))
                {
                    notification.RegisterMessage("Grupa", "Vec postoji element sa datim brojem za datu spravu i grupu.");
                    throw new BusinessException(notification);
                }
            }
        }