Beispiel #1
0
        public static void UpdatujKurs()
        {
            Console.WriteLine("Upisite id kursa: ");
            int id = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Upisite nov jezik kursa: ");
            string novJezik = Console.ReadLine();

            Console.WriteLine("Nivo id: ");
            int novNivo = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Cena: ");
            int novaCena = Convert.ToInt32(Console.ReadLine());

            Kurs kurs = new Kurs(id, novNivo, novJezik, novaCena);

            KursDAO.Update(Program.conn, kurs);
        }
        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");
            }
        }