コード例 #1
0
ファイル: Ucenik.cs プロジェクト: davidmilinkovic/Ocene
        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);
        }
コード例 #2
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;
            }
        }
コード例 #3
0
ファイル: Stampa.cs プロジェクト: davidmilinkovic/Ocene
        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);
        }