Example #1
0
        private void LoadGridCjenici()
        {
            BusinessLogic.Cjenici olaksice = new BusinessLogic.Cjenici();
            UltraCjenici.DataSource = olaksice.GetCjeniciMainGrid();

            this.UltraCjenici.DataBind();
            this.UltraCjenici.UpdateData();

            Utils.Tools.UltraGridStyling(this.UltraCjenici);
            if (UltraCjenici.DisplayLayout.Bands.Count > 0)
            {
                if (UltraCjenici.DisplayLayout.Bands[0].Columns.Count > 0)
                {
                    UltraCjenici.DisplayLayout.Bands[0].Columns["Naziv"].Width = 200;
                }
            }

            foreach (UltraGridRow row in UltraCjenici.Rows)
            {
                if (row.Index == BusinessLogic.Cjenici.pSelectedIndex)
                {
                    UltraCjenici.ActiveRow = row;
                }
            }
        }
Example #2
0
        private void LoadFormCjenik()
        {
            /*
             * Jure Males 12.07.2013
             * tijelo funkcije
             */
            BusinessLogic.Cjenici cjenici = new BusinessLogic.Cjenici();
            var cjenik = cjenici.GetCjenik(this.ID.GetValueOrDefault(0));

            TextBoxNaziv.Text           = cjenik.Naziv;
            DateTimePickerDatumOd.Value = cjenik.VrijediOd;
            DateTimePickerDatumDo.Value = (cjenik.VrijediDo ?? null);
        }
Example #3
0
        public void Delete(object sender, EventArgs e)
        {
            if (this.UltraCjenici.ActiveRow != null)
            {
                try
                {
                    int id = Convert.ToInt32(this.UltraCjenici.ActiveRow.Cells["ID"].Value);
                    if (MessageBox.Show(string.Format("Obrisati cjenik ?"),
                                        "Brisanje cjenika", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        BusinessLogic.Cjenici cjenici = new BusinessLogic.Cjenici();
                        cjenici.Delete(id);

                        if (cjenici.IsValid)
                        {
                            if (cjenici.Persist())
                            {
                                LoadGridCjenici();
                            }
                            else
                            {
                                MessageBox.Show("Nije moguće obrisati cjenik.\nPostoji veza na cjenik.", "Cjenik"
                                                , MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button3);
                            }
                        }
                        else
                        {
                            cjenici.DisplayValidationMessages();
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Za brisanje proizvoda cjenika potrebno je otići u cjenik.", "Cjenik proizvod"
                                    , MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button3);
                }
            }
        }
Example #4
0
        private bool SaveData()
        {
            this.lblValidationMessages.ResetText();

            BusinessLogic.Cjenici cjenici = new BusinessLogic.Cjenici();

            if (this.FormEditMode == Enums.FormEditMode.Insert ||
                this.FormEditMode == Enums.FormEditMode.Copy)
            {
                cjenici.Add(TextBoxNaziv.Text,
                            (DateTime)DateTimePickerDatumOd.Value,
                            (DateTimePickerDatumDo.Value == null ? null : (DateTime?)DateTimePickerDatumDo.Value), pStavke);
            }
            else if (this.FormEditMode == Enums.FormEditMode.Update)
            {
                cjenici.Update((int)ID, TextBoxNaziv.Text,
                               (DateTime)DateTimePickerDatumOd.Value,
                               (DateTimePickerDatumDo.Value == null ? null : (DateTime?)DateTimePickerDatumDo.Value), pStavke);
            }

            if (cjenici.IsValid)
            {
                bool persist = cjenici.Persist();
                if (this.FormEditMode == Enums.FormEditMode.Insert || this.FormEditMode == Enums.FormEditMode.Copy)
                {
                    FormEditMode = Enums.FormEditMode.Update;
                    BusinessLogic.Cjenici cjenik = new BusinessLogic.Cjenici();
                    ID = cjenik.GetMaxId();
                }
                return(persist);
            }
            else
            {
                cjenici.DisplayValidationMessages(this);
            }
            return(false);
        }