diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs index 24ee0ca..6eab97c 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs @@ -34,59 +34,58 @@ this.textBoxAddress = new System.Windows.Forms.TextBox(); this.groupBoxIceCreams = new System.Windows.Forms.GroupBox(); this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnManufactureName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.buttonSave = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); this.labelDate = new System.Windows.Forms.Label(); this.dateTimePickerDate = new System.Windows.Forms.DateTimePicker(); - this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnManufactureName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.labelCount = new System.Windows.Forms.Label(); + this.numericUpDownCount = new System.Windows.Forms.NumericUpDown(); this.groupBoxIceCreams.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit(); this.SuspendLayout(); // // labelName // this.labelName.AutoSize = true; - this.labelName.Location = new System.Drawing.Point(18, 10); + this.labelName.Location = new System.Drawing.Point(21, 13); this.labelName.Name = "labelName"; - this.labelName.Size = new System.Drawing.Size(62, 15); + this.labelName.Size = new System.Drawing.Size(80, 20); this.labelName.TabIndex = 0; this.labelName.Text = "Название:"; // // labelAddress // this.labelAddress.AutoSize = true; - this.labelAddress.Location = new System.Drawing.Point(266, 9); + this.labelAddress.Location = new System.Drawing.Point(304, 12); this.labelAddress.Name = "labelAddress"; - this.labelAddress.Size = new System.Drawing.Size(43, 15); + this.labelAddress.Size = new System.Drawing.Size(54, 20); this.labelAddress.TabIndex = 1; this.labelAddress.Text = "Адрес:"; // // textBoxName // - this.textBoxName.Location = new System.Drawing.Point(86, 7); - this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxName.Location = new System.Drawing.Point(107, 10); this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(138, 23); + this.textBoxName.Size = new System.Drawing.Size(157, 27); this.textBoxName.TabIndex = 2; // // textBoxAddress // - this.textBoxAddress.Location = new System.Drawing.Point(315, 6); - this.textBoxAddress.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxAddress.Location = new System.Drawing.Point(364, 9); this.textBoxAddress.Name = "textBoxAddress"; - this.textBoxAddress.Size = new System.Drawing.Size(138, 23); + this.textBoxAddress.Size = new System.Drawing.Size(157, 27); this.textBoxAddress.TabIndex = 3; // // groupBoxIceCreams // this.groupBoxIceCreams.Controls.Add(this.dataGridView); - this.groupBoxIceCreams.Location = new System.Drawing.Point(12, 62); - this.groupBoxIceCreams.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.groupBoxIceCreams.Location = new System.Drawing.Point(14, 94); this.groupBoxIceCreams.Name = "groupBoxIceCreams"; - this.groupBoxIceCreams.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBoxIceCreams.Size = new System.Drawing.Size(720, 206); + this.groupBoxIceCreams.Size = new System.Drawing.Size(823, 275); this.groupBoxIceCreams.TabIndex = 4; this.groupBoxIceCreams.TabStop = false; this.groupBoxIceCreams.Text = "Изделия"; @@ -98,57 +97,20 @@ this.ID, this.ColumnManufactureName, this.ColumnCount}); - this.dataGridView.Location = new System.Drawing.Point(5, 20); - this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView.Location = new System.Drawing.Point(6, 27); this.dataGridView.Name = "dataGridView"; this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(709, 182); + this.dataGridView.Size = new System.Drawing.Size(810, 243); this.dataGridView.TabIndex = 0; // - // buttonSave - // - this.buttonSave.Location = new System.Drawing.Point(411, 286); - this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(136, 22); - this.buttonSave.TabIndex = 5; - this.buttonSave.Text = "Сохранить"; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); - // - // buttonCancel - // - this.buttonCancel.Location = new System.Drawing.Point(579, 286); - this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(136, 22); - this.buttonCancel.TabIndex = 6; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); - // - // labelDate - // - this.labelDate.AutoSize = true; - this.labelDate.Location = new System.Drawing.Point(492, 9); - this.labelDate.Name = "labelDate"; - this.labelDate.Size = new System.Drawing.Size(90, 15); - this.labelDate.TabIndex = 7; - this.labelDate.Text = "Дата открытия:"; - // - // dateTimePickerDate - // - this.dateTimePickerDate.Location = new System.Drawing.Point(588, 7); - this.dateTimePickerDate.Name = "dateTimePickerDate"; - this.dateTimePickerDate.Size = new System.Drawing.Size(127, 23); - this.dateTimePickerDate.TabIndex = 9; - // // ID // this.ID.HeaderText = "ID"; + this.ID.MinimumWidth = 6; this.ID.Name = "ID"; this.ID.Visible = false; + this.ID.Width = 125; // // ColumnManufactureName // @@ -165,11 +127,67 @@ this.ColumnCount.Name = "ColumnCount"; this.ColumnCount.Width = 125; // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(470, 381); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(155, 29); + this.buttonSave.TabIndex = 5; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(662, 381); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(155, 29); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // labelDate + // + this.labelDate.AutoSize = true; + this.labelDate.Location = new System.Drawing.Point(562, 12); + this.labelDate.Name = "labelDate"; + this.labelDate.Size = new System.Drawing.Size(113, 20); + this.labelDate.TabIndex = 7; + this.labelDate.Text = "Дата открытия:"; + // + // dateTimePickerDate + // + this.dateTimePickerDate.Location = new System.Drawing.Point(681, 9); + this.dateTimePickerDate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.dateTimePickerDate.Name = "dateTimePickerDate"; + this.dateTimePickerDate.Size = new System.Drawing.Size(145, 27); + this.dateTimePickerDate.TabIndex = 9; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(21, 55); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(173, 20); + this.labelCount.TabIndex = 10; + this.labelCount.Text = "Вместимость магазина:"; + // + // numericUpDownCount + // + this.numericUpDownCount.Location = new System.Drawing.Point(200, 53); + this.numericUpDownCount.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.numericUpDownCount.Name = "numericUpDownCount"; + this.numericUpDownCount.Size = new System.Drawing.Size(145, 27); + this.numericUpDownCount.TabIndex = 11; + // // FormShop // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(744, 319); + this.ClientSize = new System.Drawing.Size(850, 425); + this.Controls.Add(this.numericUpDownCount); + this.Controls.Add(this.labelCount); this.Controls.Add(this.dateTimePickerDate); this.Controls.Add(this.labelDate); this.Controls.Add(this.buttonCancel); @@ -179,12 +197,12 @@ this.Controls.Add(this.textBoxName); this.Controls.Add(this.labelAddress); this.Controls.Add(this.labelName); - this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormShop"; this.Text = "Магазин"; this.Load += new System.EventHandler(this.FormShop_Load); this.groupBoxIceCreams.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -205,5 +223,7 @@ private DataGridViewTextBoxColumn ID; private DataGridViewTextBoxColumn ColumnManufactureName; private DataGridViewTextBoxColumn ColumnCount; + private Label labelCount; + private NumericUpDown numericUpDownCount; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs index dc28673..86043c9 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs @@ -30,6 +30,7 @@ namespace BlacksmithWorkshop public FormShop(ILogger logger, IShopLogic logic) { InitializeComponent(); + _logger = logger; _logic = logic; _shopManufactures = new Dictionary(); @@ -46,11 +47,13 @@ namespace BlacksmithWorkshop { Id = _id.Value }); + if (view != null) { textBoxName.Text = view.ShopName; textBoxAddress.Text = view.Address.ToString(); dateTimePickerDate.Value = view.DateOpen; + numericUpDownCount.Value = view.MaxCountManufactures; _shopManufactures = view.Manufactures ?? new Dictionary(); LoadData(); } @@ -104,13 +107,17 @@ namespace BlacksmithWorkshop Id = _id ?? 0, ShopName = textBoxName.Text, Address = textBoxAddress.Text, - DateOpen = dateTimePickerDate.Value.Date + DateOpen = dateTimePickerDate.Value.Date, + MaxCountManufactures = (int)numericUpDownCount.Value }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; Close(); diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index 8e76a27..09752bf 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -57,6 +57,7 @@ namespace BlacksmithWorkshop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } }