2021-07-21 16:57:47 +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 WorkShtatForm : Form
|
|
|
|
|
{
|
|
|
|
|
public bool isCanceled = false;
|
|
|
|
|
private Shtat shtat = null;
|
2024-09-20 08:53:52 +05:00
|
|
|
|
|
2021-07-21 16:57:47 +05:00
|
|
|
|
public WorkShtatForm(Shtat shtat = null)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (shtat != null)
|
|
|
|
|
{
|
|
|
|
|
this.shtat = shtat;
|
|
|
|
|
workButton.Text = "Изменить";
|
|
|
|
|
doljBox.Text = shtat.Doljnost;
|
|
|
|
|
kolvoBox.Text = shtat.Size.ToString();
|
2024-09-20 08:53:52 +05:00
|
|
|
|
busySizeLabel.Text = "Занято: " + (shtat.Size - FuncDB.ShtatFreeSpaceById(shtat.Id));
|
|
|
|
|
busySizeLabel.Visible = true;
|
2021-07-21 16:57:47 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2024-09-20 08:53:52 +05:00
|
|
|
|
this.ShowError(errorLabel, e.Message);
|
2021-07-21 16:57:47 +05:00
|
|
|
|
workButton.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void workButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-09-20 08:53:52 +05:00
|
|
|
|
if (string.IsNullOrEmpty(doljBox.Text))
|
|
|
|
|
throw new Exception("Ошибка указания должности.");
|
|
|
|
|
if (!int.TryParse(kolvoBox.Text, out int kolvo))
|
|
|
|
|
throw new Exception("Ошибка указания количества.");
|
2021-07-21 16:57:47 +05:00
|
|
|
|
if (shtat == null)
|
|
|
|
|
{
|
|
|
|
|
var s = new Shtat() { Doljnost = doljBox.Text, Size = kolvo };
|
2024-09-20 08:53:52 +05:00
|
|
|
|
FuncDB.ShtatAdd(s);
|
2021-07-21 16:57:47 +05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
shtat.Doljnost = doljBox.Text;
|
|
|
|
|
shtat.Size = kolvo;
|
2024-09-20 08:53:52 +05:00
|
|
|
|
FuncDB.ShtatChange(shtat);
|
2021-07-21 16:57:47 +05:00
|
|
|
|
}
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
2024-09-20 08:53:52 +05:00
|
|
|
|
catch (Exception ex) { this.ShowError(errorLabel, ex.Message); }
|
2021-07-21 16:57:47 +05:00
|
|
|
|
}
|
|
|
|
|
private void canceledButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
isCanceled = true;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|