промежуточные
This commit is contained in:
parent
91e2483fef
commit
24146e1a05
25
EmployerForm/FormMain.Designer.cs
generated
25
EmployerForm/FormMain.Designer.cs
generated
@ -41,7 +41,7 @@
|
||||
excelTable = new KryukovLib.ExcelTable(components);
|
||||
pdfDiagram = new BarsukovComponents.NotVisualComponents.PdfDiagram(components);
|
||||
wordWithTable = new BelianinComponents.WordWithTable(components);
|
||||
listBoxMany1 = new KashinComponent.ListBoxMany();
|
||||
customListBox = new BarsukovComponents.VisualComponents.CustomListBox();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -52,7 +52,7 @@
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(5, 2, 0, 2);
|
||||
menuStrip.Size = new Size(514, 24);
|
||||
menuStrip.Size = new Size(724, 24);
|
||||
menuStrip.TabIndex = 1;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
@ -120,22 +120,21 @@
|
||||
directoryToolStripMenuItem.Text = "Directory";
|
||||
directoryToolStripMenuItem.Click += DirectoryToolStripMenuItem_Click;
|
||||
//
|
||||
// listBoxMany1
|
||||
// customListBox
|
||||
//
|
||||
listBoxMany1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
listBoxMany1.Dock = DockStyle.Fill;
|
||||
listBoxMany1.Location = new Point(0, 24);
|
||||
listBoxMany1.Name = "listBoxMany1";
|
||||
listBoxMany1.SelectedIndex = -1;
|
||||
listBoxMany1.Size = new Size(514, 406);
|
||||
listBoxMany1.TabIndex = 1;
|
||||
customListBox.Location = new Point(0, 26);
|
||||
customListBox.Margin = new Padding(3, 2, 3, 2);
|
||||
customListBox.Name = "customListBox";
|
||||
customListBox.SelectedRow = -1;
|
||||
customListBox.Size = new Size(724, 308);
|
||||
customListBox.TabIndex = 2;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(514, 430);
|
||||
Controls.Add(listBoxMany1);
|
||||
ClientSize = new Size(724, 323);
|
||||
Controls.Add(customListBox);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
@ -161,6 +160,6 @@
|
||||
private KryukovLib.ExcelTable excelTable;
|
||||
private BarsukovComponents.NotVisualComponents.PdfDiagram pdfDiagram;
|
||||
private BelianinComponents.WordWithTable wordWithTable;
|
||||
private KashinComponent.ListBoxMany listBoxMany1;
|
||||
private BarsukovComponents.VisualComponents.CustomListBox customListBox;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using KryukovLib;
|
||||
using Unity;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using KashinComponent;
|
||||
using BarsukovComponents.VisualComponents; // Assuming CustomListBox is in this namespace
|
||||
|
||||
namespace EmployerForm
|
||||
{
|
||||
@ -21,7 +22,6 @@ namespace EmployerForm
|
||||
_LogicS = logicS;
|
||||
}
|
||||
|
||||
|
||||
private void DropComponents()
|
||||
{
|
||||
Controls.Clear();
|
||||
@ -33,14 +33,17 @@ namespace EmployerForm
|
||||
try
|
||||
{
|
||||
DropComponents();
|
||||
listBoxMany1.SetLayout("{Subdivision} {Id} {Fio} {Experience}", "{", "}");
|
||||
|
||||
customListBox.setTemplate("{Subdivision} {Id} {Fio} {Experience}", "{", "}");
|
||||
|
||||
var list = _LogicE.Read(null) ?? throw new Exception("Error on read");
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
listBoxMany1.AddItemInList(list[i], i, j);
|
||||
customListBox.FillProperty(list[i], i, GetPropertyName(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50,6 +53,18 @@ namespace EmployerForm
|
||||
}
|
||||
}
|
||||
|
||||
private string GetPropertyName(int index)
|
||||
{
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case 0: return "Subdivision";
|
||||
case 1: return "Id";
|
||||
case 2: return "Fio";
|
||||
case 3: return "Experience";
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
@ -67,7 +82,7 @@ namespace EmployerForm
|
||||
|
||||
private void EditEmployerToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
var selectedEmployee = listBoxMany1.GetItemFromList<EmployeeViewModel>();
|
||||
var selectedEmployee = customListBox.GetObjectFromStr<EmployeeViewModel>();
|
||||
if (selectedEmployee == null)
|
||||
{
|
||||
MessageBox.Show("Please select an employee from the list.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
@ -85,7 +100,7 @@ namespace EmployerForm
|
||||
|
||||
private void DeleteEmployerToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
var selectedEmployee = listBoxMany1.GetItemFromList<EmployeeViewModel>();
|
||||
var selectedEmployee = customListBox.GetObjectFromStr<EmployeeViewModel>();
|
||||
if (selectedEmployee == null)
|
||||
{
|
||||
MessageBox.Show("Please select an employee from the list.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
@ -108,21 +123,18 @@ namespace EmployerForm
|
||||
|
||||
private void ExcelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Ïðîâåðêà èíèöèàëèçàöèè îáúåêòà _LogicE
|
||||
if (_LogicE == null)
|
||||
{
|
||||
MessageBox.Show("Ëîãèêà íå èíèöèàëèçèðîâàíà.", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Logic not initialized.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ïðîâåðêà èíèöèàëèçàöèè îáúåêòà excelTable
|
||||
if (excelTable == null)
|
||||
{
|
||||
MessageBox.Show("Îáúåêò äëÿ ðàáîòû ñ Excel íå èíèöèàëèçèðîâàí.", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Excel object not initialized.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Îòêðûòèå äèàëîãà äëÿ ñîõðàíåíèÿ ôàéëà
|
||||
string fileName = "";
|
||||
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
|
||||
{
|
||||
@ -133,61 +145,51 @@ namespace EmployerForm
|
||||
}
|
||||
}
|
||||
|
||||
// Ïîëó÷åíèå âûáðàííîãî ýëåìåíòà èç ñïèñêà
|
||||
var ent = listBoxMany1.GetItemFromList<EmployeeViewModel>();
|
||||
if (ent == null)
|
||||
var selectedEmployee = customListBox.GetObjectFromStr<EmployeeViewModel>();
|
||||
if (selectedEmployee == null)
|
||||
{
|
||||
MessageBox.Show("Âûáåðèòå ýëåìåíò èç ñïèñêà.", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Select an item from the list.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// ×òåíèå äàííûõ ñîòðóäíèêà
|
||||
var EmplList = _LogicE.Read(new EmployeeBindingModel { Id = ent.Id });
|
||||
if (EmplList == null || EmplList.Count == 0)
|
||||
var emplList = _LogicE.Read(new EmployeeBindingModel { Id = selectedEmployee.Id });
|
||||
if (emplList == null || emplList.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Íå óäàëîñü íàéòè ñîòðóäíèêà.", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Could not find employee.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var Empl = EmplList[0];
|
||||
var empl = emplList[0];
|
||||
|
||||
// Ïðîâåðêà íàëè÷èÿ äîëæíîñòåé ó ñîòðóäíèêà
|
||||
if (string.IsNullOrEmpty(Empl.Posts))
|
||||
if (string.IsNullOrEmpty(empl.Posts))
|
||||
{
|
||||
MessageBox.Show("Ó ñîòðóäíèêà íåò äîëæíîñòåé.", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
MessageBox.Show("No positions for the employee.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ñîçäàíèå è çàïîëíåíèå ìàññèâà Data
|
||||
var posts = Empl.Posts.Split(",");
|
||||
var Data = new string[1, Math.Min(posts.Length, 5)];
|
||||
for (int i = 0; i < Data.GetLength(1); i++)
|
||||
var posts = empl.Posts.Split(",");
|
||||
var data = new string[1, Math.Min(posts.Length, 5)];
|
||||
for (int i = 0; i < data.GetLength(1); i++)
|
||||
{
|
||||
Data[0, i] = posts[i];
|
||||
data[0, i] = posts[i];
|
||||
}
|
||||
|
||||
// Îáîðà÷èâàíèå Data â ñïèñîê äëÿ ñîâìåñòèìîñòè ñ TableConfig
|
||||
var dataList = new List<string[,]>() { Data };
|
||||
var dataList = new List<string[,]>() { data };
|
||||
|
||||
// Ïðîâåðêà âûáîðà ôàéëà
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
MessageBox.Show("Ôàéë íå âûáðàí.", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("File not selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ñîçäàíèå Excel äîêóìåíòà
|
||||
excelTable.CreateDoc(new KryukovLib.Models.TableConfig
|
||||
{
|
||||
FilePath = fileName,
|
||||
Header = "Example",
|
||||
Data = dataList // Ïåðåäà÷à â âèäå ñïèñêà
|
||||
Data = dataList
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void WordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
string fileName = "";
|
||||
@ -199,6 +201,7 @@ namespace EmployerForm
|
||||
MessageBox.Show("Success", "Ready", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
var list = _LogicE.Read(null);
|
||||
wordWithTable.CreateDoc(new WordWithTableDataConfig<EmployeeViewModel>
|
||||
{
|
||||
@ -234,7 +237,7 @@ namespace EmployerForm
|
||||
var listEmp = _LogicE.Read(null);
|
||||
var listSubd = _LogicS.Read(null);
|
||||
|
||||
var Data = new Dictionary<string, List<double>>();
|
||||
var data = new Dictionary<string, List<double>>();
|
||||
|
||||
foreach (var item in listSubd)
|
||||
{
|
||||
@ -246,13 +249,12 @@ namespace EmployerForm
|
||||
listSorted.Where(y => y.Experience >= 10 && y.Experience < 20).Count(),
|
||||
listSorted.Where(y => y.Experience >= 20 && y.Experience < 30).Count());
|
||||
|
||||
Data.Add(item.Name, new List<double> { x.Item1, x.Item2, x.Item3, x.Item4 });
|
||||
data.Add(item.Name, new List<double> { x.Item1, x.Item2, x.Item3, x.Item4 });
|
||||
}
|
||||
|
||||
pdfDiagram.CreateDiagram(fileName, "Chart", "Chart", Data);
|
||||
pdfDiagram.CreateDiagram(fileName, "Chart", "Chart", data);
|
||||
}
|
||||
|
||||
|
||||
private void DirectoryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = Program.Container.Resolve<Directory>();
|
||||
|
Loading…
Reference in New Issue
Block a user