This commit is contained in:
ker73rus 2023-05-20 09:55:49 +04:00
commit 9a6f9e100b
3 changed files with 23 additions and 12 deletions

View File

@ -10,7 +10,7 @@ namespace UniversityDataBaseImplemet
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=UniversityCourseWork;Username=postgres;Password=0000"); optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=UniversityCourseWork;Username=postgres;Password=123");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -8,19 +8,21 @@ const errorDivShell = document.getElementById("error-div-shell");
students = [] students = []
window.addEventListener("load", () => { window.addEventListener("load", () => {
const studentsResponse = $.ajax({ $.ajax({
url: `/student/getallbyuser`, url: "/student/getallbyuser",
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}).done((result) => {
students = result;
}); });
students = studentsResponse;
}) })
const correctData = () => { const correctData = () => {
}; };
const validate = () => { const validate = () => {
console.log(students)
var validStudentCard = true var validStudentCard = true
if (nameInput.value === "") { if (nameInput.value === "") {
errorDivShell.style.gridTemplateRows = "1fr"; errorDivShell.style.gridTemplateRows = "1fr";
@ -37,11 +39,15 @@ const validate = () => {
errorP.innerHTML = "Заполните поле 'Дата рождения'"; errorP.innerHTML = "Заполните поле 'Дата рождения'";
return false return false
} }
if (studCardInput.value === "") {
errorDivShell.style.gridTemplateRows = "1fr";
errorP.innerHTML = "Заполните поле 'Номер студенческого билета'";
return false
}
students.forEach((student) => { students.forEach((student) => {
if (student.studentCard === parseInt(studCardInput.value)) { if (student.studentCard === parseInt(studCardInput.value)) {
errorDivShell.style.gridTemplateRows = "1fr"; errorDivShell.style.gridTemplateRows = "1fr";
errorP.innerHTML = "Заполните поле 'Дата рождения'"; errorP.innerHTML = "Заполните поле 'Номер студенческого билета' правильными данными, возможно пользователь с таким номером уже есть";
validStudentCard = false; validStudentCard = false;
} }
}); });

View File

@ -10,12 +10,13 @@ const errorDivShell = document.getElementById("error-div-shell");
students = [] students = []
window.addEventListener("load", () => { window.addEventListener("load", () => {
const studentsResponse = $.ajax({ $.ajax({
url: `/student/getallbyuser`, url: "/student/getallbyuser",
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}).done((result) => {
students = result;
}); });
students = studentsResponse;
}) })
const correctData = () => { const correctData = () => {
@ -40,11 +41,15 @@ const validate = () => {
errorP.innerHTML = "Заполните поле 'Дата рождения'"; errorP.innerHTML = "Заполните поле 'Дата рождения'";
return false return false
} }
if (studCardInput.value === "") {
errorDivShell.style.gridTemplateRows = "1fr";
errorP.innerHTML = "Заполните поле 'Номер студенческого билета'";
return false
}
students.forEach((student) => { students.forEach((student) => {
if (student.studentCard === parseInt(studCardInput.value)) { if (student.studentCard === parseInt(studCardInput.value)) {
errorDivShell.style.gridTemplateRows = "1fr"; errorDivShell.style.gridTemplateRows = "1fr";
errorP.innerHTML = "Заполните поле 'Дата рождения'"; errorP.innerHTML = "Заполните поле 'Номер студенческого билета' правильными данными, возможно пользователь с таким номером уже есть";
validStudentCard = false; validStudentCard = false;
} }
}); });