Правки и тесты

This commit is contained in:
Табеев Александр 2024-05-07 16:15:07 +04:00
parent c8723a1f49
commit 76086d8d76
30 changed files with 921 additions and 97 deletions

View File

@ -20,6 +20,8 @@ namespace AccountingWarehouseProductsContracts.BindingModels
public string SupplierName { get; set; } = string.Empty;
public string WarehouseName { get; set; } = string.Empty;
public int Count { get; set; }
public double Sum { get; set; }

View File

@ -15,9 +15,9 @@ namespace AccountingWarehouseProductsContracts.BindingModels
public double Cost { get; set; }
public string DateofFabrication { get; set; } = string.Empty;
public DateTime DateofFabrication { get; set; }
public string ValidUntil { get; set; } = string.Empty;
public DateTime? ValidUntil { get; set; }
public string Category { get; set; } = string.Empty;
}

View File

@ -11,7 +11,7 @@ namespace AccountingWarehouseProductsContracts.BindingModels
{
public int Id { get; set; }
public string ShipmentDate { get; set; } = string.Empty;
public DateTime? ShipmentDate { get; set; }
public int Count { get; set; }

View File

@ -13,7 +13,7 @@ namespace AccountingWarehouseProductsContracts.BindingModels
public string StandName { get; set; } = string.Empty;
public string DeliveryDate { get; set; } = string.Empty;
public DateTime? DeliveryDate { get; set; }
public int Count { get; set; }

View File

@ -19,6 +19,9 @@ namespace AccountingWarehouseProductsContracts.ViewModels
[DisplayName("Название продукта")]
public string ProductName { get; set; }
[DisplayName("Название поставщика")]
public string SupplierName { get; set; }
[DisplayName("Количество")]
public int Count { get; set; }

View File

@ -19,10 +19,10 @@ namespace AccountingWarehouseProductsContracts.ViewModels
public double Cost { get; set; }
[DisplayName("Дата изготовления")]
public string? DateofFabrication { get; set; } = string.Empty;
public DateTime DateofFabrication { get; set; }
[DisplayName("Годен до")]
public string ValidUntil { get; set; } = string.Empty;
public DateTime? ValidUntil { get; set; }
[DisplayName("Категория")]
public string Category { get; set; } = string.Empty;

View File

@ -14,7 +14,7 @@ namespace AccountingWarehouseProductsContracts.ViewModels
public int Id { get; set; }
[DisplayName("Дата отгрузки")]
public string ShipmentDate { get; set; } = string.Empty;
public DateTime? ShipmentDate { get; set; }
[DisplayName("Количество")]
public int Count { get; set; }

View File

@ -18,7 +18,7 @@ namespace AccountingWarehouseProductsContracts.ViewModels
public string StandName { get; set; } = string.Empty;
[DisplayName("Дата поставки")]
public string? DeliveryDate { get; set; } = string.Empty;
public DateTime? DeliveryDate { get; set; }
[DisplayName("Количество")]
public int Count { get; set; }

View File

@ -13,6 +13,8 @@ namespace AccountingWarehouseProductsDataModels.Models
string ProductName { get; }
string SupplierName { get; }
int Count { get; }
double Sum { get; }

View File

@ -12,9 +12,9 @@ namespace AccountingWarehouseProductsDataModels.Models
double Cost { get; }
string DateofFabrication { get; }
DateTime DateofFabrication { get; }
string ValidUntil { get; }
DateTime? ValidUntil { get; }
string Category { get; }
}

View File

@ -8,7 +8,7 @@ namespace AccountingWarehouseProductsDataModels.Models
{
public interface IShipmentModel : IId
{
string ShipmentDate { get; }
DateTime? ShipmentDate { get; }
int Count { get; }

View File

@ -9,7 +9,7 @@ namespace AccountingWarehouseProductsDataModels.Models
public interface IStandModel : IId
{
string StandName { get; }
string? DeliveryDate { get; }
DateTime? DeliveryDate { get; }
int Count { get; }

View File

@ -0,0 +1,333 @@
// <auto-generated />
using System;
using AccountingWarehouseProductsDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace AccountingWarehouseProductsDatabaseImplement.Migrations
{
[DbContext(typeof(AccountingWarehouseProductsDatabase))]
[Migration("20240507105735_SecondMigration")]
partial class SecondMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateofOrder")
.HasColumnType("datetime2");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<string>("SupplierName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("WarehouseName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ProductId");
b.ToTable("Orders");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.OrderProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<int>("ProductId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("ProductId");
b.ToTable("OrderProduct");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Category")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<string>("DateofFabrication")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ValidUntil")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Shipment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<string>("Recipient")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ShipmentDate")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shipments");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Stand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<string>("DeliveryDate")
.HasColumnType("nvarchar(max)");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<string>("StandName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Stands");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Supplier", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ContactPerson")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SupplierName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Suppliers");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Warehouse", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Capacity")
.HasColumnType("int");
b.Property<string>("WarehouseName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Warehouses");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.WarehouseProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<int>("WarehouseId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("WarehouseId");
b.ToTable("WarehouseProduct");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Order", b =>
{
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Product", "Product")
.WithMany("Orders")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.OrderProduct", b =>
{
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Order", "Order")
.WithMany("Products")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Product", "Product")
.WithMany("OrderProduct")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Product");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.WarehouseProduct", b =>
{
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Warehouse", "Warehouse")
.WithMany("Products")
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Warehouse");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Order", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Product", b =>
{
b.Navigation("OrderProduct");
b.Navigation("Orders");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Warehouse", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AccountingWarehouseProductsDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class SecondMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "SupplierName",
table: "Orders",
type: "nvarchar(max)",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "WarehouseName",
table: "Orders",
type: "nvarchar(max)",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "SupplierName",
table: "Orders");
migrationBuilder.DropColumn(
name: "WarehouseName",
table: "Orders");
}
}
}

View File

@ -0,0 +1,328 @@
// <auto-generated />
using System;
using AccountingWarehouseProductsDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace AccountingWarehouseProductsDatabaseImplement.Migrations
{
[DbContext(typeof(AccountingWarehouseProductsDatabase))]
[Migration("20240507120148_ThirdMigration")]
partial class ThirdMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateofOrder")
.HasColumnType("datetime2");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<string>("SupplierName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ProductId");
b.ToTable("Orders");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.OrderProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<int>("ProductId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("ProductId");
b.ToTable("OrderProduct");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Category")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<DateTime>("DateofFabrication")
.HasColumnType("datetime2");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("ValidUntil")
.IsRequired()
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Shipment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<string>("Recipient")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("ShipmentDate")
.IsRequired()
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("Shipments");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Stand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime?>("DeliveryDate")
.HasColumnType("datetime2");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<string>("StandName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Stands");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Supplier", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ContactPerson")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SupplierName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Suppliers");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Warehouse", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Capacity")
.HasColumnType("int");
b.Property<string>("WarehouseName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Warehouses");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.WarehouseProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<int>("WarehouseId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("WarehouseId");
b.ToTable("WarehouseProduct");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Order", b =>
{
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Product", "Product")
.WithMany("Orders")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.OrderProduct", b =>
{
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Order", "Order")
.WithMany("Products")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Product", "Product")
.WithMany("OrderProduct")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Product");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.WarehouseProduct", b =>
{
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Product", "Product")
.WithMany()
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AccountingWarehouseProductsDatabaseImplement.Models.Warehouse", "Warehouse")
.WithMany("Products")
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Warehouse");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Order", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Product", b =>
{
b.Navigation("OrderProduct");
b.Navigation("Orders");
});
modelBuilder.Entity("AccountingWarehouseProductsDatabaseImplement.Models.Warehouse", b =>
{
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,96 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AccountingWarehouseProductsDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class ThirdMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "WarehouseName",
table: "Orders");
migrationBuilder.AlterColumn<DateTime>(
name: "DeliveryDate",
table: "Stands",
type: "datetime2",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "ShipmentDate",
table: "Shipments",
type: "datetime2",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<DateTime>(
name: "ValidUntil",
table: "Products",
type: "datetime2",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<DateTime>(
name: "DateofFabrication",
table: "Products",
type: "datetime2",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "DeliveryDate",
table: "Stands",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ShipmentDate",
table: "Shipments",
type: "nvarchar(max)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AlterColumn<string>(
name: "ValidUntil",
table: "Products",
type: "nvarchar(max)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AlterColumn<string>(
name: "DateofFabrication",
table: "Products",
type: "nvarchar(max)",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AddColumn<string>(
name: "WarehouseName",
table: "Orders",
type: "nvarchar(max)",
nullable: false,
defaultValue: "");
}
}
}

View File

@ -55,6 +55,10 @@ namespace AccountingWarehouseProductsDatabaseImplement.Migrations
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<string>("SupplierName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ProductId");
@ -103,17 +107,16 @@ namespace AccountingWarehouseProductsDatabaseImplement.Migrations
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<string>("DateofFabrication")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateofFabrication")
.HasColumnType("datetime2");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ValidUntil")
b.Property<DateTime?>("ValidUntil")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("datetime2");
b.HasKey("Id");
@ -138,9 +141,9 @@ namespace AccountingWarehouseProductsDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ShipmentDate")
b.Property<DateTime?>("ShipmentDate")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("datetime2");
b.HasKey("Id");
@ -158,8 +161,8 @@ namespace AccountingWarehouseProductsDatabaseImplement.Migrations
b.Property<int>("Count")
.HasColumnType("int");
b.Property<string>("DeliveryDate")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeliveryDate")
.HasColumnType("datetime2");
b.Property<int>("ProductId")
.HasColumnType("int");

View File

@ -22,6 +22,8 @@ namespace AccountingWarehouseProductsDatabaseImplement.Models
public string ProductName { get; set; }
public string SupplierName { get; set; }
public int Count { get; set; }
public double Sum { get; set; }
@ -59,6 +61,7 @@ namespace AccountingWarehouseProductsDatabaseImplement.Models
ProductId = model.ProductId,
SupplierId = model.SupplierId,
ProductName = model.ProductName,
SupplierName = model.SupplierName,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
@ -92,6 +95,7 @@ namespace AccountingWarehouseProductsDatabaseImplement.Models
ProductId = ProductId,
SupplierId = SupplierId,
ProductName = ProductName,
SupplierName = SupplierName,
Count = Count,
Sum = Sum,
Status = Status,

View File

@ -22,30 +22,15 @@ namespace AccountingWarehouseProductsDatabaseImplement.Models
[Required]
public double Cost { get; set; }
//private Dictionary<int, (IOrderModel, int)>? _orderProducts = null;
[Required]
public DateTime DateofFabrication { get; set; }
[Required]
public string? DateofFabrication { get; set; } = string.Empty;
[Required]
public string ValidUntil { get; set; } = string.Empty;
public DateTime? ValidUntil { get; set; }
[Required]
public string Category { get; set; } = string.Empty;
//[NotMapped]
//public Dictionary<int, (IOrderModel, int)> OrderProducts
//{
// get
// {
// if (_orderProducts == null)
// {
// _orderProducts = Products.ToDictionary(recPC => recPC.ProductId, recPC => (recPC.Product as IProductModel, recPC.Count));
// }
// return _orderProducts;
// }
//}
[ForeignKey("ProductId")]
public virtual List<OrderProduct> OrderProduct { get; set; } = new();

View File

@ -14,7 +14,7 @@ namespace AccountingWarehouseProductsDatabaseImplement.Models
public int Id { get; set; }
[Required]
public string ShipmentDate { get; set; } = string.Empty;
public DateTime? ShipmentDate { get; set; }
[Required]
public int Count { get; set; }

View File

@ -14,7 +14,7 @@ namespace AccountingWarehouseProductsDatabaseImplement.Models
public string StandName { get; set; } = string.Empty;
public string? DeliveryDate { get; set; } = string.Empty;
public DateTime? DeliveryDate { get; set; }
public int Count { get; set; }

View File

@ -42,6 +42,7 @@
buttonArrangeOrder = new Button();
buttonChekOrder = new Button();
buttonDeliverOrder = new Button();
buttonTest = new Button();
menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
@ -173,11 +174,22 @@
buttonDeliverOrder.UseVisualStyleBackColor = true;
buttonDeliverOrder.Click += buttonDeliverOrder_Click;
//
// buttonTest
//
buttonTest.Location = new Point(1106, 366);
buttonTest.Name = "buttonTest";
buttonTest.Size = new Size(129, 43);
buttonTest.TabIndex = 8;
buttonTest.Text = "Тест времени";
buttonTest.UseVisualStyleBackColor = true;
buttonTest.Click += buttonTest_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1260, 450);
Controls.Add(buttonTest);
Controls.Add(buttonDeliverOrder);
Controls.Add(buttonChekOrder);
Controls.Add(buttonArrangeOrder);
@ -213,5 +225,6 @@
private Button buttonArrangeOrder;
private Button buttonChekOrder;
private Button buttonDeliverOrder;
private Button buttonTest;
}
}

View File

@ -16,10 +16,12 @@ namespace AccountingWarehouseProductsView
public partial class FormMain : Form
{
private readonly IOrderLogic _logic;
public FormMain(IOrderLogic logic)
private readonly IProductLogic _productLogic;
public FormMain(IOrderLogic logic, IProductLogic productLogic)
{
InitializeComponent();
_logic = logic;
_productLogic = productLogic;
}
private void продуктToolStripMenuItem_Click(object sender, EventArgs e)
@ -225,5 +227,23 @@ namespace AccountingWarehouseProductsView
}
}
}
private void buttonTest_Click(object sender, EventArgs e)
{
ProductBindingModel model = new ProductBindingModel()
{
ProductName = "Вкуснятина",
Cost = 1000000,
DateofFabrication = DateTime.Now,
ValidUntil = null,
Category = "Вкусное"
};
DateTime start = DateTime.Now;
_productLogic.Create(model);
DateTime stop = DateTime.Now;
MessageBox.Show((stop - start).ToString(), "Test", MessageBoxButtons.OK);
}
}
}

View File

@ -36,10 +36,10 @@
textBoxName = new TextBox();
textBoxPrice = new TextBox();
textBoxCategory = new TextBox();
textBoxDateofFabrication = new TextBox();
textBoxValidUntil = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
dateTimePickerDateofFabrication = new DateTimePicker();
dateTimePickerValidUntil = new DateTimePicker();
SuspendLayout();
//
// labelName
@ -113,20 +113,6 @@
textBoxCategory.Size = new Size(221, 23);
textBoxCategory.TabIndex = 7;
//
// textBoxDateofFabrication
//
textBoxDateofFabrication.Location = new Point(166, 152);
textBoxDateofFabrication.Name = "textBoxDateofFabrication";
textBoxDateofFabrication.Size = new Size(164, 23);
textBoxDateofFabrication.TabIndex = 8;
//
// textBoxValidUntil
//
textBoxValidUntil.Location = new Point(109, 194);
textBoxValidUntil.Name = "textBoxValidUntil";
textBoxValidUntil.Size = new Size(221, 23);
textBoxValidUntil.TabIndex = 9;
//
// buttonSave
//
buttonSave.Location = new Point(383, 23);
@ -147,15 +133,29 @@
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// dateTimePickerDateofFabrication
//
dateTimePickerDateofFabrication.Location = new Point(166, 150);
dateTimePickerDateofFabrication.Name = "dateTimePickerDateofFabrication";
dateTimePickerDateofFabrication.Size = new Size(164, 23);
dateTimePickerDateofFabrication.TabIndex = 12;
//
// dateTimePickerValidUntil
//
dateTimePickerValidUntil.Location = new Point(109, 194);
dateTimePickerValidUntil.Name = "dateTimePickerValidUntil";
dateTimePickerValidUntil.Size = new Size(221, 23);
dateTimePickerValidUntil.TabIndex = 13;
//
// FormProduct
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(538, 313);
Controls.Add(dateTimePickerValidUntil);
Controls.Add(dateTimePickerDateofFabrication);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxValidUntil);
Controls.Add(textBoxDateofFabrication);
Controls.Add(textBoxCategory);
Controls.Add(textBoxPrice);
Controls.Add(textBoxName);
@ -181,9 +181,9 @@
private TextBox textBoxName;
private TextBox textBoxPrice;
private TextBox textBoxCategory;
private TextBox textBoxDateofFabrication;
private TextBox textBoxValidUntil;
private Button buttonSave;
private Button buttonCancel;
private DateTimePicker dateTimePickerDateofFabrication;
private DateTimePicker dateTimePickerValidUntil;
}
}

View File

@ -36,8 +36,8 @@ namespace AccountingWarehouseProductsView
textBoxName.Text = view.ProductName;
textBoxPrice.Text = view.Cost.ToString();
textBoxCategory.Text = view.Category;
textBoxDateofFabrication.Text = view.DateofFabrication;
textBoxValidUntil.Text = view.ValidUntil;
dateTimePickerDateofFabrication.Value = view.DateofFabrication;
dateTimePickerValidUntil.Value = (DateTime)view.ValidUntil;
}
}
catch (Exception ex)
@ -63,8 +63,8 @@ namespace AccountingWarehouseProductsView
ProductName = textBoxName.Text,
Cost = Convert.ToDouble(textBoxPrice.Text),
Category = textBoxCategory.Text,
DateofFabrication = textBoxDateofFabrication.Text,
ValidUntil = textBoxValidUntil.Text
DateofFabrication = dateTimePickerDateofFabrication.Value,
ValidUntil = dateTimePickerValidUntil.Value
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)

View File

@ -31,11 +31,11 @@
labelShipmentDate = new Label();
labelCount = new Label();
labelRecipient = new Label();
textBoxShipmentDate = new TextBox();
textBoxCount = new TextBox();
textBoxRecipient = new TextBox();
ButtonSave = new Button();
ButtonCancel = new Button();
dateTimePickerShipmentDate = new DateTimePicker();
SuspendLayout();
//
// labelShipmentDate
@ -68,13 +68,6 @@
labelRecipient.TabIndex = 2;
labelRecipient.Text = "Получатель:";
//
// textBoxShipmentDate
//
textBoxShipmentDate.Location = new Point(145, 33);
textBoxShipmentDate.Name = "textBoxShipmentDate";
textBoxShipmentDate.Size = new Size(182, 23);
textBoxShipmentDate.TabIndex = 3;
//
// textBoxCount
//
textBoxCount.Location = new Point(145, 77);
@ -109,16 +102,23 @@
ButtonCancel.UseVisualStyleBackColor = true;
ButtonCancel.Click += buttonCancel_Click;
//
// dateTimePickerShipmentDate
//
dateTimePickerShipmentDate.Location = new Point(145, 31);
dateTimePickerShipmentDate.Name = "dateTimePickerShipmentDate";
dateTimePickerShipmentDate.Size = new Size(182, 23);
dateTimePickerShipmentDate.TabIndex = 8;
//
// FormShipment
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(385, 283);
Controls.Add(dateTimePickerShipmentDate);
Controls.Add(ButtonCancel);
Controls.Add(ButtonSave);
Controls.Add(textBoxRecipient);
Controls.Add(textBoxCount);
Controls.Add(textBoxShipmentDate);
Controls.Add(labelRecipient);
Controls.Add(labelCount);
Controls.Add(labelShipmentDate);
@ -134,10 +134,10 @@
private Label labelShipmentDate;
private Label labelCount;
private Label labelRecipient;
private TextBox textBoxShipmentDate;
private TextBox textBoxCount;
private TextBox textBoxRecipient;
private Button ButtonSave;
private Button ButtonCancel;
private DateTimePicker dateTimePickerShipmentDate;
}
}

View File

@ -33,7 +33,7 @@ namespace AccountingWarehouseProductsView
var view = _logic.ReadElement(new ShipmentSearchModel { Id = _id.Value });
if (view != null)
{
textBoxShipmentDate.Text = view.ShipmentDate;
dateTimePickerShipmentDate.Value = (DateTime)view.ShipmentDate;
textBoxCount.Text = view.Count.ToString();
textBoxRecipient.Text = view.Recipient;
}
@ -58,7 +58,7 @@ namespace AccountingWarehouseProductsView
var model = new ShipmentBindingModel
{
Id = _id ?? 0,
ShipmentDate = textBoxShipmentDate.Text,
ShipmentDate = dateTimePickerShipmentDate.Value,
Count = Convert.ToInt32(textBoxCount.Text),
Recipient = textBoxRecipient.Text,
};

View File

@ -30,12 +30,12 @@
{
labelDeliveryDate = new Label();
labelCount = new Label();
textBoxDeliveryDate = new TextBox();
textBoxCount = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
labelNameStand = new Label();
textBoxNameStand = new TextBox();
dateTimePickerDeliveryDate = new DateTimePicker();
SuspendLayout();
//
// labelDeliveryDate
@ -58,13 +58,6 @@
labelCount.TabIndex = 1;
labelCount.Text = "Количество:";
//
// textBoxDeliveryDate
//
textBoxDeliveryDate.Location = new Point(151, 65);
textBoxDeliveryDate.Name = "textBoxDeliveryDate";
textBoxDeliveryDate.Size = new Size(218, 23);
textBoxDeliveryDate.TabIndex = 2;
//
// textBoxCount
//
textBoxCount.Location = new Point(151, 116);
@ -109,17 +102,24 @@
textBoxNameStand.Size = new Size(191, 23);
textBoxNameStand.TabIndex = 7;
//
// dateTimePickerDeliveryDate
//
dateTimePickerDeliveryDate.Location = new Point(151, 65);
dateTimePickerDeliveryDate.Name = "dateTimePickerDeliveryDate";
dateTimePickerDeliveryDate.Size = new Size(218, 23);
dateTimePickerDeliveryDate.TabIndex = 8;
//
// FormStand
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(451, 274);
Controls.Add(dateTimePickerDeliveryDate);
Controls.Add(textBoxNameStand);
Controls.Add(labelNameStand);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxCount);
Controls.Add(textBoxDeliveryDate);
Controls.Add(labelCount);
Controls.Add(labelDeliveryDate);
Name = "FormStand";
@ -133,11 +133,11 @@
private Label labelDeliveryDate;
private Label labelCount;
private TextBox textBoxDeliveryDate;
private TextBox textBoxCount;
private Button buttonSave;
private Button buttonCancel;
private Label labelNameStand;
private TextBox textBoxNameStand;
private DateTimePicker dateTimePickerDeliveryDate;
}
}

View File

@ -1,6 +1,7 @@
using AccountingWarehouseProductsContracts.BindingModels;
using AccountingWarehouseProductsContracts.BusinessLogicsContracts;
using AccountingWarehouseProductsContracts.SearchModels;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -34,7 +35,7 @@ namespace AccountingWarehouseProductsView
if (view != null)
{
textBoxNameStand.Text = view.StandName;
textBoxDeliveryDate.Text = view.DeliveryDate;
dateTimePickerDeliveryDate.Value = (DateTime)view.DeliveryDate;
textBoxCount.Text = view.Count.ToString();
}
}
@ -47,19 +48,13 @@ namespace AccountingWarehouseProductsView
private void buttonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxDeliveryDate.Text))
{
MessageBox.Show("Заполните Дату поставки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new StandBindingModel
{
Id = _id ?? 0,
StandName = textBoxNameStand.Text,
DeliveryDate = textBoxDeliveryDate.Text,
DeliveryDate = dateTimePickerDeliveryDate.Value,
Count = Convert.ToInt32(textBoxCount.Text),
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);

View File

@ -104,7 +104,7 @@
Controls.Add(ButtonAdd);
Controls.Add(dataGridView);
Name = "FormStands";
Text = "Отгрузки";
Text = "Поставки";
Load += FormStands_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);