Ejemplo n.º 1
0
        public static void showCompetitionList(DataGrid competitionDataGrid, long _event)
        {
            try
            {
                competitionDataGrid.ItemsSource = null;
            }
            catch (Exception f)
            {
                Console.WriteLine(f);
                // Provide for exceptions.
            }

            using (var dt = new appDBEntities())
            {
                var query = from c in dt.Competitions
                            where !(from o in dt.EventCompetitions
                                    where o.EventID == MainWindow._event
                                    select o.CompetitionID).Contains(c.id)
                            select new { c.CompetitionName, c.id };
                var data = query.ToList();
                competitionDataGrid.ItemsSource = data;
                //  foreach (object str in data)
                //    eventParticipantsDataGrid.Items.Add(str);
                dt.Dispose();
            }
        }
Ejemplo n.º 2
0
        /*
         * Obsluga dodawania kolejnosci.
         */
        public static void changeOrder(long idCompetition, long idEvent, int points)
        {
            var db = new appDBEntities();

            if (idCompetition == 0)
            {
                MessageBox.Show(string.Format("Error: idCompetition =  {0},  idEvent = {1}", idCompetition, idEvent));
            }
            else
            {
                EventCompetitions c = (from EventCompetitions in db.EventCompetitions
                                       where EventCompetitions.CompetitionID == idCompetition && EventCompetitions.EventID == idEvent
                                       select EventCompetitions).First();
                if (c.Order == null)
                {
                    c.Order = 0;
                    c.Order = c.Order + points;
                }
                else
                {
                    c.Order = c.Order + points;
                }
                try
                {
                    db.SaveChanges();
                    //  MessageBox.Show(string.Format("Deleting participant with ID = {0}  from EventID = {1}", idParticipant, idEvent));
                }
                catch (Exception f)
                {
                    Console.WriteLine(f);
                    // Provide for exceptions.
                }
            }
        }
Ejemplo n.º 3
0
 public static void dbSaveChanges(appDBEntities db)
 {
     try
     {
         db.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 4
0
        /*
         * Wyswietlanie listy konkurencji zapisanych w bazie danych.
         */
        public static void showCompetitions(DataGrid competitionsDataGrid)
        {
            cleanDataGrid(competitionsDataGrid);

            using (var db = new appDBEntities())
            {
                var query = from c in db.Competitions
                            select new { c.id, c.CompetitionName };
                var data = query.ToList();
                competitionsDataGrid.ItemsSource = data;
                db.Dispose();
            }
        }
Ejemplo n.º 5
0
        /*
         * Wyswietlanie listy klubow zapisanych w bazie danych.
         */
        public static void showClubs(DataGrid clubsDataGrid)
        {
            cleanDataGrid(clubsDataGrid);

            using (var db = new appDBEntities())
            {
                var query = from c in db.Club
                            join regions in db.Regions on c.ClubRegion equals regions.id
                            select new { c.id, c.ClubName, regions.RegionName };
                var data = query.ToList();
                clubsDataGrid.ItemsSource = data;
                db.Dispose();
            }
        }
Ejemplo n.º 6
0
        /*
         * Wyswietlanie listy wydarzen zapisanych w bazie danych.
         */
        public static void showEvents(DataGrid eventsDataGrid)
        {
            cleanDataGrid(eventsDataGrid);

            using (var db = new appDBEntities())
            {
                var query = from c in db.Events
                            join regions in db.Regions on c.EventRegion equals regions.id
                            join nations in db.Nation on c.EventNation equals nations.id
                            select new { c.id, c.EventName, c.EventPlace, c.EventDate, regions.RegionName, nations.NationName };
                var data = query.ToList();
                eventsDataGrid.ItemsSource = data;
                db.Dispose();
            }
        }
Ejemplo n.º 7
0
        /*
         * Wyswietlanie list zawodnikow zapisanych w bazie danych.
         */
        public static void showParticipants(DataGrid participantsDataGrid)
        {
            cleanDataGrid(participantsDataGrid);

            using (var db = new appDBEntities())
            {
                var query = from c in db.Participant
                            join gender in db.Sex on c.Sex equals gender.id
                            join club in db.Club on c.Club equals club.id
                            join nation in db.Nation on c.Nationality equals nation.id
                            select new { c.id, c.Surname, c.Name, gender.SexName, c.City, c.BirthYear, club.ClubName, c.RegTime, nation.NationName };
                var data = query.ToList();
                participantsDataGrid.ItemsSource = data;
                db.Dispose();
            }
        }
 /*
  * Wyswietlanie listy uczestnikow przypisanych do aktualnie wybranych zawodow.
  */
 public static void showParticipants(DataGrid participantDataGrid)
 {
     using (var dt = new appDBEntities())
     {
         var query = from c in dt.Participant
                     join t2 in dt.Club on c.Club equals t2.id
                     join t3 in dt.Sex on c.Sex equals t3.id
                     join t4 in dt.Nation on c.Nationality equals t4.id
                     // where c.EventID == MainWindow._event
                     select new { c.id, c.Surname, c.Name, t3.SexName, c.BirthYear, t2.ClubName, c.City, c.RegTime, t4.NationName };
         var data = query.ToList();
         participantDataGrid.ItemsSource = data;
         //  foreach (object str in data)
         //    eventParticipantsDataGrid.Items.Add(str);
         dt.Dispose();
     }
 }
Ejemplo n.º 9
0
 /*
  * Wypełnienie ComboBoxa konkurencjami przypisanymi do danych zawodow
  */
 static public void fillCompetitionComboBox(System.Windows.Controls.ComboBox comboBox, long _event)
 {
     using (var db = new appDBEntities())
     {
         var query = from c in db.EventCompetitions
                     join com in db.Competitions on c.CompetitionID equals com.id
                     where c.EventID == _event
                     orderby c.Order //descending
                     select com.CompetitionName;
         var data = query.ToList();
         foreach (string str in data)
         {
             comboBox.Items.Add(str);
         }
         db.Dispose();
     }
 }
Ejemplo n.º 10
0
        }     //end funkcji addEvent

        /// EVENTS
        ///CLUBS
        static public void addClub(
            TextBox ClubNameTextBox,
            ComboBox ClubRegionComboBox)
        {
            // Konwersja danych znajdujacych sie w polach wypelnianych przez uzytkownika.

            string _ClubName = ClubNameTextBox.Text;

            long   _ClubRegion  = long.Parse(ClubRegionComboBox.SelectedValuePath.ToString());
            string _ClubRegion1 = ClubRegionComboBox.Text;

            // Zapisanie wartosci do bazy danych.
            using (var db = new appDBEntities())
            {
                Club newItem = new Club
                {
                    ClubName = ClubNameTextBox.Text,

                    ClubRegion = _ClubRegion
                };
                try
                {
                    //Obsluga bazy danych.
                    db.Club.Add(newItem);
                    db.SaveChanges();
                    db.Dispose();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    MessageBox.Show(string.Format("Error - {0}", e), "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                //Wyswietlenie komunikatu o poprawnosci wprowadzonych danych.
                string inf = string.Format("Club added :\n{0}\nRegion: {1}",
                                           newItem.ClubName, _ClubRegion1);
                MessageBox.Show(inf, "Information", MessageBoxButton.OK, MessageBoxImage.Information);

                //Czyszczenie pol wypelnianych przez uzytkownika.

                ClubNameTextBox.Text = null;

                ClubRegionComboBox.Text = null;
            }    //end using
        }//end funkcji addClub
Ejemplo n.º 11
0
 public static int checkPreviousCompetitionScoresDone(int Event, int Order)
 {
     try
     {
         using (var db = new appDBEntities())
         {
             var query = (from c in db.EventCompetitions
                          where c.EventID == Event && c.Order == Order - 1
                          join comp in db.Competitions on c.CompetitionID equals comp.id
                          select c.ScoresDone).FirstOrDefault();
             return(int.Parse(query.ToString()));
         }
     }
     catch (Exception f)
     {
         Console.WriteLine(f);
         return(0);
     }
 }
Ejemplo n.º 12
0
 /*
  * Pobranie ID wybranej konkurencji - wymagane do dalszych funkcji.
  */
 public static int idSelctedCompetition(ComboBox competitionComboBox)
 {
     try
     {
         dynamic currentItem = competitionComboBox.SelectedItem;
         string  lookingFor  = currentItem;
         using (var db = new appDBEntities())
         {
             var query = (from c in db.Competitions
                          where c.CompetitionName == lookingFor
                          select c.id).FirstOrDefault();
             return(int.Parse(query.ToString()));
         }
     }
     catch (Exception f)
     {
         Console.WriteLine(f);
         return(0);
     }
 }
Ejemplo n.º 13
0
        /*
         * Funkcja wypelnia liste startowa zawodnikami przypisanymi do danych zawodow.
         */
        public static void fillStartOrder(int gender)
        {
            using (var dt = new appDBEntities())
            {
                var query = from c in dt.EventParticipants
                            join t2 in dt.Participant on c.ParticipantID equals t2.id
                            join t3 in dt.Sex on t2.Sex equals t3.id
                            join t4 in dt.Club on t2.Club equals t4.id
                            where c.EventID == MainWindow._event && t2.Sex == gender
                            select new { c.id, c.ParticipantID, t2.Surname, t2.Name, t3.SexName, t2.BirthYear, t4.ClubName, t2.RegTime };

                /* TO DO LIST
                 * POBIERZ LISTE ZAWODNIKOW Z WYBRANYCH ZAWODOW
                 * DODAJ ZAWODNIKOW DO TABELI STARTORDERS
                 * WYPELNIJ SERIE/TORY STARTOWE WG WZORU
                 */
                foreach (var a in query)
                {
                    StartOrders newItem = new StartOrders
                    {
                        FKevent            = MainWindow._event,
                        FKeventParticipant = a.id,
                        FKcompetition      = MainWindow._competition,
                        FKParticipant      = a.ParticipantID,
                        EntryTime          = a.RegTime
                    };
                    //Dodaj
                    dt.StartOrders.Add(newItem);
                }
                try
                {
                    dt.SaveChanges();
                    //      MessageBox.Show(string.Format("Deleting participant with ID = {0}  from EventID = {1}", idParticipant, idEvent));
                }
                catch (Exception f)
                {
                    Console.WriteLine(f);
                    // Provide for exceptions.
                }
            }
        }
Ejemplo n.º 14
0
 /*
  * Pobiera dane dotyczace kolejnosci w ktorej bedzie rozgrywana wybrana konkurencja.
  */
 public static int orderCompetition(ComboBox competitionComboBox, int Event, int competition)
 {
     try
     {
         dynamic currentItem = competitionComboBox.SelectedItem;
         string  lookingFor  = currentItem;
         using (var db = new appDBEntities())
         {
             var query = (from c in db.EventCompetitions
                          join comp  in db.Competitions on c.CompetitionID equals comp.id
                          where comp.CompetitionName == lookingFor
                          select comp.StartOrder).FirstOrDefault();
             return(int.Parse(query.ToString()));
         }
     }
     catch (Exception f)
     {
         Console.WriteLine(f);
         return(0);
     }
 }
Ejemplo n.º 15
0
 /*
  * Wyswietlanie list startowych dla danej konkurencji.
  */
 public static void showStartOrder(DataGrid dataGrid, int gender, int competition)
 {
     browseDataBase.cleanDataGrid(dataGrid);
     try
     {
         using (var db = new appDBEntities())
         {
             var query = from c in db.StartOrders
                         join participant in db.Participant on c.FKParticipant equals participant.id
                         join sex in db.Sex on participant.Sex equals sex.id
                         join club in db.Club on participant.Club equals club.id
                         where c.FKevent == MainWindow._event &&
                         c.FKcompetition == competition &&
                         participant.Sex == gender
                         // where c.EventID == MainWindow._event
                         select new
             {
                 participant.Surname,
                 participant.Name,
                 sex.SexName,
                 participant.BirthYear,
                 club.ClubName,
                 c.Heat,
                 c.Track,
                 c.EntryTime
             };
             var query1 = query.OrderBy(c => c.Heat).ThenBy(c => c.Track);
             var data   = query1.ToList();
             dataGrid.ItemsSource = data;
             db.Dispose();
         }
     }
     catch (Exception f)
     {
         Console.WriteLine(f);
         // Provide for exceptions.
     }
 }
Ejemplo n.º 16
0
 public static void showEventCompetition(DataGrid eventCompetitionDataGrid, long _event)
 {
     try
     {
         eventCompetitionDataGrid.ItemsSource = null;
     }
     catch (Exception f)
     {
         Console.WriteLine(f);
         // Provide for exceptions.
     }
     using (var dt = new appDBEntities())
     {
         var query = from c in dt.EventCompetitions
                     join t2 in dt.Competitions on c.CompetitionID equals t2.id
                     where c.EventID == MainWindow._event
                     orderby c.Order //descending
                     select new { t2.CompetitionName, c.CompetitionID, c.Order };
         var data = query.ToList();
         eventCompetitionDataGrid.ItemsSource = data;
         dt.Dispose();
     }
 }
Ejemplo n.º 17
0
        /*
         * Przypisanie zaznaczonego zawodnika do aktualnie wybranych zawodow.
         */

        public static void addParticipantToEvent(long idParticipant, long idEvent)
        {
            using (var db = new appDBEntities())
            {
                EventParticipants newItem = new EventParticipants
                {
                    EventID       = idEvent,
                    ParticipantID = idParticipant,
                };
                try
                {
                    db.EventParticipants.Add(newItem);
                    db.SaveChanges();
                    db.Dispose();
                    MessageBox.Show(string.Format("Adding participant with ID = {0}  to EventID = {1}", idParticipant, idEvent));
                }
                catch (Exception f)
                {
                    Console.WriteLine(f);
                    // Provide for exceptions.
                }
            }
        }
Ejemplo n.º 18
0
        /*
         * Funkcja czysci poprzednia liste startowa.
         */
        public static void clearStartOrder(int gender)
        {
            var db = new appDBEntities();
            var deleteStartOrder =
                from StartOrders in db.StartOrders
                join t2 in db.Participant on StartOrders.FKParticipant equals t2.id
                where StartOrders.FKevent == MainWindow._event && StartOrders.FKcompetition == MainWindow._competition &&
                t2.Sex == gender
                select StartOrders;

            foreach (var StartOrders in deleteStartOrder)
            {
                db.StartOrders.Remove(StartOrders);
            }
            try
            {
                db.SaveChanges();
            }
            catch (Exception f)
            {
                Console.WriteLine(f);
            }
        }
Ejemplo n.º 19
0
        /*
         * Usuwa zawodnika z danej imprezy. Usuwany jest zawodnik ktory zostal zaznaczony w prawym oknie AddDeleteParticipantsWindow.
         */
        public static void deleteParticipantFromEvent(long idParticipant, long idEvent)
        {
            var db = new appDBEntities();

            var deleteParticipantInEvent =
                from EventParticipants in db.EventParticipants
                where EventParticipants.ParticipantID == idParticipant && EventParticipants.EventID == idEvent
                select EventParticipants;

            foreach (var EventParticipants in deleteParticipantInEvent)
            {
                db.EventParticipants.Remove(EventParticipants);
            }
            try
            {
                db.SaveChanges();
                MessageBox.Show(string.Format("Deleting participant with ID = {0}  from EventID = {1}", idParticipant, idEvent));
            }
            catch (Exception f)
            {
                Console.WriteLine(f);
                // Provide for exceptions.
            }
        }
Ejemplo n.º 20
0
        public static void ToPdf(int gender, int competition, string fileName)
        {
            Document  document = new Document(PageSize.A4, 25, 25, 30, 30);
            PdfWriter writer   = PdfWriter.GetInstance(document, new FileStream(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), fileName + ".pdf"), FileMode.Create));

            document.Open();

            using (var db = new appDBEntities())
            {
                /*
                 * Wygenerowanie danych ktore maja zostac pokazane w pdfie.
                 */
                var query = from c in db.StartOrders
                            join participant in db.Participant on c.FKParticipant equals participant.id
                            join sex in db.Sex on participant.Sex equals sex.id
                            join club in db.Club on participant.Club equals club.id
                            where c.FKevent == MainWindow._event &&
                            c.FKcompetition == competition &&
                            participant.Sex == gender
                            // where c.EventID == MainWindow._event
                            select new { participant.Surname,
                                         participant.Name,
                                         sex.SexName,
                                         participant.BirthYear,
                                         club.ClubName,
                                         c.Heat, c.Track,
                                         c.EntryTime };

                int columns = 8;                                               //liczba kolumn do wygenerowania (?)
                var query1  = query.OrderBy(c => c.Heat).ThenBy(c => c.Track); //query1 jest posortowane wg Serii a nastepnie numerow torow

                //numer najwiekszej i najmniejszej serii - chyba nie korzystam juz z tego xd
                int max_heat = int.Parse(query1.Max(c => c.Heat).ToString());
                int min_heat = int.Parse(query1.Min(c => c.Heat).ToString());

                //Tworzenie pdfa
                PdfPTable table = new PdfPTable(columns);
                table.WidthPercentage = 80;       //Setting the PDF File width percentage

                //creating 1st cell and show as table title - skopiowalem z neta
                PdfPCell cell = new PdfPCell();
                cell.Colspan             = 8;
                cell.Border              = 1;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.Phrase              = new Phrase("Start Order ", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 18, 1, new BaseColor(35, 21, 24)));
                cell.BackgroundColor     = new BaseColor(255, 32, 12);
                cell.PaddingBottom       = 10;

                // adding 1st cell to table
                table.AddCell(cell);

                /*var headerParagraph = new Paragraph("Raport śąóżćń", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true)));
                 * Wypisanie nazw naszych kolumn - recznie
                 */
                // creating and adding 3rd,4th,5th,6th cell using constructor and display as a students name and subkects
                table.AddCell(new PdfPCell(new Phrase("Surname", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.BLACK)))
                {
                    NoWrap = false, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                });
                table.AddCell(new PdfPCell(new Phrase("Name", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.BLACK)))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                });
                table.AddCell(new PdfPCell(new Phrase("Gender", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.BLACK)))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                });
                table.AddCell(new PdfPCell(new Phrase("Birth Year", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.BLACK)))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                });
                table.AddCell(new PdfPCell(new Phrase("Club", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.BLACK)))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                });
                table.AddCell(new PdfPCell(new Phrase("Heat", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.BLACK)))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                });
                table.AddCell(new PdfPCell(new Phrase("Track", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.BLACK)))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                });
                table.AddCell(new PdfPCell(new Phrase("Entry Time", new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.BLACK)))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                });

                /*
                 * to sa zmienne pomocnicze do porownania wartosci z poprzedniej i biezacej iteracji.
                 *
                 */
                int a = 0;
                int b = 0;
                int d = 0;
                foreach (var c in query1)
                {
                    b = int.Parse(c.Heat.ToString());
                    d = a - b;
                    a = int.Parse(c.Heat.ToString());

                    /*
                     * Jak roznica pomiedzy liczba biezacej i poprzedniej "serii" rowna sie -1 lub 0
                     * to program powinien zrobic wiersz na cala szerokosc pliku i wypisac "seria <numer_serii>"
                     * nie wiem jak zrobic wiersz na cala szerokosc
                     */
                    if (d == 1 || d == -1)
                    {
                        //creating 1st cell and show as table title
                        PdfPCell cell2 = new PdfPCell();
                        cell2.Colspan             = 8;
                        cell2.Border              = 1;
                        cell2.HorizontalAlignment = Element.ALIGN_CENTER;
                        cell2.Phrase              = new Phrase(string.Format("Heat {0}", c.Heat), new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 18, 1, new BaseColor(35, 21, 24)));
                        cell2.BackgroundColor     = new BaseColor(255, 32, 12);
                        cell2.PaddingBottom       = 10;
                        // adding 1st cell to table
                        table.AddCell(cell2);
                    }

                    /*
                     * Dodanie danych z bazy danych. */

                    table.AddCell(new PdfPCell(new Phrase(c.Surname, new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.RED)))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                    });
                    table.AddCell(new PdfPCell(new Phrase(c.Name, new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.RED)))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                    });
                    table.AddCell(new PdfPCell(new Phrase(c.SexName, new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.RED)))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                    });
                    table.AddCell(new PdfPCell(new Phrase(c.BirthYear.ToString(), new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.RED)))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                    });
                    table.AddCell(new PdfPCell(new Phrase(c.ClubName, new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.RED)))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                    });
                    table.AddCell(new PdfPCell(new Phrase(c.Heat.ToString(), new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.RED)))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                    });
                    table.AddCell(new PdfPCell(new Phrase(c.Track.ToString(), new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.RED)))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                    });
                    table.AddCell(new PdfPCell(new Phrase(c.EntryTime, new Font(BaseFont.CreateFont(@"C:\Windows\Fonts\Arial.ttf", BaseFont.CP1250, true), 8, 1, BaseColor.RED)))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, Padding = 5, BackgroundColor = BaseColor.WHITE
                    });
                }
                document.Open();
                document.Add(table);
                document.Close();
            }
        }
Ejemplo n.º 21
0
        static public void addParticipant(
            TextBox ParticipantSurnameTextBox,
            TextBox ParticipantNameTextBox,
            TextBox ParticipantCityTextBox,
            TextBox ParticipantBirthYearTextBox,
            TextBox ParticipantBirthMonthTextBox,
            TextBox ParticipantBirthDayTextBox,
            ComboBox sexNameComboBox,
            ComboBox clubNameComboBox,
            ComboBox nationNameComboBox,
            TextBox ParticipantRegTimeMinTextBox,
            TextBox ParticipantRegTimeSecTextBox,
            TextBox ParticipantRegTimeCentTextBox)
        {
            // Konwersja danych znajdujacych sie w polach wypelnianych przez uzytkownika.
            int    _BirthYear   = int.Parse(ParticipantBirthYearTextBox.Text);
            int    _BirthMonth  = int.Parse(ParticipantBirthMonthTextBox.Text);
            int    _BirthDay    = int.Parse(ParticipantBirthDayTextBox.Text);
            long   _sex         = long.Parse(sexNameComboBox.SelectedValuePath.ToString());
            long   _clubName    = long.Parse(clubNameComboBox.SelectedValuePath.ToString());
            long   _nationName  = long.Parse(nationNameComboBox.SelectedValuePath.ToString());
            string _nationName1 = nationNameComboBox.Text;
            string _clubName1   = clubNameComboBox.Text;
            string _sex1        = sexNameComboBox.Text;
            string _regTime     = participantRegTime(ParticipantRegTimeMinTextBox, ParticipantRegTimeSecTextBox, ParticipantRegTimeCentTextBox);

            //Sprawdzenie poprawnosci wprowadzaonych danych przez uzytkownika.
            if (checkIsDataCorrect(_BirthDay, _BirthMonth, _BirthYear, _regTime))
            {
                // Zapisanie wartosci do bazy danych.
                using (var db = new appDBEntities())
                {
                    Participant newItem = new Participant
                    {
                        Surname     = ParticipantSurnameTextBox.Text,
                        Name        = ParticipantNameTextBox.Text,
                        BirthDay    = _BirthYear,
                        BirthMonth  = _BirthMonth,
                        BirthYear   = _BirthDay,
                        City        = ParticipantCityTextBox.Text,
                        Sex         = _sex,
                        Club        = _clubName,
                        Nationality = _nationName,
                        RegTime     = _regTime
                    };
                    //Obsluga bazy danych.
                    db.Participant.Add(newItem);
                    db.SaveChanges();
                    db.Dispose();

                    //Wyswietlenie komunikatu o poprawnosci wprowadzonych danych.
                    string inf = string.Format("Participant added :\n{0} {1}\n\nSex: {2},  Birth: {3}-{4}-{5},\nCity: {6},  Club: {7}, Nation: {8}\nEntry Time: {9}",
                                               newItem.Surname, newItem.Name, _sex1,
                                               newItem.BirthDay, newItem.BirthMonth, newItem.BirthYear,
                                               newItem.City, _clubName1, _nationName1, _regTime);
                    MessageBox.Show(inf, "Information", MessageBoxButton.OK, MessageBoxImage.Information);

                    //Czyszczenie pol wypelnianych przez uzytkownika.
                    ParticipantBirthYearTextBox.Text  = "YYYY";
                    ParticipantBirthMonthTextBox.Text = "MM";
                    ParticipantBirthDayTextBox.Text   = "DD";

                    sexNameComboBox.Text               = null;
                    clubNameComboBox.Text              = null;
                    nationNameComboBox.Text            = null;
                    ParticipantNameTextBox.Text        = null;
                    ParticipantSurnameTextBox.Text     = null;
                    ParticipantRegTimeMinTextBox.Text  = "mm";
                    ParticipantRegTimeSecTextBox.Text  = "ss";
                    ParticipantRegTimeCentTextBox.Text = "cccc";
                    ParticipantCityTextBox.Text        = null;
                } //end using
            }     //end if
            else
            {
                MessageBox.Show("Write a correct birth date.", "Error!", MessageBoxButton.OK, MessageBoxImage.Information);
            } //end else
        }     //end funkcji addParticipant
Ejemplo n.º 22
0
        ///EVENT
        static public void addEvent(
            TextBox EventNameTextBox,
            TextBox EventPlaceTextBox,
            TextBox EventDateYearTextBox,
            TextBox EventDateMonthTextBox,
            TextBox EventDateDayTextBox,
            ComboBox EventNationComboBox,
            ComboBox EventRegionComboBox)
        {
            // Wypełnienie comboboxa
            //fillComboBoxes.fillRegionComboBox(EventRegionComboBox, MainWindow._event);
            // Konwersja danych znajdujacych sie w polach wypelnianych przez uzytkownika.
            int    _EventDateYear  = int.Parse(EventDateYearTextBox.Text);
            int    _EventDateMonth = int.Parse(EventDateMonthTextBox.Text);
            int    _EventDateDay   = int.Parse(EventDateDayTextBox.Text);
            long   _NationName     = long.Parse(EventNationComboBox.SelectedValuePath.ToString());
            string _NationName1    = EventNationComboBox.Text;
            // long _RegionName = long.Parse(RegionNameComboBox.SelectedValuePath.ToString());
            string _EventName    = EventNameTextBox.Text;
            string _EventPlace   = EventPlaceTextBox.Text;
            long   _EventRegion  = long.Parse(EventRegionComboBox.SelectedValuePath.ToString());
            string _EventRegion1 = EventRegionComboBox.Text;
            string _Date         = DateFormat(EventDateYearTextBox, EventDateMonthTextBox, EventDateDayTextBox);

            //Sprawdzenie poprawnosci wprowadzaonych danych przez uzytkownika.
            if (checkIsDataCorrectFuture(_EventDateDay, _EventDateMonth, _EventDateYear, _Date))
            {
                // Zapisanie wartosci do bazy danych.
                using (var db = new appDBEntities())
                {
                    Events newItem = new Events
                    {
                        EventName   = EventNameTextBox.Text,
                        EventPlace  = EventPlaceTextBox.Text,
                        EventDate   = _Date,
                        EventNation = _NationName,
                        EventRegion = _EventRegion
                    };
                    try {
                        //Obsluga bazy danych.
                        db.Events.Add(newItem);
                        db.SaveChanges();
                        db.Dispose();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        MessageBox.Show(string.Format("Error - {0}", e), "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    //Wyswietlenie komunikatu o poprawnosci wprowadzonych danych.
                    string inf = string.Format("Event added :\n{0}\nPlace: {1}\nDate: {2}\nNation: {3}\nRegion: {4}",
                                               newItem.EventName, newItem.EventPlace, newItem.EventDate,
                                               _NationName1, _EventRegion1);
                    MessageBox.Show(inf, "Information", MessageBoxButton.OK, MessageBoxImage.Information);

                    //Czyszczenie pol wypelnianych przez uzytkownika.
                    EventDateYearTextBox.Text  = "YYYY";
                    EventDateMonthTextBox.Text = "MM";
                    EventDateDayTextBox.Text   = "DD";

                    EventNationComboBox.Text = null;
                    EventNameTextBox.Text    = null;
                    EventPlaceTextBox.Text   = null;
                    EventRegionComboBox.Text = null;
                } //end using
            }     //end if
            else
            {
                MessageBox.Show("Write a correct date.", "Error!", MessageBoxButton.OK, MessageBoxImage.Information);
            } //end else
        }     //end funkcji addEvent
Ejemplo n.º 23
0
        /*
         * Funkcja wypelnia liste startowa zawodnikami przypisanymi do danych zawodow.
         */
        public static void swimmingGenerateStartOrder(int gender)
        {
            /*
             * Pobieramy liste zawodnikow bioracych udzial w zawodach z podzialem na plec - mezczyzni lub kobiety
             */
            using (var db = new appDBEntities())
            {
                var query = from c in db.StartOrders
                            join participant in db.Participant on c.FKParticipant equals participant.id
                            join sex in db.Sex on participant.Sex equals sex.id
                            where c.FKevent == MainWindow._event &&
                            c.FKcompetition == MainWindow._competition &&
                            participant.Sex == gender
                            orderby c.EntryTime
                            // where c.EventID == MainWindow._event
                            select c;

                /*new {participant.Surname, participant.Name, sex.SexName, participant.BirthYear,
                 * c.Number, c.Heat, c.Track, c.EntryTime};*/
                int        count_participants = query.Count();                           //liczba uczestnikow
                int        count_lanes        = 6;                                       //liczba torow
                int[]      heats_table;                                                  //tablica przechowujaca liczbe osob startujacej w danej serii
                CountHeats countHeats = new CountHeats(count_participants, count_lanes); //policz liczbe serii
                heats_table = countHeats.heats();                                        //policz liczbe osob w kazdej serii
                int   count_heats = heats_table.Count();                                 //zmienna przechowujaca liczbe serii
                int[] lanes       = { 3, 4, 2, 5, 1, 6 };                                //kolejnosc rozdawania torow dla uczestnikow
                int   lane_num    = 0;
                int   number      = 1;                                                   //zmienna do okreslania numeru zawodnika

                /*
                 * Petla przypisujaca kazdemu zawodnikowi numer, tor i serie w ktorej plynie.
                 */
                foreach (var c in query)
                {
                    c.Number = number;
                    if (heats_table[count_heats - 1] != 0)
                    {
                        if (heats_table[count_heats - 1] > 0)
                        {
                            c.Heat  = count_heats;
                            c.Track = lanes[lane_num];
                            lane_num++;
                            heats_table[count_heats - 1]--;
                        }
                    }
                    else
                    {
                        lane_num    = 0;
                        count_heats = count_heats - 1;
                        c.Heat      = count_heats;
                        c.Track     = lanes[lane_num];
                        heats_table[count_heats - 1]--;
                        lane_num++;
                    }

                    number++;
                }
                /* zapisanie zmian do bazy danych */
                addToDB.dbSaveChanges(db);
            }
        }