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