if (MessageBox.Show(this, "Вы действительно хотите уволить этого сотрудника?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return;
DbEmployee employee = _allDrawingEmploys[lstEmploys.SelectedIndices[0]];
try
{
DbHelper.FireEmployee(employee.ID);
lstEmploys.BeginUpdate();
employee.FiredDate = DbHelper.GetEmployeeInfo(employee.ID).FiredDate;
lstEmploys.EndUpdate();
}
catch (Exception excpt)
{
Program.ShowError(this, excpt);
}
}
private void showActive_CheckedChanged(object sender, EventArgs e)
{
PromptForSave();
RefreshData();
}
private void lstEmploys_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
if (lstEmploys.SelectedIndices.Count < 1)
{
уволитьToolStripMenuItem.Visible = false;
устроитьНаToolStripMenuItem.Visible = false;
сменитьУчетныеДанныеToolStripMenuItem.Visible = false;
}
else
{
DbEmployee employee = _allDrawingEmploys[lstEmploys.SelectedIndices[0]];
устроитьНаToolStripMenuItem.Visible = employee.FiredDate.HasValue;
сменитьУчетныеДанныеToolStripMenuItem.Visible = !employee.FiredDate.HasValue;
уволитьToolStripMenuItem.Visible = true;
уволитьToolStripMenuItem.Enabled = !employee.FiredDate.HasValue;
}
employeeAction.Show(lstEmploys.PointToScreen(e.Location));
}
}
private void устроитьНаРаботуToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show(this, "Вы действительно хотите принять этого сотрудника? Может все-таки не стоит?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return;
DbEmployee employee = _allDrawingEmploys[lstEmploys.SelectedIndices[0]];
try
{
DbHelper.RestoreEmployee(employee);
RefreshData();
}
catch (Exception excpt)
{
Program.ShowError(this, excpt);
}
}
private void EmployesForm_Shown(object sender, EventArgs e)
{
lstEmploys.Focus();
lstEmploys.Items[0].Selected = true;
lstEmploys_SelectedIndexChanged(lstEmploys, null);
}
private void сменитьУчетныеДанныеToolStripMenuItem_Click(object sender, EventArgs e)
{
new AssignAccountForm(_allDrawingEmploys[lstEmploys.SelectedIndices[0]]).ShowDialog(this);
}
int _employsAscSort = 1;
int _lastEmploysClickedColumn = -1;
private void lstEmploys_ColumnClick(object sender, ColumnClickEventArgs e)
{
lstEmploys.BeginUpdate();
if (_lastEmploysClickedColumn == e.Column) _employsAscSort = -_employsAscSort;
else _employsAscSort = 1;
switch (e.Column)
{
case 0: Array.Sort(_allDrawingEmploys, delegate(DbEmployee entry1, DbEmployee entry2) { return _employsAscSort * entry1.Surname.CompareTo(entry2.Surname); }); break;
}
lstEmploys.EndUpdate();
_lastEmploysClickedColumn = e.Column;
}
}
}
Класс привязки к БД.
namespace MentalHospital
{
public delegate void StatementExecutedDelegate(int statementIndex, int statementsTotal);
public class DbHelper
{
public const string AdminName = "MENTAL_HOSPITAL_ADMIN";
public const string UserName = "MENTAL_HOSPITAL_USER";
public const string PublicName = "MENTAL_HOSPITAL_PUBLIC";
/// <summary>
/// Информация о сервере БД с которым работаем
/// </summary>
public static ServerInfo ServerInfo = new ServerInfo();
public static string DBLogin = PublicName;
public static string DBPassword = "";
public static DbEmployee CurrentUser = null;
public static event StatementExecutedDelegate StatementExecuted = delegate { };
public static OracleConnection GetConnection()
{
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.