готово

This commit is contained in:
dex_moth 2024-05-14 19:05:59 +04:00
parent 113baf20a0
commit 596f77bcb9
13 changed files with 573 additions and 46 deletions

View File

@ -9,14 +9,15 @@ namespace FishFactory.Forms
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
private IWorkProcess _workProcess;
private readonly IWorkProcess _workProcess;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
_workProcess = workProcess;
}
private void FormMain_Load(object sender, EventArgs e)
{

View File

@ -101,10 +101,6 @@ namespace FishFactoryBusinessLogic.BusinessLogic
model.Status = element.Status;
model.Count = element.Count;
model.Sum = element.Sum;
if (!model.ImplementerId.HasValue)
{
model.ImplementerId = element.ImplementerId;
}
if (model.Status != orderStatus - 1)
{
@ -113,7 +109,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic
}
model.Status = orderStatus;
if (model.Status == OrderStatus.Выдан)
if (model.Status == OrderStatus.Готов)
{
model.DateImplement = DateTime.Now;
}

View File

@ -1,11 +1,6 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FishFactoryContracts.BusinessLogicsContracts
{
@ -15,17 +10,7 @@ namespace FishFactoryContracts.BusinessLogicsContracts
OrderViewModel? ReadElement(OrderSearchModel model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
/// <summary>
/// Готов
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
bool FinishOrder(OrderBindingModel model);
/// <summary>
/// Доставлен
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
bool DeliveryOrder(OrderBindingModel model);
}
}

View File

@ -1,10 +1,5 @@
using FishFactoryDataModel.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FishFactoryContracts.ViewModels
{
@ -17,7 +12,7 @@ namespace FishFactoryContracts.ViewModels
public string ClientFIO { get; set; } = string.Empty;
public int? ImplementerId { get; set; }
[DisplayName("Исполнитель")]
public string? ImplementerFIO { get; set; } = string.Empty;
public string? ImplementerFIO { get; set; } = null;
public int CannedId { get; set; }
[DisplayName("Изделие")]
public string CannedName { get; set; } = string.Empty;

View File

@ -1,6 +1,6 @@
namespace FishFactoryDataModel.Models
{
public interface IImplementerModel
public interface IImplementerModel : IId
{
string ImplementerFIO { get; }
string Password { get; }

View File

@ -26,7 +26,8 @@ namespace FishFactoryDatabaseImplement.Implements
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
{
if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue)
if (string.IsNullOrEmpty(model.ImplementerFIO) && string.IsNullOrEmpty(model.Password) &&
!model.Id.HasValue)
{
return null;
}

View File

@ -38,9 +38,9 @@ namespace FishFactoryDatabaseImplement.Implements
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
{
return new();
return null;
}
using var context = new FishFactoryDatabase();
return context.Orders

View File

@ -0,0 +1,252 @@
// <auto-generated />
using System;
using FishFactoryDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace FishFactoryDatabaseImplement.Migrations
{
[DbContext(typeof(FishFactoryDatabase))]
[Migration("20240514140738_implementer")]
partial class implementer
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CannedName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Canneds");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CannedId")
.HasColumnType("integer");
b.Property<int>("ComponentId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CannedId");
b.HasIndex("ComponentId");
b.ToTable("CannedComponents");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Cost")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Qualification")
.HasColumnType("integer");
b.Property<int>("WorkExperience")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CannedId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateImplement")
.HasColumnType("timestamp without time zone");
b.Property<int?>("ImplementerId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<double>("Sum")
.HasColumnType("double precision");
b.HasKey("Id");
b.HasIndex("CannedId");
b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.ToTable("Orders");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedComponent", b =>
{
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
.WithMany("Components")
.HasForeignKey("CannedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FishFactoryDatabaseImplement.Models.Component", "Component")
.WithMany("CannedComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Canned");
b.Navigation("Component");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
{
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
.WithMany("Orders")
.HasForeignKey("CannedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FishFactoryDatabaseImplement.Models.Client", "Client")
.WithMany()
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FishFactoryDatabaseImplement.Models.Implementer", "Implementer")
.WithMany("Order")
.HasForeignKey("ImplementerId");
b.Navigation("Canned");
b.Navigation("Client");
b.Navigation("Implementer");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Component", b =>
{
b.Navigation("CannedComponents");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
{
b.Navigation("Order");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FishFactoryDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class implementer : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,252 @@
// <auto-generated />
using System;
using FishFactoryDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace FishFactoryDatabaseImplement.Migrations
{
[DbContext(typeof(FishFactoryDatabase))]
[Migration("20240514143630_implementer2")]
partial class implementer2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CannedName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Canneds");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CannedId")
.HasColumnType("integer");
b.Property<int>("ComponentId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CannedId");
b.HasIndex("ComponentId");
b.ToTable("CannedComponents");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Cost")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Qualification")
.HasColumnType("integer");
b.Property<int>("WorkExperience")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CannedId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime?>("DateImplement")
.HasColumnType("timestamp without time zone");
b.Property<int?>("ImplementerId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<double>("Sum")
.HasColumnType("double precision");
b.HasKey("Id");
b.HasIndex("CannedId");
b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.ToTable("Orders");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedComponent", b =>
{
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
.WithMany("Components")
.HasForeignKey("CannedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FishFactoryDatabaseImplement.Models.Component", "Component")
.WithMany("CannedComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Canned");
b.Navigation("Component");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
{
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
.WithMany("Orders")
.HasForeignKey("CannedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FishFactoryDatabaseImplement.Models.Client", "Client")
.WithMany()
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FishFactoryDatabaseImplement.Models.Implementer", "Implementer")
.WithMany("Order")
.HasForeignKey("ImplementerId");
b.Navigation("Canned");
b.Navigation("Client");
b.Navigation("Implementer");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Component", b =>
{
b.Navigation("CannedComponents");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b =>
{
b.Navigation("Order");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FishFactoryDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class implementer2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -13,9 +13,9 @@ namespace FishFactoryDatabaseImplement.Models
public string Password { get; private set; } = string.Empty;
public int WorkExperience { get; private set; }
public int WorkExperience { get; private set; } = 0;
public int Qualification { get; private set; }
public int Qualification { get; private set; } = 0;
[ForeignKey("ImplementerId")]
public virtual List<Order> Order { get; set; } = new();

View File

@ -39,7 +39,8 @@ namespace FishFactoryDatabaseImplement.Models
ClientId = model.ClientId,
Client = context.Clients.First(x => x.Id == model.ClientId),
ImplementerId = model.ImplementerId,
Implementer = model.ImplementerId.HasValue ? context.Implementers.First(x => x.Id == model.ImplementerId) : null,
Implementer = model.ImplementerId == null ? null : context.Implementers.First(i => i.Id == model.ImplementerId),
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@ -73,7 +74,7 @@ namespace FishFactoryDatabaseImplement.Models
ClientId = ClientId,
ClientFIO = Client.ClientFIO,
ImplementerId = ImplementerId,
ImplementerFIO = Implementer?.ImplementerFIO,
ImplementerFIO = Implementer == null ? string.Empty : Implementer.ImplementerFIO,
Count = Count,
Sum = Sum,
Status = Status,