Example #1
0
        public static void Izmeni(Ucenik uc, int stariId)
        {
            SQLiteConnection con = new SQLiteConnection("Data Source = " + App.baza);

            con.Open();
            SQLiteCommand com = new SQLiteCommand(String.Format("UPDATE ucenici SET broj={0}, broj_reg={1}, jmbg={2}, naziv='{3}', mesto_rodj='{4}', opstina_rodj='{13}', datum_rodj='{5}', otac='{6}', majka='{7}', upisan_u={8}, redovan={9}, id_smera='{10}',trajanje={11}, veronauka = {12} WHERE broj='" + stariId.ToString() + "'",
                                                                uc.broj, uc.brojReg, uc.jmbg, uc.naziv, uc.mestoRodj, uc.datumRodj, uc.otac, uc.majka, uc.upisanU, uc.redovan, uc.smer.id, uc.trajanje, uc.veronauka, uc.opstinaRodj), con);

            com.ExecuteNonQuery();
            con.Close();
        }
Example #2
0
        private void cmbOdeljenje_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbOdeljenje.SelectedIndex != -1)
            {
                int raz = Convert.ToInt32(cmbRazred.SelectedValue);
                int ode = Convert.ToInt32(cmbOdeljenje.SelectedValue);

                lb.ItemsSource = Ucenik.Daj().Where(u => u.razred == raz && u.odeljenje == ode).ToList();
                lb.Focus();
            }
        }
Example #3
0
 private void cmbRazred_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     cmbOdeljenje.ItemsSource = Ucenik.DajOdeljenja(Convert.ToInt32(cmbRazred.SelectedValue));
     if (cmbOdeljenje.SelectedIndex == -1)
     {
         wrOdelj.Visibility = Visibility.Visible;
     }
     else
     {
         cmbOdeljenje.SelectedIndex = -1;
     }
 }
Example #4
0
        public static void Dodaj(Ucenik uc)
        {
            SQLiteConnection con = new SQLiteConnection("Data Source = " + App.baza);

            con.Open();
            SQLiteCommand com = new SQLiteCommand(String.Format("INSERT INTO ucenici VALUES ({0},{1},{2},'{3}','{4}','{13}','{5}','{6}','{7}',{8},{9},'{10}',{11},{12})",
                                                                uc.broj, uc.brojReg, uc.jmbg, uc.naziv, uc.mestoRodj, uc.datumRodj, uc.otac, uc.majka, uc.upisanU, uc.redovan, uc.smer.id, uc.trajanje, uc.veronauka, uc.opstinaRodj), con);

            com.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("Dodat učenik " + uc.naziv);
        }
Example #5
0
        public static void Izbrisi(Ucenik uc)
        {
            SQLiteConnection con = new SQLiteConnection("Data Source = " + App.baza);

            con.Open();
            SQLiteCommand com = new SQLiteCommand("DELETE FROM ucenici WHERE broj=" + uc.broj.ToString(), con);

            com.ExecuteNonQuery();
            com = new SQLiteCommand("DELETE FROM ocene WHERE id_ucenika=" + uc.broj.ToString(), con);
            com.ExecuteNonQuery();
            con.Close();
        }
Example #6
0
        public static List <int> DajOdeljenja(int razred)
        {
            HashSet <int> od = new HashSet <int>();

            foreach (Ucenik u in Ucenik.Daj().Where(x => x.razred == razred))
            {
                od.Add((int)u.odeljenje);
            }
            var lista = od.ToList();

            lista.Sort();
            return(lista);
        }
Example #7
0
        public static List <int> DajRazrede()
        {
            HashSet <int> razredi = new HashSet <int>();

            foreach (Ucenik u in Ucenik.Daj())
            {
                razredi.Add((int)u.razred);
            }
            var lista = razredi.ToList();

            lista.Sort();
            return(lista);
        }
Example #8
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            txtSearch.Text         = "";
            lb_ucenici.ItemsSource = lista;
            int    cnt = lista.Count();
            Ucenik uc  = new Ucenik()
            {
                redovan = 1
            };

            ((ObservableCollection <Ucenik>)lb_ucenici.ItemsSource).Add(uc);
            lb_ucenici.SelectedIndex = cnt;
            EditMode(false);
            mode = 2;
        }
Example #9
0
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            int olm = mode;

            mode = 0;
            if (olm == 1)
            {
                lista = Ucenik.Daj();
            }
            else if (olm == 2)
            {
                lista.Remove(lista.Last());
            }
            EditMode(true);
        }
Example #10
0
        private void btnDel_Click(object sender, RoutedEventArgs e)
        {
            if (lb_ucenici.SelectedIndex == -1)
            {
                MessageBox.Show("Morate izabrati ucenika!", "Greska", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Ucenik           uc  = (Ucenik)lb_ucenici.SelectedItem;
            MessageBoxResult res = MessageBox.Show("Da li ste sigurni da zelite da izbrisete ucenika " + uc.naziv + " sa brojem " + uc.broj.ToString() + "?", "Pitanje", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.Yes)
            {
                Ucenik.Izbrisi(uc);
                lista.Remove(uc);
                lb_ucenici.ItemsSource   = lista;
                lb_ucenici.SelectedIndex = 0;
            }
        }
Example #11
0
 private void MBroj(bool ok)
 {
     if (!ok)
     {
         txt1.Background = App.err;
         txt1.ToolTip    = "Uneti maticni broj nije validan.";
     }
     else
     {
         txt1.Background = txt2.Background;
         txt3.ToolTip    = "";
         Ucenik tren = lb_ucenici.SelectedItem as Ucenik;
         tren.sbroj = txt1.Text;
         tren.broj  = Convert.ToInt32(tren.sbroj);
         var istiSmer = Ucenik.Daj().Where(x => x.god_upisa == tren.god_upisa && x.odeljenje == tren.odeljenje).ToList();
         if (istiSmer.Count != 0)
         {
             txt11.SelectedIndex = istiSmer[0].smer.id - 1;
         }
     }
 }
Example #12
0
        public static bool ValidateBroj(string broj)
        {
            int xx = 0;

            try { xx = Convert.ToInt32(broj); }
            catch { return(false); }

            if (broj.Length != 7)
            {
                return(false);
            }
            else
            {
                var xxx = Ucenik.Daj().Where(x => x.broj == xx).ToList();
                if (xxx.Count > 0)
                {
                    return(false);
                }
            }
            return(true);
        }
Example #13
0
        public static double Prosek(Ucenik uc)
        {
            int suma = 0, del = 0;

            foreach (Predmet pr in Smer.DajPredmete(uc.smer, (int)uc.razred))
            {
                if (pr.prosek)
                {
                    int?ocena = Ucenik.OcenaIz((int)uc.broj, pr.id, App.Godina());
                    if (ocena != null)
                    {
                        suma += (int)ocena;
                        del++;
                    }
                }
            }
            if (del == 0)
            {
                return(1);
            }
            return((double)suma / del);
        }
Example #14
0
        int mode    = 0; // 0 - standard, 1 - edit, 2 - add

        public Ucenici()
        {
            InitializeComponent();

            lista = Ucenik.Daj();
            lb_ucenici.ItemsSource  = lista;
            memberCmb.ItemsSource   = Ucenik.DajPolja(true);
            memberCmb.SelectedIndex = 3;
            txt11.ItemsSource       = Smer.Daj();
            boksovi.Add(txt1);
            boksovi.Add(txt2);
            boksovi.Add(txt3);
            boksovi.Add(txt4);
            boksovi.Add(txt5);
            boksovi.Add(txt6);
            boksovi.Add(txt7);
            boksovi.Add(txt8);
            boksovi.Add(txt9);
            boksovi.Add(txt12);
            boksovi.Add(txt14);
            EditMode(true);
            Grupisanje();
        }
Example #15
0
 public Stampanje()
 {
     InitializeComponent();
     cmbRazred.ItemsSource = Ucenik.DajRazrede();
 }
Example #16
0
        private void cmbOdeljenje_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbOdeljenje.SelectedIndex != -1)
            {
                for (int i = 0; i < trenutniPredmeti.Count; i++)
                {
                    ((GridView)lvv.View).Columns.RemoveAt(1);
                }

                int raz = Convert.ToInt32(cmbRazred.SelectedValue);
                int ode = Convert.ToInt32(cmbOdeljenje.SelectedValue);
                trenutniUcenici  = Ucenik.Daj().Where(u => u.razred == raz && u.odeljenje == ode).ToList();
                cursmer          = trenutniUcenici[0].smer;
                lbSmer.Content   = cursmer.naziv;
                trenutniPredmeti = Smer.DajPredmete(cursmer, raz).ToList();

                DataTable sors = new DataTable();
                sors.Columns.Add("ime", typeof(string));

                foreach (Predmet pr in trenutniPredmeti)
                {
                    string x = pr.naziv.Trim().Replace(".", "");
                    sors.Columns.Add(x, typeof(string));

                    GridViewColumn col = new GridViewColumn();
                    col.Header = pr.naziv;

                    DataTemplate temp = new DataTemplate();

                    FrameworkElementFactory bor = new FrameworkElementFactory(typeof(Border));
                    bor.SetValue(Border.BorderBrushProperty, Brushes.LightGray);
                    bor.SetValue(Border.BorderThicknessProperty, new Thickness(0, 0, 1, 1));
                    bor.SetValue(Border.MarginProperty, new Thickness(-6, 0, -6, 0));

                    RoutedEventHandler izgubioFokus = Fokus;
                    RoutedEventHandler dobioFokus   = DFokus;

                    FrameworkElementFactory title = new FrameworkElementFactory(typeof(TextBox));
                    title.SetValue(TextBox.FontWeightProperty, FontWeights.Bold);
                    title.SetBinding(TextBox.TextProperty, new Binding(x));
                    title.SetValue(TextBox.MarginProperty, new Thickness(5));
                    title.AddHandler(TextBox.LostFocusEvent, izgubioFokus);
                    title.AddHandler(TextBox.GotFocusEvent, dobioFokus);
                    title.SetValue(TextBox.WidthProperty, (double)23);
                    title.SetValue(TextBox.TabIndexProperty, 1);
                    title.SetValue(TextBox.IsTabStopProperty, true);

                    bor.AppendChild(title);
                    temp.VisualTree  = bor;
                    col.CellTemplate = temp;

                    ((GridView)lvv.View).Columns.Add(col);
                }

                foreach (Ucenik uc in trenutniUcenici)
                {
                    DataRow row = sors.NewRow();
                    row[0] = uc.naziv;
                    int i = 1;
                    foreach (Predmet pr in trenutniPredmeti)
                    {
                        int?ocena = Ucenik.OcenaIz((int)uc.broj, pr.id, App.Godina());;
                        if (ocena == null)
                        {
                            row[i] = "";
                        }
                        else
                        {
                            row[i] = ocena.ToString();
                        }
                        i++;
                    }
                    sors.Rows.Add(row);
                }

                trenutniSors    = sors.Copy();
                lvv.ItemsSource = sors.DefaultView;
                ((GridView)lvv.View).Columns[0].Width = 200;
            }
        }
Example #17
0
        public void StampajZaUcenika(Ucenik uc)
        {
            FormFields fields = doc.FormFields;

            ucenici.Add(uc.naziv + ext);
            fields["Text1"].Result = Podesavanje.Vred("Naziv skole").Cir();
            fields["Text2"].Result = Podesavanje.Vred("Sediste").Cir();
            fields["Text5"].Result = Podesavanje.Vred("Resenje br").Cir();
            fields["Text6"].Result = Podesavanje.Vred("Resenje od").Cir();
            fields["Text3"].Result = Podesavanje.Vred("Delovodni broj i datum").Cir();
            fields["Text4"].Result = Podesavanje.Vred("Ministarstvo").Cir();

            string maticni = uc.broj.ToString();

            if (maticni.Length == 6)
            {
                maticni = "0" + maticni;
            }
            fields["Text7"].Result = maticni;

            string ime = uc.naziv.Substring(uc.naziv.LastIndexOf(" ") + 1);

            ime += " ";
            ime += uc.naziv.Substring(0, uc.naziv.LastIndexOf(" "));

            fields["Text8"].Result  = ime.Cir();
            fields["Text9"].Result  = uc.otac.Substring(uc.otac.LastIndexOf(" ") + 1).Cir();
            fields["Text10"].Result = uc.datumRodj;
            fields["Text12"].Result = uc.mestoRodj.Cir();

            string opstina = uc.opstinaRodj;
            string drzava  = "Republika Srbija";

            if (opstina.Contains(","))
            {
                drzava  = opstina.Substring(opstina.IndexOf(",") + 1);
                opstina = opstina.Substring(0, opstina.IndexOf(","));
            }

            fields["Text13"].Result = opstina.Cir();
            fields["Text14"].Result = drzava.Cir();
            fields["Text15"].Result = App.Godina().ToString();
            fields["Aaa"].Result    = (App.Godina() + 1).ToString();

            fields["Dropdown7"].DropDown.Value = 2;
            fields["Dropdown3"].DropDown.Value = (int)uc.razred + 1;
            fields["Dropdown6"].DropDown.Value = (int)uc.razred + 1;
            fields["Text19"].Result            = ((int)uc.trajanje).Rec().ToLower().Cir();
            fields["Text20"].Result            = uc.smer.naziv.Cir();

            var listaPredmeta = Smer.DajPredmete(uc.smer, (int)uc.razred);
            int?ocenaVladanje = null;

            int i = 1, j = 1;

            foreach (Predmet pr in listaPredmeta)
            {
                fields["p" + j.ToString()].Result         = "";
                fields["o" + j.ToString()].DropDown.Value = 1;
                if (pr.naziv == "Vladanje")
                {
                    ocenaVladanje = Ucenik.OcenaIz((int)uc.broj, pr.id, App.Godina());
                }
                else
                {
                    int?ocena = Ucenik.OcenaIz((int)uc.broj, pr.id, App.Godina());
                    if (ocena != null)
                    {
                        fields["p" + i.ToString()].Result         = pr.naziv.Cir();
                        fields["o" + i.ToString()].DropDown.Value = 7 - (int)ocena;
                    }
                    else
                    {
                        fields["p" + i.ToString()].Result         = "";
                        fields["o" + i.ToString()].DropDown.Value = 1;
                        i--;
                    }
                    i++;
                    j++;
                }
            }
            if (uc.veronauka == 0)
            {
                fields["ver"].DropDown.Value  = 3;
                fields["over"].DropDown.Value = 5;
            }
            else
            {
                fields["ver"].DropDown.Value  = 2;
                fields["over"].DropDown.Value = 2;
            }

            if (ocenaVladanje != null)
            {
                fields["vladanje"].DropDown.Value = 7 - (int)ocenaVladanje;
            }
            else
            {
                fields["vladanje"].DropDown.Value = 1;
            }

            double prosek  = Ucenik.Prosek(uc);
            int    rounded = (int)Math.Round(prosek + 0.01, 0);

            fields["Text29"].Result            = String.Format("{0:0.00}", prosek);
            fields["Dropdown2"].DropDown.Value = 7 - rounded;


            doc.SaveAs(_putanja + @"\" + uc.naziv + ext);
        }