Exemplo n.º 1
0
        private List <Element> getSortedElements(Sprava sprava, GrupaElementa grupa, List <Element> elementi)
        {
            List <Element> result = new List <Element>();

            foreach (Element e in elementi)
            {
                if (sprava != Sprava.Undefined)
                {
                    if (e.Sprava != sprava)
                    {
                        continue;
                    }
                }
                if (grupa != GrupaElementa.Undefined)
                {
                    if (e.Grupa != grupa)
                    {
                        continue;
                    }
                }
                if (sprava == Sprava.Undefined && grupa == GrupaElementa.Undefined)
                {
                    // TODO: Ovo je samo za moje debagovanje - da otkrijem da li ikada moze da se desi ova situacija
                    // zato sto u ovom slucaju element biva stavljen u listu result.
                    MessageDialogs.showMessage("Greska u programu", "");
                }
                result.Add(e);
            }

            PropertyDescriptor propDesc =
                TypeDescriptor.GetProperties(typeof(Element))["GrupaBroj"];

            result.Sort(new SortComparer <Element>(propDesc, ListSortDirection.Ascending));
            return(result);
        }
Exemplo n.º 2
0
        public void printWithoutPreview(Izvestaj izvestaj)
        {
            if (rezimRada == RezimRada.MyPreviewDraw)
            {
                MessageDialogs.showMessage(NO_PRINTERS_MSG, this.Text);
                return;
            }

            setIzvestaj(izvestaj);
            if (rezimRada == RezimRada.PageSizeTooSmall)
            {
                MessageDialogs.showMessage(SMALL_PAPER_SIZE_MSG, this.Text);
                return;
            }

            printDocument1.DocumentName = izvestaj.DocumentName;
            page            = 1;
            lastPageToPrint = izvestaj.LastPageNum;
            try
            {
                printDocument1.Print();
            }
            catch (InvalidPrinterException)
            {
                MessageBox.Show(PRINTING_FAILURE_MSG, this.Text);
            }
            catch (Exception)
            {
                MessageBox.Show(PRINTING_FAILURE_MSG, this.Text);
            }
        }
Exemplo n.º 3
0
 private void btnPrikazi_Click(object sender, EventArgs e)
 {
     if (selektujElementeControl1.selectedSprava() == Sprava.Undefined)
     {
         MessageDialogs.showMessage("Izaberite spravu.", this.Text);
         return;
     }
     else if (selektujElementeControl1.getSelektovaneTezine().Count == 0)
     {
         MessageDialogs.showMessage("Izaberite tezine.", this.Text);
         return;
     }
     else if (selektujElementeControl1.getSelektovaneGrupe().Count == 0)
     {
         MessageDialogs.showMessage("Izaberite grupe.", this.Text);
         return;
     }
     filterItems(selektujElementeControl1.selectedSprava(), selektujElementeControl1.getSelektovaneTezine(),
                 selektujElementeControl1.getSelektovaneGrupe());
     if (items.Count == 0)
     {
         currentIndex = -1;
         MessageDialogs.showMessage("Ne postoje elementi za zadate kriterijume.", this.Text);
     }
     else
     {
         currentIndex = 0;
     }
     panelSlika_Resize(null, null);
     setItemNumberTextBox();
 }
Exemplo n.º 4
0
        private void btnPageSetup_Click(object sender, System.EventArgs e)
        {
            if (rezimRada == RezimRada.MyPreviewDraw)
            {
                MessageDialogs.showMessage(NO_PRINTERS_MSG, this.Text);
                return;
            }

            pageSetupDialog1.Document = printDocument1;
            if (pageSetupDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    setupContent();
                }
                catch (SmallPageSizeException)
                {
                    rezimRada = RezimRada.PageSizeTooSmall;
                    drawPreviewPage();
                    return;
                }

                if (previewPage > izvestaj.LastPageNum)
                {
                    previewPage = izvestaj.LastPageNum;
                    setPageTextBox(previewPage);
                }
                drawPreviewPage();
            }
        }
Exemplo n.º 5
0
        protected void editCommand()
        {
            DomainObject entity = (DomainObject)getSelectedEntity();

            if (entity == null)
            {
                return;
            }

            EntityDetailForm form;

            try
            {
                form = createEntityDetailForm(entity.Id);
            }
            catch (InfrastructureException ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }
            catch (Exception ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }

            if (form.ShowDialog() == DialogResult.OK)
            {
                onEntityUpdated(form.Entity);
            }
        }
Exemplo n.º 6
0
        private void mnPrint_Click(object sender, EventArgs e)
        {
            VezbaEditorBaseForm childForm = this.ActiveMdiChild as VezbaEditorBaseForm;

            if (childForm == null)
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                PreviewDialog p = new PreviewDialog();
                p.setIzvestaj(new VezbaIzvestaj(childForm));
                p.ShowDialog();
            }
            catch (InfrastructureException ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
            }
            catch (Exception ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
            }
            finally
            {
                Cursor.Hide();
                Cursor.Current = Cursors.Arrow;
            }
        }
Exemplo n.º 7
0
        private void btnBrisi_Click(object sender, EventArgs e)
        {
            IList <Element> selItems = elementBrowserControl1.DataGridViewUserControl
                                       .getSelectedItems <Element>();

            if (selItems.Count == 0)
            {
                return;
            }

            bool delete;

            if (selItems.Count == 1)
            {
                delete = MessageDialogs.queryConfirmation(
                    deleteConfirmationMessage(selItems[0]), this.Text);
            }
            else
            {
                delete = MessageDialogs.queryConfirmation(
                    deleteConfirmationMessage(), this.Text);
            }
            if (!delete)
            {
                return;
            }

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

                        foreach (Element element in selItems)
                        {
                            DAOFactoryFactory.DAOFactory.GetElementDAO().MakeTransient(element);
                        }
                        session.Transaction.Commit();
                        foreach (Element element in selItems)
                        {
                            elementi.Remove(element);
                        }
                        elementBrowserControl1.setElementi(elementi);
                    }
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.SessionFactory);
            }
        }
Exemplo n.º 8
0
 private void mnPromenaGimnasticara_Click(object sender, EventArgs e)
 {
     try
     {
         GimnasticariForm f = new GimnasticariForm();
         f.ShowDialog();
     }
     catch (BusinessException ex)
     {
         MessageDialogs.showMessage(ex.Message, this.Text);
     }
     catch (InfrastructureException ex)
     {
         MessageDialogs.showError(ex.Message, this.Text);
     }
 }
Exemplo n.º 9
0
 private void mnPregledElemenata_Click(object sender, EventArgs e)
 {
     try
     {
         PregledElemenataForm f = new PregledElemenataForm();
         f.ShowDialog();
     }
     catch (BusinessException ex)
     {
         MessageDialogs.showMessage(ex.Message, this.Text);
     }
     catch (InfrastructureException ex)
     {
         MessageDialogs.showError(ex.Message, this.Text);
     }
 }
Exemplo n.º 10
0
 private void mnNaziviGrupa_Click(object sender, EventArgs e)
 {
     try
     {
         GrupeForm f = new GrupeForm();
         f.ShowDialog();
     }
     catch (BusinessException ex)
     {
         MessageDialogs.showMessage(ex.Message, this.Text);
     }
     catch (InfrastructureException ex)
     {
         MessageDialogs.showError(ex.Message, this.Text);
     }
 }
Exemplo n.º 11
0
 private void PreviewDialog_Load(object sender, System.EventArgs e)
 {
     if (rezimRada == RezimRada.PageSizeTooSmall)
     {
         MessageDialogs.showMessage(SMALL_PAPER_SIZE_MSG, this.Text);
         float pageWidth  = 210 / 25.4f;
         float pageHeight = 297 / 25.4f;
         pictureBox1.ClientSize = pageToScreen(new SizeF(pageWidth, pageHeight));
     }
     else
     {
         drawPreviewPage();
     }
     this.WindowState = FormWindowState.Maximized;
     btnZatvori.Focus();
 }
Exemplo n.º 12
0
        protected void deleteCommand()
        {
            DomainObject entity = (DomainObject)getSelectedEntity();

            if (entity == null)
            {
                return;
            }
            if (!MessageDialogs.queryConfirmation(deleteConfirmationMessage(entity), this.Text))
            {
                return;
            }

            try
            {
                using (ISession session = NHibernateHelper.OpenSession())
                    using (session.BeginTransaction())
                    {
                        CurrentSessionContext.Bind(session);
                        if (refIntegrityDeleteDlg(entity))
                        {
                            delete(entity);
                            session.Transaction.Commit();
                            onEntityDeleted(entity);
                        }
                    }
            }
            catch (InfrastructureException ex)
            {
                string errMsg = deleteErrorMessage(entity);
                MessageDialogs.showError(
                    String.Format("{0} \n\n{1}", errMsg, ex.Message),
                    this.Text);
            }
            catch (Exception ex)
            {
                string errMsg = deleteErrorMessage(entity);
                MessageDialogs.showError(
                    String.Format("{0} \n\n{1}", errMsg, ex.Message),
                    this.Text);
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.SessionFactory);
            }
        }
Exemplo n.º 13
0
 private void mnTabelaElemenata_Click(object sender, EventArgs e)
 {
     try
     {
         TabelaElemenataForm f =
             new TabelaElemenataForm(
                 TabelaElemenataForm.TabelaElemenataFormRezimRada.Edit,
                 Sprava.Undefined);
         f.ShowDialog();
     }
     catch (BusinessException ex)
     {
         MessageDialogs.showMessage(ex.Message, this.Text);
     }
     catch (InfrastructureException ex)
     {
         MessageDialogs.showError(ex.Message, this.Text);
     }
 }
Exemplo n.º 14
0
        protected override bool refIntegrityDeleteDlg(DomainObject entity)
        {
            Gimnasticar g        = (Gimnasticar)entity;
            VezbaDAO    vezbaDao = DAOFactoryFactory.DAOFactory.GetVezbaDAO();

            // TODO: Ovde prvo treba pitati sta treba raditi sa vezbama
            // za datog gimnasticara (da li ih brisati ili ih ostaviti
            // ali bez gimnasticara)

            if (vezbaDao.existsVezbaGimnasticar(g))
            {
                string msg = "Gimnasticara '{0}' nije moguce izbrisati zato sto postoje " +
                             "vezbe za datog gimnasticara. \nMorate najpre da izbrisete vezbe " +
                             "da biste mogli da izbrisete gimnsticara.";
                MessageDialogs.showMessage(String.Format(msg, g), this.Text);
                return(false);
            }
            return(true);
        }
Exemplo n.º 15
0
        protected void addCommand()
        {
            EntityDetailForm form;

            try
            {
                form = createEntityDetailForm(null);
            }
            catch (InfrastructureException ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }
            catch (Exception ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }

            if (form.ShowDialog() == DialogResult.OK)
            {
                onEntityAdded(form.Entity);
            }
        }
Exemplo n.º 16
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     Cursor.Show();
     try
     {
         PreviewDialog p = new PreviewDialog();
         p.setIzvestaj(new TabelaIzvestaj(tabela));
         p.ShowDialog();
     }
     catch (InfrastructureException ex)
     {
         MessageDialogs.showError(ex.Message, this.Text);
     }
     catch (Exception ex)
     {
         MessageDialogs.showError(ex.Message, this.Text);
     }
     finally
     {
         Cursor.Hide();
         Cursor.Current = Cursors.Arrow;
     }
 }
Exemplo n.º 17
0
 public bool brisiVezbu()
 {
     if (MessageBox.Show("Da li zelite da izbrisete vezbu?", "Potvrda",
                         MessageBoxButtons.OKCancel, MessageBoxIcon.None,
                         MessageBoxDefaultButton.Button2) != DialogResult.OK)
     {
         return(false);
     }
     if (!existsInDatabase)
     {
         return(true);
     }
     try
     {
         using (ISession session = NHibernateHelper.OpenSession())
             using (session.BeginTransaction())
             {
                 CurrentSessionContext.Bind(session);
                 DAOFactoryFactory.DAOFactory.GetVezbaDAO().MakeTransient(vezba);
                 existsInDatabase = false;
                 modified         = false;
                 session.Transaction.Commit();
                 return(true);
             }
     }
     catch (InvalidPropertyException ex)
     {
         MessageDialogs.showMessage(ex.Message, "Vezba");
         return(false);
     }
     catch (BusinessException ex)
     {
         if (ex.Notification != null)
         {
             NotificationMessage msg = ex.Notification.FirstMessage;
             MessageDialogs.showMessage(msg.Message, "Vezba");
         }
         else
         {
             MessageDialogs.showMessage(ex.Message, "Vezba");
         }
         return(false);
     }
     catch (InfrastructureException ex)
     {
         //discardChanges();
         MessageDialogs.showMessage(ex.Message, "Vezba");
         return(false);
     }
     catch (Exception ex)
     {
         //discardChanges();
         MessageDialogs.showMessage(
             Strings.getFullDatabaseAccessExceptionMessage(ex.Message), "Vezba");
         return(false);
     }
     finally
     {
         CurrentSessionContext.Unbind(NHibernateHelper.SessionFactory);
     }
 }
Exemplo n.º 18
0
        public bool save()
        {
            try
            {
                using (ISession session = NHibernateHelper.OpenSession())
                    using (session.BeginTransaction())
                    {
                        CurrentSessionContext.Bind(session);
                        Notification notification = new Notification();
                        requiredFieldsAndFormatValidation(notification);
                        if (!notification.IsValid())
                        {
                            throw new BusinessException(notification);
                        }

                        if (existsInDatabase)
                        {
                            update();
                        }
                        else
                        {
                            add();
                            existsInDatabase = true;
                        }
                        session.Transaction.Commit();

                        modified = false;
                        saveOrigData(vezba);
                        return(true);
                    }
            }
            catch (InvalidPropertyException ex)
            {
                MessageDialogs.showMessage(ex.Message, "Vezba");
                return(false);
            }
            catch (BusinessException ex)
            {
                if (ex.Notification != null)
                {
                    NotificationMessage msg = ex.Notification.FirstMessage;
                    MessageDialogs.showMessage(msg.Message, "Vezba");
                }
                else
                {
                    MessageDialogs.showMessage(ex.Message, "Vezba");
                }
                return(false);
            }
            catch (InfrastructureException ex)
            {
                //discardChanges();
                MessageDialogs.showMessage(ex.Message, "Vezba");
                return(false);
            }
            catch (Exception ex)
            {
                //discardChanges();
                MessageDialogs.showMessage(
                    Strings.getFullDatabaseAccessExceptionMessage(ex.Message), "Vezba");
                return(false);
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.SessionFactory);
            }
        }
Exemplo n.º 19
0
        private void btnPrint_Click(object sender, System.EventArgs e)
        {
            if (rezimRada == RezimRada.MyPreviewDraw)
            {
                MessageDialogs.showMessage(NO_PRINTERS_MSG, this.Text);
                return;
            }
            else if (rezimRada == RezimRada.PageSizeTooSmall)
            {
                MessageDialogs.showMessage(SMALL_PAPER_SIZE_MSG, this.Text);
                return;
            }

            printDocument1.DocumentName                = izvestaj.DocumentName;
            printDocument1.PrinterSettings.FromPage    = 1;
            printDocument1.PrinterSettings.ToPage      = izvestaj.LastPageNum;
            printDocument1.PrinterSettings.MinimumPage = 1;
            printDocument1.PrinterSettings.MaximumPage = izvestaj.LastPageNum;
            printDialog1.AllowSomePages                = true;
            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    setupContent();
                }
                catch (SmallPageSizeException)
                {
                    rezimRada = RezimRada.PageSizeTooSmall;
                    drawPreviewPage();
                    return;
                }


                if (printDialog1.PrinterSettings.PrintRange == PrintRange.SomePages)
                {
                    page            = printDocument1.PrinterSettings.FromPage;
                    lastPageToPrint = printDocument1.PrinterSettings.ToPage;
                }
                else
                {
                    page            = 1;
                    lastPageToPrint = izvestaj.LastPageNum;
                }
                try
                {
                    printDocument1.Print();
                    Opcije.Instance.PrinterName = printDocument1.PrinterSettings.PrinterName;
                }
                catch (InvalidPrinterException)
                {
                    MessageBox.Show(PRINTING_FAILURE_MSG, this.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show(PRINTING_FAILURE_MSG, this.Text);
                }

                // za slucaj da je u PrintDialogu promenjenja velicina strane

                if (previewPage > izvestaj.LastPageNum)
                {
                    previewPage = izvestaj.LastPageNum;
                    setPageTextBox(previewPage);
                }
                drawPreviewPage();
            }
        }
Exemplo n.º 20
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                using (ISession session = NHibernateHelper.OpenSession())
                    using (session.BeginTransaction())
                    {
                        CurrentSessionContext.Bind(session);
                        Notification notification = new Notification();
                        requiredFieldsAndFormatValidation(notification);
                        if (!notification.IsValid())
                        {
                            throw new BusinessException(notification);
                        }

                        if (editMode)
                        {
                            update();
                        }
                        else
                        {
                            add();
                        }
                        if (persistEntity)
                        {
                            session.Transaction.Commit();
                        }
                        closedByOK = true;
                    }
            }
            catch (InvalidPropertyException ex)
            {
                MessageDialogs.showMessage(ex.Message, this.Text);
                setFocus(ex.InvalidProperty);
                this.DialogResult = DialogResult.None;
            }
            catch (BusinessException ex)
            {
                if (ex.Notification != null)
                {
                    NotificationMessage msg = ex.Notification.FirstMessage;
                    MessageDialogs.showMessage(msg.Message, this.Text);
                    setFocus(msg.FieldName);
                }
                else
                {
                    MessageDialogs.showMessage(ex.Message, this.Text);
                }
                this.DialogResult = DialogResult.None;
            }
            catch (InfrastructureException ex)
            {
                //discardChanges();
                MessageDialogs.showMessage(ex.Message, this.Text);
                this.DialogResult = DialogResult.Cancel;
                closedByCancel    = true;
            }
            catch (Exception ex)
            {
                //discardChanges();
                MessageDialogs.showMessage(
                    Strings.getFullDatabaseAccessExceptionMessage(ex.Message), this.Text);
                this.DialogResult = DialogResult.Cancel;
                closedByCancel    = true;
            }
            finally
            {
                CurrentSessionContext.Unbind(NHibernateHelper.SessionFactory);
            }
        }
Exemplo n.º 21
0
        private bool updateEntityFromUI()
        {
            try
            {
                grupa.Naziv    = txtNaziv.Text.Trim();
                grupa.EngNaziv = txtEngNaziv.Text.Trim();
                if (!grupa.validate())
                {
                    return(false);
                }

                GrupaDAO grupaDAO = DAOFactoryFactory.DAOFactory.GetGrupaDAO();
                if (editMode)
                {
                    if (grupa.Naziv != oldNaziv || grupa.EngNaziv != oldEngNaziv)
                    {
                        grupaDAO.MakePersistent(grupa);
                        NHibernateHelper.GetCurrentSession().Transaction.Commit();
                        oldNaziv    = grupa.Naziv;
                        oldEngNaziv = grupa.EngNaziv;
                    }
                }
                else
                {
                    grupaDAO.MakePersistent(grupa);
                    NHibernateHelper.GetCurrentSession().Transaction.Commit();
                    grupe.Add(grupa);
                    editMode    = true;
                    oldNaziv    = grupa.Naziv;
                    oldEngNaziv = grupa.EngNaziv;
                }
                return(true);
            }
            catch (InvalidPropertyException ex)
            {
                MessageDialogs.showMessage(ex.Message, this.Text);
                setFocus(ex.InvalidProperty);
                return(false);
            }
            catch (BusinessException ex)
            {
                if (ex.Notification != null)
                {
                    NotificationMessage msg = ex.Notification.FirstMessage;
                    MessageDialogs.showMessage(msg.Message, this.Text);
                    setFocus(msg.FieldName);
                }
                else
                {
                    MessageDialogs.showMessage(ex.Message, this.Text);
                }
                return(false);
            }
            catch (InfrastructureException ex)
            {
                MessageDialogs.showMessage(ex.Message, this.Text);
                return(false);
            }
            catch (Exception ex)
            {
                MessageDialogs.showMessage(
                    Strings.getFullDatabaseAccessExceptionMessage(ex.Message), this.Text);
                return(false);
            }
        }