コード例 #1
0
 public bool DataBaseCheckFieldOfStudy(FieldOfStudyCheckProcedure field)
 {
     command = new MySqlCommand($"CALL czy_kierunek_istnieje('{field.StudyField}', {field.Semestr}, {field.Degree})", this.conection);
     reader  = command.ExecuteReader();
     if (reader.HasRows)
     {
         reader.Close();
         return(true);
     }
     reader.Close();
     return(false);
 }
コード例 #2
0
        private void AddNewStudent()
        {
            AddUserProcedure           newUser = new AddUserProcedure();
            FieldOfStudyCheckProcedure field   = new FieldOfStudyCheckProcedure();
            string errorMessage = "";

            if (!DataValidation.DataValidation.ValidPesel(tableRowContentList[0].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidName(tableRowContentList[1].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidSurname(tableRowContentList[2].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidDateOfBirth(tableRowContentList[3].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidSex(tableRowContentList[4].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidContactNumber(tableRowContentList[5].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidCountry(tableRowContentList[6].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidCity(tableRowContentList[7].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidStreet(tableRowContentList[8].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidHouseNumber(tableRowContentList[9].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidApartmentNumber(tableRowContentList[10].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidPostalCode(tableRowContentList[11].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidLogin(tableRowContentList[12].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidPassword(tableRowContentList[13].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidRole(tableRowContentList[14].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (tableRowContentList[14].Text == "s")
            {
                if (!DataValidation.DataValidation.ValidStudyField(tableRowContentList[15].Text, out errorMessage))
                {
                    AlertWindow alertWindow = new AlertWindow(errorMessage);
                    alertWindow.ShowDialog();
                    return;
                }

                if (!DataValidation.DataValidation.ValidSemestr(tableRowContentList[16].Text, out errorMessage))
                {
                    AlertWindow alertWindow = new AlertWindow(errorMessage);
                    alertWindow.ShowDialog();
                    return;
                }

                if (!DataValidation.DataValidation.ValidDegree(tableRowContentList[17].Text, out errorMessage))
                {
                    AlertWindow alertWindow = new AlertWindow(errorMessage);
                    alertWindow.ShowDialog();
                    return;
                }

                field.StudyField = tableRowContentList[15].Text;
                field.Semestr    = int.Parse(tableRowContentList[16].Text);
                field.Degree     = int.Parse(tableRowContentList[17].Text);

                if (!DbService.DataBaseCheckFieldOfStudy(field))
                {
                    errorMessage = "Nie istnieje kierunek lub nie ma takiego semestru na danym stopniu studiów.";
                    AlertWindow alertWindow = new AlertWindow(errorMessage);
                    alertWindow.ShowDialog();
                    return;
                }

                newUser.StudyField = tableRowContentList[15].Text;
                newUser.Semestr    = int.Parse(tableRowContentList[16].Text);
                newUser.Degree     = int.Parse(tableRowContentList[17].Text);
            }
            else
            {
                errorMessage = "Jako pracownik dziekanatu możesz dodać tylko studenta.\n" + "Jako rola użytkownika musisz więc wpisać 's'";
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (DbService.DataBaseCheckPesel(tableRowContentList[0].Text))
            {
                errorMessage = "Taki pesel już istnieje w bazie danych.";
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (DbService.DataBaseCheckLogin(tableRowContentList[12].Text))
            {
                errorMessage = "Taki login już istnieje w bazie danych.";
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            newUser.Pesel           = tableRowContentList[0].Text;
            newUser.Name            = tableRowContentList[1].Text;
            newUser.Surname         = tableRowContentList[2].Text;
            newUser.DateOfBirth     = tableRowContentList[3].Text;
            newUser.Sex             = tableRowContentList[4].Text.ToCharArray()[0];
            newUser.ContactNumber   = tableRowContentList[5].Text;
            newUser.Country         = tableRowContentList[6].Text;
            newUser.City            = tableRowContentList[7].Text;
            newUser.Street          = tableRowContentList[8].Text;
            newUser.HouseNumber     = tableRowContentList[9].Text;
            newUser.ApartmentNumber = tableRowContentList[10].Text;
            newUser.PostalCode      = tableRowContentList[11].Text;
            newUser.Login           = tableRowContentList[12].Text;
            newUser.Password        = tableRowContentList[13].Text;
            newUser.Role            = tableRowContentList[14].Text;
            newUser.CurrentUser     = signInUser.UserID;
            DbService.DataBaseAddUser(newUser);

            errorMessage = "Dodano studenta.";
            AlertWindow alertWindow2 = new AlertWindow(errorMessage);

            alertWindow2.ShowDialog();
        }
コード例 #3
0
        private void ChangeStudentData()
        {
            ChangeStudentDataProcedure changedFieldOfStudy = new ChangeStudentDataProcedure();
            ChangeDataProcedure        changedStudent      = new ChangeDataProcedure();
            FieldOfStudyCheckProcedure field = new FieldOfStudyCheckProcedure();
            string errorMessage = "";

            if (!DataValidation.DataValidation.ValidName(tableRowContentList[2].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidSurname(tableRowContentList[3].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidSex(tableRowContentList[5].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidContactNumber(tableRowContentList[6].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidCountry(tableRowContentList[7].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidCity(tableRowContentList[8].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidStreet(tableRowContentList[9].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidHouseNumber(tableRowContentList[10].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidApartmentNumber(tableRowContentList[11].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidPostalCode(tableRowContentList[12].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidStudyField(tableRowContentList[13].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidSemestr(tableRowContentList[14].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            if (!DataValidation.DataValidation.ValidDegree(tableRowContentList[15].Text, out errorMessage))
            {
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            field.StudyField = tableRowContentList[13].Text;
            field.Semestr    = int.Parse(tableRowContentList[14].Text);
            field.Degree     = int.Parse(tableRowContentList[15].Text);

            if (!DbService.DataBaseCheckFieldOfStudy(field))
            {
                errorMessage = "Nie istnieje kierunek lub nie ma takiego semestru na danym stopniu studiów.";
                AlertWindow alertWindow = new AlertWindow(errorMessage);
                alertWindow.ShowDialog();
                return;
            }

            changedStudent.Name            = tableRowContentList[2].Text;
            changedStudent.Surname         = tableRowContentList[3].Text;
            changedStudent.Sex             = tableRowContentList[5].Text;
            changedStudent.ContactNumber   = tableRowContentList[6].Text;
            changedStudent.Country         = tableRowContentList[7].Text;
            changedStudent.City            = tableRowContentList[8].Text;
            changedStudent.Street          = tableRowContentList[9].Text;
            changedStudent.HouseNumber     = tableRowContentList[10].Text;
            changedStudent.ApartmentNumber = tableRowContentList[11].Text;
            changedStudent.PostalCode      = tableRowContentList[12].Text;
            changedStudent.CurrentUser     = choosenUserID;

            changedFieldOfStudy.StudentID   = int.Parse(tableRowContentList[0].Text);
            changedFieldOfStudy.StudyField  = tableRowContentList[13].Text;
            changedFieldOfStudy.Semestr     = int.Parse(tableRowContentList[14].Text);
            changedFieldOfStudy.Degree      = int.Parse(tableRowContentList[15].Text);
            changedFieldOfStudy.CurrentUser = signInUser.UserID;

            DbService.DataBaseChangeUserData(changedStudent);
            DbService.DataBaseChangeFieldOfStudyStudent(changedFieldOfStudy);
            AlertWindow alertWindow2 = new AlertWindow("Zmiana danych przebiegła pomyślnie.");

            alertWindow2.ShowDialog();
        }