This commit is contained in:
testuser 2026-05-14 17:23:07 +04:00
commit 1c4e9ae1f4
170 changed files with 8019 additions and 0 deletions

315
Dump20260513.sql Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,86 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|c:\\users\\zaich\\source\\repos\\moduleexamen\\moduleexamen\\forms\\orderlistform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|solutionrelative:moduleexamen\\forms\\orderlistform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|c:\\users\\zaich\\source\\repos\\moduleexamen\\moduleexamen\\forms\\productlistform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|solutionrelative:moduleexamen\\forms\\productlistform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|c:\\users\\zaich\\source\\repos\\moduleexamen\\moduleexamen\\forms\\producteditform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|solutionrelative:moduleexamen\\forms\\producteditform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|c:\\users\\zaich\\source\\repos\\moduleexamen\\moduleexamen\\forms\\ordereditform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|solutionrelative:moduleexamen\\forms\\ordereditform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 3,
"Children": [
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "ProductListForm.cs",
"DocumentMoniker": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\ProductListForm.cs",
"RelativeDocumentMoniker": "moduleExamen\\Forms\\ProductListForm.cs",
"ToolTip": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\ProductListForm.cs",
"RelativeToolTip": "moduleExamen\\Forms\\ProductListForm.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAABkBAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-05-13T18:57:56.112Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "ProductEditForm.cs",
"DocumentMoniker": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\ProductEditForm.cs",
"RelativeDocumentMoniker": "moduleExamen\\Forms\\ProductEditForm.cs",
"ToolTip": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\ProductEditForm.cs",
"RelativeToolTip": "moduleExamen\\Forms\\ProductEditForm.cs",
"ViewState": "AgIAAMkAAAAAAAAAAAAQwOAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-05-13T18:57:33.34Z"
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "OrderEditForm.cs",
"DocumentMoniker": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\OrderEditForm.cs",
"RelativeDocumentMoniker": "moduleExamen\\Forms\\OrderEditForm.cs",
"ToolTip": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\OrderEditForm.cs",
"RelativeToolTip": "moduleExamen\\Forms\\OrderEditForm.cs",
"ViewState": "AgIAAFgAAAAAAAAAAAAgwJIAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-05-13T18:57:18.637Z"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "OrderListForm.cs",
"DocumentMoniker": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\OrderListForm.cs",
"RelativeDocumentMoniker": "moduleExamen\\Forms\\OrderListForm.cs",
"ToolTip": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\OrderListForm.cs*",
"RelativeToolTip": "moduleExamen\\Forms\\OrderListForm.cs*",
"ViewState": "AgIAAEYAAAAAAAAAAAAcwIAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-05-13T18:56:18.356Z",
"EditorCaption": ""
}
]
}
]
}
]
}

View File

@ -0,0 +1,88 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|c:\\users\\zaich\\source\\repos\\moduleexamen\\moduleexamen\\forms\\orderlistform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|solutionrelative:moduleexamen\\forms\\orderlistform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|c:\\users\\zaich\\source\\repos\\moduleexamen\\moduleexamen\\forms\\ordereditform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|solutionrelative:moduleexamen\\forms\\ordereditform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|c:\\users\\zaich\\source\\repos\\moduleexamen\\moduleexamen\\forms\\producteditform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|solutionrelative:moduleexamen\\forms\\producteditform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|c:\\users\\zaich\\source\\repos\\moduleexamen\\moduleexamen\\forms\\productlistform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C6778277-5D21-429C-B51D-A1DEC2F4F706}|moduleExamen\\moduleExamen.csproj|solutionrelative:moduleexamen\\forms\\productlistform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 3,
"Children": [
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "ProductListForm.cs",
"DocumentMoniker": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\ProductListForm.cs",
"RelativeDocumentMoniker": "moduleExamen\\Forms\\ProductListForm.cs",
"ToolTip": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\ProductListForm.cs*",
"RelativeToolTip": "moduleExamen\\Forms\\ProductListForm.cs*",
"ViewState": "AgIAAEcAAAAAAAAAAAAuwDsAAAAJAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-05-13T18:57:56.112Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "ProductEditForm.cs",
"DocumentMoniker": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\ProductEditForm.cs",
"RelativeDocumentMoniker": "moduleExamen\\Forms\\ProductEditForm.cs",
"ToolTip": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\ProductEditForm.cs*",
"RelativeToolTip": "moduleExamen\\Forms\\ProductEditForm.cs*",
"ViewState": "AgIAALQAAAAAAAAAAAAmwMcAAAARAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-05-13T18:57:33.34Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "OrderEditForm.cs",
"DocumentMoniker": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\OrderEditForm.cs",
"RelativeDocumentMoniker": "moduleExamen\\Forms\\OrderEditForm.cs",
"ToolTip": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\OrderEditForm.cs*",
"RelativeToolTip": "moduleExamen\\Forms\\OrderEditForm.cs*",
"ViewState": "AgIAAGAAAAAAAAAAAAAmwHcAAAAZAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-05-13T18:57:18.637Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "OrderListForm.cs",
"DocumentMoniker": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\OrderListForm.cs",
"RelativeDocumentMoniker": "moduleExamen\\Forms\\OrderListForm.cs",
"ToolTip": "C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\OrderListForm.cs",
"RelativeToolTip": "moduleExamen\\Forms\\OrderListForm.cs",
"ViewState": "AgIAAE4AAAAAAAAAAAA4wHUAAAARAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-05-13T18:56:18.356Z",
"EditorCaption": ""
}
]
}
]
}
]
}

View File

@ -0,0 +1 @@
{"CustomColumnOrderings":{"name":0,"file-path":1,"file-name":2,"neutral-value":3,"neutral-comment":4,"type":5},"ShowValidationErrors":true,"SelectedResourceGroups":["C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\OrderEditForm.resx","C:\\Users\\zaich\\source\\repos\\moduleExamen\\moduleExamen\\Forms\\LoginForm.resx"],"VisibleColumnKeys":["name","neutral-value"]}

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35312.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "moduleExamen", "moduleExamen\moduleExamen.csproj", "{C6778277-5D21-429C-B51D-A1DEC2F4F706}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C6778277-5D21-429C-B51D-A1DEC2F4F706}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6778277-5D21-429C-B51D-A1DEC2F4F706}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6778277-5D21-429C-B51D-A1DEC2F4F706}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6778277-5D21-429C-B51D-A1DEC2F4F706}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {72C2C7A5-1018-4EA5-9518-57AEAB5E8967}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,175 @@
using Microsoft.EntityFrameworkCore;
using moduleExamen.Models;
namespace moduleExamen.Data;
public class SportShopContext : DbContext
{
private static readonly string ConnectionString =
"server=91.222.238.6;username=rover_user;password=root123;database=Dem_dem";
public DbSet<Role> Roles { get; set; }
public DbSet<Status> Statuses { get; set; }
public DbSet<Ed> Eds { get; set; }
public DbSet<Manufact> Manufacts { get; set; }
public DbSet<Suplier> Supliers { get; set; }
public DbSet<TipeProduct> TipeProducts { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<Product> Products { get; set; }
public DbSet<Order> Orders { get; set; }
public DbSet<OrderItem> OrderItems { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySql(ConnectionString, ServerVersion.AutoDetect(ConnectionString));
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Role>(entity =>
{
entity.ToTable("Role");
entity.HasKey(e => e.IdRole);
entity.Property(e => e.IdRole).HasColumnName("idRole");
entity.Property(e => e.Name).HasColumnName("name").HasMaxLength(45);
});
modelBuilder.Entity<Status>(entity =>
{
entity.ToTable("Status");
entity.HasKey(e => e.IdStatus);
entity.Property(e => e.IdStatus).HasColumnName("idStatus");
entity.Property(e => e.Name).HasColumnName("name").HasMaxLength(45);
});
modelBuilder.Entity<Ed>(entity =>
{
entity.ToTable("ed");
entity.HasKey(e => e.Ided);
entity.Property(e => e.Ided).HasColumnName("ided");
entity.Property(e => e.Name).HasColumnName("name").HasMaxLength(45);
});
modelBuilder.Entity<Manufact>(entity =>
{
entity.ToTable("manufact");
entity.HasKey(e => e.Idmanufact);
entity.Property(e => e.Idmanufact).HasColumnName("idmanufact");
entity.Property(e => e.Name).HasColumnName("name").HasMaxLength(45);
});
modelBuilder.Entity<Suplier>(entity =>
{
entity.ToTable("suplier");
entity.HasKey(e => e.Idsuplier);
entity.Property(e => e.Idsuplier).HasColumnName("idsuplier");
entity.Property(e => e.Name).HasColumnName("name").HasMaxLength(45);
});
modelBuilder.Entity<TipeProduct>(entity =>
{
entity.ToTable("tipe_product");
entity.HasKey(e => e.IdtipeProduct);
entity.Property(e => e.IdtipeProduct).HasColumnName("idtipe_product");
entity.Property(e => e.Name).HasColumnName("name").HasMaxLength(45);
});
modelBuilder.Entity<User>(entity =>
{
entity.ToTable("user");
entity.HasKey(e => e.Iduser);
entity.Property(e => e.Iduser).HasColumnName("iduser");
entity.Property(e => e.Login).HasColumnName("login").HasMaxLength(45);
entity.Property(e => e.Password).HasColumnName("password").HasMaxLength(45);
entity.Property(e => e.Fio).HasColumnName("fio").HasMaxLength(45);
entity.Property(e => e.IdRole).HasColumnName("id_role");
entity.Property(e => e.Email).HasColumnName("email").HasMaxLength(45);
entity.HasOne(d => d.IdRoleNavigation)
.WithMany(p => p.Users)
.HasForeignKey(d => d.IdRole)
.HasConstraintName("id_role");
});
modelBuilder.Entity<Product>(entity =>
{
entity.ToTable("product");
entity.HasKey(e => e.Idproduct);
entity.Property(e => e.Idproduct).HasColumnName("idproduct");
entity.Property(e => e.Articl).HasColumnName("articl").HasMaxLength(45);
entity.Property(e => e.Name).HasColumnName("name").HasMaxLength(100);
entity.Property(e => e.IdTipeProduct).HasColumnName("id_tipe_product");
entity.Property(e => e.ProductContent).HasColumnName("product_content").HasMaxLength(150);
entity.Property(e => e.IdManufactur).HasColumnName("id_manufactur");
entity.Property(e => e.IdSuplier).HasColumnName("id_suplier");
entity.Property(e => e.PriceProduct).HasColumnName("price_product").HasColumnType("decimal(10,2)");
entity.Property(e => e.Sale).HasColumnName("sale");
entity.Property(e => e.KolVo).HasColumnName("kol-vo");
entity.Property(e => e.IdEd).HasColumnName("id_ed");
entity.Property(e => e.IdPhoto).HasColumnName("id_photo");
entity.HasOne(d => d.IdEdNavigation)
.WithMany(p => p.Products)
.HasForeignKey(d => d.IdEd)
.HasConstraintName("id_ed");
entity.HasOne(d => d.IdManufacturNavigation)
.WithMany(p => p.Products)
.HasForeignKey(d => d.IdManufactur)
.HasConstraintName("id_manufact");
entity.HasOne(d => d.IdSuplierNavigation)
.WithMany(p => p.Products)
.HasForeignKey(d => d.IdSuplier)
.HasConstraintName("id_supplier");
entity.HasOne(d => d.IdTipeProductNavigation)
.WithMany(p => p.Products)
.HasForeignKey(d => d.IdTipeProduct)
.HasConstraintName("id_tipe_product");
});
modelBuilder.Entity<Order>(entity =>
{
entity.ToTable("Orders");
entity.HasKey(e => e.Idzakaz);
entity.Property(e => e.Idzakaz).HasColumnName("idzakaz");
entity.Property(e => e.Article).HasColumnName("article").HasMaxLength(45);
entity.Property(e => e.Fio).HasColumnName("fio");
entity.Property(e => e.IdStatus).HasColumnName("id_Status");
entity.Property(e => e.Adrec).HasColumnName("adrec").HasMaxLength(100);
entity.Property(e => e.DataStart).HasColumnName("data_start");
entity.Property(e => e.DateEnd).HasColumnName("date_end");
entity.HasOne(d => d.FioNavigation)
.WithMany(p => p.Orders)
.HasForeignKey(d => d.Fio)
.HasConstraintName("foi");
entity.HasOne(d => d.IdStatusNavigation)
.WithMany(p => p.Orders)
.HasForeignKey(d => d.IdStatus)
.HasConstraintName("id_status");
});
modelBuilder.Entity<OrderItem>(entity =>
{
entity.ToTable("order_items");
entity.HasKey(e => e.IdorderItems);
entity.Property(e => e.IdorderItems).HasColumnName("idorder_items");
entity.Property(e => e.IdOrder).HasColumnName("id_order");
entity.Property(e => e.IdProduct).HasColumnName("id_product");
entity.Property(e => e.KolVo).HasColumnName("kol-vo");
entity.HasOne(d => d.IdOrderNavigation)
.WithMany(p => p.OrderItems)
.HasForeignKey(d => d.IdOrder)
.HasConstraintName("id_order");
entity.HasOne(d => d.IdProductNavigation)
.WithMany(p => p.OrderItems)
.HasForeignKey(d => d.IdProduct)
.HasConstraintName("id_product");
});
}
}

View File

@ -0,0 +1,145 @@
namespace moduleExamen.Forms
{
partial class LoginForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
logoPictureBox = new PictureBox();
titleLabel = new Label();
loginLabel = new Label();
loginTextBox = new TextBox();
passwordLabel = new Label();
passwordTextBox = new TextBox();
loginButton = new Button();
guestButton = new Button();
((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit();
SuspendLayout();
//
// logoPictureBox
//
logoPictureBox.Location = new Point(135, 20);
logoPictureBox.Name = "logoPictureBox";
logoPictureBox.Size = new Size(150, 150);
logoPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
logoPictureBox.TabIndex = 0;
logoPictureBox.TabStop = false;
logoPictureBox.Anchor = AnchorStyles.Top;
//
// titleLabel
//
titleLabel.AutoSize = true;
titleLabel.Font = new Font("Comic Sans MS", 16F, FontStyle.Bold);
titleLabel.ForeColor = Color.Black;
titleLabel.Location = new Point(110, 180);
titleLabel.Name = "titleLabel";
titleLabel.Text = "Вход в систему";
titleLabel.Anchor = AnchorStyles.Top;
//
// loginLabel
//
loginLabel.AutoSize = true;
loginLabel.Font = new Font("Comic Sans MS", 10F);
loginLabel.Location = new Point(60, 230);
loginLabel.Name = "loginLabel";
loginLabel.Text = "Логин:";
//
// loginTextBox
//
loginTextBox.Font = new Font("Comic Sans MS", 10F);
loginTextBox.Location = new Point(60, 255);
loginTextBox.Name = "loginTextBox";
loginTextBox.Size = new Size(280, 30);
loginTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
//
// passwordLabel
//
passwordLabel.AutoSize = true;
passwordLabel.Font = new Font("Comic Sans MS", 10F);
passwordLabel.Location = new Point(60, 295);
passwordLabel.Name = "passwordLabel";
passwordLabel.Text = "Пароль:";
//
// passwordTextBox
//
passwordTextBox.Font = new Font("Comic Sans MS", 10F);
passwordTextBox.Location = new Point(60, 320);
passwordTextBox.Name = "passwordTextBox";
passwordTextBox.Size = new Size(280, 30);
passwordTextBox.UseSystemPasswordChar = true;
passwordTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
//
// loginButton
//
loginButton.BackColor = Color.FromArgb(255, 0, 0);
loginButton.Cursor = Cursors.Hand;
loginButton.FlatAppearance.BorderSize = 0;
loginButton.FlatStyle = FlatStyle.Flat;
loginButton.Font = new Font("Comic Sans MS", 10F, FontStyle.Bold);
loginButton.ForeColor = Color.White;
loginButton.Location = new Point(60, 370);
loginButton.Name = "loginButton";
loginButton.Size = new Size(280, 40);
loginButton.Text = "Войти";
loginButton.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
loginButton.Click += LoginButton_Click;
//
// guestButton
//
guestButton.BackColor = Color.FromArgb(133, 242, 189);
guestButton.Cursor = Cursors.Hand;
guestButton.FlatAppearance.BorderSize = 0;
guestButton.FlatStyle = FlatStyle.Flat;
guestButton.Font = new Font("Comic Sans MS", 10F);
guestButton.ForeColor = Color.Black;
guestButton.Location = new Point(60, 420);
guestButton.Name = "guestButton";
guestButton.Size = new Size(280, 35);
guestButton.Text = "Войти как гость";
guestButton.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
guestButton.Click += GuestButton_Click;
//
// LoginForm
//
AcceptButton = loginButton;
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.FromArgb(192, 237, 215);
ClientSize = new Size(404, 481);
Controls.Add(logoPictureBox);
Controls.Add(titleLabel);
Controls.Add(loginLabel);
Controls.Add(loginTextBox);
Controls.Add(passwordLabel);
Controls.Add(passwordTextBox);
Controls.Add(loginButton);
Controls.Add(guestButton);
FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false;
MinimumSize = new Size(400, 500);
Name = "LoginForm";
StartPosition = FormStartPosition.CenterScreen;
Text = "Sport Farm - Авторизация";
((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit();
ResumeLayout(false);
PerformLayout();
}
private PictureBox logoPictureBox;
private Label titleLabel;
private Label loginLabel;
private TextBox loginTextBox;
private Label passwordLabel;
private TextBox passwordTextBox;
private Button loginButton;
private Button guestButton;
}
}

View File

@ -0,0 +1,71 @@
using Microsoft.EntityFrameworkCore;
using moduleExamen.Data;
using moduleExamen.Helpers;
namespace moduleExamen.Forms
{
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();
AppStyles.ApplyIcon(this);
if (File.Exists(AppStyles.LogoPath))
logoPictureBox.Image = Image.FromFile(AppStyles.LogoPath);
}
private void LoginButton_Click(object? sender, EventArgs e)
{
var login = loginTextBox.Text.Trim();
var password = passwordTextBox.Text.Trim();
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
MessageBox.Show("Введите логин и пароль.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
try
{
using var context = new SportShopContext();
var user = context.Users
.Include(u => u.IdRoleNavigation)
.FirstOrDefault(u => u.Login == login && u.Password == password);
if (user == null)
{
MessageBox.Show("Неверный логин или пароль.", "Ошибка авторизации",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
SessionManager.CurrentUser = user;
var productForm = new ProductListForm();
productForm.Show();
Hide();
productForm.FormClosed += (_, _) =>
{
SessionManager.CurrentUser = null;
loginTextBox.Clear();
passwordTextBox.Clear();
Show();
};
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка подключения к базе данных:\n{ex.Message}",
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void GuestButton_Click(object? sender, EventArgs e)
{
SessionManager.CurrentUser = null;
var productForm = new ProductListForm();
productForm.Show();
Hide();
productForm.FormClosed += (_, _) => Show();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,254 @@
namespace moduleExamen.Forms
{
partial class OrderEditForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
headerPanel = new Panel();
logoPictureBox = new PictureBox();
idLabel = new Label();
articleLabel = new Label();
articleTextBox = new TextBox();
statusLabel = new Label();
statusComboBox = new ComboBox();
addressLabel = new Label();
addressTextBox = new TextBox();
dateStartLabel = new Label();
dateStartPicker = new DateTimePicker();
dateEndLabel = new Label();
dateEndCheckBox = new CheckBox();
dateEndPicker = new DateTimePicker();
saveButton = new Button();
cancelButton = new Button();
headerPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit();
SuspendLayout();
//
// headerPanel
//
headerPanel.BackColor = Color.FromArgb(133, 242, 189);
headerPanel.Controls.Add(logoPictureBox);
headerPanel.Controls.Add(idLabel);
headerPanel.Dock = DockStyle.Top;
headerPanel.Location = new Point(0, 0);
headerPanel.Name = "headerPanel";
headerPanel.Size = new Size(434, 60);
headerPanel.TabIndex = 13;
//
// logoPictureBox
//
logoPictureBox.Location = new Point(10, 5);
logoPictureBox.Name = "logoPictureBox";
logoPictureBox.Size = new Size(50, 50);
logoPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
logoPictureBox.TabIndex = 0;
logoPictureBox.TabStop = false;
//
// idLabel
//
idLabel.AutoSize = true;
idLabel.Font = new Font("Comic Sans MS", 14F, FontStyle.Bold);
idLabel.ForeColor = Color.Black;
idLabel.Location = new Point(70, 15);
idLabel.Name = "idLabel";
idLabel.Size = new Size(130, 27);
idLabel.TabIndex = 1;
idLabel.Text = "Новый заказ";
//
// articleLabel
//
articleLabel.AutoSize = true;
articleLabel.Font = new Font("Comic Sans MS", 9F);
articleLabel.Location = new Point(20, 75);
articleLabel.Name = "articleLabel";
articleLabel.Size = new Size(60, 17);
articleLabel.TabIndex = 0;
articleLabel.Text = "Артикул:";
//
// articleTextBox
//
articleTextBox.Font = new Font("Comic Sans MS", 10F);
articleTextBox.Location = new Point(20, 97);
articleTextBox.Name = "articleTextBox";
articleTextBox.Size = new Size(390, 26);
articleTextBox.TabIndex = 1;
//
// statusLabel
//
statusLabel.AutoSize = true;
statusLabel.Font = new Font("Comic Sans MS", 9F);
statusLabel.Location = new Point(20, 132);
statusLabel.Name = "statusLabel";
statusLabel.Size = new Size(87, 17);
statusLabel.TabIndex = 2;
statusLabel.Text = "Статус заказа:";
//
// statusComboBox
//
statusComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
statusComboBox.Font = new Font("Comic Sans MS", 10F);
statusComboBox.Location = new Point(20, 154);
statusComboBox.Name = "statusComboBox";
statusComboBox.Size = new Size(390, 26);
statusComboBox.TabIndex = 3;
//
// addressLabel
//
addressLabel.AutoSize = true;
addressLabel.Font = new Font("Comic Sans MS", 9F);
addressLabel.Location = new Point(20, 189);
addressLabel.Name = "addressLabel";
addressLabel.Size = new Size(134, 17);
addressLabel.TabIndex = 4;
addressLabel.Text = "Адрес пункта выдачи:";
//
// addressTextBox
//
addressTextBox.Font = new Font("Comic Sans MS", 10F);
addressTextBox.Location = new Point(20, 211);
addressTextBox.Name = "addressTextBox";
addressTextBox.Size = new Size(390, 26);
addressTextBox.TabIndex = 5;
//
// dateStartLabel
//
dateStartLabel.AutoSize = true;
dateStartLabel.Font = new Font("Comic Sans MS", 9F);
dateStartLabel.Location = new Point(20, 246);
dateStartLabel.Name = "dateStartLabel";
dateStartLabel.Size = new Size(77, 17);
dateStartLabel.TabIndex = 6;
dateStartLabel.Text = "Дата заказа:";
//
// dateStartPicker
//
dateStartPicker.Font = new Font("Comic Sans MS", 10F);
dateStartPicker.Format = DateTimePickerFormat.Short;
dateStartPicker.Location = new Point(20, 268);
dateStartPicker.Name = "dateStartPicker";
dateStartPicker.Size = new Size(390, 26);
dateStartPicker.TabIndex = 7;
//
// dateEndLabel
//
dateEndLabel.AutoSize = true;
dateEndLabel.Font = new Font("Comic Sans MS", 9F);
dateEndLabel.Location = new Point(20, 303);
dateEndLabel.Name = "dateEndLabel";
dateEndLabel.Size = new Size(85, 17);
dateEndLabel.TabIndex = 8;
dateEndLabel.Text = "Дата выдачи:";
//
// dateEndCheckBox
//
dateEndCheckBox.AutoSize = true;
dateEndCheckBox.Font = new Font("Comic Sans MS", 9F);
dateEndCheckBox.Location = new Point(120, 303);
dateEndCheckBox.Name = "dateEndCheckBox";
dateEndCheckBox.Size = new Size(70, 21);
dateEndCheckBox.TabIndex = 9;
dateEndCheckBox.Text = "Указать";
dateEndCheckBox.CheckedChanged += DateEndCheckBox_CheckedChanged;
//
// dateEndPicker
//
dateEndPicker.Enabled = false;
dateEndPicker.Font = new Font("Comic Sans MS", 10F);
dateEndPicker.Format = DateTimePickerFormat.Short;
dateEndPicker.Location = new Point(20, 325);
dateEndPicker.Name = "dateEndPicker";
dateEndPicker.Size = new Size(390, 26);
dateEndPicker.TabIndex = 10;
//
// saveButton
//
saveButton.BackColor = Color.FromArgb(255, 0, 0);
saveButton.Cursor = Cursors.Hand;
saveButton.FlatAppearance.BorderSize = 0;
saveButton.FlatStyle = FlatStyle.Flat;
saveButton.Font = new Font("Comic Sans MS", 10F, FontStyle.Bold);
saveButton.ForeColor = Color.White;
saveButton.Location = new Point(120, 370);
saveButton.Name = "saveButton";
saveButton.Size = new Size(150, 40);
saveButton.TabIndex = 11;
saveButton.Text = "Сохранить";
saveButton.UseVisualStyleBackColor = false;
saveButton.Click += SaveButton_Click;
//
// cancelButton
//
cancelButton.BackColor = Color.FromArgb(133, 242, 189);
cancelButton.Cursor = Cursors.Hand;
cancelButton.FlatAppearance.BorderSize = 0;
cancelButton.FlatStyle = FlatStyle.Flat;
cancelButton.Font = new Font("Comic Sans MS", 10F);
cancelButton.Location = new Point(280, 370);
cancelButton.Name = "cancelButton";
cancelButton.Size = new Size(100, 40);
cancelButton.TabIndex = 12;
cancelButton.Text = "Отмена";
cancelButton.UseVisualStyleBackColor = false;
cancelButton.Click += CancelButton_Click;
//
// OrderEditForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.FromArgb(192, 237, 215);
ClientSize = new Size(434, 431);
Controls.Add(articleLabel);
Controls.Add(articleTextBox);
Controls.Add(statusLabel);
Controls.Add(statusComboBox);
Controls.Add(addressLabel);
Controls.Add(addressTextBox);
Controls.Add(dateStartLabel);
Controls.Add(dateStartPicker);
Controls.Add(dateEndLabel);
Controls.Add(dateEndCheckBox);
Controls.Add(dateEndPicker);
Controls.Add(saveButton);
Controls.Add(cancelButton);
Controls.Add(headerPanel);
FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false;
MinimumSize = new Size(450, 470);
Name = "OrderEditForm";
StartPosition = FormStartPosition.CenterScreen;
Text = "Sport Farm - Заказ";
Load += OrderEditForm_Load;
headerPanel.ResumeLayout(false);
headerPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit();
ResumeLayout(false);
PerformLayout();
}
private Panel headerPanel;
private PictureBox logoPictureBox;
private Label idLabel;
private Label articleLabel;
private TextBox articleTextBox;
private Label statusLabel;
private ComboBox statusComboBox;
private Label addressLabel;
private TextBox addressTextBox;
private Label dateStartLabel;
private DateTimePicker dateStartPicker;
private Label dateEndLabel;
private CheckBox dateEndCheckBox;
private DateTimePicker dateEndPicker;
private Button saveButton;
private Button cancelButton;
}
}

View File

@ -0,0 +1,135 @@
using moduleExamen.Data;
using moduleExamen.Helpers;
using moduleExamen.Models;
namespace moduleExamen.Forms
{
public partial class OrderEditForm : Form
{
private readonly Order? editingOrder;
private readonly bool isEditing;
public OrderEditForm(Order? order)
{
InitializeComponent();
AppStyles.ApplyIcon(this);
if (File.Exists(AppStyles.LogoPath))
logoPictureBox.Image = Image.FromFile(AppStyles.LogoPath);
editingOrder = order;
isEditing = order != null;
Text = isEditing ? "Sport Farm - Редактирование заказа" : "Sport Farm - Добавление заказа";
idLabel.Text = isEditing ? $"Заказ #{order!.Idzakaz}" : "Новый заказ";
LoadStatuses();
if (isEditing) FillFields();
}
private void DateEndCheckBox_CheckedChanged(object? sender, EventArgs e)
{
dateEndPicker.Enabled = dateEndCheckBox.Checked;
}
private void CancelButton_Click(object? sender, EventArgs e) => Close();
private void LoadStatuses()
{
try
{
using var context = new SportShopContext();
var statuses = context.Statuses.ToList();
statusComboBox.DataSource = statuses;
statusComboBox.DisplayMember = "Name";
statusComboBox.ValueMember = "IdStatus";
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка загрузки статусов:\n{ex.Message}", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FillFields()
{
if (editingOrder == null) return;
articleTextBox.Text = editingOrder.Article;
statusComboBox.SelectedValue = editingOrder.IdStatus;
addressTextBox.Text = editingOrder.Adrec;
dateStartPicker.Value = editingOrder.DataStart.ToDateTime(TimeOnly.MinValue);
if (editingOrder.DateEnd.HasValue)
{
dateEndCheckBox.Checked = true;
dateEndPicker.Value = editingOrder.DateEnd.Value.ToDateTime(TimeOnly.MinValue);
}
}
private void SaveButton_Click(object? sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(articleTextBox.Text))
{
MessageBox.Show("Введите артикул заказа.", "Ошибка валидации",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
articleTextBox.Focus();
return;
}
if (string.IsNullOrWhiteSpace(addressTextBox.Text))
{
MessageBox.Show("Введите адрес пункта выдачи.", "Ошибка валидации",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
addressTextBox.Focus();
return;
}
if (statusComboBox.SelectedValue == null)
{
MessageBox.Show("Выберите статус заказа.", "Ошибка валидации",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
try
{
using var context = new SportShopContext();
var newStatusId = (int)statusComboBox.SelectedValue;
Order order;
if (isEditing)
{
order = context.Orders.First(o => o.Idzakaz == editingOrder!.Idzakaz);
}
else
{
// Fio = 1 — ID первого пользователя по умолчанию (FK на таблицу User)
order = new Order { Fio = 1 };
context.Orders.Add(order);
}
order.Article = articleTextBox.Text.Trim();
order.IdStatus = newStatusId;
order.Adrec = addressTextBox.Text.Trim();
order.DataStart = DateOnly.FromDateTime(dateStartPicker.Value);
order.DateEnd = dateEndCheckBox.Checked ? DateOnly.FromDateTime(dateEndPicker.Value) : null;
context.SaveChanges();
MessageBox.Show("Заказ сохранён.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка сохранения:\n{ex.Message}", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void OrderEditForm_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,240 @@
namespace moduleExamen.Forms
{
partial class OrderListForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
headerPanel = new Panel();
logoPictureBox = new PictureBox();
titleLabel = new Label();
backButton = new Button();
buttonPanel = new Panel();
addButton = new Button();
deleteButton = new Button();
orderGrid = new DataGridView();
idColumn = new DataGridViewTextBoxColumn();
articleColumn = new DataGridViewTextBoxColumn();
userColumn = new DataGridViewTextBoxColumn();
statusColumn = new DataGridViewTextBoxColumn();
addressColumn = new DataGridViewTextBoxColumn();
dateStartColumn = new DataGridViewTextBoxColumn();
dateEndColumn = new DataGridViewTextBoxColumn();
itemsColumn = new DataGridViewTextBoxColumn();
headerPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit();
buttonPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)orderGrid).BeginInit();
SuspendLayout();
//
// headerPanel
//
headerPanel.BackColor = Color.FromArgb(133, 242, 189);
headerPanel.Controls.Add(logoPictureBox);
headerPanel.Controls.Add(titleLabel);
headerPanel.Controls.Add(backButton);
headerPanel.Dock = DockStyle.Top;
headerPanel.Location = new Point(0, 0);
headerPanel.Name = "headerPanel";
headerPanel.Size = new Size(884, 60);
headerPanel.TabIndex = 2;
headerPanel.Resize += HeaderPanel_Resize;
//
// logoPictureBox
//
logoPictureBox.Location = new Point(10, 5);
logoPictureBox.Name = "logoPictureBox";
logoPictureBox.Size = new Size(50, 50);
logoPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
logoPictureBox.TabIndex = 0;
logoPictureBox.TabStop = false;
//
// titleLabel
//
titleLabel.AutoSize = true;
titleLabel.Font = new Font("Comic Sans MS", 14F, FontStyle.Bold);
titleLabel.ForeColor = Color.Black;
titleLabel.Location = new Point(70, 15);
titleLabel.Name = "titleLabel";
titleLabel.Size = new Size(211, 27);
titleLabel.TabIndex = 1;
titleLabel.Text = "Sport Farm - Заказы";
//
// backButton
//
backButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
backButton.BackColor = Color.FromArgb(180, 180, 180);
backButton.Cursor = Cursors.Hand;
backButton.FlatAppearance.BorderSize = 0;
backButton.FlatStyle = FlatStyle.Flat;
backButton.Font = new Font("Comic Sans MS", 9F);
backButton.ForeColor = Color.Black;
backButton.Location = new Point(792, 24);
backButton.Name = "backButton";
backButton.Size = new Size(70, 30);
backButton.TabIndex = 2;
backButton.Text = "Назад";
backButton.UseVisualStyleBackColor = false;
backButton.Click += BackButton_Click;
//
// buttonPanel
//
buttonPanel.Controls.Add(addButton);
buttonPanel.Controls.Add(deleteButton);
buttonPanel.Dock = DockStyle.Bottom;
buttonPanel.Location = new Point(0, 461);
buttonPanel.Name = "buttonPanel";
buttonPanel.Padding = new Padding(10);
buttonPanel.Size = new Size(884, 50);
buttonPanel.TabIndex = 1;
//
// addButton
//
addButton.BackColor = Color.FromArgb(255, 0, 0);
addButton.Cursor = Cursors.Hand;
addButton.FlatAppearance.BorderSize = 0;
addButton.FlatStyle = FlatStyle.Flat;
addButton.Font = new Font("Comic Sans MS", 10F, FontStyle.Bold);
addButton.ForeColor = Color.White;
addButton.Location = new Point(10, 7);
addButton.Name = "addButton";
addButton.Size = new Size(150, 35);
addButton.TabIndex = 0;
addButton.Text = "Добавить заказ";
addButton.UseVisualStyleBackColor = false;
addButton.Click += AddButton_Click;
//
// deleteButton
//
deleteButton.BackColor = Color.FromArgb(200, 60, 60);
deleteButton.Cursor = Cursors.Hand;
deleteButton.FlatAppearance.BorderSize = 0;
deleteButton.FlatStyle = FlatStyle.Flat;
deleteButton.Font = new Font("Comic Sans MS", 10F);
deleteButton.ForeColor = Color.White;
deleteButton.Location = new Point(170, 7);
deleteButton.Name = "deleteButton";
deleteButton.Size = new Size(150, 35);
deleteButton.TabIndex = 1;
deleteButton.Text = "Удалить заказ";
deleteButton.UseVisualStyleBackColor = false;
deleteButton.Click += DeleteButton_Click;
//
// orderGrid
//
orderGrid.AllowUserToAddRows = false;
orderGrid.AllowUserToDeleteRows = false;
orderGrid.BackgroundColor = Color.White;
orderGrid.BorderStyle = BorderStyle.None;
orderGrid.Columns.AddRange(new DataGridViewColumn[] { idColumn, articleColumn, userColumn, statusColumn, addressColumn, dateStartColumn, dateEndColumn, itemsColumn });
orderGrid.Dock = DockStyle.Fill;
orderGrid.Font = new Font("Comic Sans MS", 9F);
orderGrid.Location = new Point(0, 60);
orderGrid.Name = "orderGrid";
orderGrid.ReadOnly = true;
orderGrid.RowHeadersVisible = false;
orderGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
orderGrid.Size = new Size(884, 401);
orderGrid.TabIndex = 0;
orderGrid.CellDoubleClick += OrderGrid_CellDoubleClick;
//
// idColumn
//
idColumn.HeaderText = "ID";
idColumn.Name = "idColumn";
idColumn.ReadOnly = true;
idColumn.Width = 50;
//
// articleColumn
//
articleColumn.HeaderText = "Артикул";
articleColumn.Name = "articleColumn";
articleColumn.ReadOnly = true;
//
// userColumn
//
userColumn.HeaderText = "Клиент";
userColumn.Name = "userColumn";
userColumn.ReadOnly = true;
userColumn.Width = 150;
//
// statusColumn
//
statusColumn.HeaderText = "Статус";
statusColumn.Name = "statusColumn";
statusColumn.ReadOnly = true;
statusColumn.Width = 110;
//
// addressColumn
//
addressColumn.HeaderText = "Адрес пункта выдачи";
addressColumn.Name = "addressColumn";
addressColumn.ReadOnly = true;
addressColumn.Width = 180;
//
// dateStartColumn
//
dateStartColumn.HeaderText = "Дата заказа";
dateStartColumn.Name = "dateStartColumn";
dateStartColumn.ReadOnly = true;
//
// dateEndColumn
//
dateEndColumn.HeaderText = "Дата выдачи";
dateEndColumn.Name = "dateEndColumn";
dateEndColumn.ReadOnly = true;
//
// itemsColumn
//
itemsColumn.HeaderText = "Товаров";
itemsColumn.Name = "itemsColumn";
itemsColumn.ReadOnly = true;
itemsColumn.Width = 70;
//
// OrderListForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.FromArgb(192, 237, 215);
ClientSize = new Size(884, 511);
Controls.Add(orderGrid);
Controls.Add(buttonPanel);
Controls.Add(headerPanel);
MinimumSize = new Size(750, 450);
Name = "OrderListForm";
StartPosition = FormStartPosition.CenterScreen;
Text = "Sport Farm - Заказы";
headerPanel.ResumeLayout(false);
headerPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit();
buttonPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)orderGrid).EndInit();
ResumeLayout(false);
}
private Panel headerPanel;
private PictureBox logoPictureBox;
private Label titleLabel;
private Button backButton;
private Panel buttonPanel;
private Button addButton;
private Button deleteButton;
private DataGridView orderGrid;
private DataGridViewTextBoxColumn idColumn;
private DataGridViewTextBoxColumn articleColumn;
private DataGridViewTextBoxColumn userColumn;
private DataGridViewTextBoxColumn statusColumn;
private DataGridViewTextBoxColumn addressColumn;
private DataGridViewTextBoxColumn dateStartColumn;
private DataGridViewTextBoxColumn dateEndColumn;
private DataGridViewTextBoxColumn itemsColumn;
}
}

View File

@ -0,0 +1,124 @@
using Microsoft.EntityFrameworkCore;
using moduleExamen.Data;
using moduleExamen.Helpers;
using moduleExamen.Models;
namespace moduleExamen.Forms
{
public partial class OrderListForm : Form
{
private List<Order> orders = new();
public OrderListForm()
{
InitializeComponent();
AppStyles.ApplyIcon(this);
if (File.Exists(AppStyles.LogoPath))
logoPictureBox.Image = Image.FromFile(AppStyles.LogoPath);
addButton.Visible = SessionManager.IsAdmin;
deleteButton.Visible = SessionManager.IsAdmin;
LoadData();
}
private void HeaderPanel_Resize(object? sender, EventArgs e)
{
backButton.Location = new Point(headerPanel.ClientSize.Width - backButton.Width - 10, 10);
}
private void BackButton_Click(object? sender, EventArgs e) => Close();
private void LoadData()
{
try
{
using var context = new SportShopContext();
orders = context.Orders
.Include(o => o.FioNavigation)
.Include(o => o.IdStatusNavigation)
.Include(o => o.OrderItems)
.OrderByDescending(o => o.DataStart)
.ToList();
orderGrid.Rows.Clear();
foreach (var o in orders)
{
var rowIndex = orderGrid.Rows.Add(
o.Idzakaz,
o.Article,
o.FioNavigation?.Fio ?? "—",
o.IdStatusNavigation?.Name ?? "—",
o.Adrec,
o.DataStart.ToString("dd.MM.yyyy"),
o.DateEnd?.ToString("dd.MM.yyyy") ?? "—",
o.OrderItems.Count
);
orderGrid.Rows[rowIndex].Tag = o;
}
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка загрузки заказов:\n{ex.Message}", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void OrderGrid_CellDoubleClick(object? sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || !SessionManager.IsAdmin) return;
var order = orderGrid.Rows[e.RowIndex].Tag as Order;
if (order == null) return;
var editForm = new OrderEditForm(order);
editForm.FormClosed += (_, _) => LoadData();
editForm.Show();
}
private void AddButton_Click(object? sender, EventArgs e)
{
var editForm = new OrderEditForm(null);
editForm.FormClosed += (_, _) => LoadData();
editForm.Show();
}
private void DeleteButton_Click(object? sender, EventArgs e)
{
if (orderGrid.CurrentRow?.Tag is not Order order) return;
var result = MessageBox.Show(
$"Вы уверены, что хотите удалить заказ \"{order.Article}\"?\nЗарезервированные товары будут возвращены на склад.",
"Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result != DialogResult.Yes) return;
try
{
using var context = new SportShopContext();
var dbOrder = context.Orders
.Include(o => o.OrderItems)
.FirstOrDefault(o => o.Idzakaz == order.Idzakaz);
if (dbOrder != null)
{
context.OrderItems.RemoveRange(dbOrder.OrderItems);
context.Orders.Remove(dbOrder);
context.SaveChanges();
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка удаления:\n{ex.Message}", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void OrderListForm_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,389 @@
namespace moduleExamen.Forms
{
partial class ProductEditForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
headerPanel = new Panel();
logoPictureBox = new PictureBox();
idLabel = new Label();
photoPictureBox = new PictureBox();
changePhotoButton = new Button();
articlLabel = new Label();
articlTextBox = new TextBox();
nameLabel = new Label();
nameTextBox = new TextBox();
catLabel = new Label();
categoryComboBox = new ComboBox();
descLabel = new Label();
descriptionTextBox = new TextBox();
manLabel = new Label();
manufacturerComboBox = new ComboBox();
supLabel = new Label();
supplierComboBox = new ComboBox();
priceLabel = new Label();
priceTextBox = new TextBox();
edLabel = new Label();
edComboBox = new ComboBox();
kolvoLabel = new Label();
kolvoTextBox = new TextBox();
saleLabel = new Label();
saleTextBox = new TextBox();
saveButton = new Button();
cancelButton = new Button();
headerPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit();
((System.ComponentModel.ISupportInitialize)photoPictureBox).BeginInit();
SuspendLayout();
//
// headerPanel
//
headerPanel.BackColor = Color.FromArgb(133, 242, 189);
headerPanel.Controls.Add(logoPictureBox);
headerPanel.Controls.Add(idLabel);
headerPanel.Dock = DockStyle.Top;
headerPanel.Location = new Point(0, 0);
headerPanel.Name = "headerPanel";
headerPanel.Size = new Size(534, 60);
headerPanel.TabIndex = 22;
//
// logoPictureBox
//
logoPictureBox.Location = new Point(10, 5);
logoPictureBox.Name = "logoPictureBox";
logoPictureBox.Size = new Size(50, 50);
logoPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
logoPictureBox.TabIndex = 0;
logoPictureBox.TabStop = false;
//
// idLabel
//
idLabel.AutoSize = true;
idLabel.Font = new Font("Comic Sans MS", 12F, FontStyle.Bold);
idLabel.ForeColor = Color.Black;
idLabel.Location = new Point(70, 15);
idLabel.Name = "idLabel";
idLabel.Size = new Size(106, 23);
idLabel.TabIndex = 1;
idLabel.Text = "ID: (новый)";
//
// photoPictureBox
//
photoPictureBox.BackColor = Color.WhiteSmoke;
photoPictureBox.BorderStyle = BorderStyle.FixedSingle;
photoPictureBox.Location = new Point(20, 70);
photoPictureBox.Name = "photoPictureBox";
photoPictureBox.Size = new Size(150, 150);
photoPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
photoPictureBox.TabIndex = 0;
photoPictureBox.TabStop = false;
//
// changePhotoButton
//
changePhotoButton.Cursor = Cursors.Hand;
changePhotoButton.Font = new Font("Comic Sans MS", 9F);
changePhotoButton.Location = new Point(180, 130);
changePhotoButton.Name = "changePhotoButton";
changePhotoButton.Size = new Size(130, 30);
changePhotoButton.TabIndex = 1;
changePhotoButton.Text = "Изменить фото";
changePhotoButton.Click += ChangePhoto_Click;
//
// articlLabel
//
articlLabel.AutoSize = true;
articlLabel.Font = new Font("Comic Sans MS", 9F);
articlLabel.Location = new Point(180, 70);
articlLabel.Name = "articlLabel";
articlLabel.Size = new Size(60, 17);
articlLabel.TabIndex = 30;
articlLabel.Text = "Артикул:";
//
// articlTextBox
//
articlTextBox.Font = new Font("Comic Sans MS", 10F);
articlTextBox.Location = new Point(180, 90);
articlTextBox.Name = "articlTextBox";
articlTextBox.Size = new Size(330, 26);
articlTextBox.TabIndex = 31;
//
// nameLabel
//
nameLabel.AutoSize = true;
nameLabel.Font = new Font("Comic Sans MS", 9F);
nameLabel.Location = new Point(20, 235);
nameLabel.Name = "nameLabel";
nameLabel.Size = new Size(97, 17);
nameLabel.TabIndex = 2;
nameLabel.Text = "Наименование:";
//
// nameTextBox
//
nameTextBox.Font = new Font("Comic Sans MS", 10F);
nameTextBox.Location = new Point(20, 257);
nameTextBox.Name = "nameTextBox";
nameTextBox.Size = new Size(490, 26);
nameTextBox.TabIndex = 3;
//
// catLabel
//
catLabel.AutoSize = true;
catLabel.Font = new Font("Comic Sans MS", 9F);
catLabel.Location = new Point(20, 292);
catLabel.Name = "catLabel";
catLabel.Size = new Size(71, 17);
catLabel.TabIndex = 4;
catLabel.Text = "Категория:";
//
// categoryComboBox
//
categoryComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
categoryComboBox.Font = new Font("Comic Sans MS", 9F);
categoryComboBox.Location = new Point(20, 314);
categoryComboBox.Name = "categoryComboBox";
categoryComboBox.Size = new Size(490, 25);
categoryComboBox.TabIndex = 5;
//
// descLabel
//
descLabel.AutoSize = true;
descLabel.Font = new Font("Comic Sans MS", 9F);
descLabel.Location = new Point(20, 349);
descLabel.Name = "descLabel";
descLabel.Size = new Size(71, 17);
descLabel.TabIndex = 6;
descLabel.Text = "Описание:";
//
// descriptionTextBox
//
descriptionTextBox.Font = new Font("Comic Sans MS", 10F);
descriptionTextBox.Location = new Point(20, 371);
descriptionTextBox.MaxLength = 150;
descriptionTextBox.Multiline = true;
descriptionTextBox.Name = "descriptionTextBox";
descriptionTextBox.Size = new Size(490, 50);
descriptionTextBox.TabIndex = 7;
//
// manLabel
//
manLabel.AutoSize = true;
manLabel.Font = new Font("Comic Sans MS", 9F);
manLabel.Location = new Point(20, 431);
manLabel.Name = "manLabel";
manLabel.Size = new Size(103, 17);
manLabel.TabIndex = 8;
manLabel.Text = "Производитель:";
//
// manufacturerComboBox
//
manufacturerComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
manufacturerComboBox.Font = new Font("Comic Sans MS", 9F);
manufacturerComboBox.Location = new Point(20, 453);
manufacturerComboBox.Name = "manufacturerComboBox";
manufacturerComboBox.Size = new Size(235, 25);
manufacturerComboBox.TabIndex = 9;
//
// supLabel
//
supLabel.AutoSize = true;
supLabel.Font = new Font("Comic Sans MS", 9F);
supLabel.Location = new Point(275, 431);
supLabel.Name = "supLabel";
supLabel.Size = new Size(78, 17);
supLabel.TabIndex = 10;
supLabel.Text = "Поставщик:";
//
// supplierComboBox
//
supplierComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
supplierComboBox.Font = new Font("Comic Sans MS", 9F);
supplierComboBox.Location = new Point(275, 453);
supplierComboBox.Name = "supplierComboBox";
supplierComboBox.Size = new Size(235, 25);
supplierComboBox.TabIndex = 11;
//
// priceLabel
//
priceLabel.AutoSize = true;
priceLabel.Font = new Font("Comic Sans MS", 9F);
priceLabel.Location = new Point(20, 488);
priceLabel.Name = "priceLabel";
priceLabel.Size = new Size(40, 17);
priceLabel.TabIndex = 12;
priceLabel.Text = "Цена:";
//
// priceTextBox
//
priceTextBox.Font = new Font("Comic Sans MS", 10F);
priceTextBox.Location = new Point(20, 510);
priceTextBox.Name = "priceTextBox";
priceTextBox.Size = new Size(150, 26);
priceTextBox.TabIndex = 13;
//
// edLabel
//
edLabel.AutoSize = true;
edLabel.Font = new Font("Comic Sans MS", 9F);
edLabel.Location = new Point(190, 488);
edLabel.Name = "edLabel";
edLabel.Size = new Size(95, 17);
edLabel.TabIndex = 14;
edLabel.Text = "Ед. измерения:";
//
// edComboBox
//
edComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
edComboBox.Font = new Font("Comic Sans MS", 9F);
edComboBox.Location = new Point(190, 510);
edComboBox.Name = "edComboBox";
edComboBox.Size = new Size(120, 25);
edComboBox.TabIndex = 15;
//
// kolvoLabel
//
kolvoLabel.AutoSize = true;
kolvoLabel.Font = new Font("Comic Sans MS", 9F);
kolvoLabel.Location = new Point(330, 488);
kolvoLabel.Name = "kolvoLabel";
kolvoLabel.Size = new Size(53, 17);
kolvoLabel.TabIndex = 16;
kolvoLabel.Text = "Кол-во:";
//
// kolvoTextBox
//
kolvoTextBox.Font = new Font("Comic Sans MS", 10F);
kolvoTextBox.Location = new Point(330, 510);
kolvoTextBox.Name = "kolvoTextBox";
kolvoTextBox.Size = new Size(80, 26);
kolvoTextBox.TabIndex = 17;
//
// saleLabel
//
saleLabel.AutoSize = true;
saleLabel.Font = new Font("Comic Sans MS", 9F);
saleLabel.Location = new Point(420, 488);
saleLabel.Name = "saleLabel";
saleLabel.Size = new Size(66, 17);
saleLabel.TabIndex = 18;
saleLabel.Text = "Скидка %:";
//
// saleTextBox
//
saleTextBox.Font = new Font("Comic Sans MS", 10F);
saleTextBox.Location = new Point(420, 510);
saleTextBox.Name = "saleTextBox";
saleTextBox.Size = new Size(90, 26);
saleTextBox.TabIndex = 19;
//
// saveButton
//
saveButton.BackColor = Color.FromArgb(255, 0, 0);
saveButton.Cursor = Cursors.Hand;
saveButton.FlatAppearance.BorderSize = 0;
saveButton.FlatStyle = FlatStyle.Flat;
saveButton.Font = new Font("Comic Sans MS", 10F, FontStyle.Bold);
saveButton.ForeColor = Color.White;
saveButton.Location = new Point(190, 555);
saveButton.Name = "saveButton";
saveButton.Size = new Size(150, 40);
saveButton.TabIndex = 20;
saveButton.Text = "Сохранить";
saveButton.UseVisualStyleBackColor = false;
saveButton.Click += SaveButton_Click;
//
// cancelButton
//
cancelButton.Cursor = Cursors.Hand;
cancelButton.FlatStyle = FlatStyle.Flat;
cancelButton.Font = new Font("Comic Sans MS", 10F);
cancelButton.Location = new Point(350, 555);
cancelButton.Name = "cancelButton";
cancelButton.Size = new Size(100, 40);
cancelButton.TabIndex = 21;
cancelButton.Text = "Отмена";
cancelButton.Click += CancelButton_Click;
//
// ProductEditForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.FromArgb(192, 237, 215);
ClientSize = new Size(534, 621);
Controls.Add(photoPictureBox);
Controls.Add(changePhotoButton);
Controls.Add(articlLabel);
Controls.Add(articlTextBox);
Controls.Add(nameLabel);
Controls.Add(nameTextBox);
Controls.Add(catLabel);
Controls.Add(categoryComboBox);
Controls.Add(descLabel);
Controls.Add(descriptionTextBox);
Controls.Add(manLabel);
Controls.Add(manufacturerComboBox);
Controls.Add(supLabel);
Controls.Add(supplierComboBox);
Controls.Add(priceLabel);
Controls.Add(priceTextBox);
Controls.Add(edLabel);
Controls.Add(edComboBox);
Controls.Add(kolvoLabel);
Controls.Add(kolvoTextBox);
Controls.Add(saleLabel);
Controls.Add(saleTextBox);
Controls.Add(saveButton);
Controls.Add(cancelButton);
Controls.Add(headerPanel);
FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false;
MinimumSize = new Size(500, 650);
Name = "ProductEditForm";
StartPosition = FormStartPosition.CenterScreen;
Text = "Sport Farm - Товар";
Load += ProductEditForm_Load;
headerPanel.ResumeLayout(false);
headerPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit();
((System.ComponentModel.ISupportInitialize)photoPictureBox).EndInit();
ResumeLayout(false);
PerformLayout();
}
private Panel headerPanel;
private PictureBox logoPictureBox;
private Label idLabel;
private PictureBox photoPictureBox;
private Button changePhotoButton;
private Label articlLabel;
private TextBox articlTextBox;
private Label nameLabel;
private TextBox nameTextBox;
private Label catLabel;
private ComboBox categoryComboBox;
private Label descLabel;
private TextBox descriptionTextBox;
private Label manLabel;
private ComboBox manufacturerComboBox;
private Label supLabel;
private ComboBox supplierComboBox;
private Label priceLabel;
private TextBox priceTextBox;
private Label edLabel;
private ComboBox edComboBox;
private Label kolvoLabel;
private TextBox kolvoTextBox;
private Label saleLabel;
private TextBox saleTextBox;
private Button saveButton;
private Button cancelButton;
}
}

View File

@ -0,0 +1,196 @@
using moduleExamen.Data;
using moduleExamen.Helpers;
using moduleExamen.Models;
namespace moduleExamen.Forms
{
public partial class ProductEditForm : Form
{
private readonly Product? editingProduct;
private readonly bool isEditing;
private byte[]? photoBytes;
public ProductEditForm(Product? product)
{
InitializeComponent();
AppStyles.ApplyIcon(this);
if (File.Exists(AppStyles.LogoPath))
logoPictureBox.Image = Image.FromFile(AppStyles.LogoPath);
editingProduct = product;
isEditing = product != null;
Text = isEditing ? "Sport Farm - Редактирование товара" : "Sport Farm - Добавление товара";
idLabel.Text = isEditing ? $"ID товара: {product!.Idproduct}" : "ID: (новый)";
LoadComboBoxData();
if (isEditing)
FillFields();
}
private void LoadComboBoxData()
{
try
{
using var context = new SportShopContext();
var categories = context.TipeProducts.ToList();
categoryComboBox.DataSource = categories;
categoryComboBox.DisplayMember = "Name";
categoryComboBox.ValueMember = "IdtipeProduct";
var mans = context.Manufacts.ToList();
manufacturerComboBox.DataSource = mans;
manufacturerComboBox.DisplayMember = "Name";
manufacturerComboBox.ValueMember = "Idmanufact";
var sups = context.Supliers.ToList();
supplierComboBox.DataSource = sups;
supplierComboBox.DisplayMember = "Name";
supplierComboBox.ValueMember = "Idsuplier";
var eds = context.Eds.ToList();
edComboBox.DataSource = eds;
edComboBox.DisplayMember = "Name";
edComboBox.ValueMember = "Ided";
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка загрузки справочников:\n{ex.Message}", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FillFields()
{
if (editingProduct == null) return;
articlTextBox.Text = editingProduct.Articl;
articlTextBox.ReadOnly = true;
nameTextBox.Text = editingProduct.Name;
categoryComboBox.SelectedValue = editingProduct.IdTipeProduct;
descriptionTextBox.Text = editingProduct.ProductContent;
manufacturerComboBox.SelectedValue = editingProduct.IdManufactur;
supplierComboBox.SelectedValue = editingProduct.IdSuplier;
priceTextBox.Text = editingProduct.PriceProduct.ToString("F2");
edComboBox.SelectedValue = editingProduct.IdEd;
kolvoTextBox.Text = editingProduct.KolVo?.ToString() ?? "0";
saleTextBox.Text = editingProduct.Sale?.ToString() ?? "0";
photoBytes = editingProduct.IdPhoto;
if (photoBytes != null && photoBytes.Length > 0)
{
try
{
using var ms = new MemoryStream(photoBytes);
photoPictureBox.Image = Image.FromStream(ms);
}
catch { }
}
}
private void ChangePhoto_Click(object? sender, EventArgs e)
{
using var dialog = new OpenFileDialog
{
Title = "Выберите изображение",
Filter = "Изображения (*.jpg;*.png)|*.jpg;*.png"
};
if (dialog.ShowDialog() != DialogResult.OK) return;
try
{
using var original = Image.FromFile(dialog.FileName);
var resized = new Bitmap(original, new Size(
Math.Min(original.Width, 350),
Math.Min(original.Height, 350)));
using var ms = new MemoryStream();
resized.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
photoBytes = ms.ToArray();
photoPictureBox.Image = resized;
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка загрузки изображения:\n{ex.Message}", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelButton_Click(object? sender, EventArgs e) => Close();
private void SaveButton_Click(object? sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(nameTextBox.Text))
{
MessageBox.Show("Введите наименование товара.");
return;
}
if (!decimal.TryParse(priceTextBox.Text, out var price))
{
MessageBox.Show("Введите корректную цену.");
return;
}
if (!int.TryParse(kolvoTextBox.Text, out var kolvo))
{
MessageBox.Show("Введите корректное количество.");
return;
}
if (!int.TryParse(saleTextBox.Text, out var sale))
{
MessageBox.Show("Введите корректную скидку.");
return;
}
try
{
using var context = new SportShopContext();
Product product;
if (isEditing)
{
product = context.Products.Find(editingProduct!.Idproduct)!;
}
else
{
product = new Product();
product.Articl = articlTextBox.Text.Trim();
context.Products.Add(product);
}
product.Name = nameTextBox.Text.Trim();
product.IdTipeProduct = (int)categoryComboBox.SelectedValue;
product.ProductContent = descriptionTextBox.Text.Trim();
product.IdManufactur = (int)manufacturerComboBox.SelectedValue;
product.IdSuplier = (int)supplierComboBox.SelectedValue;
product.PriceProduct = price;
product.IdEd = (int)edComboBox.SelectedValue;
product.KolVo = kolvo;
product.Sale = sale;
product.IdPhoto = photoBytes;
context.SaveChanges();
MessageBox.Show("Данные сохранены.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка сохранения:\n{ex.Message}", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ProductEditForm_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,387 @@
namespace moduleExamen.Forms
{
partial class ProductListForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
headerPanel = new Panel();
logoPictureBox = new PictureBox();
headerTitle = new Label();
userLabel = new Label();
backButton = new Button();
filterPanel = new Panel();
searchLabel = new Label();
searchTextBox = new TextBox();
manufacturerLabel = new Label();
manufacturerComboBox = new ComboBox();
sortLabel = new Label();
sortComboBox = new ComboBox();
countLabel = new Label();
buttonPanel = new Panel();
addButton = new Button();
deleteButton = new Button();
ordersButton = new Button();
productGrid = new DataGridView();
photoColumn = new DataGridViewImageColumn();
productNameColumn = new DataGridViewTextBoxColumn();
categoryColumn = new DataGridViewTextBoxColumn();
manufacturerColumn = new DataGridViewTextBoxColumn();
priceColumn = new DataGridViewTextBoxColumn();
saleColumn = new DataGridViewTextBoxColumn();
kolVoColumn = new DataGridViewTextBoxColumn();
descriptionColumn = new DataGridViewTextBoxColumn();
headerPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)logoPictureBox).BeginInit();
filterPanel.SuspendLayout();
buttonPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)productGrid).BeginInit();
SuspendLayout();
//
// headerPanel
//
headerPanel.BackColor = Color.FromArgb(133, 242, 189);
headerPanel.Controls.Add(logoPictureBox);
headerPanel.Controls.Add(headerTitle);
headerPanel.Controls.Add(userLabel);
headerPanel.Controls.Add(backButton);
headerPanel.Dock = DockStyle.Top;
headerPanel.Location = new Point(0, 0);
headerPanel.Name = "headerPanel";
headerPanel.Size = new Size(1084, 60);
headerPanel.TabIndex = 3;
//
// logoPictureBox
//
logoPictureBox.Location = new Point(10, 5);
logoPictureBox.Name = "logoPictureBox";
logoPictureBox.Size = new Size(50, 50);
logoPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
logoPictureBox.TabIndex = 0;
logoPictureBox.TabStop = false;
//
// headerTitle
//
headerTitle.AutoSize = true;
headerTitle.Font = new Font("Comic Sans MS", 14F, FontStyle.Bold);
headerTitle.ForeColor = Color.Black;
headerTitle.Location = new Point(70, 15);
headerTitle.Name = "headerTitle";
headerTitle.Size = new Size(301, 27);
headerTitle.TabIndex = 1;
headerTitle.Text = "Sport Farm - Каталог товаров";
//
// userLabel
//
userLabel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
userLabel.AutoSize = true;
userLabel.Font = new Font("Comic Sans MS", 10F);
userLabel.ForeColor = Color.Black;
userLabel.Location = new Point(849, 27);
userLabel.Name = "userLabel";
userLabel.Size = new Size(105, 19);
userLabel.TabIndex = 2;
userLabel.Text = "Пользователь";
//
// backButton
//
backButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
backButton.BackColor = Color.FromArgb(200, 60, 60);
backButton.Cursor = Cursors.Hand;
backButton.FlatAppearance.BorderSize = 0;
backButton.FlatStyle = FlatStyle.Flat;
backButton.Font = new Font("Comic Sans MS", 9F);
backButton.ForeColor = Color.White;
backButton.Location = new Point(983, 24);
backButton.Name = "backButton";
backButton.Size = new Size(70, 30);
backButton.TabIndex = 3;
backButton.Text = "Выход";
backButton.UseVisualStyleBackColor = false;
backButton.Click += BackButton_Click;
//
// filterPanel
//
filterPanel.Controls.Add(searchLabel);
filterPanel.Controls.Add(searchTextBox);
filterPanel.Controls.Add(manufacturerLabel);
filterPanel.Controls.Add(manufacturerComboBox);
filterPanel.Controls.Add(sortLabel);
filterPanel.Controls.Add(sortComboBox);
filterPanel.Controls.Add(countLabel);
filterPanel.Dock = DockStyle.Top;
filterPanel.Location = new Point(0, 60);
filterPanel.Name = "filterPanel";
filterPanel.Padding = new Padding(10, 10, 10, 5);
filterPanel.Size = new Size(1084, 50);
filterPanel.TabIndex = 2;
//
// searchLabel
//
searchLabel.AutoSize = true;
searchLabel.Font = new Font("Comic Sans MS", 9F);
searchLabel.Location = new Point(10, 17);
searchLabel.Name = "searchLabel";
searchLabel.Size = new Size(50, 17);
searchLabel.TabIndex = 0;
searchLabel.Text = "Поиск:";
//
// searchTextBox
//
searchTextBox.Font = new Font("Comic Sans MS", 10F);
searchTextBox.Location = new Point(60, 13);
searchTextBox.Name = "searchTextBox";
searchTextBox.PlaceholderText = "Название, описание, производитель...";
searchTextBox.Size = new Size(200, 26);
searchTextBox.TabIndex = 1;
searchTextBox.TextChanged += SearchTextBox_TextChanged;
//
// manufacturerLabel
//
manufacturerLabel.AutoSize = true;
manufacturerLabel.Font = new Font("Comic Sans MS", 9F);
manufacturerLabel.Location = new Point(280, 17);
manufacturerLabel.Name = "manufacturerLabel";
manufacturerLabel.Size = new Size(103, 17);
manufacturerLabel.TabIndex = 2;
manufacturerLabel.Text = "Производитель:";
//
// manufacturerComboBox
//
manufacturerComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
manufacturerComboBox.Font = new Font("Comic Sans MS", 9F);
manufacturerComboBox.Location = new Point(390, 13);
manufacturerComboBox.Name = "manufacturerComboBox";
manufacturerComboBox.Size = new Size(180, 25);
manufacturerComboBox.TabIndex = 3;
manufacturerComboBox.SelectedIndexChanged += ManufacturerComboBox_SelectedIndexChanged;
//
// sortLabel
//
sortLabel.AutoSize = true;
sortLabel.Font = new Font("Comic Sans MS", 9F);
sortLabel.Location = new Point(590, 17);
sortLabel.Name = "sortLabel";
sortLabel.Size = new Size(77, 17);
sortLabel.TabIndex = 4;
sortLabel.Text = "Сортировка:";
//
// sortComboBox
//
sortComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
sortComboBox.Font = new Font("Comic Sans MS", 9F);
sortComboBox.Items.AddRange(new object[] { "Без сортировки", "Цена по возрастанию", "Цена по убыванию" });
sortComboBox.Location = new Point(680, 13);
sortComboBox.Name = "sortComboBox";
sortComboBox.Size = new Size(180, 25);
sortComboBox.TabIndex = 5;
sortComboBox.SelectedIndexChanged += SortComboBox_SelectedIndexChanged;
//
// countLabel
//
countLabel.AutoSize = true;
countLabel.Font = new Font("Comic Sans MS", 9F);
countLabel.Location = new Point(880, 17);
countLabel.Name = "countLabel";
countLabel.Size = new Size(0, 17);
countLabel.TabIndex = 6;
//
// buttonPanel
//
buttonPanel.Controls.Add(addButton);
buttonPanel.Controls.Add(deleteButton);
buttonPanel.Controls.Add(ordersButton);
buttonPanel.Dock = DockStyle.Bottom;
buttonPanel.Location = new Point(0, 611);
buttonPanel.Name = "buttonPanel";
buttonPanel.Padding = new Padding(10);
buttonPanel.Size = new Size(1084, 50);
buttonPanel.TabIndex = 1;
//
// addButton
//
addButton.BackColor = Color.FromArgb(255, 0, 0);
addButton.Cursor = Cursors.Hand;
addButton.FlatAppearance.BorderSize = 0;
addButton.FlatStyle = FlatStyle.Flat;
addButton.Font = new Font("Comic Sans MS", 10F, FontStyle.Bold);
addButton.ForeColor = Color.White;
addButton.Location = new Point(10, 7);
addButton.Name = "addButton";
addButton.Size = new Size(150, 35);
addButton.TabIndex = 0;
addButton.Text = "Добавить товар";
addButton.UseVisualStyleBackColor = false;
addButton.Click += AddButton_Click;
//
// deleteButton
//
deleteButton.BackColor = Color.FromArgb(200, 60, 60);
deleteButton.Cursor = Cursors.Hand;
deleteButton.FlatAppearance.BorderSize = 0;
deleteButton.FlatStyle = FlatStyle.Flat;
deleteButton.Font = new Font("Comic Sans MS", 10F);
deleteButton.ForeColor = Color.White;
deleteButton.Location = new Point(170, 7);
deleteButton.Name = "deleteButton";
deleteButton.Size = new Size(150, 35);
deleteButton.TabIndex = 1;
deleteButton.Text = "Удалить товар";
deleteButton.UseVisualStyleBackColor = false;
deleteButton.Click += DeleteButton_Click;
//
// ordersButton
//
ordersButton.BackColor = Color.FromArgb(133, 242, 189);
ordersButton.Cursor = Cursors.Hand;
ordersButton.FlatAppearance.BorderSize = 0;
ordersButton.FlatStyle = FlatStyle.Flat;
ordersButton.Font = new Font("Comic Sans MS", 10F);
ordersButton.ForeColor = Color.Black;
ordersButton.Location = new Point(330, 7);
ordersButton.Name = "ordersButton";
ordersButton.Size = new Size(120, 35);
ordersButton.TabIndex = 2;
ordersButton.Text = "Заказы";
ordersButton.UseVisualStyleBackColor = false;
ordersButton.Click += OrdersButton_Click;
//
// productGrid
//
productGrid.AllowUserToAddRows = false;
productGrid.AllowUserToDeleteRows = false;
productGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
productGrid.BackgroundColor = Color.White;
productGrid.BorderStyle = BorderStyle.None;
productGrid.Columns.AddRange(new DataGridViewColumn[] { photoColumn, productNameColumn, categoryColumn, manufacturerColumn, priceColumn, saleColumn, kolVoColumn, descriptionColumn });
productGrid.Dock = DockStyle.Fill;
productGrid.Font = new Font("Comic Sans MS", 9F);
productGrid.Location = new Point(0, 110);
productGrid.Name = "productGrid";
productGrid.ReadOnly = true;
productGrid.RowHeadersVisible = false;
productGrid.RowTemplate.Height = 60;
productGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
productGrid.Size = new Size(1084, 501);
productGrid.TabIndex = 0;
productGrid.CellDoubleClick += ProductGrid_CellDoubleClick;
productGrid.CellFormatting += ProductGrid_CellFormatting;
//
// photoColumn
//
photoColumn.HeaderText = "Фото";
photoColumn.ImageLayout = DataGridViewImageCellLayout.Zoom;
photoColumn.Name = "photoColumn";
photoColumn.ReadOnly = true;
photoColumn.Width = 70;
//
// productNameColumn
//
productNameColumn.HeaderText = "Наименование";
productNameColumn.Name = "productNameColumn";
productNameColumn.ReadOnly = true;
productNameColumn.Width = 180;
//
// categoryColumn
//
categoryColumn.HeaderText = "Категория";
categoryColumn.Name = "categoryColumn";
categoryColumn.ReadOnly = true;
//
// manufacturerColumn
//
manufacturerColumn.HeaderText = "Производитель";
manufacturerColumn.Name = "manufacturerColumn";
manufacturerColumn.ReadOnly = true;
manufacturerColumn.Width = 110;
//
// priceColumn
//
priceColumn.HeaderText = "Цена";
priceColumn.Name = "priceColumn";
priceColumn.ReadOnly = true;
priceColumn.Width = 120;
//
// saleColumn
//
saleColumn.HeaderText = "Скидка";
saleColumn.Name = "saleColumn";
saleColumn.ReadOnly = true;
saleColumn.Width = 60;
//
// kolVoColumn
//
kolVoColumn.HeaderText = "На складе";
kolVoColumn.Name = "kolVoColumn";
kolVoColumn.ReadOnly = true;
kolVoColumn.Width = 70;
//
// descriptionColumn
//
descriptionColumn.HeaderText = "Описание";
descriptionColumn.Name = "descriptionColumn";
descriptionColumn.ReadOnly = true;
descriptionColumn.Width = 200;
//
// ProductListForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.FromArgb(192, 237, 215);
ClientSize = new Size(1084, 661);
Controls.Add(productGrid);
Controls.Add(buttonPanel);
Controls.Add(filterPanel);
Controls.Add(headerPanel);
MinimumSize = new Size(900, 550);
Name = "ProductListForm";
StartPosition = FormStartPosition.CenterScreen;
Text = "Sport Farm - Товары";
Load += ProductListForm_Load;
headerPanel.ResumeLayout(false);
headerPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)logoPictureBox).EndInit();
filterPanel.ResumeLayout(false);
filterPanel.PerformLayout();
buttonPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)productGrid).EndInit();
ResumeLayout(false);
}
private Panel headerPanel;
private PictureBox logoPictureBox;
private Label headerTitle;
private Label userLabel;
private Button backButton;
private Panel filterPanel;
private Label searchLabel;
private TextBox searchTextBox;
private Label manufacturerLabel;
private ComboBox manufacturerComboBox;
private Label sortLabel;
private ComboBox sortComboBox;
private Label countLabel;
private Panel buttonPanel;
private Button addButton;
private Button deleteButton;
private Button ordersButton;
private DataGridView productGrid;
private DataGridViewImageColumn photoColumn;
private DataGridViewTextBoxColumn articlColumn;
private DataGridViewTextBoxColumn productNameColumn;
private DataGridViewTextBoxColumn categoryColumn;
private DataGridViewTextBoxColumn manufacturerColumn;
private DataGridViewTextBoxColumn priceColumn;
private DataGridViewTextBoxColumn saleColumn;
private DataGridViewTextBoxColumn kolVoColumn;
private DataGridViewTextBoxColumn descriptionColumn;
}
}

View File

@ -0,0 +1,252 @@
using Microsoft.EntityFrameworkCore;
using moduleExamen.Data;
using moduleExamen.Helpers;
using moduleExamen.Models;
namespace moduleExamen.Forms
{
public partial class ProductListForm : Form
{
private List<Product> allProducts = new();
private List<Manufact> manufacturers = new();
// Ссылка на открытую форму редактирования — не даём открыть две одновременно
private ProductEditForm? openEditForm;
public ProductListForm()
{
InitializeComponent();
AppStyles.ApplyIcon(this);
if (File.Exists(AppStyles.LogoPath))
logoPictureBox.Image = Image.FromFile(AppStyles.LogoPath);
userLabel.Text = SessionManager.IsGuest
? "Гость"
: $"{SessionManager.CurrentUser!.Fio} ({SessionManager.RoleName})";
addButton.Visible = SessionManager.IsAdmin;
deleteButton.Visible = SessionManager.IsAdmin;
ordersButton.Visible = SessionManager.IsManagerOrAdmin;
if (!SessionManager.IsManagerOrAdmin)
{
ordersButton.Location = new Point(10, 7);
}
if (!SessionManager.IsManagerOrAdmin)
{
searchTextBox.Visible = false;
searchLabel.Visible = false;
manufacturerComboBox.Visible = false;
manufacturerLabel.Visible = false;
sortComboBox.Visible = false;
sortLabel.Visible = false;
}
sortComboBox.SelectedIndex = 0;
LoadData();
}
private void BackButton_Click(object? sender, EventArgs e) => Close();
private void SearchTextBox_TextChanged(object? sender, EventArgs e) => ApplyFilters();
private void ManufacturerComboBox_SelectedIndexChanged(object? sender, EventArgs e) => ApplyFilters();
private void SortComboBox_SelectedIndexChanged(object? sender, EventArgs e) => ApplyFilters();
private void LoadData()
{
try
{
using var context = new SportShopContext();
allProducts = context.Products
.Include(p => p.IdManufacturNavigation)
.Include(p => p.IdTipeProductNavigation)
.Include(p => p.IdEdNavigation)
.Include(p => p.IdSuplierNavigation)
.Include(p => p.OrderItems)
.ToList();
manufacturers = context.Manufacts.OrderBy(m => m.Name).ToList();
manufacturerComboBox.Items.Clear();
manufacturerComboBox.Items.Add("Все производители");
foreach (var m in manufacturers)
manufacturerComboBox.Items.Add(m.Name);
manufacturerComboBox.SelectedIndex = 0;
ApplyFilters();
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка загрузки данных:\n{ex.Message}", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ApplyFilters()
{
var filtered = allProducts.AsEnumerable();
// Фильтры доступны только менеджеру и админу
if (SessionManager.IsManagerOrAdmin)
{
var searchText = searchTextBox.Text.Trim().ToLower();
if (!string.IsNullOrEmpty(searchText))
{
filtered = filtered.Where(p =>
p.Name.ToLower().Contains(searchText) ||
p.ProductContent.ToLower().Contains(searchText) ||
p.IdManufacturNavigation.Name.ToLower().Contains(searchText));
}
if (manufacturerComboBox.SelectedIndex > 0)
{
var selectedManufacturer = manufacturerComboBox.SelectedItem?.ToString();
filtered = filtered.Where(p => p.IdManufacturNavigation.Name == selectedManufacturer);
}
filtered = sortComboBox.SelectedIndex switch
{
1 => filtered.OrderBy(p => p.FinalPrice),
2 => filtered.OrderByDescending(p => p.FinalPrice),
_ => filtered
};
}
var list = filtered.ToList();
countLabel.Text = $"{list.Count} из {allProducts.Count}";
productGrid.Rows.Clear();
foreach (var p in list)
{
var photoImage = GetProductImage(p);
var priceText = FormatPrice(p);
var rowIndex = productGrid.Rows.Add(
photoImage,
p.Articl,
p.Name,
p.IdTipeProductNavigation?.Name ?? "",
p.IdManufacturNavigation?.Name ?? "",
priceText,
p.Sale.HasValue && p.Sale > 0 ? $"{p.Sale}%" : "—",
p.KolVo?.ToString() ?? "0",
p.ProductContent
);
// доступ при дабл клике
productGrid.Rows[rowIndex].Tag = p;
}
}
private static string FormatPrice(Product p)
{
if (p.Sale.HasValue && p.Sale > 0)
return $"{p.PriceProduct:N2} → {p.FinalPrice:N2} руб.";
return $"{p.PriceProduct:N2} руб.";
}
private static Image GetProductImage(Product p)
{
if (p.IdPhoto != null && p.IdPhoto.Length > 0)
{
try
{
using var ms = new MemoryStream(p.IdPhoto);
return Image.FromStream(ms);
}
catch { }
}
if (File.Exists(AppStyles.PicturePath))
return Image.FromFile(AppStyles.PicturePath);
var bmp = new Bitmap(60, 60);
using var g = Graphics.FromImage(bmp);
g.Clear(Color.LightGray);
g.DrawString("Нет фото", new Font("Segoe UI", 8f), Brushes.Gray, 5, 15);
return bmp;
}
private void ProductGrid_CellFormatting(object? sender, DataGridViewCellFormattingEventArgs e)
{
}
private void ProductGrid_CellDoubleClick(object? sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || !SessionManager.IsAdmin) return;
var product = productGrid.Rows[e.RowIndex].Tag as Product;
if (product == null) return;
OpenEditForm(product);
}
private void AddButton_Click(object? sender, EventArgs e) => OpenEditForm(null);
private void OpenEditForm(Product? product)
{
if (openEditForm != null && !openEditForm.IsDisposed)
{
MessageBox.Show("Уже открыто окно редактирования. Закройте его перед открытием нового.",
"Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
openEditForm.BringToFront();
return;
}
openEditForm = new ProductEditForm(product);
openEditForm.FormClosed += (_, _) =>
{
openEditForm = null;
LoadData();
};
openEditForm.Show();
}
private void DeleteButton_Click(object? sender, EventArgs e)
{
if (productGrid.CurrentRow?.Tag is not Product product) return;
// валидация
if (product.OrderItems.Count > 0)
{
MessageBox.Show("Невозможно удалить товар, так как он присутствует в заказе.",
"Удаление невозможно", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
var result = MessageBox.Show(
$"Вы уверены, что хотите удалить товар \"{product.Name}\"?",
"Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result != DialogResult.Yes) return;
try
{
using var context = new SportShopContext();
var dbProduct = context.Products.Find(product.Idproduct);
if (dbProduct != null)
{
context.Products.Remove(dbProduct);
context.SaveChanges();
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка удаления:\n{ex.Message}", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void OrdersButton_Click(object? sender, EventArgs e)
{
var orderForm = new OrderListForm();
orderForm.Show();
}
private void ProductListForm_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,31 @@
namespace moduleExamen.Helpers;
public static class AppStyles
{
// Основной фон RGB(192, 237, 215)
public static readonly Color BackgroundColor = Color.FromArgb(192, 237, 215);
// Дополнительный фон RGB(133, 242, 189)
public static readonly Color SecondaryColor = Color.FromArgb(133, 242, 189);
// Акцентирование внимания #ff0000
public static readonly Color AccentColor = Color.FromArgb(255, 0, 0);
public static readonly Color PrimaryColor = Color.FromArgb(133, 242, 189);
public static readonly Color DiscountHighColor = Color.FromArgb(144, 238, 144);
public static readonly Color OutOfStockColor = Color.FromArgb(211, 211, 211);
// Шрифт Comic Sans MS
public static readonly Font TitleFont = new("Comic Sans MS", 16f, FontStyle.Bold);
public static readonly Font RegularFont = new("Comic Sans MS", 10f);
public static readonly Font SmallFont = new("Comic Sans MS", 9f);
public static string IconPath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "icon.ico");
public static string LogoPath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "logo.png");
public static string PicturePath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "picture.png");
public static void ApplyIcon(Form form)
{
var iconPath = IconPath;
if (File.Exists(iconPath))
form.Icon = new Icon(iconPath);
}
}

View File

@ -0,0 +1,13 @@
using moduleExamen.Models;
namespace moduleExamen.Helpers;
public static class SessionManager
{
public static User? CurrentUser { get; set; }
public static string RoleName => CurrentUser?.IdRoleNavigation?.Name ?? "Гость";
public static bool IsGuest => CurrentUser == null;
public static bool IsAdmin => RoleName == "Админ";
public static bool IsManager => RoleName == "Менеджер";
public static bool IsManagerOrAdmin => IsAdmin || IsManager;
}

View File

@ -0,0 +1,9 @@
namespace moduleExamen.Models;
public class Ed
{
public int Ided { get; set; }
public string Name { get; set; } = null!;
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
}

View File

@ -0,0 +1,9 @@
namespace moduleExamen.Models;
public class Manufact
{
public int Idmanufact { get; set; }
public string Name { get; set; } = null!;
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
}

View File

@ -0,0 +1,16 @@
namespace moduleExamen.Models;
public class Order
{
public int Idzakaz { get; set; }
public string Article { get; set; } = null!;
public int Fio { get; set; }
public int IdStatus { get; set; }
public string Adrec { get; set; } = null!;
public DateOnly DataStart { get; set; }
public DateOnly? DateEnd { get; set; }
public virtual User FioNavigation { get; set; } = null!;
public virtual Status IdStatusNavigation { get; set; } = null!;
public virtual ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
}

View File

@ -0,0 +1,12 @@
namespace moduleExamen.Models;
public class OrderItem
{
public int IdorderItems { get; set; }
public int IdOrder { get; set; }
public int IdProduct { get; set; }
public int KolVo { get; set; }
public virtual Order IdOrderNavigation { get; set; } = null!;
public virtual Product IdProductNavigation { get; set; } = null!;
}

View File

@ -0,0 +1,30 @@
namespace moduleExamen.Models;
public class Product
{
public int Idproduct { get; set; }
public string Articl { get; set; } = null!;
public string Name { get; set; } = null!;
public int IdTipeProduct { get; set; }
public string ProductContent { get; set; } = null!;
public int IdManufactur { get; set; }
public int IdSuplier { get; set; }
public decimal PriceProduct { get; set; }
public int? Sale { get; set; }
public int? KolVo { get; set; }
public int IdEd { get; set; }
public byte[]? IdPhoto { get; set; }
public virtual Ed IdEdNavigation { get; set; } = null!;
public virtual Manufact IdManufacturNavigation { get; set; } = null!;
public virtual Suplier IdSuplierNavigation { get; set; } = null!;
public virtual TipeProduct IdTipeProductNavigation { get; set; } = null!;
public virtual ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
/// <summary>
/// Итоговая цена с учётом скидки
/// </summary>
public decimal FinalPrice => Sale.HasValue && Sale.Value > 0
? PriceProduct * (100 - Sale.Value) / 100
: PriceProduct;
}

View File

@ -0,0 +1,9 @@
namespace moduleExamen.Models;
public class Role
{
public int IdRole { get; set; }
public string Name { get; set; } = null!;
public virtual ICollection<User> Users { get; set; } = new List<User>();
}

View File

@ -0,0 +1,9 @@
namespace moduleExamen.Models;
public class Status
{
public int IdStatus { get; set; }
public string Name { get; set; } = null!;
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
}

View File

@ -0,0 +1,9 @@
namespace moduleExamen.Models;
public class Suplier
{
public int Idsuplier { get; set; }
public string Name { get; set; } = null!;
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
}

View File

@ -0,0 +1,9 @@
namespace moduleExamen.Models;
public class TipeProduct
{
public int IdtipeProduct { get; set; }
public string Name { get; set; } = null!;
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
}

View File

@ -0,0 +1,14 @@
namespace moduleExamen.Models;
public class User
{
public int Iduser { get; set; }
public string Login { get; set; } = null!;
public string Password { get; set; } = null!;
public string Fio { get; set; } = null!;
public int IdRole { get; set; }
public string Email { get; set; } = null!;
public virtual Role IdRoleNavigation { get; set; } = null!;
public virtual ICollection<Order> Orders { get; set; } = new List<Order>();
}

View File

@ -0,0 +1,14 @@
using moduleExamen.Forms;
namespace moduleExamen
{
internal static class Program
{
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
Application.Run(new LoginForm());
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Some files were not shown because too many files have changed in this diff Show More