Ejemplo n.º 1
0
        private void bSacuvaj_Click(object sender, RoutedEventArgs e)
        {
            this.original.SetValues(copyObj);

            if (mod == MOD.DODAVANJE)
            {
                try
                {
                    Aplikacija.Instanca.Kursevi.Add(original);
                    KursDAO.Create(original);
                }
                catch { }
            }
            else
            {
                try { KursDAO.Update(original); }
                catch { }
            }
            KursDAO.Read();
            this.DialogResult = true;
            this.Close();
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                original.Jezik        = cbJezik.SelectedItem as Jezik;
                original.TipKursa     = cbTip.SelectedItem as TipKursa;
                original.Cena         = Convert.ToDouble(tbCena.Text);
                original.DatumPocetak = dpDatumPocetak.SelectedDate.Value;
                original.DatumKraj    = dpDatumKraj.SelectedDate.Value;
                if (cbStatus.IsChecked == true)
                {
                    original.Status = true;
                }
                else
                {
                    original.Status = false;
                }
                if (mod == MOD.DODAVANJE)
                {
                    int id = Aplikacija.Instanca.Kursevi.Count + 1;
                    original.Id = id;
                    Aplikacija.Instanca.Kursevi.Add(original);
                    KursDAO.Create(original);
                }
                else
                {
                    KursDAO.Update(original);
                }

                this.Close();
            }
            catch (FormatException)
            {
                MessageBox.Show("Plata mora biti broj");
            }
        }