diff --git a/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514142102_InitialCreate.Designer.cs b/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514175153_InitialCreate.Designer.cs similarity index 96% rename from TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514142102_InitialCreate.Designer.cs rename to TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514175153_InitialCreate.Designer.cs index ac5fd1f..89d7e98 100644 --- a/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514142102_InitialCreate.Designer.cs +++ b/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514175153_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using TransportLogisticDatabaseImplement; namespace TransportLogisticDatabaseImplement.Migrations { [DbContext(typeof(TransportLogisticDatabase))] - [Migration("20240514142102_InitialCreate")] + [Migration("20240514175153_InitialCreate")] partial class InitialCreate { /// @@ -100,7 +100,7 @@ namespace TransportLogisticDatabaseImplement.Migrations b.Property("Status") .HasColumnType("int"); - b.Property("StorageId") + b.Property("StorageId") .HasColumnType("int"); b.HasKey("Id"); @@ -207,21 +207,15 @@ namespace TransportLogisticDatabaseImplement.Migrations modelBuilder.Entity("TransportLogisticDatabaseImplement.Models.Order", b => { - b.HasOne("TransportLogisticDatabaseImplement.Models.Customer", "Customer") + b.HasOne("TransportLogisticDatabaseImplement.Models.Customer", null) .WithMany("Order") .HasForeignKey("CustomerId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("TransportLogisticDatabaseImplement.Models.Storage", "Storage") + b.HasOne("TransportLogisticDatabaseImplement.Models.Storage", null) .WithMany("Orders") - .HasForeignKey("StorageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - - b.Navigation("Storage"); + .HasForeignKey("StorageId"); }); modelBuilder.Entity("TransportLogisticDatabaseImplement.Models.OrderGood", b => diff --git a/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514142102_InitialCreate.cs b/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514175153_InitialCreate.cs similarity index 98% rename from TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514142102_InitialCreate.cs rename to TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514175153_InitialCreate.cs index b7356e6..cf3f15e 100644 --- a/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514142102_InitialCreate.cs +++ b/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/20240514175153_InitialCreate.cs @@ -81,7 +81,7 @@ namespace TransportLogisticDatabaseImplement.Migrations StartStorageId = table.Column(type: "int", nullable: false), FinishStorageId = table.Column(type: "int", nullable: false), CustomerId = table.Column(type: "int", nullable: false), - StorageId = table.Column(type: "int", nullable: false) + StorageId = table.Column(type: "int", nullable: true) }, constraints: table => { @@ -96,8 +96,7 @@ namespace TransportLogisticDatabaseImplement.Migrations name: "FK_Orders_Storages_StorageId", column: x => x.StorageId, principalTable: "Storages", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( diff --git a/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/TransportLogisticDatabaseModelSnapshot.cs b/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/TransportLogisticDatabaseModelSnapshot.cs index bbb705a..2839f38 100644 --- a/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/TransportLogisticDatabaseModelSnapshot.cs +++ b/TransportLogistic/TransportLogisticDatabaseImplement/Migrations/TransportLogisticDatabaseModelSnapshot.cs @@ -97,7 +97,7 @@ namespace TransportLogisticDatabaseImplement.Migrations b.Property("Status") .HasColumnType("int"); - b.Property("StorageId") + b.Property("StorageId") .HasColumnType("int"); b.HasKey("Id"); @@ -204,21 +204,15 @@ namespace TransportLogisticDatabaseImplement.Migrations modelBuilder.Entity("TransportLogisticDatabaseImplement.Models.Order", b => { - b.HasOne("TransportLogisticDatabaseImplement.Models.Customer", "Customer") + b.HasOne("TransportLogisticDatabaseImplement.Models.Customer", null) .WithMany("Order") .HasForeignKey("CustomerId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("TransportLogisticDatabaseImplement.Models.Storage", "Storage") + b.HasOne("TransportLogisticDatabaseImplement.Models.Storage", null) .WithMany("Orders") - .HasForeignKey("StorageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - - b.Navigation("Storage"); + .HasForeignKey("StorageId"); }); modelBuilder.Entity("TransportLogisticDatabaseImplement.Models.OrderGood", b => diff --git a/TransportLogistic/TransportLogisticDatabaseImplement/Models/Order.cs b/TransportLogistic/TransportLogisticDatabaseImplement/Models/Order.cs index 9e01cfb..2140acb 100644 --- a/TransportLogistic/TransportLogisticDatabaseImplement/Models/Order.cs +++ b/TransportLogistic/TransportLogisticDatabaseImplement/Models/Order.cs @@ -21,7 +21,6 @@ namespace TransportLogisticDatabaseImplement.Models public int StartStorageId { get; set; } [Required] public int FinishStorageId { get; set; } - [Required] public int CustomerId { get; set; } [Required] diff --git a/TransportLogistic/TransportLogisticForm/FormCreateOrder.cs b/TransportLogistic/TransportLogisticForm/FormCreateOrder.cs index 66704f2..ad5fb12 100644 --- a/TransportLogistic/TransportLogisticForm/FormCreateOrder.cs +++ b/TransportLogistic/TransportLogisticForm/FormCreateOrder.cs @@ -55,7 +55,6 @@ namespace TransportLogisticForm if (startList != null) { comboBoxStart.DisplayMember = "Name"; - comboBoxStart.DisplayMember = "Address"; comboBoxStart.ValueMember = "Id"; comboBoxStart.DataSource = startList; comboBoxStart.SelectedItem = null; @@ -71,7 +70,6 @@ namespace TransportLogisticForm if (finishList != null) { comboBoxFinish.DisplayMember = "Name"; - comboBoxFinish.DisplayMember = "Address"; comboBoxFinish.ValueMember = "Id"; comboBoxFinish.DataSource = finishList; comboBoxFinish.SelectedItem = null; @@ -86,12 +84,10 @@ namespace TransportLogisticForm var customerList = _logicC.ReadList(null); if (customerList != null) { - comboBoxFinish.DisplayMember = "Name"; - comboBoxFinish.DisplayMember = "Lastname"; - comboBoxFinish.DisplayMember = "Email"; - comboBoxFinish.ValueMember = "Id"; - comboBoxFinish.DataSource = customerList; - comboBoxFinish.SelectedItem = null; + comboBoxCustomer.DisplayMember = "Lastname"; + comboBoxCustomer.ValueMember = "Id"; + comboBoxCustomer.DataSource = customerList; + comboBoxCustomer.SelectedItem = null; } } catch (Exception ex) diff --git a/TransportLogistic/TransportLogisticForm/FormCustomers.Designer.cs b/TransportLogistic/TransportLogisticForm/FormCustomers.Designer.cs index 2721b4a..16a41cb 100644 --- a/TransportLogistic/TransportLogisticForm/FormCustomers.Designer.cs +++ b/TransportLogistic/TransportLogisticForm/FormCustomers.Designer.cs @@ -31,8 +31,8 @@ dataGridView1 = new DataGridView(); buttonUpd = new Button(); buttonDel = new Button(); - button1 = new Button(); - button2 = new Button(); + buttonEdit = new Button(); + buttonAdd = new Button(); ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); SuspendLayout(); // @@ -52,7 +52,7 @@ // // buttonUpd // - buttonUpd.Location = new Point(556, 166); + buttonUpd.Location = new Point(556, 252); buttonUpd.Margin = new Padding(5, 4, 5, 4); buttonUpd.Name = "buttonUpd"; buttonUpd.Size = new Size(113, 53); @@ -63,7 +63,7 @@ // // buttonDel // - buttonDel.Location = new Point(556, 105); + buttonDel.Location = new Point(556, 191); buttonDel.Margin = new Padding(5, 4, 5, 4); buttonDel.Name = "buttonDel"; buttonDel.Size = new Size(113, 53); @@ -72,36 +72,39 @@ buttonDel.UseVisualStyleBackColor = true; buttonDel.Click += buttonDel_Click; // - // button1 + // buttonEdit // - button1.Location = new Point(574, 249); - button1.Name = "button1"; - button1.Size = new Size(75, 23); - button1.TabIndex = 11; - button1.Text = "button1"; - button1.UseVisualStyleBackColor = true; + buttonEdit.Location = new Point(556, 131); + buttonEdit.Name = "buttonEdit"; + buttonEdit.Size = new Size(113, 53); + buttonEdit.TabIndex = 21; + buttonEdit.Text = "Изменить"; + buttonEdit.UseVisualStyleBackColor = true; + buttonEdit.Click += buttonEdit_Click; // - // button2 + // buttonAdd // - button2.Location = new Point(579, 316); - button2.Name = "button2"; - button2.Size = new Size(75, 23); - button2.TabIndex = 12; - button2.Text = "button2"; - button2.UseVisualStyleBackColor = true; + buttonAdd.Location = new Point(556, 72); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(113, 53); + buttonAdd.TabIndex = 20; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; // // FormCustomers // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(683, 498); - Controls.Add(button2); - Controls.Add(button1); + Controls.Add(buttonEdit); + Controls.Add(buttonAdd); Controls.Add(buttonUpd); Controls.Add(buttonDel); Controls.Add(dataGridView1); Name = "FormCustomers"; Text = "Заказчики"; + Load += FormCustomers_Load; ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); ResumeLayout(false); } @@ -111,7 +114,7 @@ private DataGridView dataGridView1; private Button buttonUpd; private Button buttonDel; - private Button button1; - private Button button2; + private Button buttonEdit; + private Button buttonAdd; } } \ No newline at end of file diff --git a/TransportLogistic/TransportLogisticForm/FormCustomers.cs b/TransportLogistic/TransportLogisticForm/FormCustomers.cs index 5f62e3f..68bf837 100644 --- a/TransportLogistic/TransportLogisticForm/FormCustomers.cs +++ b/TransportLogistic/TransportLogisticForm/FormCustomers.cs @@ -64,5 +64,33 @@ namespace TransportLogisticForm { LoadData(); } + + private void buttonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCustomer)); + if (service is FormCustomer form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void buttonEdit_Click(object sender, EventArgs e) + { + if (dataGridView1.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCustomer)); + if (service is FormCustomer form) + { + form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } } } diff --git a/TransportLogistic/TransportLogisticForm/FormGood.Designer.cs b/TransportLogistic/TransportLogisticForm/FormGood.Designer.cs index f8dbf68..03b4d1b 100644 --- a/TransportLogistic/TransportLogisticForm/FormGood.Designer.cs +++ b/TransportLogistic/TransportLogisticForm/FormGood.Designer.cs @@ -32,6 +32,10 @@ textBoxName = new TextBox(); buttonCancel = new Button(); buttonSave = new Button(); + textBox1 = new TextBox(); + label2 = new Label(); + textBox2 = new TextBox(); + label3 = new Label(); SuspendLayout(); // // label1 @@ -52,7 +56,7 @@ // // buttonCancel // - buttonCancel.Location = new Point(272, 68); + buttonCancel.Location = new Point(272, 149); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(95, 43); buttonCancel.TabIndex = 3; @@ -62,7 +66,7 @@ // // buttonSave // - buttonSave.Location = new Point(171, 68); + buttonSave.Location = new Point(171, 149); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(95, 43); buttonSave.TabIndex = 4; @@ -70,17 +74,53 @@ buttonSave.UseVisualStyleBackColor = true; buttonSave.Click += buttonSave_Click; // + // textBox1 + // + textBox1.Location = new Point(98, 107); + textBox1.Name = "textBox1"; + textBox1.Size = new Size(269, 27); + textBox1.TabIndex = 6; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 110); + label2.Name = "label2"; + label2.Size = new Size(63, 20); + label2.TabIndex = 5; + label2.Text = "Размер:"; + // + // textBox2 + // + textBox2.Location = new Point(98, 65); + textBox2.Name = "textBox2"; + textBox2.Size = new Size(269, 27); + textBox2.TabIndex = 8; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(12, 68); + label3.Name = "label3"; + label3.Size = new Size(36, 20); + label3.TabIndex = 7; + label3.Text = "Вес:"; + // // FormGood // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(391, 132); + ClientSize = new Size(391, 204); + Controls.Add(textBox2); + Controls.Add(label3); + Controls.Add(textBox1); + Controls.Add(label2); Controls.Add(buttonSave); Controls.Add(buttonCancel); Controls.Add(textBoxName); Controls.Add(label1); Name = "FormGood"; - Text = "Товар"; + Text = "Создание товара"; Load += FormGood_Load; ResumeLayout(false); PerformLayout(); @@ -92,5 +132,9 @@ private TextBox textBoxName; private Button buttonCancel; private Button buttonSave; + private TextBox textBox1; + private Label label2; + private TextBox textBox2; + private Label label3; } } \ No newline at end of file diff --git a/TransportLogistic/TransportLogisticForm/FormGood.cs b/TransportLogistic/TransportLogisticForm/FormGood.cs index 92eb777..5648953 100644 --- a/TransportLogistic/TransportLogisticForm/FormGood.cs +++ b/TransportLogistic/TransportLogisticForm/FormGood.cs @@ -24,7 +24,7 @@ namespace TransportLogisticForm if (view != null) { textBoxName.Text = view.Name; - + textBox2.Text = view.Size; } } catch (Exception ex) @@ -47,6 +47,8 @@ namespace TransportLogisticForm { Id = _id ?? 0, Name = textBoxName.Text, + Weight = Convert.ToDouble(textBox1.Text), + Size = textBox2.Text }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) diff --git a/TransportLogistic/TransportLogisticForm/FormGoods.Designer.cs b/TransportLogistic/TransportLogisticForm/FormGoods.Designer.cs index 63e33a3..7e18cca 100644 --- a/TransportLogistic/TransportLogisticForm/FormGoods.Designer.cs +++ b/TransportLogistic/TransportLogisticForm/FormGoods.Designer.cs @@ -97,6 +97,7 @@ Controls.Add(dataGridView); Name = "FormGoods"; Text = "Товары"; + Load += FormGoods_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } diff --git a/TransportLogistic/TransportLogisticForm/FormMain.cs b/TransportLogistic/TransportLogisticForm/FormMain.cs index 3fe528e..87e8fde 100644 --- a/TransportLogistic/TransportLogisticForm/FormMain.cs +++ b/TransportLogistic/TransportLogisticForm/FormMain.cs @@ -23,7 +23,7 @@ namespace TransportLogisticForm if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["Id"].Visible = true; dataGridView.Columns["Status"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["DateCreate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["DateDelivered"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; @@ -33,8 +33,8 @@ namespace TransportLogisticForm dataGridView.Columns["FinishStorageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["CustomerId"].Visible = false; dataGridView.Columns["CustomerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["OrderTransports"].Visible = false; - dataGridView.Columns["OrderGoods"].Visible = false; + dataGridView.Columns["OrderTransports"].Visible = true; + dataGridView.Columns["OrderGoods"].Visible = true; } } catch (Exception ex) diff --git a/TransportLogistic/TransportLogisticForm/FormStorages.Designer.cs b/TransportLogistic/TransportLogisticForm/FormStorages.Designer.cs index 45a5a72..85ae9df 100644 --- a/TransportLogistic/TransportLogisticForm/FormStorages.Designer.cs +++ b/TransportLogistic/TransportLogisticForm/FormStorages.Designer.cs @@ -28,35 +28,17 @@ /// private void InitializeComponent() { - button2 = new Button(); - button1 = new Button(); buttonUpd = new Button(); buttonDel = new Button(); dataGridView1 = new DataGridView(); + buttonEdit = new Button(); + buttonAdd = new Button(); ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); SuspendLayout(); // - // button2 - // - button2.Location = new Point(576, 315); - button2.Name = "button2"; - button2.Size = new Size(75, 23); - button2.TabIndex = 17; - button2.Text = "button2"; - button2.UseVisualStyleBackColor = true; - // - // button1 - // - button1.Location = new Point(571, 248); - button1.Name = "button1"; - button1.Size = new Size(75, 23); - button1.TabIndex = 16; - button1.Text = "button1"; - button1.UseVisualStyleBackColor = true; - // // buttonUpd // - buttonUpd.Location = new Point(553, 165); + buttonUpd.Location = new Point(556, 252); buttonUpd.Margin = new Padding(5, 4, 5, 4); buttonUpd.Name = "buttonUpd"; buttonUpd.Size = new Size(113, 53); @@ -67,7 +49,7 @@ // // buttonDel // - buttonDel.Location = new Point(553, 104); + buttonDel.Location = new Point(556, 191); buttonDel.Margin = new Padding(5, 4, 5, 4); buttonDel.Name = "buttonDel"; buttonDel.Size = new Size(113, 53); @@ -90,28 +72,48 @@ dataGridView1.Size = new Size(529, 498); dataGridView1.TabIndex = 13; // + // buttonEdit + // + buttonEdit.Location = new Point(556, 131); + buttonEdit.Name = "buttonEdit"; + buttonEdit.Size = new Size(113, 53); + buttonEdit.TabIndex = 19; + buttonEdit.Text = "Изменить"; + buttonEdit.UseVisualStyleBackColor = true; + buttonEdit.Click += buttonEdit_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(556, 72); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(113, 53); + buttonAdd.TabIndex = 18; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // // FormStorages // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(683, 499); - Controls.Add(button2); - Controls.Add(button1); + Controls.Add(buttonEdit); + Controls.Add(buttonAdd); Controls.Add(buttonUpd); Controls.Add(buttonDel); Controls.Add(dataGridView1); Name = "FormStorages"; Text = "Склады"; + Load += FormStorages_Load; ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); ResumeLayout(false); } #endregion - - private Button button2; - private Button button1; private Button buttonUpd; private Button buttonDel; private DataGridView dataGridView1; + private Button buttonEdit; + private Button buttonAdd; } } \ No newline at end of file diff --git a/TransportLogistic/TransportLogisticForm/FormStorages.cs b/TransportLogistic/TransportLogisticForm/FormStorages.cs index 7887b9d..34a193a 100644 --- a/TransportLogistic/TransportLogisticForm/FormStorages.cs +++ b/TransportLogistic/TransportLogisticForm/FormStorages.cs @@ -1,4 +1,5 @@ -using TransportLogisticContracts.BindingModels; +using System.Windows.Forms; +using TransportLogisticContracts.BindingModels; using TransportLogisticContracts.BusinessLogicsContracts; namespace TransportLogisticForm @@ -62,5 +63,33 @@ namespace TransportLogisticForm { LoadData(); } + + private void buttonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormStorage)); + if (service is FormStorage form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void buttonEdit_Click(object sender, EventArgs e) + { + if (dataGridView1.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormStorage)); + if (service is FormTransport form) + { + form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } } } diff --git a/TransportLogistic/TransportLogisticForm/FormTransport.Designer.cs b/TransportLogistic/TransportLogisticForm/FormTransport.Designer.cs index d6bb657..20cfffb 100644 --- a/TransportLogistic/TransportLogisticForm/FormTransport.Designer.cs +++ b/TransportLogistic/TransportLogisticForm/FormTransport.Designer.cs @@ -32,11 +32,13 @@ buttonCancel = new Button(); textBoxName = new TextBox(); label1 = new Label(); + textBox1 = new TextBox(); + label2 = new Label(); SuspendLayout(); // // buttonSave // - buttonSave.Location = new Point(171, 66); + buttonSave.Location = new Point(171, 119); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(95, 43); buttonSave.TabIndex = 8; @@ -46,7 +48,7 @@ // // buttonCancel // - buttonCancel.Location = new Point(272, 66); + buttonCancel.Location = new Point(272, 119); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(95, 43); buttonCancel.TabIndex = 7; @@ -56,9 +58,9 @@ // // textBoxName // - textBoxName.Location = new Point(98, 18); + textBoxName.Location = new Point(56, 18); textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(269, 27); + textBoxName.Size = new Size(311, 27); textBoxName.TabIndex = 6; // // label1 @@ -66,21 +68,40 @@ label1.AutoSize = true; label1.Location = new Point(12, 21); label1.Name = "label1"; - label1.Size = new Size(80, 20); + label1.Size = new Size(38, 20); label1.TabIndex = 5; - label1.Text = "Название:"; + label1.Text = "Тип:"; + // + // textBox1 + // + textBox1.Location = new Point(171, 65); + textBox1.Name = "textBox1"; + textBox1.Size = new Size(196, 27); + textBox1.TabIndex = 10; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 68); + label2.Name = "label2"; + label2.Size = new Size(144, 20); + label2.TabIndex = 9; + label2.Text = "Грузоподъемность:"; // // FormTransport // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(386, 131); + ClientSize = new Size(386, 174); + Controls.Add(textBox1); + Controls.Add(label2); Controls.Add(buttonSave); Controls.Add(buttonCancel); Controls.Add(textBoxName); Controls.Add(label1); Name = "FormTransport"; - Text = "Транспорт"; + Text = "Создание транспорта"; + Load += FormTransports_Load; ResumeLayout(false); PerformLayout(); } @@ -91,5 +112,7 @@ private Button buttonCancel; private TextBox textBoxName; private Label label1; + private TextBox textBox1; + private Label label2; } } \ No newline at end of file diff --git a/TransportLogistic/TransportLogisticForm/FormTransport.cs b/TransportLogistic/TransportLogisticForm/FormTransport.cs index f41a16d..f221d59 100644 --- a/TransportLogistic/TransportLogisticForm/FormTransport.cs +++ b/TransportLogistic/TransportLogisticForm/FormTransport.cs @@ -24,7 +24,6 @@ namespace TransportLogisticForm if (view != null) { textBoxName.Text = view.Type; - } } catch (Exception ex) @@ -47,6 +46,7 @@ namespace TransportLogisticForm { Id = _id ?? 0, Type = textBoxName.Text, + LoadCapacity = Convert.ToDouble(textBox1.Text) }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) diff --git a/TransportLogistic/TransportLogisticForm/FormTransports.cs b/TransportLogistic/TransportLogisticForm/FormTransports.cs index 1035928..967d03b 100644 --- a/TransportLogistic/TransportLogisticForm/FormTransports.cs +++ b/TransportLogistic/TransportLogisticForm/FormTransports.cs @@ -36,7 +36,7 @@ namespace TransportLogisticForm private void buttonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormGood)); + var service = Program.ServiceProvider?.GetService(typeof(FormTransport)); if (service is FormTransport form) { if (form.ShowDialog() == DialogResult.OK) @@ -50,7 +50,7 @@ namespace TransportLogisticForm { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormGood)); + var service = Program.ServiceProvider?.GetService(typeof(FormTransport)); if (service is FormTransport form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); diff --git a/TransportLogistic/TransportLogisticForm/Program.cs b/TransportLogistic/TransportLogisticForm/Program.cs index 325dcc3..3671612 100644 --- a/TransportLogistic/TransportLogisticForm/Program.cs +++ b/TransportLogistic/TransportLogisticForm/Program.cs @@ -41,10 +41,12 @@ namespace TransportLogisticForm services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient();