Work with Chel

This commit is contained in:
Georgy Khatuncev 2021-07-23 16:44:42 +05:00
parent 72593767df
commit 4922109f92
18 changed files with 772 additions and 81 deletions

Binary file not shown.

@ -32,10 +32,10 @@ namespace Diplom_O.DataBase
{ {
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; } public int Id { get; set; }
[ForeignKey("Dogovor")] [ForeignKey("Chel")]
public int ChelId { get; set; } public int ChelId { get; set; }
public Chel Chel { get; set; } public Chel Chel { get; set; }
[ForeignKey("Dogovor")] [ForeignKey("Shtat")]
public int ShtatId { get; set; } public int ShtatId { get; set; }
public Shtat Shtat { get; set; } public Shtat Shtat { get; set; }

@ -47,7 +47,7 @@ namespace Diplom_O.DataBase
where a.Doljnost.ToLower().Contains(f) && a.Active where a.Doljnost.ToLower().Contains(f) && a.Active
select a).ToArray(); select a).ToArray();
var res = new List<(Shtat shtat, int ost)>(); var res = new List<(Shtat shtat, int ost)>();
for(var i = 0; i < shtat.Length; i++) for (var i = 0; i < shtat.Length; i++)
res.Add((shtat[i], shtat[i].Size - BusySizeShtat(shtat[i].Id))); res.Add((shtat[i], shtat[i].Size - BusySizeShtat(shtat[i].Id)));
return res.ToArray(); return res.ToArray();
} }
@ -129,5 +129,61 @@ namespace Diplom_O.DataBase
} }
catch { throw; } catch { throw; }
} }
public static Chel GetChel(int id)
{
try
{
using (var db = new MainDB())
{
var res = from a in db.Chely
where a.Id == id
select a;
try { return res.Single(); }
catch { return null; }
}
}
catch { throw; }
}
public static Chel[] ListChel(string filter = null)
{
try
{
using (var db = new MainDB())
{
var f = (string.IsNullOrEmpty(filter)) ? "" : filter.ToLower();
return (string.IsNullOrEmpty(f)) ?
(from a in db.Chely
select a).ToArray() :
(from a in db.Chely
where
a.FName.ToLower().Contains(f) ||
a.SName.ToLower().Contains(f) ||
a.TName.ToLower().Contains(f) ||
a.Birthday.ToString("yyyy.MM.dd").ToLower().Contains(f) ||
a.Address.ToLower().Contains(f) ||
a.INN.ToLower().Contains(f) ||
a.SNILS.ToLower().Contains(f) ||
a.Pasport.ToLower().Contains(f)
select a).ToArray();
}
}
catch { throw; }
}
public static bool HaveChelFromRabotniky(int id, bool all=false)
{
try
{
using (var db = new MainDB())
{
var res = (from a in db.Rabotniky
where a.ChelId == id && (all || !a.End.HasValue)
select a).ToArray();
return res.Length > 0;
}
}
catch { throw; }
}
} }
} }

@ -283,6 +283,12 @@
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SupportForms\WorkChelForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SupportForms\WorkChelForm.Designer.cs">
<DependentUpon>WorkChelForm.cs</DependentUpon>
</Compile>
<Compile Include="SupportForms\WorkShtatForm.cs"> <Compile Include="SupportForms\WorkShtatForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -304,6 +310,9 @@
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<EmbeddedResource Include="SupportForms\WorkChelForm.resx">
<DependentUpon>WorkChelForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SupportForms\WorkShtatForm.resx"> <EmbeddedResource Include="SupportForms\WorkShtatForm.resx">
<DependentUpon>WorkShtatForm.cs</DependentUpon> <DependentUpon>WorkShtatForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

@ -36,18 +36,28 @@ namespace Diplom_O
this.chelRodMI = new System.Windows.Forms.ToolStripMenuItem(); this.chelRodMI = new System.Windows.Forms.ToolStripMenuItem();
this.errorLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.errorLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.shtatGridView = new System.Windows.Forms.DataGridView(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.delRodButton = new System.Windows.Forms.Button();
this.changeRodButton = new System.Windows.Forms.Button();
this.addRodButton = new System.Windows.Forms.Button();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.rodGridView = new System.Windows.Forms.DataGridView();
this.chelGridView = new System.Windows.Forms.DataGridView();
this.selectButton = new System.Windows.Forms.Button(); this.selectButton = new System.Windows.Forms.Button();
this.delButton = new System.Windows.Forms.Button(); this.delButton = new System.Windows.Forms.Button();
this.changeButton = new System.Windows.Forms.Button(); this.changeButton = new System.Windows.Forms.Button();
this.addButton = new System.Windows.Forms.Button(); this.addButton = new System.Windows.Forms.Button();
this.freeShtatCheckBox = new System.Windows.Forms.CheckBox(); this.showWorkerCheckBox = new System.Windows.Forms.CheckBox();
this.dropFindButton = new System.Windows.Forms.Button(); this.dropFindButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.findBox = new System.Windows.Forms.TextBox(); this.findBox = new System.Windows.Forms.TextBox();
this.menuStrip.SuspendLayout(); this.menuStrip.SuspendLayout();
this.statusStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.shtatGridView)).BeginInit(); this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.rodGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.chelGridView)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// menuStrip // menuStrip
@ -59,7 +69,7 @@ namespace Diplom_O
this.chelRodMI}); this.chelRodMI});
this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip"; this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1055, 24); this.menuStrip.Size = new System.Drawing.Size(1102, 24);
this.menuStrip.TabIndex = 1; this.menuStrip.TabIndex = 1;
this.menuStrip.Text = "menuStrip1"; this.menuStrip.Text = "menuStrip1";
// //
@ -102,123 +112,225 @@ namespace Diplom_O
this.errorLabel}); this.errorLabel});
this.statusStrip1.Location = new System.Drawing.Point(0, 545); this.statusStrip1.Location = new System.Drawing.Point(0, 545);
this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(1055, 22); this.statusStrip1.Size = new System.Drawing.Size(1102, 22);
this.statusStrip1.TabIndex = 16; this.statusStrip1.TabIndex = 16;
this.statusStrip1.Text = "statusStrip1"; this.statusStrip1.Text = "statusStrip1";
// //
// shtatGridView // groupBox1
// //
this.shtatGridView.AllowUserToAddRows = false; this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.shtatGridView.AllowUserToDeleteRows = false;
this.shtatGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.shtatGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.groupBox1.Controls.Add(this.rodGridView);
this.shtatGridView.Location = new System.Drawing.Point(12, 112); this.groupBox1.Controls.Add(this.comboBox1);
this.shtatGridView.MultiSelect = false; this.groupBox1.Controls.Add(this.linkLabel1);
this.shtatGridView.Name = "shtatGridView"; this.groupBox1.Controls.Add(this.delRodButton);
this.shtatGridView.ReadOnly = true; this.groupBox1.Controls.Add(this.button1);
this.shtatGridView.RowHeadersVisible = false; this.groupBox1.Controls.Add(this.changeRodButton);
this.shtatGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.groupBox1.Controls.Add(this.addRodButton);
this.shtatGridView.Size = new System.Drawing.Size(318, 430); this.groupBox1.Location = new System.Drawing.Point(760, 27);
this.shtatGridView.TabIndex = 25; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(330, 515);
this.groupBox1.TabIndex = 26;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Родственники";
//
// button1
//
this.button1.Location = new System.Drawing.Point(6, 19);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(25, 23);
this.button1.TabIndex = 27;
this.button1.Text = "...";
this.button1.UseVisualStyleBackColor = true;
//
// delRodButton
//
this.delRodButton.Location = new System.Drawing.Point(168, 56);
this.delRodButton.Name = "delRodButton";
this.delRodButton.Size = new System.Drawing.Size(75, 23);
this.delRodButton.TabIndex = 29;
this.delRodButton.Text = "Удалить";
this.delRodButton.UseVisualStyleBackColor = true;
//
// changeRodButton
//
this.changeRodButton.Location = new System.Drawing.Point(87, 56);
this.changeRodButton.Name = "changeRodButton";
this.changeRodButton.Size = new System.Drawing.Size(75, 23);
this.changeRodButton.TabIndex = 28;
this.changeRodButton.Text = "Изменить";
this.changeRodButton.UseVisualStyleBackColor = true;
//
// addRodButton
//
this.addRodButton.Location = new System.Drawing.Point(6, 56);
this.addRodButton.Name = "addRodButton";
this.addRodButton.Size = new System.Drawing.Size(75, 23);
this.addRodButton.TabIndex = 27;
this.addRodButton.Text = "Добавить";
this.addRodButton.UseVisualStyleBackColor = true;
//
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(37, 24);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(81, 13);
this.linkLabel1.TabIndex = 30;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "Фамилия И.О.";
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"Родственная связь"});
this.comboBox1.Location = new System.Drawing.Point(168, 21);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(156, 21);
this.comboBox1.TabIndex = 31;
//
// rodGridView
//
this.rodGridView.AllowUserToAddRows = false;
this.rodGridView.AllowUserToDeleteRows = false;
this.rodGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.rodGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.rodGridView.Location = new System.Drawing.Point(6, 85);
this.rodGridView.MultiSelect = false;
this.rodGridView.Name = "rodGridView";
this.rodGridView.ReadOnly = true;
this.rodGridView.RowHeadersVisible = false;
this.rodGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.rodGridView.Size = new System.Drawing.Size(318, 424);
this.rodGridView.TabIndex = 32;
//
// chelGridView
//
this.chelGridView.AllowUserToAddRows = false;
this.chelGridView.AllowUserToDeleteRows = false;
this.chelGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.chelGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.chelGridView.Location = new System.Drawing.Point(12, 79);
this.chelGridView.MultiSelect = false;
this.chelGridView.Name = "chelGridView";
this.chelGridView.ReadOnly = true;
this.chelGridView.RowHeadersVisible = false;
this.chelGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.chelGridView.Size = new System.Drawing.Size(742, 434);
this.chelGridView.TabIndex = 35;
// //
// selectButton // selectButton
// //
this.selectButton.Location = new System.Drawing.Point(255, 83); this.selectButton.Location = new System.Drawing.Point(12, 27);
this.selectButton.Name = "selectButton"; this.selectButton.Name = "selectButton";
this.selectButton.Size = new System.Drawing.Size(75, 23); this.selectButton.Size = new System.Drawing.Size(75, 23);
this.selectButton.TabIndex = 24; this.selectButton.TabIndex = 34;
this.selectButton.Text = "Выбрать"; this.selectButton.Text = "Выбрать";
this.selectButton.UseVisualStyleBackColor = true; this.selectButton.UseVisualStyleBackColor = true;
this.selectButton.Visible = false;
// //
// delButton // delButton
// //
this.delButton.Location = new System.Drawing.Point(174, 83); this.delButton.Location = new System.Drawing.Point(255, 27);
this.delButton.Name = "delButton"; this.delButton.Name = "delButton";
this.delButton.Size = new System.Drawing.Size(75, 23); this.delButton.Size = new System.Drawing.Size(75, 23);
this.delButton.TabIndex = 23; this.delButton.TabIndex = 33;
this.delButton.Text = "Удалить"; this.delButton.Text = "Удалить";
this.delButton.UseVisualStyleBackColor = true; this.delButton.UseVisualStyleBackColor = true;
// //
// changeButton // changeButton
// //
this.changeButton.Location = new System.Drawing.Point(93, 83); this.changeButton.Location = new System.Drawing.Point(174, 27);
this.changeButton.Name = "changeButton"; this.changeButton.Name = "changeButton";
this.changeButton.Size = new System.Drawing.Size(75, 23); this.changeButton.Size = new System.Drawing.Size(75, 23);
this.changeButton.TabIndex = 22; this.changeButton.TabIndex = 32;
this.changeButton.Text = "Изменить"; this.changeButton.Text = "Изменить";
this.changeButton.UseVisualStyleBackColor = true; this.changeButton.UseVisualStyleBackColor = true;
// //
// addButton // addButton
// //
this.addButton.Location = new System.Drawing.Point(12, 83); this.addButton.Location = new System.Drawing.Point(93, 27);
this.addButton.Name = "addButton"; this.addButton.Name = "addButton";
this.addButton.Size = new System.Drawing.Size(75, 23); this.addButton.Size = new System.Drawing.Size(75, 23);
this.addButton.TabIndex = 21; this.addButton.TabIndex = 31;
this.addButton.Text = "Добавить"; this.addButton.Text = "Добавить";
this.addButton.UseVisualStyleBackColor = true; this.addButton.UseVisualStyleBackColor = true;
// //
// freeShtatCheckBox // showWorkerCheckBox
// //
this.freeShtatCheckBox.AutoSize = true; this.showWorkerCheckBox.AutoSize = true;
this.freeShtatCheckBox.Checked = true; this.showWorkerCheckBox.Checked = true;
this.freeShtatCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; this.showWorkerCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.freeShtatCheckBox.Location = new System.Drawing.Point(15, 58); this.showWorkerCheckBox.Location = new System.Drawing.Point(12, 56);
this.freeShtatCheckBox.Name = "freeShtatCheckBox"; this.showWorkerCheckBox.Name = "showWorkerCheckBox";
this.freeShtatCheckBox.Size = new System.Drawing.Size(218, 17); this.showWorkerCheckBox.Size = new System.Drawing.Size(204, 17);
this.freeShtatCheckBox.TabIndex = 20; this.showWorkerCheckBox.TabIndex = 30;
this.freeShtatCheckBox.Text = оrазать/скрыть занятые должности"; this.showWorkerCheckBox.Text = оrазать/скрыть трудоустроенных";
this.freeShtatCheckBox.UseVisualStyleBackColor = true; this.showWorkerCheckBox.UseVisualStyleBackColor = true;
// //
// dropFindButton // dropFindButton
// //
this.dropFindButton.Location = new System.Drawing.Point(255, 25); this.dropFindButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.dropFindButton.Location = new System.Drawing.Point(679, 519);
this.dropFindButton.Name = "dropFindButton"; this.dropFindButton.Name = "dropFindButton";
this.dropFindButton.Size = new System.Drawing.Size(75, 23); this.dropFindButton.Size = new System.Drawing.Size(75, 23);
this.dropFindButton.TabIndex = 19; this.dropFindButton.TabIndex = 29;
this.dropFindButton.Text = "Сбросить"; this.dropFindButton.Text = "Сбросить";
this.dropFindButton.UseVisualStyleBackColor = true; this.dropFindButton.UseVisualStyleBackColor = true;
// //
// label1 // label1
// //
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 30); this.label1.Location = new System.Drawing.Point(12, 524);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(39, 13); this.label1.Size = new System.Drawing.Size(39, 13);
this.label1.TabIndex = 18; this.label1.TabIndex = 28;
this.label1.Text = "Поиск"; this.label1.Text = "Поиск";
// //
// findBox // findBox
// //
this.findBox.Location = new System.Drawing.Point(57, 27); this.findBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.findBox.Location = new System.Drawing.Point(57, 521);
this.findBox.Name = "findBox"; this.findBox.Name = "findBox";
this.findBox.Size = new System.Drawing.Size(192, 20); this.findBox.Size = new System.Drawing.Size(616, 20);
this.findBox.TabIndex = 17; this.findBox.TabIndex = 27;
// //
// ChelForm // ChelForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1055, 567); this.ClientSize = new System.Drawing.Size(1102, 567);
this.Controls.Add(this.shtatGridView); this.Controls.Add(this.chelGridView);
this.Controls.Add(this.selectButton); this.Controls.Add(this.selectButton);
this.Controls.Add(this.delButton); this.Controls.Add(this.delButton);
this.Controls.Add(this.changeButton); this.Controls.Add(this.changeButton);
this.Controls.Add(this.addButton); this.Controls.Add(this.addButton);
this.Controls.Add(this.freeShtatCheckBox); this.Controls.Add(this.showWorkerCheckBox);
this.Controls.Add(this.dropFindButton); this.Controls.Add(this.dropFindButton);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.findBox); this.Controls.Add(this.findBox);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.statusStrip1); this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.menuStrip); this.Controls.Add(this.menuStrip);
this.Name = "ChelForm"; this.Name = "ChelForm";
this.Text = "ChelForm"; this.Text = "Люди / Родственники";
this.menuStrip.ResumeLayout(false); this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout(); this.menuStrip.PerformLayout();
this.statusStrip1.ResumeLayout(false); this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout(); this.statusStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.shtatGridView)).EndInit(); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.rodGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.chelGridView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -233,12 +345,20 @@ namespace Diplom_O
private System.Windows.Forms.ToolStripMenuItem chelRodMI; private System.Windows.Forms.ToolStripMenuItem chelRodMI;
private System.Windows.Forms.ToolStripStatusLabel errorLabel; private System.Windows.Forms.ToolStripStatusLabel errorLabel;
private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.DataGridView shtatGridView; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.DataGridView rodGridView;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.Button delRodButton;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button changeRodButton;
private System.Windows.Forms.Button addRodButton;
private System.Windows.Forms.DataGridView chelGridView;
private System.Windows.Forms.Button selectButton; private System.Windows.Forms.Button selectButton;
private System.Windows.Forms.Button delButton; private System.Windows.Forms.Button delButton;
private System.Windows.Forms.Button changeButton; private System.Windows.Forms.Button changeButton;
private System.Windows.Forms.Button addButton; private System.Windows.Forms.Button addButton;
private System.Windows.Forms.CheckBox freeShtatCheckBox; private System.Windows.Forms.CheckBox showWorkerCheckBox;
private System.Windows.Forms.Button dropFindButton; private System.Windows.Forms.Button dropFindButton;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox findBox; private System.Windows.Forms.TextBox findBox;

@ -1,4 +1,5 @@
using System; using Diplom_O.DataBase;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -12,39 +13,174 @@ namespace Diplom_O
{ {
public partial class ChelForm : Form public partial class ChelForm : Form
{ {
public ChelForm() private Task errDrop;
private void ShowError(string msg = null)
{ {
InitializeComponent(); errorLabel.Text = string.IsNullOrEmpty(msg) ? "Неизвестная ошибка." : msg;
errorLabel.Visible = true;
errDrop = new Task(() =>
{
var fd = errDrop.Id;
Task.Delay(5000).Wait();
if (errDrop.Id == fd)
if (InvokeRequired) Invoke((Action)(() => { errorLabel.Visible = false; }));
else errorLabel.Visible = false;
});
errDrop.Start();
} }
private void delButton_Click(object sender, EventArgs e) private Task filterDrop;
private void findBox_TextChanged(object sender, EventArgs e)
{ {
filterDrop = new Task(() =>
} {
var fd = filterDrop.Id;
private void changeButton_Click(object sender, EventArgs e) Task.Delay(1000).Wait();
{ if (filterDrop.Id == fd)
if (InvokeRequired) Invoke((Action)(() => { resetShatTable(); }));
} else resetShatTable();
});
private void addButton_Click(object sender, EventArgs e) filterDrop.Start();
{
}
private void freeShtatCheckBox_CheckedChanged(object sender, EventArgs e)
{
} }
private void dropFindButton_Click(object sender, EventArgs e) private void dropFindButton_Click(object sender, EventArgs e)
{ {
findBox.Text = "";
filterDrop = new Task(() => { return; });
resetShatTable();
} }
private void findBox_TextChanged(object sender, EventArgs e) private void resetChelTable()
{ {
try
{
{
chelGridView.Rows.Clear();
chelGridView.Columns.Clear();
var c = chelGridView.Columns;
c.Add("Id", "№");
c.Add("FIO", "Должность");
c.Add("Male", "Пол");
c.Add("Birthday", "Дата рождения");
c.Add("Adress", "Адрес");
c.Add("INN", "ИНН");
c.Add("SNILS", "СНИЛС");
c.Add("Pasport", "Паспорт");
c[0].Width = 40;
c[1].Width = 120;
c[2].Width = 40;
c[3].Width = 40;
c[4].Width = 120;
c[5].Width = 40;
c[6].Width = 40;
c[7].Width = 120;
c[4].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
c[7].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
}
{
var arr = FuncDB.ListChel(findBox.Text);
var r = chelGridView.Rows;
foreach (var chel in arr)
if (showWorkerCheckBox.Checked || !FuncDB.HaveChelFromRabotniky(chel.Id))
r.Add(new object[] {
chel.Id,
chel.FName +
(string.IsNullOrEmpty(chel.SName) ? "" : (" " + chel.SName[0] + ".")) +
(string.IsNullOrEmpty(chel.TName) ? "" : (" " + chel.TName[0] + ".")),
chel.Male ? "Муж" : "Жен",
chel.Birthday.ToString("yyyy.MM.dd"),
chel.Address,
chel.INN,
chel.SNILS,
chel.Pasport
});
}
if (chelGridView.Rows.Count > 0)
chelGridView.Rows[0].Selected = true;
}
catch (Exception e) { ShowError(e.Message); }
}
private Chel selectedChel()
{
try
{
if (chelGridView.SelectedRows.Count != 1) throw new Exception("Человек не выбран.");
var chel = FuncDB.GetChel((int)chelGridView.SelectedRows[0].Cells[0].Value);
return chel;
}
catch (Exception e) { ShowError(e.Message); return null; }
}
public Shtat formResult = null;
public ChelForm(bool select = false)
{
try
{
InitializeComponent();
Init(select);
resetChelTable();
}
catch { this.Close(); }
}
public void Init(bool s)
{
if (s) selectButton.Visible = true;
chelRodMI.Enabled = false;
}
private void addButton_Click(object sender, EventArgs e)
{
var res = new SupportForms.WorkChelForm();
res.ShowDialog();
if (!res.isCanceled)
resetChelTable();
}
private void changeButton_Click(object sender, EventArgs e)
{
var chel = selectedChel();
if (chel == null) { ShowError("Человек не выбран."); return; }
var res = new SupportForms.WorkChelForm(chel);
res.ShowDialog();
if (!res.isCanceled)
resetChelTable();
}
private void delButton_Click(object sender, EventArgs e)
{
var chel = selectedChel();
if (chel == null) { ShowError("Человек не выбран."); return; }
try
{
FuncDB.DelChel(chel);
resetChelTable();
}
catch (Exception ex) { ShowError(ex.Message); }
}
public void MI_Click(object sender, EventArgs e)
{
object form = null;
var idxMenu = -1;
try { idxMenu = menuStrip.Items.IndexOf((ToolStripMenuItem)sender); }
catch { };
switch (idxMenu)
{
case 0: form = new ShtatForm(); break;
case 1: form = new RabForm(); break;
case 2: form = new OtpForm(); break;
case 3: form = new ChelForm(); break;
}
if (form != null)
{
this.Hide();
((Form)form).Closed += (s, args) => this.Close();
((Form)form).Show();
return;
}
ShowError("Ошибка перехода на новую форму.");
}
private void checkBox_CheckedChanged(object sender, EventArgs e)
{
resetChelTable();
} }
} }
} }

@ -123,4 +123,7 @@
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>248, 17</value> <value>248, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>58</value>
</metadata>
</root> </root>

@ -133,11 +133,11 @@ namespace Diplom_O
this.freeShtatCheckBox.TabIndex = 6; this.freeShtatCheckBox.TabIndex = 6;
this.freeShtatCheckBox.Text = оrазать/скрыть занятые должности"; this.freeShtatCheckBox.Text = оrазать/скрыть занятые должности";
this.freeShtatCheckBox.UseVisualStyleBackColor = true; this.freeShtatCheckBox.UseVisualStyleBackColor = true;
this.freeShtatCheckBox.CheckedChanged += new System.EventHandler(this.freeShtatCheckBox_CheckedChanged); this.freeShtatCheckBox.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);
// //
// addButton // addButton
// //
this.addButton.Location = new System.Drawing.Point(12, 27); this.addButton.Location = new System.Drawing.Point(93, 27);
this.addButton.Name = "addButton"; this.addButton.Name = "addButton";
this.addButton.Size = new System.Drawing.Size(75, 23); this.addButton.Size = new System.Drawing.Size(75, 23);
this.addButton.TabIndex = 7; this.addButton.TabIndex = 7;
@ -147,7 +147,7 @@ namespace Diplom_O
// //
// changeButton // changeButton
// //
this.changeButton.Location = new System.Drawing.Point(93, 27); this.changeButton.Location = new System.Drawing.Point(174, 27);
this.changeButton.Name = "changeButton"; this.changeButton.Name = "changeButton";
this.changeButton.Size = new System.Drawing.Size(75, 23); this.changeButton.Size = new System.Drawing.Size(75, 23);
this.changeButton.TabIndex = 8; this.changeButton.TabIndex = 8;
@ -157,7 +157,7 @@ namespace Diplom_O
// //
// delButton // delButton
// //
this.delButton.Location = new System.Drawing.Point(174, 27); this.delButton.Location = new System.Drawing.Point(255, 27);
this.delButton.Name = "delButton"; this.delButton.Name = "delButton";
this.delButton.Size = new System.Drawing.Size(75, 23); this.delButton.Size = new System.Drawing.Size(75, 23);
this.delButton.TabIndex = 9; this.delButton.TabIndex = 9;
@ -167,7 +167,7 @@ namespace Diplom_O
// //
// selectButton // selectButton
// //
this.selectButton.Location = new System.Drawing.Point(255, 27); this.selectButton.Location = new System.Drawing.Point(12, 27);
this.selectButton.Name = "selectButton"; this.selectButton.Name = "selectButton";
this.selectButton.Size = new System.Drawing.Size(75, 23); this.selectButton.Size = new System.Drawing.Size(75, 23);
this.selectButton.TabIndex = 13; this.selectButton.TabIndex = 13;

@ -161,7 +161,7 @@ namespace Diplom_O
ShowError("Ошибка перехода на новую форму."); ShowError("Ошибка перехода на новую форму.");
} }
private void freeShtatCheckBox_CheckedChanged(object sender, EventArgs e) private void checkBox_CheckedChanged(object sender, EventArgs e)
{ {
resetShatTable(); resetShatTable();
} }

160
SupportForms/WorkChelForm.Designer.cs generated Normal file

@ -0,0 +1,160 @@

namespace Diplom_O.SupportForms
{
partial class WorkChelForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.doljBox = new System.Windows.Forms.TextBox();
this.kolvoBox = new System.Windows.Forms.TextBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.errorLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.workButton = new System.Windows.Forms.Button();
this.canceledButton = new System.Windows.Forms.Button();
this.busySizeLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// doljBox
//
this.doljBox.Location = new System.Drawing.Point(87, 12);
this.doljBox.Name = "doljBox";
this.doljBox.Size = new System.Drawing.Size(162, 20);
this.doljBox.TabIndex = 0;
//
// kolvoBox
//
this.kolvoBox.Location = new System.Drawing.Point(87, 38);
this.kolvoBox.Name = "kolvoBox";
this.kolvoBox.Size = new System.Drawing.Size(162, 20);
this.kolvoBox.TabIndex = 1;
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.errorLabel,
this.busySizeLabel});
this.statusStrip1.Location = new System.Drawing.Point(0, 90);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(262, 22);
this.statusStrip1.TabIndex = 2;
this.statusStrip1.Text = "statusStrip1";
//
// errorLabel
//
this.errorLabel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold);
this.errorLabel.ForeColor = System.Drawing.Color.Red;
this.errorLabel.Name = "errorLabel";
this.errorLabel.Size = new System.Drawing.Size(57, 17);
this.errorLabel.Text = "Ошибка.";
this.errorLabel.Visible = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Должность";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 41);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(69, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Кол-во мест";
//
// workButton
//
this.workButton.Location = new System.Drawing.Point(175, 64);
this.workButton.Name = "workButton";
this.workButton.Size = new System.Drawing.Size(75, 23);
this.workButton.TabIndex = 5;
this.workButton.Text = "Добавить";
this.workButton.UseVisualStyleBackColor = true;
this.workButton.Click += new System.EventHandler(this.workButton_Click);
//
// canceledButton
//
this.canceledButton.Location = new System.Drawing.Point(94, 64);
this.canceledButton.Name = "canceledButton";
this.canceledButton.Size = new System.Drawing.Size(75, 23);
this.canceledButton.TabIndex = 6;
this.canceledButton.Text = "Отмена";
this.canceledButton.UseVisualStyleBackColor = true;
this.canceledButton.Click += new System.EventHandler(this.canceledButton_Click);
//
// busySizeLabel
//
this.busySizeLabel.Name = "busySizeLabel";
this.busySizeLabel.Size = new System.Drawing.Size(51, 17);
this.busySizeLabel.Text = "Занято: ";
this.busySizeLabel.Visible = false;
//
// WorkShtatForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(262, 112);
this.ControlBox = false;
this.Controls.Add(this.canceledButton);
this.Controls.Add(this.workButton);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.kolvoBox);
this.Controls.Add(this.doljBox);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "WorkShtatForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Штатное место";
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox doljBox;
private System.Windows.Forms.TextBox kolvoBox;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel errorLabel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button workButton;
private System.Windows.Forms.Button canceledButton;
private System.Windows.Forms.ToolStripStatusLabel busySizeLabel;
}
}

@ -0,0 +1,81 @@
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
{
private Task errDrop;
private void ShowError(string msg = null)
{
errorLabel.Text = string.IsNullOrEmpty(msg) ? "Неизвестная ошибка." : msg;
errorLabel.Visible = true;
errDrop = new Task(() =>
{
var fd = errDrop.Id;
Task.Delay(5000).Wait();
if (errDrop.Id == fd)
if (InvokeRequired) Invoke((Action)(() => { errorLabel.Visible = false; }));
else errorLabel.Visible = false;
});
errDrop.Start();
}
public bool isCanceled = false;
private Chel chel = null;
public WorkChelForm(Chel chel = null)
{
InitializeComponent();
try
{
if (shtat != null)
{
this.shtat = shtat;
workButton.Text = "Изменить";
doljBox.Text = shtat.Doljnost;
kolvoBox.Text = shtat.Size.ToString();
busySizeLabel.Text = "Занято: " + FuncDB.BusySizeShtat(shtat.Id);
}
}
catch (Exception e)
{
ShowError(e.Message);
workButton.Enabled = false;
}
}
private void workButton_Click(object sender, EventArgs e)
{
try
{
if (!int.TryParse(kolvoBox.Text, out int kolvo)) throw new Exception("Ошибка указания количества.");
if (shtat == null)
{
var s = new Shtat() { Doljnost = doljBox.Text, Size = kolvo };
FuncDB.AddShtat(s);
}
else
{
shtat.Doljnost = doljBox.Text;
shtat.Size = kolvo;
FuncDB.ChangeShtat(shtat);
}
this.Close();
}
catch (Exception ex) { ShowError(ex.Message); }
}
private void canceledButton_Click(object sender, EventArgs e)
{
isCanceled = true;
this.Close();
}
}
}

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.