//|| DateTime.Parse(txtPlacementDate.Text) != _previouslySelectedEmployee.PlacementDate
|| DateTime.Parse(txtBirthDate.Text) != _previouslySelectedEmployee.BirthDate
|| (cmbPost.SelectedItem != null && (cmbPost.SelectedItem as DbPost).Id != _previouslySelectedEmployee.PostID)
|| employeeImage.BackgroundImage != _previouslySelectedEmployee.Photography
)
{
if (MessageBox.Show(this, "Данные сотрудника были изменены. Сохранить?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
DbEmployee tempEmployee = new DbEmployee();
tempEmployee.ID = _previouslySelectedEmployee.ID;
tempEmployee.HumanID = _previouslySelectedEmployee.HumanID;
tempEmployee.Name = txtName.Text;
tempEmployee.Surname = txtSurname.Text;
tempEmployee.Patronymic = txtPatronymic.Text;
tempEmployee.Passport = txtPassport.Text;
tempEmployee.Photography = employeeImage.BackgroundImage as Bitmap;
tempEmployee.PostID = (cmbPost.SelectedItem as DbPost).Id;
DbHelper.AdminUpdateEmployeeInfo(tempEmployee);
lstEmploys.BeginUpdate();
_previouslySelectedEmployee.Name = txtName.Text;
_previouslySelectedEmployee.Surname = txtSurname.Text;
_previouslySelectedEmployee.Patronymic = txtPatronymic.Text;
_previouslySelectedEmployee.Passport = txtPassport.Text;
_previouslySelectedEmployee.Phone = txtPhone.Text;
//_previouslySelectedEmployee.PlacementDate = DateTime.Parse(txtPlacementDate.Text);
_previouslySelectedEmployee.BirthDate = DbHelper.ToDate(DateTime.Parse(txtBirthDate.Text));
_previouslySelectedEmployee.PostID = (cmbPost.SelectedItem as DbPost).Id;
_previouslySelectedEmployee.Photography = employeeImage.BackgroundImage as Bitmap;
lstEmploys.EndUpdate();
}
else
{
txtName.Text = _previouslySelectedEmployee.Name;
txtSurname.Text = _previouslySelectedEmployee.Surname;
txtPatronymic.Text = _previouslySelectedEmployee.Patronymic;
txtPassport.Text = _previouslySelectedEmployee.Passport;
txtPhone.Text = _previouslySelectedEmployee.Phone;
//txtPlacementDate.Text = _previouslySelectedEmployee.PlacementDate.ToString();
txtBirthDate.Text = _previouslySelectedEmployee.BirthDate.ToShortDateString();
cmbPost.SelectedIndex = GetPostIndex(_previouslySelectedEmployee.PostID);
employeeImage.BackgroundImage = _previouslySelectedEmployee.Photography;
}
}
}
catch (Exception excpt)
{
Program.ShowError(this, excpt);
}
}
private void lstEmploys_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstEmploys.SelectedIndices.Count < 1) return;
DbEmployee employee = _allDrawingEmploys[lstEmploys.SelectedIndices[0]];
PromptForSave();
txtName.Text = employee.Name;
txtSurname.Text = employee.Surname;
txtPatronymic.Text = employee.Patronymic;
txtPassport.Text = employee.Passport;
txtBirthDate.Text = employee.BirthDate.ToShortDateString();
txtPlacementDate.Text = employee.PlacementDate.ToString();
txtFired.Text = employee.FiredDate == null ? "еще работает...пока" : employee.FiredDate.Value.ToString();
txtPhone.Text = employee.Phone;
employeeImage.BackgroundImage = employee.Photography;
cmbPost.SelectedIndex = GetPostIndex(employee.PostID);
_previouslySelectedEmployee = employee;
}
private void EmployesForm_FormClosing(object sender, FormClosingEventArgs e)
{
PromptForSave();
}
private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
{
if (new AddEmployeeForm().ShowDialog(this) == DialogResult.OK)
RefreshData();
}
private void уволитьToolStripMenuItem_Click(object sender, EventArgs e)
{
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.