Вроде теперь точно всё

This commit is contained in:
Ismailov_Rovshan 2023-11-16 02:01:56 +04:00
parent a68eabe9c7
commit 66df1c294a
3 changed files with 36 additions and 34 deletions

View File

@ -40,9 +40,9 @@ namespace WinForms
this.сохранитьВПдфToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.сохранитьВПдфToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.статусыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.статусыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wordText1 = new VisualCompLib.Components.WordText(this.components); this.wordText1 = new VisualCompLib.Components.WordText(this.components);
this.excelChart1 = new Lab2.ChartComponent(this.components); this.excelChart1 = new UnvisableComponents.ExcelChart(this.components);
this.componentDocumentWithTableMultiHeaderPdf1 = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf(this.components); this.componentDocumentWithTableMultiHeaderPdf1 = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf(this.components);
this.myTreeView1 = new kop.components.TreeClassView(); this.myTreeView1 = new VisableComponents.MyTreeView();
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -58,7 +58,7 @@ namespace WinForms
this.сохранитьВПдфToolStripMenuItem, this.сохранитьВПдфToolStripMenuItem,
this.статусыToolStripMenuItem}); this.статусыToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(267, 172); this.contextMenuStrip1.Size = new System.Drawing.Size(255, 200);
// //
// добавитьToolStripMenuItem // добавитьToolStripMenuItem
// //
@ -89,23 +89,23 @@ namespace WinForms
this.сохранитьВВордToolStripMenuItem.Name = "сохранитьВВордToolStripMenuItem"; this.сохранитьВВордToolStripMenuItem.Name = "сохранитьВВордToolStripMenuItem";
this.сохранитьВВордToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); this.сохранитьВВордToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.сохранитьВВордToolStripMenuItem.Size = new System.Drawing.Size(266, 24); this.сохранитьВВордToolStripMenuItem.Size = new System.Drawing.Size(266, 24);
this.сохранитьВВордToolStripMenuItem.Text = "Сохранить в Ворд"; this.сохранитьВВордToolStripMenuItem.Text = "Сохранить в Word";
this.сохранитьВВордToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВВордToolStripMenuItem_Click); this.сохранитьВВордToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВВордToolStripMenuItem_Click);
// //
// сохранитьВЭксельToolStripMenuItem // сохранитьВЭксельToolStripMenuItem
// //
this.сохранитьВЭксельToolStripMenuItem.Name = "сохранитьВЭксельToolStripMenuItem"; this.сохранитьВЭксельToolStripMenuItem.Name = "сохранитьВЭксельToolStripMenuItem";
this.сохранитьВЭксельToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); this.сохранитьВЭксельToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this.сохранитьВЭксельToolStripMenuItem.Size = new System.Drawing.Size(266, 24); this.сохранитьВЭксельToolStripMenuItem.Size = new System.Drawing.Size(254, 24);
this.сохранитьВЭксельToolStripMenuItem.Text = "Сохранить в Эксель"; this.сохранитьВЭксельToolStripMenuItem.Text = "Сохранить в Exel";
this.сохранитьВЭксельToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВЭксельToolStripMenuItem_Click); this.сохранитьВЭксельToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВЭксельToolStripMenuItem_Click);
// //
// сохранитьВПдфToolStripMenuItem // сохранитьВПдфToolStripMenuItem
// //
this.сохранитьВПдфToolStripMenuItem.Name = "сохранитьВПдфToolStripMenuItem"; this.сохранитьВПдфToolStripMenuItem.Name = "сохранитьВПдфToolStripMenuItem";
this.сохранитьВПдфToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T))); this.сохранитьВПдфToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
this.сохранитьВПдфToolStripMenuItem.Size = new System.Drawing.Size(266, 24); this.сохранитьВПдфToolStripMenuItem.Size = new System.Drawing.Size(254, 24);
this.сохранитьВПдфToolStripMenuItem.Text = "Сохранить в пдф"; this.сохранитьВПдфToolStripMenuItem.Text = "Сохранить в PDF";
this.сохранитьВПдфToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВПдфToolStripMenuItem_Click); this.сохранитьВПдфToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВПдфToolStripMenuItem_Click);
// //
// статусыToolStripMenuItem // статусыToolStripMenuItem
@ -118,9 +118,13 @@ namespace WinForms
// //
// myTreeView1 // myTreeView1
// //
this.myTreeView1.Location = new System.Drawing.Point(12, 12); this.myTreeView1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.myTreeView1.BackColor = System.Drawing.SystemColors.ControlDark;
this.myTreeView1.Location = new System.Drawing.Point(12, 13);
this.myTreeView1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.myTreeView1.MinimumSize = new System.Drawing.Size(200, 200);
this.myTreeView1.Name = "myTreeView1"; this.myTreeView1.Name = "myTreeView1";
this.myTreeView1.Size = new System.Drawing.Size(658, 374); this.myTreeView1.Size = new System.Drawing.Size(658, 372);
this.myTreeView1.TabIndex = 1; this.myTreeView1.TabIndex = 1;
// //
// FormMain // FormMain
@ -130,7 +134,7 @@ namespace WinForms
this.ClientSize = new System.Drawing.Size(682, 398); this.ClientSize = new System.Drawing.Size(682, 398);
this.Controls.Add(this.myTreeView1); this.Controls.Add(this.myTreeView1);
this.Name = "FormMain"; this.Name = "FormMain";
this.Text = "Учет клиентов"; this.Text = "Заказы";
this.Load += new System.EventHandler(this.FormMain_Load); this.Load += new System.EventHandler(this.FormMain_Load);
this.contextMenuStrip1.ResumeLayout(false); this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
@ -149,11 +153,10 @@ namespace WinForms
private ToolStripMenuItem статусыToolStripMenuItem; private ToolStripMenuItem статусыToolStripMenuItem;
private VisualCompLib.Components.WordText wordText1; private VisualCompLib.Components.WordText wordText1;
private UnvisableComponents.ExcelChart excelChart1;
//private TreeClassView myTreeView1; //private Lab2.ChartComponent excelChart1;
private Lab2.ChartComponent excelChart1;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf1; private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf1;
private kop.components.TreeClassView myTreeView1; private VisableComponents.MyTreeView myTreeView1;
} }
} }

View File

@ -1,6 +1,5 @@
using ComponentsLibraryNet60.DocumentWithTable; using ComponentsLibraryNet60.DocumentWithTable;
using ComponentsLibraryNet60.Models; using ComponentsLibraryNet60.Models;
using Lab2;
using OrdersContracts.BindingModels; using OrdersContracts.BindingModels;
using OrdersContracts.BusinessLogicContracts; using OrdersContracts.BusinessLogicContracts;
using OrdersContracts.ViewModels; using OrdersContracts.ViewModels;
@ -13,6 +12,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using UnvisableComponents;
using VisualComponentsLib.Components; using VisualComponentsLib.Components;
namespace WinForms namespace WinForms
@ -27,7 +27,7 @@ namespace WinForms
_statusLogic = statusLogic; _statusLogic = statusLogic;
InitializeComponent(); InitializeComponent();
List<string> stringToHierachy = new List<string>() { "Status", "Amount", "Id", "Name" }; List<string> stringToHierachy = new List<string>() { "Status", "Amount", "Id", "Name" };
myTreeView1.setHierarchy(stringToHierachy); myTreeView1.addToHierarchy(stringToHierachy);
ContextMenuStrip = contextMenuStrip1; ContextMenuStrip = contextMenuStrip1;
} }
private void FormMain_Load(object sender, EventArgs e) private void FormMain_Load(object sender, EventArgs e)
@ -42,9 +42,9 @@ namespace WinForms
var list = _orderLogic.Read(null); var list = _orderLogic.Read(null);
for (int i = 0; i < list.Count; i++) for (int i = 0; i < list.Count; i++)
{ {
if (list[i].Amount == null || list[i].Amount == "") { list[i].Amount = "нет"; } if (list[i].Amount == null || list[i].Amount == "") { list[i].Amount = "Заказы, оплаченные скидками"; }
} }
myTreeView1.setData(list); myTreeView1.LoadTree(list);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -60,8 +60,6 @@ namespace WinForms
{ {
LoadData(); LoadData();
} }
} }
private void UpdateElement() private void UpdateElement()
@ -69,7 +67,7 @@ namespace WinForms
var service = Program.ServiceProvider?.GetService(typeof(FormOrder)); var service = Program.ServiceProvider?.GetService(typeof(FormOrder));
if (!(service is FormOrder form)) return; if (!(service is FormOrder form)) return;
var selectedOrder = myTreeView1.GetSelectedClass<OrderBindingModel>(); var selectedOrder = myTreeView1.GetNode(typeof(OrderBindingModel));
if (selectedOrder != null) if (selectedOrder != null)
{ {
form.Id = Convert.ToInt32((selectedOrder as OrderBindingModel).Id); form.Id = Convert.ToInt32((selectedOrder as OrderBindingModel).Id);
@ -88,7 +86,7 @@ namespace WinForms
{ {
if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
var selectedOrder = myTreeView1.GetSelectedClass<OrderBindingModel>(); var selectedOrder = myTreeView1.GetNode(typeof(OrderBindingModel));
int id = Convert.ToInt32((selectedOrder as OrderBindingModel).Id); int id = Convert.ToInt32((selectedOrder as OrderBindingModel).Id);
try try
{ {
@ -120,14 +118,14 @@ namespace WinForms
{ {
foreach (var item in list) foreach (var item in list)
{ {
if (item.Amount != null && item.Amount != "") if (item.Amount == null || item.Amount == "")
{ {
string orders = string.Concat("ФИО: ", item.Name, " Отзывы: ", item.Info); string orders = string.Concat("ФИО: ", item.Name, " Описание: ", item.Info);
textList.Add(orders); textList.Add(orders);
} }
} }
string[] textArray = textList.ToArray(); string[] textArray = textList.ToArray();
wordText1.CreateWordText(new(fileName, "Документ по клиентам, совершавшим покупки (ФИО клиента и его отзывы)", textArray)); wordText1.CreateWordText(new(fileName, "Заказы, которые были оплачены скидками", textArray));
} }
} }
@ -158,9 +156,10 @@ namespace WinForms
excelChart1.Load(new ChartInfo excelChart1.Load(new ChartInfo
{ {
Path = fileName, Path = fileName,
Title = "Сколько клиентов какого статуса совершали покупки", Title = "Статусы заказов",
DiagrammTitle = "Круговая диаграмма", DiagrammTitle = "Круговая диаграмма",
Data = dates, Dates = dates,
DirLegend = DirectionLegend.Right
}); });
} }
@ -180,19 +179,19 @@ namespace WinForms
var orders = _orderLogic.Read(null); var orders = _orderLogic.Read(null);
for (int i = 0; i < orders.Count; i++) for (int i = 0; i < orders.Count; i++)
{ {
if (orders[i].Amount == null || orders[i].Amount == "") { orders[i].Amount = "нет"; } if (orders[i].Amount == null || orders[i].Amount == "") { orders[i].Amount = "нет2"; }
} }
componentDocumentWithTableMultiHeaderPdf1.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<OrderViewModel> componentDocumentWithTableMultiHeaderPdf1.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<OrderViewModel>
{ {
FilePath = fileName, FilePath = fileName,
Header = "Отчет по клиентам", Header = "Отчет по заказам",
ColumnsRowsWidth = new List<(int, int)> { (5, 5), (10, 5), (15, 0), (15, 0) }, ColumnsRowsWidth = new List<(int, int)> { (5, 5), (10, 5), (15, 0), (15, 0) },
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)> Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
{ {
(0, 0, "Id", "Id"), (0, 0, "Id", "Id"),
(1, 0, "ФИО", "Name"), (1, 0, "ФИО", "Name"),
(2, 0, "Статус", "Status"), (2, 0, "Статус", "Status"),
(3, 0, "Сумма покупок", "Amount") (3, 0, "Сумма заказа", "Amount")
}, },
Data = orders Data = orders
}); });

View File

@ -15,8 +15,8 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="UnvisableConponents" Version="1.0.0" /> <PackageReference Include="UnvisableComponents" Version="1.0.0" />
<PackageReference Include="VisableComponents" Version="1.0.1" /> <PackageReference Include="VisableComponents" Version="1.0.9" />
<PackageReference Include="VisualCompLib" Version="1.0.0" /> <PackageReference Include="VisualCompLib" Version="1.0.0" />
</ItemGroup> </ItemGroup>