generated from admin/template
port3000
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"Version": 1,
|
||||||
|
"WorkspaceRootPath": "C:\\Users\\Alexa\\Desktop\\miu\\zxc-alexa\\works\\demo\\1\\demka\\",
|
||||||
|
"Documents": [],
|
||||||
|
"DocumentGroupContainers": [
|
||||||
|
{
|
||||||
|
"Orientation": 0,
|
||||||
|
"VerticalTabListWidth": 256,
|
||||||
|
"DocumentGroups": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class Category
|
||||||
|
{
|
||||||
|
public int IdCategory { get; set; }
|
||||||
|
|
||||||
|
public string? NameCategory { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class Manufacturer
|
||||||
|
{
|
||||||
|
public int IdManufacturer { get; set; }
|
||||||
|
|
||||||
|
public string? NameManufacturer { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class Order
|
||||||
|
{
|
||||||
|
public int IdOrder { get; set; }
|
||||||
|
|
||||||
|
public string? OrderDate { get; set; }
|
||||||
|
|
||||||
|
public string? DeliveryDate { get; set; }
|
||||||
|
|
||||||
|
public int? IdPoint { get; set; }
|
||||||
|
|
||||||
|
public int? IdUser { get; set; }
|
||||||
|
|
||||||
|
public int? ReceiveCode { get; set; }
|
||||||
|
|
||||||
|
public int? IdStatus { get; set; }
|
||||||
|
|
||||||
|
public virtual Point? IdPointNavigation { get; set; }
|
||||||
|
|
||||||
|
public virtual Status? IdStatusNavigation { get; set; }
|
||||||
|
|
||||||
|
public virtual User? IdUserNavigation { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<OrderProduct> OrderProducts { get; set; } = new List<OrderProduct>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class OrderProduct
|
||||||
|
{
|
||||||
|
public int? IdOrder { get; set; }
|
||||||
|
|
||||||
|
public int? IdProduct { get; set; }
|
||||||
|
|
||||||
|
public int? Quantity { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 1
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public virtual Order? IdOrderNavigation { get; set; }
|
||||||
|
|
||||||
|
public virtual Product? IdProductNavigation { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class Point
|
||||||
|
{
|
||||||
|
public int IdPoint { get; set; }
|
||||||
|
|
||||||
|
public int? Index { get; set; }
|
||||||
|
|
||||||
|
public string? City { get; set; }
|
||||||
|
|
||||||
|
public string? Street { get; set; }
|
||||||
|
|
||||||
|
public int? House { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
|
||||||
|
}
|
||||||
@@ -15,75 +15,136 @@ public partial class PostgresContext : DbContext
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual DbSet<IdCategory> IdCategories { get; set; }
|
public virtual DbSet<Category> Categories { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<IdManufacturer> IdManufacturers { get; set; }
|
public virtual DbSet<Manufacturer> Manufacturers { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<IdOrder> IdOrders { get; set; }
|
public virtual DbSet<Order> Orders { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<IdProduct> IdProducts { get; set; }
|
public virtual DbSet<OrderProduct> OrderProducts { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<IdStatus> IdStatuses { get; set; }
|
public virtual DbSet<Point> Points { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<IdSupplier> IdSuppliers { get; set; }
|
public virtual DbSet<Product> Products { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<IdUnit> IdUnits { get; set; }
|
public virtual DbSet<Role> Roles { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<RoleId> RoleIds { get; set; }
|
public virtual DbSet<Status> Statuses { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<Tovar> Tovars { get; set; }
|
public virtual DbSet<Supplier> Suppliers { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<UserId> UserIds { get; set; }
|
public virtual DbSet<Unit> Units { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<ЗаказImport> ЗаказImports { get; set; }
|
public virtual DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
|
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
|
||||||
=> optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=mysecretpassword");
|
=> optionsBuilder.UseNpgsql("Host=localhost;Port=5434;Database=postgres;Username=postgres;Password=mysecretpassword");
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.Entity<IdCategory>(entity =>
|
modelBuilder.Entity<Category>(entity =>
|
||||||
{
|
{
|
||||||
entity
|
entity.HasKey(e => e.IdCategory).HasName("id_category_pk");
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("id_category");
|
|
||||||
|
|
||||||
entity.Property(e => e.IdCategory1).HasColumnName("id_category");
|
entity.Property(e => e.IdCategory)
|
||||||
|
.ValueGeneratedNever()
|
||||||
|
.HasColumnName("id_category");
|
||||||
entity.Property(e => e.NameCategory)
|
entity.Property(e => e.NameCategory)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnName("name_category");
|
.HasColumnName("name_category");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<IdManufacturer>(entity =>
|
modelBuilder.Entity<Manufacturer>(entity =>
|
||||||
{
|
{
|
||||||
entity
|
entity.HasKey(e => e.IdManufacturer).HasName("id_manufacturer_pk");
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("id_manufacturer");
|
|
||||||
|
|
||||||
entity.Property(e => e.IdManufacturer1).HasColumnName("id_manufacturer");
|
entity.Property(e => e.IdManufacturer)
|
||||||
|
.ValueGeneratedNever()
|
||||||
|
.HasColumnName("id_manufacturer");
|
||||||
entity.Property(e => e.NameManufacturer)
|
entity.Property(e => e.NameManufacturer)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnName("name_manufacturer");
|
.HasColumnName("name_manufacturer");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<IdOrder>(entity =>
|
modelBuilder.Entity<Order>(entity =>
|
||||||
{
|
{
|
||||||
entity
|
entity.HasKey(e => e.IdOrder).HasName("заказ_import_pk");
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("id_order");
|
|
||||||
|
|
||||||
entity.Property(e => e.IdOrder1).HasColumnName("id_order");
|
entity.Property(e => e.IdOrder)
|
||||||
entity.Property(e => e.IdProduct).HasColumnName("id_product");
|
.ValueGeneratedNever()
|
||||||
entity.Property(e => e.Quantity).HasColumnName("quantity");
|
.HasColumnName("id_order");
|
||||||
|
entity.Property(e => e.DeliveryDate)
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnName("delivery_date");
|
||||||
|
entity.Property(e => e.IdPoint).HasColumnName("id_point");
|
||||||
|
entity.Property(e => e.IdStatus).HasColumnName("id_status");
|
||||||
|
entity.Property(e => e.IdUser).HasColumnName("id_user");
|
||||||
|
entity.Property(e => e.OrderDate)
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnName("order_date");
|
||||||
|
entity.Property(e => e.ReceiveCode).HasColumnName("receive_code");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdPointNavigation).WithMany(p => p.Orders)
|
||||||
|
.HasForeignKey(d => d.IdPoint)
|
||||||
|
.HasConstraintName("заказ_import_tovar_fk");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdStatusNavigation).WithMany(p => p.Orders)
|
||||||
|
.HasForeignKey(d => d.IdStatus)
|
||||||
|
.HasConstraintName("заказ_import_id_status_fk");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdUserNavigation).WithMany(p => p.Orders)
|
||||||
|
.HasForeignKey(d => d.IdUser)
|
||||||
|
.HasConstraintName("заказ_import_user_id_fk");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<IdProduct>(entity =>
|
modelBuilder.Entity<OrderProduct>(entity =>
|
||||||
{
|
{
|
||||||
entity
|
entity.HasKey(e => e.Id).HasName("id_order_pk");
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("id_product");
|
|
||||||
|
|
||||||
|
entity.ToTable("Order_product");
|
||||||
|
|
||||||
|
entity.Property(e => e.Id)
|
||||||
|
.HasComment("1")
|
||||||
|
.UseIdentityAlwaysColumn()
|
||||||
|
.HasColumnName("id");
|
||||||
|
entity.Property(e => e.IdOrder).HasColumnName("id_order");
|
||||||
|
entity.Property(e => e.IdProduct).HasColumnName("id_product");
|
||||||
|
entity.Property(e => e.Quantity).HasColumnName("quantity");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdOrderNavigation).WithMany(p => p.OrderProducts)
|
||||||
|
.HasForeignKey(d => d.IdOrder)
|
||||||
|
.HasConstraintName("id_order_заказ_import_fk");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdProductNavigation).WithMany(p => p.OrderProducts)
|
||||||
|
.HasForeignKey(d => d.IdProduct)
|
||||||
|
.HasConstraintName("id_order_id_product_fk");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<Point>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.IdPoint).HasName("tovar_pk");
|
||||||
|
|
||||||
|
entity.Property(e => e.IdPoint)
|
||||||
|
.ValueGeneratedNever()
|
||||||
|
.HasColumnName("id_point");
|
||||||
|
entity.Property(e => e.City)
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnName("city");
|
||||||
|
entity.Property(e => e.House).HasColumnName("house");
|
||||||
|
entity.Property(e => e.Index).HasColumnName("index");
|
||||||
|
entity.Property(e => e.Street)
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnName("street");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<Product>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.IdProduct).HasName("id_product_pk");
|
||||||
|
|
||||||
|
entity.Property(e => e.IdProduct)
|
||||||
|
.ValueGeneratedNever()
|
||||||
|
.HasColumnName("id_product");
|
||||||
entity.Property(e => e.Article)
|
entity.Property(e => e.Article)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnName("article");
|
.HasColumnName("article");
|
||||||
@@ -93,7 +154,6 @@ public partial class PostgresContext : DbContext
|
|||||||
entity.Property(e => e.Discount).HasColumnName("discount");
|
entity.Property(e => e.Discount).HasColumnName("discount");
|
||||||
entity.Property(e => e.IdCategory).HasColumnName("id_category");
|
entity.Property(e => e.IdCategory).HasColumnName("id_category");
|
||||||
entity.Property(e => e.IdManufacturer).HasColumnName("id_manufacturer");
|
entity.Property(e => e.IdManufacturer).HasColumnName("id_manufacturer");
|
||||||
entity.Property(e => e.IdProduct1).HasColumnName("id_product");
|
|
||||||
entity.Property(e => e.IdSupplier).HasColumnName("id_supplier");
|
entity.Property(e => e.IdSupplier).HasColumnName("id_supplier");
|
||||||
entity.Property(e => e.IdUnit).HasColumnName("id_unit");
|
entity.Property(e => e.IdUnit).HasColumnName("id_unit");
|
||||||
entity.Property(e => e.Name)
|
entity.Property(e => e.Name)
|
||||||
@@ -104,115 +164,93 @@ public partial class PostgresContext : DbContext
|
|||||||
.HasColumnName("photo");
|
.HasColumnName("photo");
|
||||||
entity.Property(e => e.Price).HasColumnName("price");
|
entity.Property(e => e.Price).HasColumnName("price");
|
||||||
entity.Property(e => e.StockQty).HasColumnName("stock_qty");
|
entity.Property(e => e.StockQty).HasColumnName("stock_qty");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdCategoryNavigation).WithMany(p => p.Products)
|
||||||
|
.HasForeignKey(d => d.IdCategory)
|
||||||
|
.HasConstraintName("id_product_id_category_fk");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdManufacturerNavigation).WithMany(p => p.Products)
|
||||||
|
.HasForeignKey(d => d.IdManufacturer)
|
||||||
|
.HasConstraintName("id_product_id_manufacturer_fk");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdSupplierNavigation).WithMany(p => p.Products)
|
||||||
|
.HasForeignKey(d => d.IdSupplier)
|
||||||
|
.HasConstraintName("id_product_id_supplier_fk");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.IdUnitNavigation).WithMany(p => p.Products)
|
||||||
|
.HasForeignKey(d => d.IdUnit)
|
||||||
|
.HasConstraintName("id_product_id_unit_fk");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<IdStatus>(entity =>
|
modelBuilder.Entity<Role>(entity =>
|
||||||
{
|
{
|
||||||
entity
|
entity.HasKey(e => e.IdRole).HasName("role_id_pk");
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("id_status");
|
|
||||||
|
|
||||||
entity.Property(e => e.IdStatus1).HasColumnName("id_status");
|
entity.Property(e => e.IdRole)
|
||||||
entity.Property(e => e.NameStatus)
|
.ValueGeneratedNever()
|
||||||
.HasMaxLength(50)
|
.HasColumnName("id_role");
|
||||||
.HasColumnName("name_status");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity<IdSupplier>(entity =>
|
|
||||||
{
|
|
||||||
entity
|
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("id_supplier");
|
|
||||||
|
|
||||||
entity.Property(e => e.IdSupplier1).HasColumnName("id_supplier");
|
|
||||||
entity.Property(e => e.NameSupplier)
|
|
||||||
.HasMaxLength(50)
|
|
||||||
.HasColumnName("name_supplier");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity<IdUnit>(entity =>
|
|
||||||
{
|
|
||||||
entity
|
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("id_unit");
|
|
||||||
|
|
||||||
entity.Property(e => e.IdUnit1).HasColumnName("id_unit");
|
|
||||||
entity.Property(e => e.NameUnit)
|
|
||||||
.HasMaxLength(50)
|
|
||||||
.HasColumnName("name_unit");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity<RoleId>(entity =>
|
|
||||||
{
|
|
||||||
entity
|
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("role_id");
|
|
||||||
|
|
||||||
entity.Property(e => e.IdRole).HasColumnName("id_role");
|
|
||||||
entity.Property(e => e.NameRole)
|
entity.Property(e => e.NameRole)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnName("name_role");
|
.HasColumnName("name_role");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<Tovar>(entity =>
|
modelBuilder.Entity<Status>(entity =>
|
||||||
{
|
{
|
||||||
entity
|
entity.HasKey(e => e.IdStatus).HasName("id_status_pk");
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("tovar");
|
|
||||||
|
|
||||||
entity.Property(e => e.City)
|
entity.Property(e => e.IdStatus)
|
||||||
|
.ValueGeneratedNever()
|
||||||
|
.HasColumnName("id_status");
|
||||||
|
entity.Property(e => e.NameStatus)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnName("city");
|
.HasColumnName("name_status");
|
||||||
entity.Property(e => e.Column10).HasMaxLength(50);
|
|
||||||
entity.Property(e => e.Column11).HasMaxLength(50);
|
|
||||||
entity.Property(e => e.Column6).HasMaxLength(50);
|
|
||||||
entity.Property(e => e.Column7).HasMaxLength(50);
|
|
||||||
entity.Property(e => e.Column8).HasMaxLength(50);
|
|
||||||
entity.Property(e => e.Column9).HasMaxLength(50);
|
|
||||||
entity.Property(e => e.House).HasColumnName("house");
|
|
||||||
entity.Property(e => e.IdPoint).HasColumnName("id_point");
|
|
||||||
entity.Property(e => e.Index).HasColumnName("index");
|
|
||||||
entity.Property(e => e.Street)
|
|
||||||
.HasMaxLength(50)
|
|
||||||
.HasColumnName("street");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<UserId>(entity =>
|
modelBuilder.Entity<Supplier>(entity =>
|
||||||
{
|
{
|
||||||
entity
|
entity.HasKey(e => e.IdSupplier).HasName("id_supplier_pk");
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("user_id");
|
|
||||||
|
|
||||||
|
entity.Property(e => e.IdSupplier)
|
||||||
|
.ValueGeneratedNever()
|
||||||
|
.HasColumnName("id_supplier");
|
||||||
|
entity.Property(e => e.NameSupplier)
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnName("name_supplier");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<Unit>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.IdUnit).HasName("id_unit_pk");
|
||||||
|
|
||||||
|
entity.Property(e => e.IdUnit)
|
||||||
|
.ValueGeneratedNever()
|
||||||
|
.HasColumnName("id_unit");
|
||||||
|
entity.Property(e => e.NameUnit)
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnName("name_unit");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<User>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(e => e.IdUser).HasName("user_id_pk");
|
||||||
|
|
||||||
|
entity.Property(e => e.IdUser)
|
||||||
|
.ValueGeneratedNever()
|
||||||
|
.HasColumnName("id_user");
|
||||||
entity.Property(e => e.FullName)
|
entity.Property(e => e.FullName)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnName("full_name");
|
.HasColumnName("full_name");
|
||||||
entity.Property(e => e.IdRole).HasColumnName("id_role");
|
entity.Property(e => e.IdRole).HasColumnName("id_role");
|
||||||
entity.Property(e => e.IdUser).HasColumnName("id_user");
|
|
||||||
entity.Property(e => e.Login)
|
entity.Property(e => e.Login)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnName("login");
|
.HasColumnName("login");
|
||||||
entity.Property(e => e.Password)
|
entity.Property(e => e.Password)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasColumnName("password");
|
.HasColumnName("password");
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity<ЗаказImport>(entity =>
|
entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.Users)
|
||||||
{
|
.HasForeignKey(d => d.IdRole)
|
||||||
entity
|
.HasConstraintName("user_id_role_id_fk");
|
||||||
.HasNoKey()
|
|
||||||
.ToTable("заказ_import");
|
|
||||||
|
|
||||||
entity.Property(e => e.DeliveryDate)
|
|
||||||
.HasMaxLength(50)
|
|
||||||
.HasColumnName("delivery_date");
|
|
||||||
entity.Property(e => e.IdOrder).HasColumnName("id_order");
|
|
||||||
entity.Property(e => e.IdPoint).HasColumnName("id_point");
|
|
||||||
entity.Property(e => e.IdStatus).HasColumnName("id_status");
|
|
||||||
entity.Property(e => e.IdUser).HasColumnName("id_user");
|
|
||||||
entity.Property(e => e.OrderDate)
|
|
||||||
.HasMaxLength(50)
|
|
||||||
.HasColumnName("order_date");
|
|
||||||
entity.Property(e => e.ReceiveCode).HasColumnName("receive_code");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
OnModelCreatingPartial(modelBuilder);
|
OnModelCreatingPartial(modelBuilder);
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class Product
|
||||||
|
{
|
||||||
|
public int IdProduct { get; set; }
|
||||||
|
|
||||||
|
public string? Article { get; set; }
|
||||||
|
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
public int? IdUnit { get; set; }
|
||||||
|
|
||||||
|
public int? Price { get; set; }
|
||||||
|
|
||||||
|
public int? IdSupplier { get; set; }
|
||||||
|
|
||||||
|
public int? IdManufacturer { get; set; }
|
||||||
|
|
||||||
|
public int? IdCategory { get; set; }
|
||||||
|
|
||||||
|
public int? Discount { get; set; }
|
||||||
|
|
||||||
|
public int? StockQty { get; set; }
|
||||||
|
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
|
public string? Photo { get; set; }
|
||||||
|
|
||||||
|
public virtual Category? IdCategoryNavigation { get; set; }
|
||||||
|
|
||||||
|
public virtual Manufacturer? IdManufacturerNavigation { get; set; }
|
||||||
|
|
||||||
|
public virtual Supplier? IdSupplierNavigation { get; set; }
|
||||||
|
|
||||||
|
public virtual Unit? IdUnitNavigation { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<OrderProduct> OrderProducts { get; set; } = new List<OrderProduct>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class Role
|
||||||
|
{
|
||||||
|
public int IdRole { get; set; }
|
||||||
|
|
||||||
|
public string? NameRole { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<User> Users { get; set; } = new List<User>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class Status
|
||||||
|
{
|
||||||
|
public int IdStatus { get; set; }
|
||||||
|
|
||||||
|
public string? NameStatus { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class Supplier
|
||||||
|
{
|
||||||
|
public int IdSupplier { get; set; }
|
||||||
|
|
||||||
|
public string? NameSupplier { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class Unit
|
||||||
|
{
|
||||||
|
public int IdUnit { get; set; }
|
||||||
|
|
||||||
|
public string? NameUnit { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace demka.Models;
|
||||||
|
|
||||||
|
public partial class User
|
||||||
|
{
|
||||||
|
public int IdUser { get; set; }
|
||||||
|
|
||||||
|
public string? FullName { get; set; }
|
||||||
|
|
||||||
|
public string? Login { get; set; }
|
||||||
|
|
||||||
|
public string? Password { get; set; }
|
||||||
|
|
||||||
|
public int? IdRole { get; set; }
|
||||||
|
|
||||||
|
public virtual Role? IdRoleNavigation { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
|
||||||
|
}
|
||||||
@@ -3,41 +3,45 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:models="clr-namespace:demka.Models"
|
xmlns:models="clr-namespace:demka.Models"
|
||||||
|
xmlns:views="clr-namespace:demka.Views"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="demka.Views.MainWindow"
|
x:Class="demka.Views.MainWindow"
|
||||||
Title="demka">
|
x:DataType="views:MainWindow"
|
||||||
|
Title="demka - Авторизация">
|
||||||
|
|
||||||
<!-- главный каркас топ-бар и список -->
|
<StackPanel Spacing="10" Margin="20">
|
||||||
<Grid RowDefinitions="Auto, *" Margin="20">
|
|
||||||
|
|
||||||
<!-- топ-бар поиск, сортировка, фильтр -->
|
<!-- Заголовок -->
|
||||||
<Grid Grid.Row="0" ColumnDefinitions="*, Auto, Auto" ColumnSpacing="10" Margin="0,0,0,20">
|
<TextBlock Text="Вход"
|
||||||
<TextBox Grid.Column="0" Watermark="Введите для поиска" />
|
FontSize="22"
|
||||||
<ComboBox Grid.Column="1" PlaceholderText="Сортировка" MinWidth="120" HorizontalAlignment="Stretch" />
|
FontWeight="Bold" />
|
||||||
<ComboBox Grid.Column="2" PlaceholderText="Фильтрация" MinWidth="120" HorizontalAlignment="Stretch" />
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<!-- Список элементов ListBox -->
|
<!-- Поле имени -->
|
||||||
<ListBox Grid.Row="1" x:Name="ProductList">
|
<TextBlock Text="Логин:" />
|
||||||
<ListBox.ItemTemplate>
|
<TextBox x:Name="NameTextBox"
|
||||||
<DataTemplate DataType="{x:Type models:Tovar}">
|
PlaceholderText="Введите ваш логин" />
|
||||||
<StackPanel Margin="8" Spacing="4">
|
|
||||||
<!-- Основная информация об адресе / пункте -->
|
<!-- Поле пароля -->
|
||||||
|
<TextBlock Text="Пароль:" />
|
||||||
|
<TextBox x:Name="PasswordTextBox"
|
||||||
|
PasswordChar="•" />
|
||||||
|
|
||||||
|
<!-- Кнопки -->
|
||||||
<StackPanel Orientation="Horizontal" Spacing="10">
|
<StackPanel Orientation="Horizontal" Spacing="10">
|
||||||
<TextBlock Text="{Binding City, StringFormat='Город: {0}'}" FontWeight="SemiBold" FontSize="16" />
|
<Button x:Name="SubmitButton"
|
||||||
<TextBlock Text="{Binding Street, StringFormat='Улица: {0}'}" FontSize="16" />
|
Content="Вход"
|
||||||
<TextBlock Text="{Binding House, StringFormat='Д. {0}'}" FontSize="16" />
|
Click="OnSubmitClick" />
|
||||||
|
<Button x:Name="OnLoginButton"
|
||||||
|
Content="Войти как гость"
|
||||||
|
Foreground="Blue"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Click="OnLoginClick" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Дополнительные поля -->
|
<!-- Сообщение о результате -->
|
||||||
<StackPanel Orientation="Horizontal" Spacing="15">
|
<TextBlock x:Name="MessageText"
|
||||||
<TextBlock Text="{Binding Index, StringFormat='Индекс: {0}', TargetNullValue='—'}" Foreground="Gray" FontSize="12" />
|
Foreground="Gray"
|
||||||
<TextBlock Text="{Binding IdPoint, StringFormat='ID пункта: {0}', TargetNullValue='—'}" Foreground="Gray" FontSize="12" />
|
TextWrapping="Wrap" />
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.ItemTemplate>
|
|
||||||
</ListBox>
|
|
||||||
|
|
||||||
</Grid>
|
</StackPanel>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -1,24 +1,62 @@
|
|||||||
|
using System;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Media;
|
||||||
using demka.Models;
|
using demka.Models;
|
||||||
using System.Linq;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace demka.Views;
|
||||||
|
|
||||||
namespace demka.Views
|
|
||||||
{
|
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
// создание контекста базы данных
|
private async void OnSubmitClick(object sender, RoutedEventArgs e)
|
||||||
using var context = new PostgresContext();
|
{
|
||||||
|
string login = NameTextBox.Text?.Trim() ?? "";
|
||||||
|
string password = PasswordTextBox.Text ?? "";
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(login) || string.IsNullOrWhiteSpace(password))
|
||||||
|
{
|
||||||
|
MessageText.Text = "Заполните все поля!";
|
||||||
|
MessageText.Foreground = Brushes.Red;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var items = context.Tovars.ToList();
|
using var db = new PostgresContext();
|
||||||
|
|
||||||
// установка источника данных в code-behind
|
// Подгружаем роль пользователя с помощью Include
|
||||||
ProductList.ItemsSource = items;
|
var user = await db.Users
|
||||||
|
.Include(u => u.IdRoleNavigation)
|
||||||
|
.FirstOrDefaultAsync(u => u.Login == login && u.Password == password);
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
MessageText.Text = "Неверный логин или пароль!";
|
||||||
|
MessageText.Foreground = Brushes.Red;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageText.Text = $"Добро пожаловать, {user.FullName}!";
|
||||||
|
MessageText.Foreground = Brushes.Green;
|
||||||
|
|
||||||
|
// Определяем роль (например: "Администратор", "Менеджер", "Клиент")
|
||||||
|
string roleName = user.IdRoleNavigation?.NameRole ?? "Клиент";
|
||||||
|
|
||||||
|
// Открываем окно товаров, передавая туда роль или пользователя
|
||||||
|
Tovar tovarWindow = new Tovar(roleName);
|
||||||
|
tovarWindow.Show();
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLoginClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// Вход в роли гостя
|
||||||
|
Tovar tovarWindow = new Tovar("Гость");
|
||||||
|
tovarWindow.Show();
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="450"
|
||||||
|
x:Class="demka.Views.ProductEditWindow"
|
||||||
|
Title="Карточка товара" Width="400" Height="450" WindowStartupLocation="CenterOwner">
|
||||||
|
|
||||||
|
<StackPanel Spacing="10" Margin="20">
|
||||||
|
<TextBlock Text="Наименование:" />
|
||||||
|
<TextBox x:Name="NameTextBox" />
|
||||||
|
|
||||||
|
<TextBlock Text="Артикул:" />
|
||||||
|
<TextBox x:Name="ArticleTextBox" />
|
||||||
|
|
||||||
|
<TextBlock Text="Цена:" />
|
||||||
|
<TextBox x:Name="PriceTextBox" />
|
||||||
|
|
||||||
|
<TextBlock Text="Количество на складе:" />
|
||||||
|
<TextBox x:Name="StockTextBox" />
|
||||||
|
|
||||||
|
<TextBlock Text="Описание:" />
|
||||||
|
<TextBox x:Name="DescriptionTextBox" AcceptsReturn="True" Height="60" />
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Right" Margin="0,15,0,0">
|
||||||
|
<Button Content="Отмена" Click="OnCancelClick" Width="90" />
|
||||||
|
<Button Content="Сохранить" Click="OnSaveClick" Width="90" Background="LightGreen" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using demka.Models;
|
||||||
|
|
||||||
|
namespace demka.Views
|
||||||
|
{
|
||||||
|
public partial class ProductEditWindow : Window
|
||||||
|
{
|
||||||
|
public Product CurrentProduct { get; set; }
|
||||||
|
public bool IsSaved { get; private set; } = false;
|
||||||
|
|
||||||
|
public ProductEditWindow() : this(new Product()) { }
|
||||||
|
|
||||||
|
public ProductEditWindow(Product product)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
CurrentProduct = product;
|
||||||
|
|
||||||
|
// Заполняем поля данными (если это редактирование, они будут заполнены, если добавление — пустыми)
|
||||||
|
NameTextBox.Text = CurrentProduct.Name;
|
||||||
|
ArticleTextBox.Text = CurrentProduct.Article;
|
||||||
|
PriceTextBox.Text = CurrentProduct.Price?.ToString() ?? "";
|
||||||
|
StockTextBox.Text = CurrentProduct.StockQty?.ToString() ?? "";
|
||||||
|
DescriptionTextBox.Text = CurrentProduct.Description;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSaveClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// Считываем измененные или новые данные
|
||||||
|
CurrentProduct.Name = NameTextBox.Text;
|
||||||
|
CurrentProduct.Article = ArticleTextBox.Text;
|
||||||
|
|
||||||
|
if (int.TryParse(PriceTextBox.Text, out int price))
|
||||||
|
CurrentProduct.Price = price;
|
||||||
|
|
||||||
|
if (int.TryParse(StockTextBox.Text, out int stock))
|
||||||
|
CurrentProduct.StockQty = stock;
|
||||||
|
|
||||||
|
CurrentProduct.Description = DescriptionTextBox.Text;
|
||||||
|
|
||||||
|
IsSaved = true;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCancelClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:models="clr-namespace:demka.Models"
|
||||||
|
xmlns:views="clr-namespace:demka.Views"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="600"
|
||||||
|
x:Class="demka.Views.Tovar"
|
||||||
|
x:DataType="views:Tovar"
|
||||||
|
Title="Система управления - ООО «Обувь»">
|
||||||
|
|
||||||
|
<Grid RowDefinitions="Auto, *" Margin="15">
|
||||||
|
|
||||||
|
<!-- Верхняя строка с информацией о текущей роли -->
|
||||||
|
<TextBlock Grid.Row="0" x:Name="RoleInfoTextBlock" Foreground="DarkSlateGray" FontWeight="Bold" Margin="0,0,0,10" FontSize="14" />
|
||||||
|
|
||||||
|
<!-- Вкладки системы -->
|
||||||
|
<TabControl Grid.Row="1" x:Name="MainTabControl">
|
||||||
|
|
||||||
|
<!-- ВКЛАДКА 1: ТОВАРЫ -->
|
||||||
|
<TabItem Header="Товары" x:Name="ProductsTab">
|
||||||
|
<Grid RowDefinitions="Auto, *, Auto" Margin="0,10,0,0">
|
||||||
|
|
||||||
|
<!-- Панель поиска, сортировки и фильтрации -->
|
||||||
|
<Grid Grid.Row="0" ColumnDefinitions="*, 150, 150" ColumnSpacing="10" Margin="0,0,0,10" x:Name="FilterPanel">
|
||||||
|
<TextBox Grid.Column="0" x:Name="SearchTextBox" Watermark="Введите для поиска..." />
|
||||||
|
<ComboBox Grid.Column="1" x:Name="SortComboBox" PlaceholderText="Сортировка">
|
||||||
|
<ComboBoxItem Content="Без сортировки" />
|
||||||
|
<ComboBoxItem Content="Цена по возрастанию" />
|
||||||
|
<ComboBoxItem Content="Цена по убыванию" />
|
||||||
|
</ComboBox>
|
||||||
|
<ComboBox Grid.Column="2" x:Name="FilterComboBox" PlaceholderText="Фильтрация" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Список товаров -->
|
||||||
|
<ListBox Grid.Row="1" x:Name="ProductListBox"
|
||||||
|
ItemsSource="{Binding TovarList}"
|
||||||
|
x:CompileBindings="False">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type models:Product}">
|
||||||
|
<Border BorderBrush="LightGray" BorderThickness="1" CornerRadius="4" Padding="10" Margin="5">
|
||||||
|
<Grid ColumnDefinitions="100, *, Auto" ColumnSpacing="15">
|
||||||
|
<Image Grid.Column="0" Width="80" Height="80" Source="{Binding Photo}" Stretch="UniformToFill" />
|
||||||
|
<StackPanel Grid.Column="1" Spacing="4" VerticalAlignment="Center">
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||||
|
<TextBlock Text="{Binding IdCategoryNavigation.NameCategory}" FontWeight="SemiBold" />
|
||||||
|
<TextBlock Text="|" />
|
||||||
|
<TextBlock Text="{Binding Name}" FontWeight="Bold" FontSize="16" />
|
||||||
|
</StackPanel>
|
||||||
|
<TextBlock Text="{Binding Article, StringFormat='Артикул: {0}'}" Foreground="Gray" FontSize="12" />
|
||||||
|
<TextBlock Text="{Binding Description, StringFormat='Описание: {0}'}" TextWrapping="Wrap" FontSize="13" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
|
||||||
|
<TextBlock Text="{Binding Price, StringFormat='{}{0} руб.'}" FontSize="16" FontWeight="Bold" Foreground="DarkBlue" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
|
||||||
|
<!-- Панель управления товарами (Администратор) -->
|
||||||
|
<StackPanel Grid.Row="2" Orientation="Horizontal" Spacing="10" Margin="0,10,0,0" x:Name="AdminPanel">
|
||||||
|
<Button Content="Добавить товар" Click="OnAddProductClick" Background="LightGreen" />
|
||||||
|
<Button Content="Редактировать товар" Click="OnEditProductClick" Background="LightYellow" />
|
||||||
|
<Button Content="Удалить товар" Click="OnDeleteProductClick" Background="LightCoral" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
<!-- ВКЛАДКА 2: ЗАКАЗЫ -->
|
||||||
|
<TabItem Header="Заказы" x:Name="OrdersTab">
|
||||||
|
<Grid RowDefinitions="*, Auto" Margin="0,10,0,0">
|
||||||
|
<ListBox Grid.Row="0" x:Name="OrderListBox"
|
||||||
|
ItemsSource="{Binding OrderList}"
|
||||||
|
x:CompileBindings="False">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type models:Order}">
|
||||||
|
<Border BorderBrush="LightGray" BorderThickness="1" CornerRadius="4" Padding="10" Margin="5">
|
||||||
|
<StackPanel Spacing="5">
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="15">
|
||||||
|
<TextBlock Text="{Binding IdOrder, StringFormat='Заказ № {0}'}" FontWeight="Bold" FontSize="16" />
|
||||||
|
<TextBlock Text="{Binding OrderDate, StringFormat='Дата: {0}'}" Foreground="Gray" />
|
||||||
|
<TextBlock Text="{Binding DeliveryDate, StringFormat='Доставка: {0}'}" Foreground="Gray" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="15">
|
||||||
|
<TextBlock Text="{Binding IdStatusNavigation.NameStatus, StringFormat='Статус: {0}'}" FontWeight="SemiBold" Foreground="DarkGreen" />
|
||||||
|
<TextBlock Text="{Binding IdPointNavigation.City, StringFormat='Пункт выдачи: г. {0}'}" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
|
||||||
|
<!-- Панель управления заказами (Администратор) -->
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal" Spacing="10" Margin="0,10,0,0" x:Name="AdminOrdersPanel">
|
||||||
|
<Button Content="Добавить заказ" Click="OnAddOrderClick" Background="LightGreen" />
|
||||||
|
<Button Content="Редактировать заказ" Click="OnEditOrderClick" Background="LightYellow" />
|
||||||
|
<Button Content="Удалить заказ" Click="OnDeleteOrderClick" Background="LightCoral" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
</TabControl>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using demka.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace demka.Views
|
||||||
|
{
|
||||||
|
public partial class Tovar : Window
|
||||||
|
{
|
||||||
|
// Коллекции для списков на форме
|
||||||
|
public ObservableCollection<Product> TovarList { get; set; } = [];
|
||||||
|
public ObservableCollection<Order> OrderList { get; set; } = [];
|
||||||
|
private readonly string _role;
|
||||||
|
|
||||||
|
public Tovar() : this("Гость") { }
|
||||||
|
|
||||||
|
//мяу
|
||||||
|
// Конструктор принимает роль из окна авторизации
|
||||||
|
public Tovar(string role)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = this;
|
||||||
|
_role = role;
|
||||||
|
|
||||||
|
RoleInfoTextBlock.Text = $"Роль: {_role}";
|
||||||
|
|
||||||
|
// Настройка видимости по ролям (ТЗ)
|
||||||
|
bool isGuest = _role is "Гость" or "Клиент" or "авторизованный клиент";
|
||||||
|
bool isAdmin = _role == "Администратор";
|
||||||
|
|
||||||
|
FilterPanel.IsVisible = OrdersTab.IsVisible = !isGuest;
|
||||||
|
AdminPanel.IsVisible = AdminOrdersPanel.IsVisible = isAdmin;
|
||||||
|
|
||||||
|
LoadData(); // Загружаем данные в списки
|
||||||
|
|
||||||
|
// События для поиска, сортировки и фильтра
|
||||||
|
SearchTextBox.TextChanged += (_, _) => LoadData();
|
||||||
|
SortComboBox.SelectionChanged += (_, _) => LoadData();
|
||||||
|
FilterComboBox.SelectionChanged += (_, _) => LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Главный метод загрузки данных из БД с учетом фильтров
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
using var db = new PostgresContext();
|
||||||
|
|
||||||
|
// 1. Загрузка товаров
|
||||||
|
var query = db.Products.Include(p => p.IdCategoryNavigation).Include(p => p.IdManufacturerNavigation).AsQueryable();
|
||||||
|
|
||||||
|
if (_role != "Гость" && _role != "Клиент")
|
||||||
|
{
|
||||||
|
// Поиск
|
||||||
|
string text = SearchTextBox?.Text?.Trim().ToLower() ?? "";
|
||||||
|
if (!string.IsNullOrEmpty(text))
|
||||||
|
query = query.Where(p => p.Name!.ToLower().Contains(text) || p.Description!.ToLower().Contains(text));
|
||||||
|
|
||||||
|
// Фильтрация по категории
|
||||||
|
if (FilterComboBox?.SelectedItem is ComboBoxItem { Tag: int id } && id > 0)
|
||||||
|
query = query.Where(p => p.IdCategory == id);
|
||||||
|
|
||||||
|
// Сортировка
|
||||||
|
query = SortComboBox?.SelectedItem switch {
|
||||||
|
ComboBoxItem { Content: "Цена по возрастанию" } => query.OrderBy(p => p.Price),
|
||||||
|
ComboBoxItem { Content: "Цена по убыванию" } => query.OrderByDescending(p => p.Price),
|
||||||
|
_ => query
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
TovarList.Clear();
|
||||||
|
foreach (var p in query) TovarList.Add(p);
|
||||||
|
|
||||||
|
// Заполняем выпадающий список категорий один раз
|
||||||
|
if (FilterComboBox.ItemCount == 0)
|
||||||
|
{
|
||||||
|
FilterComboBox.Items.Add(new ComboBoxItem { Content = "Все категории", Tag = 0 });
|
||||||
|
foreach (var c in db.Categories)
|
||||||
|
FilterComboBox.Items.Add(new ComboBoxItem { Content = c.NameCategory, Tag = c.IdCategory });
|
||||||
|
FilterComboBox.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Загрузка заказов (если вкладка доступна)
|
||||||
|
if (OrdersTab.IsVisible)
|
||||||
|
{
|
||||||
|
OrderList.Clear();
|
||||||
|
foreach (var o in db.Orders.Include(o => o.IdStatusNavigation).Include(o => o.IdPointNavigation))
|
||||||
|
OrderList.Add(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- УПРАВЛЕНИЕ ТОВАРАМИ (Добавить / Редактировать / Удалить) ---
|
||||||
|
private async void OnAddProductClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var p = new Product();
|
||||||
|
var window = new ProductEditWindow(p);
|
||||||
|
await window.ShowDialog(this);
|
||||||
|
|
||||||
|
if (!window.IsSaved) return;
|
||||||
|
using var db = new PostgresContext();
|
||||||
|
p.IdProduct = db.Products.Any() ? db.Products.Max(x => x.IdProduct) + 1 : 1;
|
||||||
|
db.Products.Add(p);
|
||||||
|
db.SaveChanges();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEditProductClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (ProductListBox.SelectedItem is not Product p) return;
|
||||||
|
var window = new ProductEditWindow(p);
|
||||||
|
await window.ShowDialog(this);
|
||||||
|
|
||||||
|
if (!window.IsSaved) return;
|
||||||
|
using var db = new PostgresContext();
|
||||||
|
db.Products.Update(p);
|
||||||
|
db.SaveChanges();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDeleteProductClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (ProductListBox.SelectedItem is not Product p) return;
|
||||||
|
using var db = new PostgresContext();
|
||||||
|
db.Products.Remove(p);
|
||||||
|
db.SaveChanges();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- УПРАВЛЕНИЕ ЗАКАЗАМИ ---
|
||||||
|
private void OnAddOrderClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
using var db = new PostgresContext();
|
||||||
|
db.Orders.Add(new Order {
|
||||||
|
IdOrder = db.Orders.Any() ? db.Orders.Max(x => x.IdOrder) + 1 : 1,
|
||||||
|
OrderDate = DateTime.Now.ToShortDateString(),
|
||||||
|
IdStatus = 1
|
||||||
|
});
|
||||||
|
db.SaveChanges();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEditOrderClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (OrderListBox.SelectedItem is not Order o) return;
|
||||||
|
using var db = new PostgresContext();
|
||||||
|
o.DeliveryDate = DateTime.Now.AddDays(3).ToShortDateString();
|
||||||
|
db.Orders.Update(o);
|
||||||
|
db.SaveChanges();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDeleteOrderClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (OrderListBox.SelectedItem is not Order o) return;
|
||||||
|
using var db = new PostgresContext();
|
||||||
|
db.Orders.Remove(o);
|
||||||
|
db.SaveChanges();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Models\" />
|
|
||||||
<AvaloniaResource Include="Assets\**" />
|
<AvaloniaResource Include="Assets\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -27,4 +26,8 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.*" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Models\" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user