2021-07-23 16:44:42 +05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Diplom_O.DataBase;
|
|
|
|
|
|
|
|
|
|
namespace Diplom_O.SupportForms
|
|
|
|
|
{
|
|
|
|
|
public partial class WorkChelForm : Form
|
|
|
|
|
{
|
|
|
|
|
public bool isCanceled = false;
|
|
|
|
|
private Chel chel = null;
|
|
|
|
|
public WorkChelForm(Chel chel = null)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2021-07-25 09:43:21 +05:00
|
|
|
|
maleBox.SelectedIndex = 0;
|
|
|
|
|
birthdayBox.Value = DateTime.Now;
|
2021-07-23 16:44:42 +05:00
|
|
|
|
try
|
|
|
|
|
{
|
2021-07-25 09:43:21 +05:00
|
|
|
|
if (chel != null)
|
2021-07-23 16:44:42 +05:00
|
|
|
|
{
|
2021-07-25 09:43:21 +05:00
|
|
|
|
this.chel = chel;
|
2021-07-23 16:44:42 +05:00
|
|
|
|
workButton.Text = "Изменить";
|
2021-07-25 09:43:21 +05:00
|
|
|
|
fNameBox.Text = chel.FName;
|
|
|
|
|
sNameBox.Text = chel.SName;
|
|
|
|
|
tNameBox.Text = chel.TName;
|
|
|
|
|
maleBox.SelectedIndex = chel.Male ? 0 : 1;
|
|
|
|
|
birthdayBox.Value = chel.Birthday;
|
|
|
|
|
addressBox.Text = chel.Address;
|
2024-09-20 08:53:52 +05:00
|
|
|
|
phoneBox.Text = chel.Phone;
|
2021-07-25 09:43:21 +05:00
|
|
|
|
innBox.Text = chel.INN;
|
|
|
|
|
snilsBox.Text = chel.SNILS;
|
|
|
|
|
pasportBox.Text = chel.Pasport;
|
2024-09-20 08:53:52 +05:00
|
|
|
|
checkBox1.Checked = chel.Pensia;
|
2021-07-23 16:44:42 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2024-09-20 08:53:52 +05:00
|
|
|
|
this.ShowError(errorLabel, e.Message);
|
2021-07-23 16:44:42 +05:00
|
|
|
|
workButton.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void workButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-09-20 08:53:52 +05:00
|
|
|
|
if (maleBox.SelectedIndex == -1)
|
|
|
|
|
throw new Exception("Пол не указан.");
|
|
|
|
|
var _chel = new Chel();
|
|
|
|
|
_chel.FName = fNameBox.Text;
|
|
|
|
|
_chel.SName = sNameBox.Text;
|
|
|
|
|
_chel.TName = tNameBox.Text;
|
|
|
|
|
_chel.Male = maleBox.SelectedIndex == 0;
|
|
|
|
|
_chel.Birthday = birthdayBox.Value;
|
|
|
|
|
_chel.Address = addressBox.Text;
|
|
|
|
|
_chel.Phone = phoneBox.Text;
|
|
|
|
|
_chel.INN = innBox.Text;
|
|
|
|
|
_chel.SNILS = snilsBox.Text;
|
|
|
|
|
_chel.Pasport = pasportBox.Text;
|
|
|
|
|
_chel.Pensia = checkBox1.Checked;
|
|
|
|
|
FuncDB.ChelCheckValid(_chel);
|
2021-07-25 09:43:21 +05:00
|
|
|
|
if (chel == null)
|
2024-09-20 08:53:52 +05:00
|
|
|
|
FuncDB.ChelAdd(_chel);
|
2021-07-23 16:44:42 +05:00
|
|
|
|
else
|
2024-09-20 08:53:52 +05:00
|
|
|
|
{
|
|
|
|
|
_chel.Id = chel.Id;
|
|
|
|
|
FuncDB.ChelChange(_chel);
|
2021-07-23 16:44:42 +05:00
|
|
|
|
}
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
2024-09-20 08:53:52 +05:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
this.ShowError(errorLabel, ex.Message);
|
|
|
|
|
}
|
2021-07-23 16:44:42 +05:00
|
|
|
|
}
|
|
|
|
|
private void canceledButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
isCanceled = true;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|