Example #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");
                }
            }
        }