все круды и 1/3 документов работают

This commit is contained in:
ityurner02@mail.ru 2023-10-26 22:26:41 +04:00
parent ce203b3ffa
commit d25940be9c
10 changed files with 297 additions and 97 deletions

View File

@ -28,32 +28,34 @@
/// </summary>
private void InitializeComponent()
{
this.dropDownList = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
dropDownList = new ComboBox();
SuspendLayout();
//
// dropDownList
//
this.dropDownList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.dropDownList.FormattingEnabled = true;
this.dropDownList.Location = new System.Drawing.Point(3, 3);
this.dropDownList.Name = "dropDownList";
this.dropDownList.Size = new System.Drawing.Size(187, 24);
this.dropDownList.TabIndex = 0;
this.dropDownList.SelectedValueChanged += new System.EventHandler(this.comboBox_SelectedValueChanged);
dropDownList.DropDownStyle = ComboBoxStyle.DropDownList;
dropDownList.FormattingEnabled = true;
dropDownList.Location = new Point(3, 4);
dropDownList.Margin = new Padding(3, 4, 3, 4);
dropDownList.Name = "dropDownList";
dropDownList.Size = new Size(187, 28);
dropDownList.TabIndex = 0;
dropDownList.SelectedValueChanged += comboBox_SelectedValueChanged;
//
// MyDropDownList
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.dropDownList);
this.Name = "MyDropDownList";
this.Size = new System.Drawing.Size(193, 30);
this.ResumeLayout(false);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
Controls.Add(dropDownList);
Margin = new Padding(3, 4, 3, 4);
Name = "MyDropDownList";
Size = new Size(193, 38);
ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ComboBox dropDownList;
private ComboBox dropDownList;
}
}

View File

@ -10,7 +10,7 @@ using System.Windows.Forms;
namespace VisualCompLib
{
public partial class MyDropDownList: UserControl
public partial class MyDropDownList : UserControl
{
public MyDropDownList()
{

View File

@ -36,8 +36,8 @@
label3 = new Label();
buttonSave = new Button();
buttonCancel = new Button();
myDropDownList1 = new VisualCompLib.MyDropDownList();
controlInputNullableInt1 = new ControlsLibraryNet60.Input.ControlInputNullableInt();
myDropDownList1 = new VisualCompLib.MyDropDownList();
SuspendLayout();
//
// LabelFIO
@ -108,6 +108,7 @@
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
@ -119,16 +120,7 @@
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отменить";
buttonCancel.UseVisualStyleBackColor = true;
//
// myDropDownList1
//
myDropDownList1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
myDropDownList1.Location = new Point(14, 107);
myDropDownList1.Margin = new Padding(3, 4, 3, 4);
myDropDownList1.Name = "myDropDownList1";
myDropDownList1.SelectedValue = "";
myDropDownList1.Size = new Size(195, 37);
myDropDownList1.TabIndex = 11;
buttonCancel.Click += buttonCancel_Click;
//
// controlInputNullableInt1
//
@ -139,13 +131,22 @@
controlInputNullableInt1.TabIndex = 12;
controlInputNullableInt1.Value = null;
//
// myDropDownList1
//
myDropDownList1.Location = new Point(12, 105);
myDropDownList1.Margin = new Padding(3, 4, 3, 4);
myDropDownList1.Name = "myDropDownList1";
myDropDownList1.SelectedValue = "";
myDropDownList1.Size = new Size(198, 39);
myDropDownList1.TabIndex = 13;
//
// FormClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(273, 397);
Controls.Add(controlInputNullableInt1);
Controls.Add(myDropDownList1);
Controls.Add(controlInputNullableInt1);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label3);
@ -172,7 +173,7 @@
private Label label3;
private Button buttonSave;
private Button buttonCancel;
private VisualCompLib.MyDropDownList myDropDownList1;
private ControlsLibraryNet60.Input.ControlInputNullableInt controlInputNullableInt1;
private VisualCompLib.MyDropDownList myDropDownList1;
}
}

View File

@ -47,10 +47,6 @@ namespace WinForms
{
controlInputNullableInt1.Value = view.Amount;
}
else
{
controlInputNullableInt1.Value = 0;
}
}
}
catch (Exception ex)

View File

@ -28,19 +28,93 @@
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
contextMenuStrip1 = new ContextMenuStrip(components);
добавитьToolStripMenuItem = new ToolStripMenuItem();
редактироватьToolStripMenuItem = new ToolStripMenuItem();
удалитьToolStripMenuItem = new ToolStripMenuItem();
сохранитьВВордToolStripMenuItem = new ToolStripMenuItem();
сохранитьВЭксельToolStripMenuItem = new ToolStripMenuItem();
сохранитьВПдфToolStripMenuItem = new ToolStripMenuItem();
статусыToolStripMenuItem = new ToolStripMenuItem();
myTreeView1 = new VisableComponents.MyTreeView();
wordText1 = new VisualCompLib.Components.WordText(components);
contextMenuStrip1.SuspendLayout();
SuspendLayout();
//
// contextMenuStrip1
//
contextMenuStrip1.ImageScalingSize = new Size(20, 20);
contextMenuStrip1.Items.AddRange(new ToolStripItem[] { добавитьToolStripMenuItem, редактироватьToolStripMenuItem, удалитьToolStripMenuItem, сохранитьВВордToolStripMenuItem, сохранитьВЭксельToolStripMenuItem, сохранитьВПдфToolStripMenuItem, статусыToolStripMenuItem });
contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.Size = new Size(267, 172);
//
// добавитьToolStripMenuItem
//
добавитьToolStripMenuItem.Name = обавитьToolStripMenuItem";
добавитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
добавитьToolStripMenuItem.Size = new Size(266, 24);
добавитьToolStripMenuItem.Text = "Добавить";
добавитьToolStripMenuItem.Click += добавитьToolStripMenuItem_Click;
//
// редактироватьToolStripMenuItem
//
редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
редактироватьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
редактироватьToolStripMenuItem.Size = new Size(266, 24);
редактироватьToolStripMenuItem.Text = "Редактировать";
редактироватьToolStripMenuItem.Click += редактироватьToolStripMenuItem_Click;
//
// удалитьToolStripMenuItem
//
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
удалитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
удалитьToolStripMenuItem.Size = new Size(266, 24);
удалитьToolStripMenuItem.Text = "Удалить";
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
//
// сохранитьВВордToolStripMenuItem
//
сохранитьВВордToolStripMenuItem.Name = "сохранитьВВордToolStripMenuItem";
сохранитьВВордToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
сохранитьВВордToolStripMenuItem.Size = new Size(266, 24);
сохранитьВВордToolStripMenuItem.Text = "Сохранить в Ворд";
сохранитьВВордToolStripMenuItem.Click += сохранитьВВордToolStripMenuItem_Click;
//
// сохранитьВЭксельToolStripMenuItem
//
сохранитьВЭксельToolStripMenuItem.Name = "сохранитьВЭксельToolStripMenuItem";
сохранитьВЭксельToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
сохранитьВЭксельToolStripMenuItem.Size = new Size(266, 24);
сохранитьВЭксельToolStripMenuItem.Text = "Сохранить в Эксель";
сохранитьВЭксельToolStripMenuItem.Click += сохранитьВЭксельToolStripMenuItem_Click;
//
// сохранитьВПдфToolStripMenuItem
//
сохранитьВПдфToolStripMenuItem.Name = "сохранитьВПдфToolStripMenuItem";
сохранитьВПдфToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
сохранитьВПдфToolStripMenuItem.Size = new Size(266, 24);
сохранитьВПдфToolStripMenuItem.Text = "Сохранить в пдф";
сохранитьВПдфToolStripMenuItem.Click += сохранитьВПдфToolStripMenuItem_Click;
//
// статусыToolStripMenuItem
//
статусыToolStripMenuItem.Name = "статусыToolStripMenuItem";
статусыToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.Tab;
статусыToolStripMenuItem.Size = new Size(266, 24);
статусыToolStripMenuItem.Text = "Статусы";
статусыToolStripMenuItem.Click += статусыToolStripMenuItem_Click;
//
// myTreeView1
//
myTreeView1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
myTreeView1.BackColor = SystemColors.ControlDark;
myTreeView1.Location = new Point(12, 27);
myTreeView1.Location = new Point(12, 13);
myTreeView1.Margin = new Padding(3, 4, 3, 4);
myTreeView1.MinimumSize = new Size(200, 200);
myTreeView1.Name = "myTreeView1";
myTreeView1.Size = new Size(780, 406);
myTreeView1.TabIndex = 0;
myTreeView1.Size = new Size(776, 424);
myTreeView1.TabIndex = 1;
//
// FormMain
//
@ -51,11 +125,20 @@
Name = "FormMain";
Text = "Учет клиентов";
Load += FormMain_Load;
contextMenuStrip1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ContextMenuStrip contextMenuStrip1;
private ToolStripMenuItem добавитьToolStripMenuItem;
private ToolStripMenuItem редактироватьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem сохранитьВВордToolStripMenuItem;
private ToolStripMenuItem сохранитьВЭксельToolStripMenuItem;
private ToolStripMenuItem сохранитьВПдфToolStripMenuItem;
private ToolStripMenuItem статусыToolStripMenuItem;
private VisableComponents.MyTreeView myTreeView1;
private VisualCompLib.Components.WordText wordText1;
}
}

View File

@ -1,5 +1,11 @@
using ClientsContracts.BusinessLogicContracts;
using ClientBusinessLogic.BusinessLogics;
using ClientsContracts.BusinessLogicContracts;
using ClientsContracts.ViewModels;
using ClientsContracts.BindingModels;
using ControlsLibraryNet60.Data;
using Unity;
using DocumentFormat.OpenXml.Spreadsheet;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace WinForms
{
@ -14,6 +20,7 @@ namespace WinForms
InitializeComponent();
List<string> stringToHierachy = new List<string>() { "Status", "Amount", "Id", "Name" };
myTreeView1.addToHierarchy(stringToHierachy);
myTreeView1.ContextMenuStrip = contextMenuStrip1;
}
private void FormMain_Load(object sender, EventArgs e)
{
@ -25,6 +32,10 @@ namespace WinForms
try
{
var list = _clientLogic.Read(null);
for (int i = 0; i < list.Count; i++)
{
if (list[i].Amount == null) { list[i].Amount = 0; }
}
myTreeView1.LoadTree(list);
}
catch (Exception ex)
@ -41,5 +52,106 @@ namespace WinForms
LoadData();
}
}
private void UpdateElement()
{
var form = Program.Container.Resolve<FormClient>();
var selectedClient = myTreeView1.GetNode(typeof(ClientBindingModel));
if (selectedClient != null)
{
form.Id = Convert.ToInt32((selectedClient as ClientBindingModel).Id);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
else
{
MessageBox.Show("Выберите клиента для редактирования");
}
}
private void DeleteElement()
{
if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
var selectedClient = myTreeView1.GetNode(typeof(ClientBindingModel));
int id = Convert.ToInt32((selectedClient as ClientBindingModel).Id);
try
{
_clientLogic.Delete(new ClientBindingModel { Id = id });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
private void CreateWord()
{
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
List<string> textList = new List<string>();
var list = _clientLogic.Read(null);
if (list != null)
{
foreach (var item in list)
{
if(item.Amount != null)
{
string clients = string.Concat("ФИО: ", item.Name, " Отзывы: ", item.Reviews);
textList.Add(clients);
}
}
string[] textArray = textList.ToArray();
wordText1.CreateWordText(new(fileName, "Документ по клиентам, совершавшим покупки (ФИО клиента и его отзывы)", textArray));
}
}
private void статусыToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = Program.Container.Resolve<FormStatus>();
form.ShowDialog();
}
private void сохранитьВПдфToolStripMenuItem_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
private void сохранитьВЭксельToolStripMenuItem_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
private void сохранитьВВордToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateWord();
}
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
{
DeleteElement();
}
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateElement();
}
private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
{
AddNewElement();
}
}
}

View File

@ -117,4 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="wordText1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>202, 17</value>
</metadata>
</root>

View File

@ -19,7 +19,7 @@ namespace WinForms
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(Container.Resolve<FormClient>());
Application.Run(Container.Resolve<FormMain>());
}
private static IUnityContainer BuildUnityContainer()
{

View File

@ -17,7 +17,7 @@
</PackageReference>
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="UnvisableComponents" Version="1.0.0" />
<PackageReference Include="VisableComponents" Version="1.0.8" />
<PackageReference Include="VisableComponents" Version="1.0.9" />
<PackageReference Include="VisualCompLib" Version="1.0.0" />
</ItemGroup>