Прямее ровнее

This commit is contained in:
frog24 2024-05-08 23:41:41 +04:00
parent 87391c25c1
commit be017f5d16
2 changed files with 17 additions and 5 deletions

View File

@ -29,6 +29,7 @@ namespace DepartmentStaffDatabase
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE department SET name = @name, head = @head WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Id", department.Id);
cmd.Parameters.AddWithValue("@name", department.DepartmentName);
cmd.Parameters.AddWithValue("@head", department.Head);
cmd.ExecuteNonQuery();
@ -119,6 +120,7 @@ namespace DepartmentStaffDatabase
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE position SET name = @name, salary = @salary, departmentId = @departmentId WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Id", position.Id);
cmd.Parameters.AddWithValue("@name", position.PositionName);
cmd.Parameters.AddWithValue("@salary", position.Salary);
cmd.Parameters.AddWithValue("@departmentId", position.DepartmentId);
@ -217,6 +219,7 @@ namespace DepartmentStaffDatabase
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE employee SET name = @name, birthdate = @birthdate, " +
$"address = @address, phoneNumber = @phoneNumber, email = @email, positionId = @positionId WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Id", employee.Id);
cmd.Parameters.AddWithValue("@name", employee.EmployeeName);
cmd.Parameters.AddWithValue("@Birthdate", employee.Birthdate);
cmd.Parameters.AddWithValue("@Address", employee.Address);
@ -323,6 +326,7 @@ namespace DepartmentStaffDatabase
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE contract SET dateOfConclusion = @dateOfConclusion, duration = @duration, employeeId = @employeeId WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Id", contract.Id);
cmd.Parameters.AddWithValue("@dateOfConclusion", contract.DateOfConclusion);
cmd.Parameters.AddWithValue("@duration", contract.Duration);
cmd.Parameters.AddWithValue("@employeeId", contract.EmployeeId);
@ -399,6 +403,7 @@ namespace DepartmentStaffDatabase
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE course SET eventDateb = @eventDateb, hoursNumber = @hoursNumber, result = @result WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Id", course.Id);
cmd.Parameters.AddWithValue("@EventDateb", course.DateOfEvent);
cmd.Parameters.AddWithValue("@HoursNumber", course.HoursNumber);
cmd.Parameters.AddWithValue("@Result", course.Result);

View File

@ -25,11 +25,18 @@ namespace DepartmentStaffView
{
try
{
//if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
//{
// MessageBox.Show("Заполните поля. Они все обязательные!");
// return;
//}
if (string.IsNullOrEmpty(textBoxAddress.Text))
{
textBoxAddress.Text = "None";
}
if (string.IsNullOrEmpty(textBoxEmail.Text))
{
textBoxEmail.Text = "None";
}
if (string.IsNullOrEmpty(textBoxPhone.Text))
{
textBoxPhone.Text = "None";
}
if (EmployeeId.HasValue)
{
db.UpdateEmployee(new()