продвигаюсь помаленьку

This commit is contained in:
ityurner02@mail.ru 2023-10-25 23:06:54 +04:00
parent 21b0c10895
commit ce203b3ffa
15 changed files with 715 additions and 580 deletions

178
COP/WinForms/FormClient.Designer.cs generated Normal file
View File

@ -0,0 +1,178 @@
namespace WinForms
{
partial class FormClient
{
/// <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()
{
LabelFIO = new Label();
textBoxName = new TextBox();
label1 = new Label();
label2 = new Label();
textBoxReviews = new TextBox();
label3 = new Label();
buttonSave = new Button();
buttonCancel = new Button();
myDropDownList1 = new VisualCompLib.MyDropDownList();
controlInputNullableInt1 = new ControlsLibraryNet60.Input.ControlInputNullableInt();
SuspendLayout();
//
// LabelFIO
//
LabelFIO.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
LabelFIO.AutoSize = true;
LabelFIO.Location = new Point(15, 13);
LabelFIO.Name = "LabelFIO";
LabelFIO.Size = new Size(42, 20);
LabelFIO.TabIndex = 0;
LabelFIO.Text = "ФИО";
//
// textBoxName
//
textBoxName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBoxName.Location = new Point(15, 41);
textBoxName.Margin = new Padding(3, 4, 3, 4);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(244, 27);
textBoxName.TabIndex = 1;
//
// label1
//
label1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label1.AutoSize = true;
label1.Location = new Point(14, 81);
label1.Name = "label1";
label1.Size = new Size(52, 20);
label1.TabIndex = 3;
label1.Text = "Статус";
//
// label2
//
label2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label2.AutoSize = true;
label2.Location = new Point(15, 148);
label2.Name = "label2";
label2.Size = new Size(63, 20);
label2.TabIndex = 4;
label2.Text = "Отзывы";
//
// textBoxReviews
//
textBoxReviews.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBoxReviews.Location = new Point(15, 175);
textBoxReviews.Margin = new Padding(3, 4, 3, 4);
textBoxReviews.Name = "textBoxReviews";
textBoxReviews.Size = new Size(244, 27);
textBoxReviews.TabIndex = 5;
//
// label3
//
label3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label3.AutoSize = true;
label3.Location = new Point(15, 212);
label3.Name = "label3";
label3.Size = new Size(116, 20);
label3.TabIndex = 7;
label3.Text = "Сумма покупок";
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonSave.Location = new Point(14, 311);
buttonSave.Margin = new Padding(3, 4, 3, 4);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(243, 31);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonCancel.Location = new Point(14, 349);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(243, 31);
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;
//
// controlInputNullableInt1
//
controlInputNullableInt1.Location = new Point(14, 240);
controlInputNullableInt1.Margin = new Padding(5, 8, 5, 8);
controlInputNullableInt1.Name = "controlInputNullableInt1";
controlInputNullableInt1.Size = new Size(244, 39);
controlInputNullableInt1.TabIndex = 12;
controlInputNullableInt1.Value = null;
//
// FormClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(273, 397);
Controls.Add(controlInputNullableInt1);
Controls.Add(myDropDownList1);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label3);
Controls.Add(textBoxReviews);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(textBoxName);
Controls.Add(LabelFIO);
Margin = new Padding(3, 4, 3, 4);
Name = "FormClient";
Text = "Клиенты";
Load += FormClient_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label LabelFIO;
private TextBox textBoxName;
private Label label1;
private Label label2;
private TextBox textBoxReviews;
private Label label3;
private Button buttonSave;
private Button buttonCancel;
private VisualCompLib.MyDropDownList myDropDownList1;
private ControlsLibraryNet60.Input.ControlInputNullableInt controlInputNullableInt1;
}
}

108
COP/WinForms/FormClient.cs Normal file
View File

@ -0,0 +1,108 @@
using ClientsContracts.BindingModels;
using ClientsContracts.BusinessLogicContracts;
using ClientsContracts.ViewModels;
using ControlsLibraryNet60.Input;
using System.Windows.Forms;
namespace WinForms
{
public partial class FormClient : Form
{
public int Id { set { id = value; } }
private readonly IClientLogic _logic;
private readonly IStatusLogic _logicS;
private int? id;
public FormClient(IClientLogic logic, IStatusLogic logicS)
{
InitializeComponent();
_logic = logic;
_logicS = logicS;
}
private void FormClient_Load(object sender, EventArgs e)
{
List<StatusViewModel> viewS = _logicS.Read(null);
if (viewS != null)
{
List<string> list = new List<string>();
foreach (StatusViewModel s in viewS)
{
list.Add(s.Name);
}
myDropDownList1.LoadValues(list);
}
if (id.HasValue)
{
try
{
ClientViewModel view = _logic.Read(new ClientBindingModel { Id = id.Value })?[0];
if (view != null)
{
textBoxReviews.Text = view.Reviews;
textBoxName.Text = view.Name;
myDropDownList1.SelectedValue = view.Status;
if (view.Amount != null)
{
controlInputNullableInt1.Value = view.Amount;
}
else
{
controlInputNullableInt1.Value = 0;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(myDropDownList1.SelectedValue))
{
MessageBox.Show("Выберите статус", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (textBoxReviews.Text == null)
{
MessageBox.Show("Заполните отзывы", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
int? amount = controlInputNullableInt1.Value;
try
{
_logic.CreateOrUpdate(new ClientBindingModel
{
Id = id,
Reviews = textBoxReviews.Text,
Name = textBoxName.Text,
Status = myDropDownList1.SelectedValue.ToString(),
Amount = amount
});
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -1,231 +0,0 @@
namespace WinForms
{
partial class FormForComponents
{
/// <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()
{
dropDownList = new VisualCompLib.MyDropDownList();
buttonAdd = new Button();
buttonInfo = new Button();
labelInfo = new Label();
buttonClear = new Button();
emailTextBox = new VisualCompLib.MyEmailTextBox();
labelShow = new Label();
buttonShow = new Button();
buttonSetExample = new Button();
labelExample = new Label();
textBoxExample = new TextBox();
listBoxObj = new VisualCompLib.MyListBoxObjects();
buttonAddObjects = new Button();
buttonShowItem = new Button();
labelShowInput = new Label();
SuspendLayout();
//
// dropDownList
//
dropDownList.Location = new Point(3, 3);
dropDownList.Margin = new Padding(3, 4, 3, 4);
dropDownList.Name = "dropDownList";
dropDownList.SelectedValue = "";
dropDownList.Size = new Size(196, 36);
dropDownList.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.Location = new Point(3, 46);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(92, 29);
buttonAdd.TabIndex = 1;
buttonAdd.Text = "добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// buttonInfo
//
buttonInfo.Location = new Point(211, 46);
buttonInfo.Name = "buttonInfo";
buttonInfo.Size = new Size(94, 29);
buttonInfo.TabIndex = 2;
buttonInfo.Text = "показать";
buttonInfo.UseVisualStyleBackColor = true;
buttonInfo.Click += buttonInfo_Click;
//
// labelInfo
//
labelInfo.AutoSize = true;
labelInfo.Location = new Point(205, 9);
labelInfo.Name = "labelInfo";
labelInfo.Size = new Size(154, 20);
labelInfo.TabIndex = 3;
labelInfo.Text = "Выбранный элемент";
//
// buttonClear
//
buttonClear.Location = new Point(101, 46);
buttonClear.Name = "buttonClear";
buttonClear.Size = new Size(94, 29);
buttonClear.TabIndex = 4;
buttonClear.Text = "очистить";
buttonClear.UseVisualStyleBackColor = true;
buttonClear.Click += buttonClear_Click;
//
// emailTextBox
//
emailTextBox.Location = new Point(12, 132);
emailTextBox.Margin = new Padding(3, 4, 3, 4);
emailTextBox.Name = "emailTextBox";
emailTextBox.Pattern = null;
emailTextBox.Size = new Size(179, 34);
emailTextBox.TabIndex = 5;
//
// labelShow
//
labelShow.AutoSize = true;
labelShow.Location = new Point(12, 170);
labelShow.Name = "labelShow";
labelShow.Size = new Size(76, 20);
labelShow.TabIndex = 10;
labelShow.Text = "проверка";
//
// buttonShow
//
buttonShow.Location = new Point(12, 196);
buttonShow.Name = "buttonShow";
buttonShow.Size = new Size(94, 29);
buttonShow.TabIndex = 9;
buttonShow.Text = "Проверка";
buttonShow.UseVisualStyleBackColor = true;
buttonShow.Click += buttonShow_Click;
//
// buttonSetExample
//
buttonSetExample.Location = new Point(12, 328);
buttonSetExample.Name = "buttonSetExample";
buttonSetExample.Size = new Size(188, 29);
buttonSetExample.TabIndex = 8;
buttonSetExample.Text = "Поменять пример";
buttonSetExample.UseVisualStyleBackColor = true;
buttonSetExample.Click += buttonSetExample_Click;
//
// labelExample
//
labelExample.AutoSize = true;
labelExample.Location = new Point(12, 263);
labelExample.Name = "labelExample";
labelExample.Size = new Size(147, 20);
labelExample.TabIndex = 7;
labelExample.Text = "Для ввода примера";
//
// textBoxExample
//
textBoxExample.Location = new Point(12, 295);
textBoxExample.Name = "textBoxExample";
textBoxExample.Size = new Size(188, 27);
textBoxExample.TabIndex = 6;
//
// listBoxObj
//
listBoxObj.Location = new Point(388, 13);
listBoxObj.Margin = new Padding(3, 4, 3, 4);
listBoxObj.Name = "listBoxObj";
listBoxObj.SelectedIndex = -1;
listBoxObj.Size = new Size(368, 159);
listBoxObj.TabIndex = 11;
//
// buttonAddObjects
//
buttonAddObjects.Location = new Point(388, 179);
buttonAddObjects.Name = "buttonAddObjects";
buttonAddObjects.Size = new Size(380, 29);
buttonAddObjects.TabIndex = 12;
buttonAddObjects.Text = "Добавить";
buttonAddObjects.UseVisualStyleBackColor = true;
buttonAddObjects.Click += buttonAddObjects_Click;
//
// buttonShowItem
//
buttonShowItem.Location = new Point(388, 310);
buttonShowItem.Name = "buttonShowItem";
buttonShowItem.Size = new Size(380, 29);
buttonShowItem.TabIndex = 13;
buttonShowItem.Text = "Получить";
buttonShowItem.UseVisualStyleBackColor = true;
buttonShowItem.Click += buttonShowItem_Click;
//
// labelShowInput
//
labelShowInput.AutoSize = true;
labelShowInput.Location = new Point(388, 273);
labelShowInput.Name = "labelShowInput";
labelShowInput.Size = new Size(54, 20);
labelShowInput.TabIndex = 14;
labelShowInput.Text = "Вывод";
//
// FormForComponents
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dropDownList);
Controls.Add(buttonAdd);
Controls.Add(buttonInfo);
Controls.Add(labelInfo);
Controls.Add(buttonClear);
Controls.Add(emailTextBox);
Controls.Add(textBoxExample);
Controls.Add(labelExample);
Controls.Add(buttonSetExample);
Controls.Add(labelShow);
Controls.Add(buttonShow);
Controls.Add(listBoxObj);
Controls.Add(buttonAddObjects);
Controls.Add(buttonShowItem);
Controls.Add(labelShowInput);
Name = "FormForComponents";
Text = "Form1";
ResumeLayout(false);
PerformLayout();
}
#endregion
private VisualCompLib.MyDropDownList dropDownList;
private Button buttonAdd;
private Button buttonInfo;
private Label labelInfo;
private Button buttonClear;
private VisualCompLib.MyEmailTextBox emailTextBox;
private TextBox textBoxExample;
private Label labelExample;
private Button buttonSetExample;
private Label labelShow;
private Button buttonShow;
private VisualCompLib.MyListBoxObjects listBoxObj;
private Button buttonAddObjects;
private Button buttonShowItem;
private Label labelShowInput;
}
}

View File

@ -1,79 +0,0 @@
using VisualCompLib.Object;
namespace WinForms
{
public partial class FormForComponents : Form
{
List<string> list = new List<string>();
List<Student> students = new List<Student>();
public FormForComponents()
{
list = new List<string>();
list.AddRange(new string[] { "õëåá", "ìîëîêî", "êîëáàñà" });
Student student1 = new Student("Âàñèëüåâ", "ÏÈáä-32", "ÔÈÑÒ", 3);
Student student2 = new Student("Èâàíîâ", "ÐÒáä-11", "ÐÒÔ", 1);
Student student3 = new Student("Ñìèðíîâà", "ËÌÊÊáä-41", "ÃÔ", 4);
students.Add(student1);
students.Add(student2);
students.Add(student3);
InitializeComponent();
dropDownList.LoadValues(new List<string>() { "ñîê", "ÿáëîêî", "ëóê" });
emailTextBox.Pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
listBoxObj.SetLayoutInfo("Ôàìèëèÿ *Name* Ãðóïïà *Group* Ôàêóëüòåò *Faculty* Êóðñ *Course*", "*", "*");
dropDownList.ValueChanged += CustomEventHandler;
}
private void CustomEventHandler(object sender, EventArgs e)
{
MessageBox.Show("Âûáðàííûé ýëåìåíò èçìåíåí");
}
private void buttonAdd_Click(object sender, EventArgs e)
{
dropDownList.LoadValues(list);
}
private void buttonInfo_Click(object sender, EventArgs e)
{
labelInfo.Text = dropDownList.SelectedValue;
}
private void buttonClear_Click(object sender, EventArgs e)
{
dropDownList.Clear();
}
private void buttonSetExample_Click(object sender, EventArgs e)
{
if (textBoxExample.Text == String.Empty)
{
return;
}
emailTextBox.setExample(textBoxExample.Text);
}
private void buttonShow_Click(object sender, EventArgs e)
{
try
{
if (emailTextBox.TextBoxValue != null)
{
labelShow.Text = "ïîäõîäèò";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void buttonAddObjects_Click(object sender, EventArgs e)
{
listBoxObj.AddInListBox<Student>(students);
}
private void buttonShowItem_Click(object sender, EventArgs e)
{
string str = listBoxObj.GetObjectFromStr<Student>().Name + " " + listBoxObj.GetObjectFromStr<Student>().Group + " " + listBoxObj.GetObjectFromStr<Student>().Faculty + " " + listBoxObj.GetObjectFromStr<Student>().Course;
labelShowInput.Text = str;
}
}
}

61
COP/WinForms/FormMain.Designer.cs generated Normal file
View File

@ -0,0 +1,61 @@
namespace WinForms
{
partial class FormMain
{
/// <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()
{
myTreeView1 = new VisableComponents.MyTreeView();
SuspendLayout();
//
// myTreeView1
//
myTreeView1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
myTreeView1.BackColor = SystemColors.ControlDark;
myTreeView1.Location = new Point(12, 27);
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;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(myTreeView1);
Name = "FormMain";
Text = "Учет клиентов";
Load += FormMain_Load;
ResumeLayout(false);
}
#endregion
private VisableComponents.MyTreeView myTreeView1;
}
}

45
COP/WinForms/FormMain.cs Normal file
View File

@ -0,0 +1,45 @@
using ClientsContracts.BusinessLogicContracts;
using Unity;
namespace WinForms
{
public partial class FormMain : Form
{
private readonly IClientLogic _clientLogic;
private readonly IStatusLogic _statusLogic;
public FormMain(IClientLogic clientLogic, IStatusLogic statusLogic)
{
_clientLogic = clientLogic;
_statusLogic = statusLogic;
InitializeComponent();
List<string> stringToHierachy = new List<string>() { "Status", "Amount", "Id", "Name" };
myTreeView1.addToHierarchy(stringToHierachy);
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _clientLogic.Read(null);
myTreeView1.LoadTree(list);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AddNewElement()
{
var form = Program.Container.Resolve<FormClient>();
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}

View File

@ -117,13 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="wordText.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="wordLineChart.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>134, 17</value>
</metadata>
<metadata name="wordTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>286, 17</value>
</metadata>
</root>

67
COP/WinForms/FormStatus.Designer.cs generated Normal file
View File

@ -0,0 +1,67 @@
namespace WinForms
{
partial class FormStatus
{
/// <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.dataGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.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.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 12);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(236, 217);
this.dataGridView.TabIndex = 0;
this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit);
this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyDown);
//
// FormStatus
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(260, 241);
this.Controls.Add(this.dataGridView);
this.Name = "FormStatus";
this.Text = "Статусы";
this.Load += new System.EventHandler(this.FormStatus_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
}
}

109
COP/WinForms/FormStatus.cs Normal file
View File

@ -0,0 +1,109 @@
using ClientsContracts.BindingModels;
using ClientsContracts.BusinessLogicContracts;
using System.ComponentModel;
namespace WinForms
{
public partial class FormStatus : Form
{
private readonly IStatusLogic statusLogic;
BindingList<StatusBindingModel> list;
public FormStatus(IStatusLogic _statusLogic)
{
InitializeComponent();
statusLogic = _statusLogic;
list = new BindingList<StatusBindingModel>();
dataGridView.AllowUserToAddRows = false;
}
private void LoadData()
{
try
{
var list1 = statusLogic.Read(null);
list.Clear();
foreach (var item in list1)
{
list.Add(new StatusBindingModel
{
Id = item.Id,
Name = item.Name,
});
}
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns[0].Visible = false;
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormStatus_Load(object sender, EventArgs e)
{
LoadData();
}
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
var typeName = (string)dataGridView.CurrentRow.Cells[1].Value;
if (!string.IsNullOrEmpty(typeName))
{
if (dataGridView.CurrentRow.Cells[0].Value != null)
{
statusLogic.CreateOrUpdate(new StatusBindingModel()
{
Id = Convert.ToInt32(dataGridView.CurrentRow.Cells[0].Value),
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
});
}
else
{
statusLogic.CreateOrUpdate(new StatusBindingModel()
{
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
});
}
}
else
{
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Insert)
{
if (dataGridView.Rows.Count == 0)
{
list.Add(new StatusBindingModel());
dataGridView.DataSource = new BindingList<StatusBindingModel>(list);
dataGridView.CurrentCell = dataGridView.Rows[0].Cells[1];
return;
}
if (dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1].Value != null)
{
list.Add(new StatusBindingModel());
dataGridView.DataSource = new BindingList<StatusBindingModel>(list);
dataGridView.CurrentCell = dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1];
return;
}
}
if (e.KeyData == Keys.Delete)
{
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
statusLogic.Delete(new StatusBindingModel() { Id = (int)dataGridView.CurrentRow.Cells[0].Value });
LoadData();
}
}
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -1,134 +0,0 @@
namespace WinForms
{
partial class FormWord
{
/// <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()
{
components = new System.ComponentModel.Container();
wordText = new VisualCompLib.Components.WordText(components);
groupBox1 = new GroupBox();
button1 = new Button();
wordLineChart = new VisualCompLib.Components.WordLineChart(components);
groupBox3 = new GroupBox();
button3 = new Button();
groupBox2 = new GroupBox();
button2 = new Button();
wordTable = new VisualCompLib.Components.WordTable(components);
groupBox1.SuspendLayout();
groupBox3.SuspendLayout();
groupBox2.SuspendLayout();
SuspendLayout();
//
// groupBox1
//
groupBox1.Controls.Add(button1);
groupBox1.Location = new Point(12, 12);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(120, 80);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Большой текст";
//
// button1
//
button1.Location = new Point(6, 45);
button1.Name = "button1";
button1.Size = new Size(94, 29);
button1.TabIndex = 0;
button1.Text = "Создать";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// groupBox3
//
groupBox3.Controls.Add(button3);
groupBox3.Location = new Point(331, 12);
groupBox3.Name = "groupBox3";
groupBox3.Size = new Size(120, 80);
groupBox3.TabIndex = 1;
groupBox3.TabStop = false;
groupBox3.Text = "Линейная диаграмма";
//
// button3
//
button3.Location = new Point(6, 45);
button3.Name = "button3";
button3.Size = new Size(94, 29);
button3.TabIndex = 0;
button3.Text = "Создать";
button3.UseVisualStyleBackColor = true;
button3.Click += button3_Click;
//
// groupBox2
//
groupBox2.Controls.Add(button2);
groupBox2.Location = new Point(171, 12);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(120, 80);
groupBox2.TabIndex = 1;
groupBox2.TabStop = false;
groupBox2.Text = "Таблица";
//
// button2
//
button2.Location = new Point(6, 45);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 0;
button2.Text = "Создать";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// FormWord
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(463, 114);
Controls.Add(groupBox2);
Controls.Add(groupBox3);
Controls.Add(groupBox1);
Name = "FormWord";
Text = "Невизуальные компоненты";
groupBox1.ResumeLayout(false);
groupBox3.ResumeLayout(false);
groupBox2.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private VisualCompLib.Components.WordText wordText;
private GroupBox groupBox1;
private Button button1;
private VisualCompLib.Components.WordLineChart wordLineChart;
private GroupBox groupBox3;
private Button button3;
private GroupBox groupBox2;
private Button button2;
private VisualCompLib.Components.WordTable wordTable;
}
}

View File

@ -1,122 +0,0 @@
using DocumentFormat.OpenXml.Wordprocessing;
using VisualCompLib.Components;
using VisualCompLib.Components.SupportClasses;
using VisualCompLib.Components.SupportClasses.Enums;
using VisualCompLib.Object;
namespace WinForms
{
public partial class FormWord : Form
{
string[] testArray = { "Зайцев. Да и вонь же тут у вас, сеньор! Не продохнешь! Воняет сургучом, кислятиной какой-то, клопами... Пфуй!", "Смотритель. Без запаха нельзя.", "Зайцев. Завтра разбудите меня в шесть часов... И чтоб тройка была готова... Мне нужно к девяти часам в город поспеть.", "Смотритель. Ладно...", "Зайцев. Который теперь час?" };
public FormWord()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
LargeText largeText = new(dialog.FileName, "Ночь перед судом", testArray);
wordText.CreateWordText(largeText);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
List<int[]> mergedColumns = new()
{
new int[] { 0, 1, 2 }
};
List<ColumnDefinition> columnDefinitions = new List<ColumnDefinition>
{
new ColumnDefinition { Header = "Образование", PropertyName = "Eduction", Weight = 35 },
new ColumnDefinition { Header = "", PropertyName = "Education1", Weight = 35 },
new ColumnDefinition { Header = "", PropertyName = "Education2", Weight = 10 },
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
};
List<ColumnDefinition> columnDefinitions2 = new List<ColumnDefinition>
{
new ColumnDefinition { Header = "Группа", PropertyName = "Group", Weight = 35 },
new ColumnDefinition { Header = "Факультатив", PropertyName = "Faculty", Weight = 35 },
new ColumnDefinition { Header = "Курс", PropertyName = "Course", Weight = 10 },
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
};
List<Student> data = new List<Student>
{
new Student { Group = "ПИбд-32", Faculty = "ФИСТ", Course = 3, Name = "Васильев" },
new Student { Group = "РТбд-11", Faculty = "РТФ", Course = 1, Name = "Иванов" },
new Student { Group = "ЛМККбд-41", Faculty = "ГФ", Course = 4, Name = "Смирнова" }
};
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
BigTable<Student> bigTable = new(dialog.FileName, "Задание 2", columnDefinitions, columnDefinitions2, data, mergedColumns);
wordTable.CreateTable(bigTable);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button3_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
string[] month = { "Январь", "Февраль", "Март" };
double[] profit1 = { 300, 440, 270 };
double[] profit2 = { 500, 620, 310 };
double[] profit3 = { 420, 189, 430 };
SimpleLineChart lineChart = new(dialog.FileName, "Третье задание", "График прибыли", EnumAreaLegend.Right, new List<DataLineChart> {
new DataLineChart("Компания 1", month, profit1), new DataLineChart("Компания 2", month, profit2), new DataLineChart("Компания 3", month, profit3),
});
wordLineChart.AddLineChart(lineChart);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -1,17 +1,37 @@
using ClientsContracts.BusinessLogicContracts;
using ClientsContracts.StorageContracts;
using ClientsDatabaseImplement.Implements;
using Unity;
using Unity.Lifetime;
namespace WinForms
{
internal static class Program
{
private static IUnityContainer container = null;
public static IUnityContainer Container { get { if (container == null) { container = BuildUnityContainer(); } return container; } }
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormWord());
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(Container.Resolve<FormClient>());
}
private static IUnityContainer BuildUnityContainer()
{
var currentContainer = new UnityContainer();
currentContainer.RegisterType<IClientStorage, ClientStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IStatusStorage, StatusStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IClientLogic, ClientBusinessLogic.BusinessLogics.ClientLogic>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IStatusLogic, ClientBusinessLogic.BusinessLogics.StatusLogic>(new HierarchicalLifetimeManager());
return currentContainer;
}
}
}

View File

@ -15,12 +15,14 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="UnvisableComponents" Version="1.0.0" />
<PackageReference Include="VisableComponents" Version="1.0.0" />
<PackageReference Include="VisableComponents" Version="1.0.8" />
<PackageReference Include="VisualCompLib" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClientBusinessLogic\ClientBusinessLogic.csproj" />
<ProjectReference Include="..\ClientsDatabaseImplement\ClientsDatabaseImplement.csproj" />
</ItemGroup>