示例#1
0
        public void Delete(object sender, EventArgs e)
        {
            if (this.UltraOlaksice.ActiveRow != null)
            {
                decimal?iznos    = null;
                decimal?postotak = null;
                try
                {
                    iznos = (decimal?)UltraOlaksice.ActiveRow.Cells["OlaksicaIznos"].Value;
                }
                catch { }
                try
                {
                    postotak = (decimal?)UltraOlaksice.ActiveRow.Cells["OlaksicaPostotak"].Value;
                }
                catch { }

                if (postotak == null || iznos == null)
                {
                    try
                    {
                        int id = Convert.ToInt32(this.UltraOlaksice.ActiveRow.Cells["ID"].Value);
                        if (MessageBox.Show(string.Format("Obrisati olakšicu '{0}-{1}'?", id, this.UltraOlaksice.ActiveRow.Cells["Naziv"].Value),
                                            "Brisanje olakšice", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            BusinessLogic.Olaksice olaksice = new BusinessLogic.Olaksice();
                            olaksice.Delete(id);

                            if (olaksice.IsValid)
                            {
                                olaksice.Persist();
                                LoadGridOlaksice();
                            }
                            else
                            {
                                olaksice.DisplayValidationMessages();
                            }
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Za brisanje olakšice proizvoda potrebno je otići u cjenik.", "Olakšice proizvod"
                                        , MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button3);
                    }
                }
                else
                {
                    MessageBox.Show("Nije moguće brisati nultu olakšicu");
                }
            }
        }
示例#2
0
        private bool SaveData()
        {
            this.lblValidationMessages.ResetText();

            BusinessLogic.Olaksice olak = new BusinessLogic.Olaksice();

            decimal?iznos = null, postotak = null;

            if (ultraNumericIznosOlaksice.Value != null)
            {
                iznos = Decimal.Parse(ultraNumericIznosOlaksice.Value.ToString());
            }
            if (ultraNumericPostotakOlaksice.Value != null)
            {
                postotak = Decimal.Parse(ultraNumericPostotakOlaksice.Value.ToString());
            }


            if (this.FormEditMode == Enums.FormEditMode.Insert ||
                this.FormEditMode == Enums.FormEditMode.Copy)
            {
                olak.Add(TextBoxNaziv.Text, postotak, iznos);
            }
            else if (this.FormEditMode == Enums.FormEditMode.Update)
            {
                olak.Update(this.ID.Value,
                            this.TextBoxNaziv.Text.Trim(),
                            postotak,
                            iznos);
            }

            if (olak.IsValid)
            {
                return(olak.Persist());
            }
            else
            {
                olak.DisplayValidationMessages(this);
            }

            return(false);
        }