diff --git a/COP/WinForms/FormClient.Designer.cs b/COP/WinForms/FormClient.Designer.cs new file mode 100644 index 0000000..9d3e2dd --- /dev/null +++ b/COP/WinForms/FormClient.Designer.cs @@ -0,0 +1,178 @@ +namespace WinForms +{ + partial class FormClient + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/COP/WinForms/FormClient.cs b/COP/WinForms/FormClient.cs new file mode 100644 index 0000000..915acd8 --- /dev/null +++ b/COP/WinForms/FormClient.cs @@ -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 viewS = _logicS.Read(null); + if (viewS != null) + { + List list = new List(); + 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(); + } + } +} diff --git a/COP/WinForms/FormForComponents.resx b/COP/WinForms/FormClient.resx similarity index 100% rename from COP/WinForms/FormForComponents.resx rename to COP/WinForms/FormClient.resx diff --git a/COP/WinForms/FormForComponents.Designer.cs b/COP/WinForms/FormForComponents.Designer.cs deleted file mode 100644 index d9fecdc..0000000 --- a/COP/WinForms/FormForComponents.Designer.cs +++ /dev/null @@ -1,231 +0,0 @@ -namespace WinForms -{ - partial class FormForComponents - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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; - } -} \ No newline at end of file diff --git a/COP/WinForms/FormForComponents.cs b/COP/WinForms/FormForComponents.cs deleted file mode 100644 index 04e93f2..0000000 --- a/COP/WinForms/FormForComponents.cs +++ /dev/null @@ -1,79 +0,0 @@ -using VisualCompLib.Object; - -namespace WinForms -{ - public partial class FormForComponents : Form - { - List list = new List(); - List students = new List(); - public FormForComponents() - { - list = new List(); - 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() { "", "", "" }); - 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(students); - } - - private void buttonShowItem_Click(object sender, EventArgs e) - { - string str = listBoxObj.GetObjectFromStr().Name + " " + listBoxObj.GetObjectFromStr().Group + " " + listBoxObj.GetObjectFromStr().Faculty + " " + listBoxObj.GetObjectFromStr().Course; - labelShowInput.Text = str; - } - } -} \ No newline at end of file diff --git a/COP/WinForms/FormMain.Designer.cs b/COP/WinForms/FormMain.Designer.cs new file mode 100644 index 0000000..58b902a --- /dev/null +++ b/COP/WinForms/FormMain.Designer.cs @@ -0,0 +1,61 @@ +namespace WinForms +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/COP/WinForms/FormMain.cs b/COP/WinForms/FormMain.cs new file mode 100644 index 0000000..1b92c62 --- /dev/null +++ b/COP/WinForms/FormMain.cs @@ -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 stringToHierachy = new List() { "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(); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } +} diff --git a/COP/WinForms/FormWord.resx b/COP/WinForms/FormMain.resx similarity index 90% rename from COP/WinForms/FormWord.resx rename to COP/WinForms/FormMain.resx index a545853..af32865 100644 --- a/COP/WinForms/FormWord.resx +++ b/COP/WinForms/FormMain.resx @@ -117,13 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - - - 134, 17 - - - 286, 17 - \ No newline at end of file diff --git a/COP/WinForms/FormStatus.Designer.cs b/COP/WinForms/FormStatus.Designer.cs new file mode 100644 index 0000000..e1cf829 --- /dev/null +++ b/COP/WinForms/FormStatus.Designer.cs @@ -0,0 +1,67 @@ +namespace WinForms +{ + partial class FormStatus + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/COP/WinForms/FormStatus.cs b/COP/WinForms/FormStatus.cs new file mode 100644 index 0000000..6143373 --- /dev/null +++ b/COP/WinForms/FormStatus.cs @@ -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 list; + public FormStatus(IStatusLogic _statusLogic) + { + InitializeComponent(); + statusLogic = _statusLogic; + list = new BindingList(); + 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(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(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(); + } + } + } + } +} diff --git a/COP/WinForms/FormStatus.resx b/COP/WinForms/FormStatus.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/COP/WinForms/FormStatus.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/COP/WinForms/FormWord.Designer.cs b/COP/WinForms/FormWord.Designer.cs deleted file mode 100644 index 17af3bb..0000000 --- a/COP/WinForms/FormWord.Designer.cs +++ /dev/null @@ -1,134 +0,0 @@ -namespace WinForms -{ - partial class FormWord - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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; - } -} \ No newline at end of file diff --git a/COP/WinForms/FormWord.cs b/COP/WinForms/FormWord.cs deleted file mode 100644 index 0ecb7de..0000000 --- a/COP/WinForms/FormWord.cs +++ /dev/null @@ -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 mergedColumns = new() - { - new int[] { 0, 1, 2 } - }; - - - - List columnDefinitions = new List - { - 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 columnDefinitions2 = new List - { - 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 data = new List - { - 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 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 { - 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); - } - } - } - } -} diff --git a/COP/WinForms/Program.cs b/COP/WinForms/Program.cs index ccc4695..5af4c61 100644 --- a/COP/WinForms/Program.cs +++ b/COP/WinForms/Program.cs @@ -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; } } /// /// The main entry point for the application. /// [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()); + } + private static IUnityContainer BuildUnityContainer() + { + var currentContainer = new UnityContainer(); + + currentContainer.RegisterType(new HierarchicalLifetimeManager()); + currentContainer.RegisterType(new HierarchicalLifetimeManager()); + + currentContainer.RegisterType(new HierarchicalLifetimeManager()); + currentContainer.RegisterType(new HierarchicalLifetimeManager()); + + return currentContainer; } } } \ No newline at end of file diff --git a/COP/WinForms/WinForms.csproj b/COP/WinForms/WinForms.csproj index 950ca23..1154e74 100644 --- a/COP/WinForms/WinForms.csproj +++ b/COP/WinForms/WinForms.csproj @@ -15,12 +15,14 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + - + +