Esempio n. 1
0
        // When window first load
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            using (ShootappDBEntities context = new ShootappDBEntities())
            {
                //Sets competition details
                List <competition> getInfoQ = context.competitions.Where(c => c.id == compId).ToList();

                if (getInfoQ.Count == 0)
                {
                    this.Close();
                    return;
                }

                cname = getInfoQ[0].name;
                cdate = getInfoQ[0].date;

                var singleQ = context.singleprintviews.Where(s => s.cid == compId && s.hits != null).OrderByDescending(s => s.score);
                singlePrintList = singleQ.ToList();

                var teamQ = context.teamprintviews.Where(t => t.cid == compId && t.hits != null);
                teamPrintList = teamQ.ToList();

                var tidQ = context.teamdistviews.Where(t => t.cid == compId);
                teamIds = tidQ.ToList();
            }
            FillTextSingle();
            FillTextTeam();
        }
Esempio n. 2
0
        // When window first load
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            using (ShootappDBEntities context = new ShootappDBEntities())
            {
                //Sets competition details
                List <competition> getInfoQ = context.competitions.Where(c => c.id == compId).ToList();
                cname = getInfoQ[0].name;
                cdate = getInfoQ[0].date;

                var singleQ = context.singleprintviews.Where(s => s.cid == compId && s.hits != null).OrderByDescending(s => s.score);
                singlePrintList = singleQ.ToList();

                var teamQ = context.teamprintviews.Where(t => t.cid == compId && t.hits != null);
                teamPrintList = teamQ.ToList();

                var tidQ = context.teamdistviews.Where(t => t.cid == compId);
                teamIds = tidQ.ToList();


                // Connect alternative grids
                var query2 = from cv in context.competitionviews
                             where cv.comid == compId
                             select cv;

                if (query2 != null)
                {
                    List <competitionview> qcv = query2.ToList();

                    FlipStringHits(qcv);

                    shootersSingleGrid.ItemsSource = qcv;

                    ListCollectionView view = new ListCollectionView(qcv);
                    view.GroupDescriptions.Add(new PropertyGroupDescription("teaname"));

                    competitionGrid.ItemsSource = view;
                }
            }
            FillTextSingle();
            FillTextTeam();
        }
Esempio n. 3
0
        // Create teams and text
        private void FillTextTeam()
        {
            txbTeam.Text = String.Format("{0}, {1}\n\n", cname, cdate.ToShortDateString());

            txbTeam.Text += String.Format("{0} {1}{2,20}{3,4}{4,4}{5,4}{6,4}{7,4}{8,4}{9,4}{10,4}{11,4}{12,4}{13,4}{14,10}{15,10}{16,10}\n", "MESTO", "EKIPA", "M", 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, "X", "STRELI", "ODBITEK", "REZULTAT");

            TeamPrint tp;

            using (ShootappDBEntities context = new ShootappDBEntities())
            {
                foreach (teamdistview tdw in teamIds)
                {
                    List <teamprintview> tempTeam = context.teamprintviews.Where(t => t.tid == tdw.tid && t.cid == compId && t.hits != null).ToList();

                    if (tempTeam.Count == 0)
                    {
                        continue;
                    }
                    else
                    {
                        tp = new TeamPrint(tempTeam);
                        TeamsL.Add(tp);
                    }
                }
            }

            TeamsL.Sort();
            TeamsL.Reverse();

            int rank = 1;

            foreach (TeamPrint t in TeamsL)
            {
                t.GlobalRank  = rank;
                txbTeam.Text += t.ToString();
                rank++;
            }
        }
Esempio n. 4
0
        //CODE FOR CREATING FIXED DOCUMENT
        private void FillTextTeam()
        {
            int rank           = 1;
            int blocks_on_page = 10;
            int counter        = 10;

            FixedPage   page        = null;
            TextBlock   pageText    = null;
            PageContent pageContent = null;
            TeamPrint   tp;

            using (ShootappDBEntities context = new ShootappDBEntities())
            {
                foreach (teamdistview tdw in teamIds)
                {
                    List <teamprintview> tempTeam = context.teamprintviews.Where(t => t.tid == tdw.tid && t.cid == compId && t.hits != null).ToList();

                    if (tempTeam.Count == 0)
                    {
                        continue;
                    }
                    else
                    {
                        tp = new TeamPrint(tempTeam);
                        TeamsL.Add(tp);
                    }
                }
            }

            TeamsL.Sort();
            TeamsL.Reverse();

            foreach (TeamPrint t in TeamsL)
            {
                t.GlobalRank = rank;

                if (counter % blocks_on_page == 0)
                {
                    page                = new FixedPage();
                    pageText            = new TextBlock();
                    pageContent         = new PageContent();
                    pageText.FontFamily = new FontFamily("Consolas");

                    pageText.Text = String.Format("\n   {0}, {1}{2,70}. stran\n\n", cname, cdate.ToShortDateString(), counter / blocks_on_page);

                    pageText.Text += String.Format("   {0} {1}{2,20}{3,4}{4,4}{5,4}{6,4}{7,4}{8,4}{9,4}{10,4}{11,4}{12,4}{13,4}{14,13}{15,13}\n", "MESTO", "EKIPA", "M", 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, "STRELI", "REZULTAT");
                }

                pageText.Text += t.ToString();

                if (counter % blocks_on_page == 0)
                {
                    page.Children.Add(pageText);
                    ((IAddChild)pageContent).AddChild(page);
                    fixed_document.Pages.Add(pageContent);
                }

                rank++;
                counter++;
            }
        }
Esempio n. 5
0
        public void ImportData()
        {
            string name;
            string surname;
            string team;

            string read_string;

            string csvFile = @"C:\Shootapp1991\ImportCSV\ShootersTeams.csv";

            try
            {
                using (StreamReader sr = new StreamReader(csvFile))
                {
                    while ((read_string = sr.ReadLine()) != null)
                    {
                        string[] split_string = read_string.Split(',');

                        name    = split_string[0];
                        surname = split_string[1];
                        team    = split_string[2];

                        if (name.ToLower() == "name" && surname.ToLower() == "surname" && team.ToLower() == "team")
                        {
                            continue;
                        }

                        if (name != String.Empty && surname != String.Empty && team != String.Empty)
                        {
                            team teamIn = new team();
                            teamIn.name = team;

                            using (ShootappDBEntities context = new ShootappDBEntities())
                            {
                                context.teams.Add(teamIn);
                                try
                                {
                                    context.SaveChanges();
                                }
                                catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException e)
                                {
                                    //Do nothing
                                }
                            }

                            using (ShootappDBEntities context = new ShootappDBEntities())
                            {
                                teamIn = context.teams.FirstOrDefault(t => t.name == teamIn.name);

                                shooter shooter1 = new shooter();
                                shooter1.name    = name;
                                shooter1.surname = surname;
                                shooter1.tid     = teamIn.id;

                                context.shooters.Add(shooter1);

                                try
                                {
                                    context.SaveChanges();
                                }
                                catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException e)
                                {
                                    //Do nothing
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString() + "\n" + e.Message, "Warning");
            }
        }
Esempio n. 6
0
        public void ImportData()
        {
            string name;
            string surname;
            string team;

            string[] split_string;
            string   read_string;
            string   csvFile = null;

            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                csvFile = openFileDialog.FileName;
            }

            if (csvFile == null)
            {
                return;
            }

            try
            {
                using (StreamReader sr = new StreamReader(csvFile))
                {
                    // Checks if file has right structure
                    if ((read_string = sr.ReadLine()) != null)
                    {
                        split_string = read_string.Split(',');

                        name    = split_string[0];
                        surname = split_string[1];
                        team    = split_string[2];

                        if (name != "NAME" || surname != "SURNAME" || team != "TEAM")
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }

                    while ((read_string = sr.ReadLine()) != null)
                    {
                        split_string = read_string.Split(',');

                        name    = split_string[0];
                        surname = split_string[1];
                        team    = split_string[2];

                        if (name != String.Empty && surname != String.Empty && team != String.Empty)
                        {
                            team teamIn = new team();
                            teamIn.name = team;

                            using (ShootappDBEntities context = new ShootappDBEntities())
                            {
                                context.teams.Add(teamIn);
                                try
                                {
                                    context.SaveChanges();
                                }
                                catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException)
                                {
                                    //Do nothing
                                }
                            }

                            using (ShootappDBEntities context = new ShootappDBEntities())
                            {
                                teamIn = context.teams.FirstOrDefault(t => t.name == teamIn.name);

                                shooter shooter1 = new shooter();
                                shooter1.name    = name;
                                shooter1.surname = surname;
                                shooter1.tid     = teamIn.id;

                                context.shooters.Add(shooter1);

                                try
                                {
                                    context.SaveChanges();
                                }
                                catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException)
                                {
                                    //Do nothing
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString() + "\n" + e.Message, "Warning");
            }
        }