public void DataBaseChangeFieldOfStudyStudent(ChangeStudentDataProcedure studentFieldOfStudy) { command = new MySqlCommand($"call zmien_kierunek_semestr_stopien({studentFieldOfStudy.StudentID}, '{studentFieldOfStudy.StudyField}', {studentFieldOfStudy.Semestr}, {studentFieldOfStudy.Degree}, {studentFieldOfStudy.CurrentUser});", this.conection); adapter.InsertCommand = command; adapter.InsertCommand.ExecuteNonQuery(); command.Dispose(); }
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(); }