From 8106e3460bff779b88d8498059919eed1b2937ec Mon Sep 17 00:00:00 2001 From: ksenianeva <95441235+ksenianeva@users.noreply.github.com> Date: Sat, 27 May 2023 12:20:39 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A8=D0=B5=D1=81=D1=82=D0=B0=D1=8F=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F.=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B2=20order.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TravelCompany/FormMain.Designer.cs | 30 ++- TravelCompany/TravelCompany/FormMain.cs | 10 + .../BusinessLogic/OrderLogic.cs | 3 +- .../20230515055249_UpdLab6.Designer.cs | 245 ++++++++++++++++++ .../Migrations/20230515055249_UpdLab6.cs | 67 +++++ .../TravelCompanyDatabaseModelSnapshot.cs | 38 +++ .../TravelCompanyDatabase.cs | 2 +- .../Implements/ImplementerStorage.cs | 2 +- .../Models/Order.cs | 5 +- 9 files changed, 386 insertions(+), 16 deletions(-) create mode 100644 TravelCompany/TravelCompanyDatabaseImplement/Migrations/20230515055249_UpdLab6.Designer.cs create mode 100644 TravelCompany/TravelCompanyDatabaseImplement/Migrations/20230515055249_UpdLab6.cs diff --git a/TravelCompany/TravelCompany/FormMain.Designer.cs b/TravelCompany/TravelCompany/FormMain.Designer.cs index 6c0fcb4..b697091 100644 --- a/TravelCompany/TravelCompany/FormMain.Designer.cs +++ b/TravelCompany/TravelCompany/FormMain.Designer.cs @@ -38,12 +38,13 @@ this.списокУсловийToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.условияПоПоездкамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.ButtonTakeOrderInWork = new System.Windows.Forms.Button(); this.ButtonOrderReady = new System.Windows.Forms.Button(); this.ButtonIssuedOrder = new System.Windows.Forms.Button(); this.ButtonRef = new System.Windows.Forms.Button(); - this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip.SuspendLayout(); this.SuspendLayout(); @@ -82,7 +83,8 @@ this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.условияToolStripMenuItem, this.путешествияToolStripMenuItem, - this.клиентыToolStripMenuItem}); + this.клиентыToolStripMenuItem, + this.исполнителиToolStripMenuItem}); this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24); this.справочникиToolStripMenuItem.Text = "Справочники"; @@ -90,21 +92,21 @@ // условияToolStripMenuItem // this.условияToolStripMenuItem.Name = "условияToolStripMenuItem"; - this.условияToolStripMenuItem.Size = new System.Drawing.Size(182, 26); + this.условияToolStripMenuItem.Size = new System.Drawing.Size(224, 26); this.условияToolStripMenuItem.Text = "Условия"; this.условияToolStripMenuItem.Click += new System.EventHandler(this.условияToolStripMenuItem_Click); // // путешествияToolStripMenuItem // this.путешествияToolStripMenuItem.Name = "путешествияToolStripMenuItem"; - this.путешествияToolStripMenuItem.Size = new System.Drawing.Size(182, 26); + this.путешествияToolStripMenuItem.Size = new System.Drawing.Size(224, 26); this.путешествияToolStripMenuItem.Text = "Путешествия"; this.путешествияToolStripMenuItem.Click += new System.EventHandler(this.путешествияToolStripMenuItem_Click); // // клиентыToolStripMenuItem // this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26); + this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26); this.клиентыToolStripMenuItem.Text = "Клиенты"; this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click); // @@ -139,6 +141,13 @@ this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); // + // запускРаботToolStripMenuItem + // + this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem"; + this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24); + this.запускРаботToolStripMenuItem.Text = "Запуск работ"; + this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click); + // // buttonCreateOrder // this.buttonCreateOrder.Location = new System.Drawing.Point(1224, 36); @@ -194,12 +203,12 @@ this.ButtonRef.UseVisualStyleBackColor = true; this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); // - // запускРаботToolStripMenuItem + // исполнителиToolStripMenuItem // - this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem"; - this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24); - this.запускРаботToolStripMenuItem.Text = "Запуск работ"; - this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click); + this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem"; + this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.исполнителиToolStripMenuItem.Text = "Исполнители"; + this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click); // // FormMain // @@ -244,5 +253,6 @@ private ToolStripMenuItem списокЗаказовToolStripMenuItem; private ToolStripMenuItem клиентыToolStripMenuItem; private ToolStripMenuItem запускРаботToolStripMenuItem; + private ToolStripMenuItem исполнителиToolStripMenuItem; } } \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormMain.cs b/TravelCompany/TravelCompany/FormMain.cs index b27843f..344260a 100644 --- a/TravelCompany/TravelCompany/FormMain.cs +++ b/TravelCompany/TravelCompany/FormMain.cs @@ -35,6 +35,7 @@ namespace TravelCompany dataGridView.DataSource = list; dataGridView.Columns["TravelId"].Visible = false; dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["ImplementerId"].Visible = false; dataGridView.Columns["TravelName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } @@ -198,5 +199,14 @@ namespace TravelCompany MessageBoxButtons.OK, MessageBoxIcon.Information); } + + private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); + if (service is FormImplementers form) + { + form.ShowDialog(); + } + } } } diff --git a/TravelCompany/TravelCompanyBusinessLogic/BusinessLogic/OrderLogic.cs b/TravelCompany/TravelCompanyBusinessLogic/BusinessLogic/OrderLogic.cs index 6c66529..50dcb94 100644 --- a/TravelCompany/TravelCompanyBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/TravelCompany/TravelCompanyBusinessLogic/BusinessLogic/OrderLogic.cs @@ -129,7 +129,8 @@ namespace TravelCompanyBusinessLogic.BusinessLogic if (element.Status != OrderStatus.Принят) { _logger.LogWarning("Status change operation failed"); - throw new InvalidOperationException("Заказ должен быть переведен в статус принятого перед его выполнением!"); + throw new InvalidOperationException("Заказ должен быть переведен " + + "в статус принятого перед его выполнением!"); } model.Status = OrderStatus.Выполняется; _orderStorage.Update(model); diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20230515055249_UpdLab6.Designer.cs b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20230515055249_UpdLab6.Designer.cs new file mode 100644 index 0000000..00b4c13 --- /dev/null +++ b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20230515055249_UpdLab6.Designer.cs @@ -0,0 +1,245 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using TravelCompanyDatabaseImplement; + +#nullable disable + +namespace TravelCompanyDatabaseImplement.Migrations +{ + [DbContext(typeof(TravelCompanyDatabase))] + [Migration("20230515055249_UpdLab6")] + partial class UpdLab6 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Condition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConditionName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Conditions"); + }); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.Property("TravelId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("TravelId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("TravelName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Travels"); + }); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.TravelCondition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConditionId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("TravelId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConditionId"); + + b.HasIndex("TravelId"); + + b.ToTable("TravelConditions"); + }); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Order", b => + { + b.HasOne("TravelCompanyDatabaseImplement.Models.Client", "Client") + .WithMany() + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TravelCompanyDatabaseImplement.Models.Implementer", "Implementer") + .WithMany() + .HasForeignKey("ImplementerId"); + + b.HasOne("TravelCompanyDatabaseImplement.Models.Travel", "Travel") + .WithMany() + .HasForeignKey("TravelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Travel"); + }); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.TravelCondition", b => + { + b.HasOne("TravelCompanyDatabaseImplement.Models.Condition", "Condition") + .WithMany("TravelConditions") + .HasForeignKey("ConditionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TravelCompanyDatabaseImplement.Models.Travel", "Travel") + .WithMany("Conditions") + .HasForeignKey("TravelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Condition"); + + b.Navigation("Travel"); + }); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Condition", b => + { + b.Navigation("TravelConditions"); + }); + + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b => + { + b.Navigation("Conditions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20230515055249_UpdLab6.cs b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20230515055249_UpdLab6.cs new file mode 100644 index 0000000..cce360c --- /dev/null +++ b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20230515055249_UpdLab6.cs @@ -0,0 +1,67 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TravelCompanyDatabaseImplement.Migrations +{ + /// + public partial class UpdLab6 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: true); + + migrationBuilder.CreateTable( + name: "Implementers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + WorkExperience = table.Column(type: "int", nullable: false), + Qualification = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Implementers", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ImplementerId", + table: "Orders", + column: "ImplementerId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.DropTable( + name: "Implementers"); + + migrationBuilder.DropIndex( + name: "IX_Orders_ImplementerId", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "ImplementerId", + table: "Orders"); + } + } +} diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/TravelCompanyDatabaseModelSnapshot.cs b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/TravelCompanyDatabaseModelSnapshot.cs index 6e8d60c..6b71a12 100644 --- a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/TravelCompanyDatabaseModelSnapshot.cs +++ b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/TravelCompanyDatabaseModelSnapshot.cs @@ -67,6 +67,33 @@ namespace TravelCompanyDatabaseImplement.Migrations b.ToTable("Conditions"); }); + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -87,6 +114,9 @@ namespace TravelCompanyDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("Status") .HasColumnType("int"); @@ -100,6 +130,8 @@ namespace TravelCompanyDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("TravelId"); b.ToTable("Orders"); @@ -159,6 +191,10 @@ namespace TravelCompanyDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("TravelCompanyDatabaseImplement.Models.Implementer", "Implementer") + .WithMany() + .HasForeignKey("ImplementerId"); + b.HasOne("TravelCompanyDatabaseImplement.Models.Travel", "Travel") .WithMany() .HasForeignKey("TravelId") @@ -167,6 +203,8 @@ namespace TravelCompanyDatabaseImplement.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Travel"); }); diff --git a/TravelCompany/TravelCompanyDatabaseImplement/TravelCompanyDatabase.cs b/TravelCompany/TravelCompanyDatabaseImplement/TravelCompanyDatabase.cs index 3a13175..b788f2a 100644 --- a/TravelCompany/TravelCompanyDatabaseImplement/TravelCompanyDatabase.cs +++ b/TravelCompany/TravelCompanyDatabaseImplement/TravelCompanyDatabase.cs @@ -15,7 +15,7 @@ namespace TravelCompanyDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=TravelCompanyDatabaseFullLab6;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=TravelCompanyDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/TravelCompany/TravelCompanyFileImplement/Implements/ImplementerStorage.cs b/TravelCompany/TravelCompanyFileImplement/Implements/ImplementerStorage.cs index 0ae758a..1e93416 100644 --- a/TravelCompany/TravelCompanyFileImplement/Implements/ImplementerStorage.cs +++ b/TravelCompany/TravelCompanyFileImplement/Implements/ImplementerStorage.cs @@ -8,7 +8,7 @@ using TravelCompanyContracts.BindingModels; using TravelCompanyContracts.SearchModels; using TravelCompanyContracts.StoragesContracts; using TravelCompanyContracts.ViewModels; -using TravelCompanyListImplement.Models; +using TravelCompanyFileImplement.Models; namespace TravelCompanyFileImplement.Implements { diff --git a/TravelCompany/TravelCompanyFileImplement/Models/Order.cs b/TravelCompany/TravelCompanyFileImplement/Models/Order.cs index f1eb4f8..2515aea 100644 --- a/TravelCompany/TravelCompanyFileImplement/Models/Order.cs +++ b/TravelCompany/TravelCompanyFileImplement/Models/Order.cs @@ -92,9 +92,8 @@ namespace TravelCompanyFileImplement.Models new XElement("Status", ((int)Status).ToString()), new XElement("DateCreate", DateCreate.ToString()), new XElement("DateImplement", DateImplement.ToString(), - new XElement("ClientId", ClientId))); - new XElement("ImplementerId", ImplementerId.ToString()), - + new XElement("ClientId", ClientId)), + new XElement("ImplementerId", ImplementerId.ToString())); } }