From 7a1a987b5c891969547de6664d525bcb7c06d00a Mon Sep 17 00:00:00 2001 From: Samusev Date: Mon, 9 Mar 2026 18:18:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=D1=82?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 63 +++ .gitignore | 363 ++++++++++++++++++ 1202.cs | 19 + AuthForm.Designer.cs | 111 ++++++ AuthForm.cs | 65 ++++ AuthForm.resx | 120 ++++++ CardForm.Designer.cs | 101 +++++ CardForm.cs | 42 ++ CardForm.resx | 120 ++++++ Category.cs | 13 + Delivery.cs | 29 ++ EditForm.Designer.cs | 343 +++++++++++++++++ EditForm.cs | 57 +++ EditForm.resx | 150 ++++++++ Form1.Designer.cs | 293 ++++++++++++++ Form1.cs | 124 ++++++ Form1.resx | 141 +++++++ Ispr2522SamusevOvLazarev2Context.cs | 311 +++++++++++++++ MainCardForm.Designer.cs | 161 ++++++++ MainCardForm.cs | 131 +++++++ MainCardForm.resx | 135 +++++++ Manufacturer.cs | 13 + Name.cs | 15 + OrdersProduct.cs | 19 + PickUpPoint.cs | 15 + Product.cs | 73 ++++ ProductName.cs | 13 + Program.cs | 17 + Properties/DataSources/Category.datasource | 10 + .../DataSources/Manufacturer.datasource | 10 + .../DataSources/OrdersProduct.datasource | 10 + Properties/DataSources/Product.datasource | 10 + Properties/DataSources/ProductName.datasource | 10 + Properties/DataSources/Supplier.datasource | 10 + Properties/Resources.Designer.cs | 63 +++ Properties/Resources.resx | 120 ++++++ Role.cs | 13 + Status.cs | 13 + Supplier.cs | 13 + User.cs | 21 + samusev-42.csproj | 39 ++ samusev-42.sln | 25 ++ 42 files changed, 3424 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 1202.cs create mode 100644 AuthForm.Designer.cs create mode 100644 AuthForm.cs create mode 100644 AuthForm.resx create mode 100644 CardForm.Designer.cs create mode 100644 CardForm.cs create mode 100644 CardForm.resx create mode 100644 Category.cs create mode 100644 Delivery.cs create mode 100644 EditForm.Designer.cs create mode 100644 EditForm.cs create mode 100644 EditForm.resx create mode 100644 Form1.Designer.cs create mode 100644 Form1.cs create mode 100644 Form1.resx create mode 100644 Ispr2522SamusevOvLazarev2Context.cs create mode 100644 MainCardForm.Designer.cs create mode 100644 MainCardForm.cs create mode 100644 MainCardForm.resx create mode 100644 Manufacturer.cs create mode 100644 Name.cs create mode 100644 OrdersProduct.cs create mode 100644 PickUpPoint.cs create mode 100644 Product.cs create mode 100644 ProductName.cs create mode 100644 Program.cs create mode 100644 Properties/DataSources/Category.datasource create mode 100644 Properties/DataSources/Manufacturer.datasource create mode 100644 Properties/DataSources/OrdersProduct.datasource create mode 100644 Properties/DataSources/Product.datasource create mode 100644 Properties/DataSources/ProductName.datasource create mode 100644 Properties/DataSources/Supplier.datasource create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Role.cs create mode 100644 Status.cs create mode 100644 Supplier.cs create mode 100644 User.cs create mode 100644 samusev-42.csproj create mode 100644 samusev-42.sln diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,363 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/1202.cs b/1202.cs new file mode 100644 index 0000000..ecb4ad1 --- /dev/null +++ b/1202.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace samusev_42 +{ + public partial class Product + { + [NotMapped] + public string CountUnit + { + /// Объединение колонок "Количечество и Штук", чтобы выглядело красиво + get { return Count + " " + Unit.ToString(); } + } + } +} diff --git a/AuthForm.Designer.cs b/AuthForm.Designer.cs new file mode 100644 index 0000000..eabc386 --- /dev/null +++ b/AuthForm.Designer.cs @@ -0,0 +1,111 @@ +namespace samusev_42 +{ + partial class AuthForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + textBoxLogin = new TextBox(); + textBoxPassword = new TextBox(); + buttonLogin = new Button(); + label1 = new Label(); + label2 = new Label(); + SuspendLayout(); + // + // textBoxLogin + // + textBoxLogin.Font = new Font("Segoe UI Semibold", 14.25F, FontStyle.Bold); + textBoxLogin.Location = new Point(28, 66); + textBoxLogin.Name = "textBoxLogin"; + textBoxLogin.Size = new Size(230, 33); + textBoxLogin.TabIndex = 0; + // + // textBoxPassword + // + textBoxPassword.Font = new Font("Segoe UI Semibold", 14.25F, FontStyle.Bold); + textBoxPassword.Location = new Point(28, 165); + textBoxPassword.Name = "textBoxPassword"; + textBoxPassword.Size = new Size(230, 33); + textBoxPassword.TabIndex = 1; + // + // buttonLogin + // + buttonLogin.BackColor = Color.MistyRose; + buttonLogin.Font = new Font("Segoe UI Semibold", 14.25F, FontStyle.Bold); + buttonLogin.Location = new Point(75, 233); + buttonLogin.Name = "buttonLogin"; + buttonLogin.Size = new Size(148, 42); + buttonLogin.TabIndex = 2; + buttonLogin.Text = "Войти"; + buttonLogin.UseVisualStyleBackColor = false; + buttonLogin.Click += buttonLogin_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Font = new Font("Segoe UI Semibold", 14.25F, FontStyle.Bold); + label1.Location = new Point(111, 28); + label1.Name = "label1"; + label1.Size = new Size(71, 25); + label1.TabIndex = 3; + label1.Text = "Логин:"; + // + // label2 + // + label2.AutoSize = true; + label2.Font = new Font("Segoe UI Semibold", 14.25F, FontStyle.Bold); + label2.Location = new Point(98, 128); + label2.Name = "label2"; + label2.Size = new Size(84, 25); + label2.TabIndex = 4; + label2.Text = "Пароль:"; + // + // AuthForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.PeachPuff; + ClientSize = new Size(286, 308); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(buttonLogin); + Controls.Add(textBoxPassword); + Controls.Add(textBoxLogin); + Name = "AuthForm"; + Text = "AuthForm"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox textBoxLogin; + private TextBox textBoxPassword; + private Button buttonLogin; + private Label label1; + private Label label2; + } +} \ No newline at end of file diff --git a/AuthForm.cs b/AuthForm.cs new file mode 100644 index 0000000..58bc560 --- /dev/null +++ b/AuthForm.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace samusev_42 +{ + public partial class AuthForm : Form + { + Ispr2522SamusevOvLazarev2Context context = new Ispr2522SamusevOvLazarev2Context(); + + public AuthForm() + { + InitializeComponent(); + } + + private void buttonLogin_Click(object sender, EventArgs e) + { + try + { + string inputLogin = textBoxLogin.Text.Trim(); + string inputPassword = textBoxPassword.Text.Trim(); + + + if (string.IsNullOrEmpty(inputLogin) || string.IsNullOrEmpty(inputPassword)) + { + MessageBox.Show("Введите логин и пароль!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + + var user = context.Users.FirstOrDefault(x => x.Login == inputLogin && x.Password == inputPassword); + + if (user != null) + { + + this.Hide(); + + Form1 mainForm = new Form1(); + mainForm.ShowDialog(); + + + this.Close(); + } + else + { + + MessageBox.Show("Пользователь не найден! Проверьте правильность данных.", + "Ошибка авторизации", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + catch (Exception ex) + { + + MessageBox.Show($"Ошибка подключения: {ex.Message}", "Критическая ошибка"); + } + } + } +} + diff --git a/AuthForm.resx b/AuthForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/AuthForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CardForm.Designer.cs b/CardForm.Designer.cs new file mode 100644 index 0000000..f3c3123 --- /dev/null +++ b/CardForm.Designer.cs @@ -0,0 +1,101 @@ +namespace samusev_42 +{ + partial class CardForm + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + labelName = new Label(); + labelPrice = new Label(); + pictureBoxProduct = new PictureBox(); + labelDescription = new Label(); + ((System.ComponentModel.ISupportInitialize)pictureBoxProduct).BeginInit(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold); + labelName.Location = new Point(220, 30); + labelName.Name = "labelName"; + labelName.Size = new Size(45, 17); + labelName.TabIndex = 0; + labelName.Text = "label1"; + // + // labelPrice + // + labelPrice.AutoSize = true; + labelPrice.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold); + labelPrice.Location = new Point(220, 61); + labelPrice.Name = "labelPrice"; + labelPrice.Size = new Size(45, 17); + labelPrice.TabIndex = 1; + labelPrice.Text = "label2"; + // + // pictureBoxProduct + // + pictureBoxProduct.BackColor = Color.White; + pictureBoxProduct.Location = new Point(16, 12); + pictureBoxProduct.Name = "pictureBoxProduct"; + pictureBoxProduct.Size = new Size(181, 118); + pictureBoxProduct.TabIndex = 2; + pictureBoxProduct.TabStop = false; + // + // labelDescription + // + labelDescription.AutoSize = true; + labelDescription.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold); + labelDescription.Location = new Point(220, 87); + labelDescription.Name = "labelDescription"; + labelDescription.Size = new Size(45, 17); + labelDescription.TabIndex = 3; + labelDescription.Text = "label1"; + // + // CardForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.Bisque; + Controls.Add(labelDescription); + Controls.Add(pictureBoxProduct); + Controls.Add(labelPrice); + Controls.Add(labelName); + Name = "CardForm"; + Size = new Size(708, 149); + Load += CardForm_Load; + ((System.ComponentModel.ISupportInitialize)pictureBoxProduct).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelPrice; + private PictureBox pictureBoxProduct; + private Label labelDescription; + } +} diff --git a/CardForm.cs b/CardForm.cs new file mode 100644 index 0000000..fb02c32 --- /dev/null +++ b/CardForm.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace samusev_42 +{ + public partial class CardForm : UserControl + { + public CardForm(Product product) + { + InitializeComponent(); + + labelName.Text = product.IdProductNameNavigation?.ProductName1 ?? "Название отсутствует"; + + labelPrice.Text = $"{product.Price:C2}"; + + labelDescription.Text = product.Description; + + if (!string.IsNullOrEmpty(product.Photo)) + { + try + { + pictureBoxProduct.ImageLocation = product.Photo; + } + catch + { + } + } + } + + private void CardForm_Load(object sender, EventArgs e) + { + + } + } +} diff --git a/CardForm.resx b/CardForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/CardForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Category.cs b/Category.cs new file mode 100644 index 0000000..c627845 --- /dev/null +++ b/Category.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class Category +{ + public int IdCategory { get; set; } + + public string CategoryName { get; set; } = null!; + + public virtual ICollection Products { get; set; } = new List(); +} diff --git a/Delivery.cs b/Delivery.cs new file mode 100644 index 0000000..e204610 --- /dev/null +++ b/Delivery.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class Delivery +{ + public int IdDelivery { get; set; } + + public DateTime DateOrder { get; set; } + + public DateTime DateDelivery { get; set; } + + public int IdPickUpPoint { get; set; } + + public int IdUser { get; set; } + + public int Code { get; set; } + + public int IdStatus { get; set; } + + public virtual PickUpPoint IdPickUpPointNavigation { get; set; } = null!; + + public virtual Status IdStatusNavigation { get; set; } = null!; + + public virtual User IdUserNavigation { get; set; } = null!; + + public virtual ICollection OrdersProducts { get; set; } = new List(); +} diff --git a/EditForm.Designer.cs b/EditForm.Designer.cs new file mode 100644 index 0000000..dde5efe --- /dev/null +++ b/EditForm.Designer.cs @@ -0,0 +1,343 @@ +namespace samusev_42 +{ + partial class EditForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + productBindingSource = new BindingSource(components); + textBox2 = new TextBox(); + textBox4 = new TextBox(); + textBox5 = new TextBox(); + textBox8 = new TextBox(); + textBox10 = new TextBox(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + label5 = new Label(); + label6 = new Label(); + label7 = new Label(); + label8 = new Label(); + label9 = new Label(); + label10 = new Label(); + comboBox1 = new ComboBox(); + productNameBindingSource = new BindingSource(components); + comboBox2 = new ComboBox(); + supplierBindingSource = new BindingSource(components); + comboBox3 = new ComboBox(); + manufacturerBindingSource = new BindingSource(components); + comboBox4 = new ComboBox(); + categoryBindingSource = new BindingSource(components); + SaveEditButton = new Button(); + ((System.ComponentModel.ISupportInitialize)productBindingSource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)productNameBindingSource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)supplierBindingSource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)manufacturerBindingSource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)categoryBindingSource).BeginInit(); + SuspendLayout(); + // + // productBindingSource + // + productBindingSource.DataSource = typeof(Product); + // + // textBox2 + // + textBox2.DataBindings.Add(new Binding("DataContext", productBindingSource, "Article", true)); + textBox2.DataBindings.Add(new Binding("Text", productBindingSource, "Article", true, DataSourceUpdateMode.OnPropertyChanged)); + textBox2.Location = new Point(152, 32); + textBox2.Name = "textBox2"; + textBox2.Size = new Size(148, 23); + textBox2.TabIndex = 1; + // + // textBox4 + // + textBox4.DataBindings.Add(new Binding("DataContext", productBindingSource, "Count", true)); + textBox4.DataBindings.Add(new Binding("Text", productBindingSource, "Count", true, DataSourceUpdateMode.OnPropertyChanged)); + textBox4.Location = new Point(152, 119); + textBox4.Name = "textBox4"; + textBox4.Size = new Size(148, 23); + textBox4.TabIndex = 3; + // + // textBox5 + // + textBox5.DataBindings.Add(new Binding("DataContext", productBindingSource, "Price", true)); + textBox5.DataBindings.Add(new Binding("Text", productBindingSource, "Price", true, DataSourceUpdateMode.OnPropertyChanged)); + textBox5.Location = new Point(152, 162); + textBox5.Name = "textBox5"; + textBox5.Size = new Size(148, 23); + textBox5.TabIndex = 4; + // + // textBox8 + // + textBox8.DataBindings.Add(new Binding("DataContext", productBindingSource, "Discount", true)); + textBox8.DataBindings.Add(new Binding("Text", productBindingSource, "Discount", true, DataSourceUpdateMode.OnPropertyChanged)); + textBox8.Location = new Point(152, 300); + textBox8.Name = "textBox8"; + textBox8.Size = new Size(148, 23); + textBox8.TabIndex = 7; + // + // textBox10 + // + textBox10.DataBindings.Add(new Binding("DataContext", productBindingSource, "Description", true)); + textBox10.DataBindings.Add(new Binding("Text", productBindingSource, "Description", true, DataSourceUpdateMode.OnPropertyChanged)); + textBox10.Location = new Point(152, 389); + textBox10.Name = "textBox10"; + textBox10.Size = new Size(148, 23); + textBox10.TabIndex = 9; + // + // label2 + // + label2.AutoSize = true; + label2.Font = new Font("Segoe UI Black", 11.25F, FontStyle.Bold); + label2.Location = new Point(44, 32); + label2.Name = "label2"; + label2.Size = new Size(80, 20); + label2.TabIndex = 12; + label2.Text = "Артикул:"; + // + // label3 + // + label3.AutoSize = true; + label3.Font = new Font("Segoe UI Black", 11.25F, FontStyle.Bold); + label3.Location = new Point(41, 75); + label3.Name = "label3"; + label3.Size = new Size(86, 20); + label3.TabIndex = 13; + label3.Text = "Название:"; + // + // label4 + // + label4.AutoSize = true; + label4.Font = new Font("Segoe UI Black", 11.25F, FontStyle.Bold); + label4.Location = new Point(50, 118); + label4.Name = "label4"; + label4.Size = new Size(69, 20); + label4.TabIndex = 14; + label4.Text = "Кол-во\u001e:"; + // + // label5 + // + label5.AutoSize = true; + label5.Font = new Font("Segoe UI Black", 11.25F, FontStyle.Bold); + label5.Location = new Point(50, 161); + label5.Name = "label5"; + label5.Size = new Size(52, 20); + label5.TabIndex = 15; + label5.Text = "Цена:"; + // + // label6 + // + label6.AutoSize = true; + label6.Font = new Font("Segoe UI Black", 11.25F, FontStyle.Bold); + label6.Location = new Point(38, 211); + label6.Name = "label6"; + label6.Size = new Size(100, 20); + label6.TabIndex = 16; + label6.Text = "Поставщик:"; + // + // label7 + // + label7.AutoSize = true; + label7.Font = new Font("Segoe UI Black", 11.25F, FontStyle.Bold); + label7.Location = new Point(12, 252); + label7.Name = "label7"; + label7.Size = new Size(137, 20); + label7.TabIndex = 17; + label7.Text = "Производитель:"; + label7.Click += label7_Click; + // + // label8 + // + label8.AutoSize = true; + label8.Font = new Font("Segoe UI Black", 11.25F, FontStyle.Bold); + label8.Location = new Point(41, 300); + label8.Name = "label8"; + label8.Size = new Size(69, 20); + label8.TabIndex = 18; + label8.Text = "Скидка:"; + // + // label9 + // + label9.AutoSize = true; + label9.Font = new Font("Segoe UI Black", 11.25F, FontStyle.Bold); + label9.Location = new Point(31, 348); + label9.Name = "label9"; + label9.Size = new Size(92, 20); + label9.TabIndex = 19; + label9.Text = "Категория:"; + // + // label10 + // + label10.AutoSize = true; + label10.Font = new Font("Segoe UI Black", 11.25F, FontStyle.Bold); + label10.Location = new Point(37, 389); + label10.Name = "label10"; + label10.Size = new Size(86, 20); + label10.TabIndex = 20; + label10.Text = "Описание:"; + // + // comboBox1 + // + comboBox1.DataBindings.Add(new Binding("SelectedValue", productBindingSource, "IdProductName", true, DataSourceUpdateMode.OnPropertyChanged)); + comboBox1.DataSource = productNameBindingSource; + comboBox1.DisplayMember = "ProductName1"; + comboBox1.FormattingEnabled = true; + comboBox1.Location = new Point(152, 75); + comboBox1.Name = "comboBox1"; + comboBox1.Size = new Size(148, 23); + comboBox1.TabIndex = 23; + comboBox1.ValueMember = "IdProductName"; + // + // productNameBindingSource + // + productNameBindingSource.DataSource = typeof(ProductName); + // + // comboBox2 + // + comboBox2.DataBindings.Add(new Binding("SelectedValue", productBindingSource, "IdSupplier", true)); + comboBox2.DataSource = supplierBindingSource; + comboBox2.DisplayMember = "SupplierName"; + comboBox2.FormattingEnabled = true; + comboBox2.Location = new Point(152, 208); + comboBox2.Name = "comboBox2"; + comboBox2.Size = new Size(148, 23); + comboBox2.TabIndex = 24; + comboBox2.ValueMember = "IdSupplier"; + // + // supplierBindingSource + // + supplierBindingSource.DataSource = typeof(Supplier); + // + // comboBox3 + // + comboBox3.DataBindings.Add(new Binding("SelectedValue", productBindingSource, "IdManufacturer", true)); + comboBox3.DataSource = manufacturerBindingSource; + comboBox3.DisplayMember = "ManufacturerName"; + comboBox3.FormattingEnabled = true; + comboBox3.Location = new Point(152, 252); + comboBox3.Name = "comboBox3"; + comboBox3.Size = new Size(148, 23); + comboBox3.TabIndex = 25; + comboBox3.ValueMember = "IdManufacturer"; + // + // manufacturerBindingSource + // + manufacturerBindingSource.DataSource = typeof(Manufacturer); + // + // comboBox4 + // + comboBox4.DataBindings.Add(new Binding("SelectedValue", productBindingSource, "IdCategory", true)); + comboBox4.DataSource = categoryBindingSource; + comboBox4.DisplayMember = "CategoryName"; + comboBox4.FormattingEnabled = true; + comboBox4.Location = new Point(152, 345); + comboBox4.Name = "comboBox4"; + comboBox4.Size = new Size(148, 23); + comboBox4.TabIndex = 26; + comboBox4.ValueMember = "IdCategory"; + // + // categoryBindingSource + // + categoryBindingSource.DataSource = typeof(Category); + // + // SaveEditButton + // + SaveEditButton.BackColor = Color.MistyRose; + SaveEditButton.DialogResult = DialogResult.OK; + SaveEditButton.Font = new Font("Segoe UI Black", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 204); + SaveEditButton.Location = new Point(85, 445); + SaveEditButton.Name = "SaveEditButton"; + SaveEditButton.Size = new Size(160, 46); + SaveEditButton.TabIndex = 27; + SaveEditButton.Text = "Сохранить"; + SaveEditButton.UseVisualStyleBackColor = false; + SaveEditButton.Click += SaveEditButton_Click; + // + // EditForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.PeachPuff; + ClientSize = new Size(324, 503); + Controls.Add(SaveEditButton); + Controls.Add(comboBox4); + Controls.Add(comboBox3); + Controls.Add(comboBox2); + Controls.Add(comboBox1); + Controls.Add(label10); + Controls.Add(label9); + Controls.Add(label8); + Controls.Add(label7); + Controls.Add(label6); + Controls.Add(label5); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(textBox10); + Controls.Add(textBox8); + Controls.Add(textBox5); + Controls.Add(textBox4); + Controls.Add(textBox2); + Name = "EditForm"; + Text = "EditForm"; + Load += EditForm_Load; + ((System.ComponentModel.ISupportInitialize)productBindingSource).EndInit(); + ((System.ComponentModel.ISupportInitialize)productNameBindingSource).EndInit(); + ((System.ComponentModel.ISupportInitialize)supplierBindingSource).EndInit(); + ((System.ComponentModel.ISupportInitialize)manufacturerBindingSource).EndInit(); + ((System.ComponentModel.ISupportInitialize)categoryBindingSource).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private Label label2; + private Label label3; + private Label label4; + private Label label5; + private Label label6; + private Label label7; + private Label label8; + private Label label9; + private Label label10; + public TextBox textBox2; + public TextBox textBox4; + public TextBox textBox5; + public TextBox textBox8; + public TextBox textBox10; + public BindingSource productBindingSource; + public ComboBox comboBox1; + public ComboBox comboBox2; + public ComboBox comboBox3; + public ComboBox comboBox4; + public BindingSource productNameBindingSource; + public BindingSource supplierBindingSource; + public BindingSource manufacturerBindingSource; + public BindingSource categoryBindingSource; + public Button SaveEditButton; + } +} \ No newline at end of file diff --git a/EditForm.cs b/EditForm.cs new file mode 100644 index 0000000..13db807 --- /dev/null +++ b/EditForm.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace samusev_42 +{ + public partial class EditForm : Form + { + /// валидация + public EditForm() + { + InitializeComponent(); + + + this.textBox5.Validating += textBoxPrice_Validating; + } + + private void textBoxPrice_Validating(object sender, CancelEventArgs e) + { + + if (!string.IsNullOrWhiteSpace(textBox5.Text) && !decimal.TryParse(textBox5.Text, out _)) + { + MessageBox.Show("В поле 'Цена' можно вводить только числа!", "Ошибка формата", + MessageBoxButtons.OK, MessageBoxIcon.Warning); + + textBox5.SelectAll(); + e.Cancel = true; + } + } + + private void SaveEditButton_Click(object sender, EventArgs e) + { + + } + + private void label10_Click(object sender, EventArgs e) + { + + } + + private void EditForm_Load(object sender, EventArgs e) + { + + } + + private void label7_Click(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/EditForm.resx b/EditForm.resx new file mode 100644 index 0000000..65eb38e --- /dev/null +++ b/EditForm.resx @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 190, 17 + + + 190, 17 + + + 395, 17 + + + 395, 17 + + + 568, 17 + + + 568, 17 + + + 771, 17 + + + 771, 17 + + + 31 + + \ No newline at end of file diff --git a/Form1.Designer.cs b/Form1.Designer.cs new file mode 100644 index 0000000..80dd39b --- /dev/null +++ b/Form1.Designer.cs @@ -0,0 +1,293 @@ +namespace samusev_42 +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + bindingSource1 = new BindingSource(components); + button1 = new Button(); + categorySource = new BindingSource(components); + dataGridView1 = new DataGridView(); + idProductDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + articleDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + idProductNameDataGridViewTextBoxColumn = new DataGridViewComboBoxColumn(); + product_nameSource = new BindingSource(components); + Column2 = new DataGridViewTextBoxColumn(); + countDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + unitDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + priceDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + idSupplierDataGridViewTextBoxColumn = new DataGridViewComboBoxColumn(); + SupplierSource = new BindingSource(components); + idManufacturerDataGridViewTextBoxColumn = new DataGridViewComboBoxColumn(); + manufacturerSource = new BindingSource(components); + discountDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + idCategoryDataGridViewTextBoxColumn = new DataGridViewComboBoxColumn(); + descriptionDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + photoDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + button2 = new Button(); + buttonDelete = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)categorySource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)product_nameSource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)SupplierSource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)manufacturerSource).BeginInit(); + SuspendLayout(); + // + // bindingSource1 + // + bindingSource1.DataSource = typeof(Product); + // + // button1 + // + button1.BackColor = Color.MistyRose; + button1.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + button1.Location = new Point(128, 810); + button1.Name = "button1"; + button1.Size = new Size(161, 38); + button1.TabIndex = 1; + button1.Text = "Сохранить"; + button1.UseVisualStyleBackColor = false; + button1.Click += button1_Click; + // + // categorySource + // + categorySource.DataSource = typeof(Category); + // + // dataGridView1 + // + dataGridView1.AutoGenerateColumns = false; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Columns.AddRange(new DataGridViewColumn[] { idProductDataGridViewTextBoxColumn, articleDataGridViewTextBoxColumn, idProductNameDataGridViewTextBoxColumn, Column2, countDataGridViewTextBoxColumn, unitDataGridViewTextBoxColumn, priceDataGridViewTextBoxColumn, idSupplierDataGridViewTextBoxColumn, idManufacturerDataGridViewTextBoxColumn, discountDataGridViewTextBoxColumn, idCategoryDataGridViewTextBoxColumn, descriptionDataGridViewTextBoxColumn, photoDataGridViewTextBoxColumn }); + dataGridView1.DataSource = bindingSource1; + dataGridView1.Location = new Point(12, 12); + dataGridView1.Name = "dataGridView1"; + dataGridView1.Size = new Size(1055, 779); + dataGridView1.TabIndex = 2; + // + // idProductDataGridViewTextBoxColumn + // + idProductDataGridViewTextBoxColumn.DataPropertyName = "IdProduct"; + idProductDataGridViewTextBoxColumn.HeaderText = "№ Товара"; + idProductDataGridViewTextBoxColumn.Name = "idProductDataGridViewTextBoxColumn"; + // + // articleDataGridViewTextBoxColumn + // + articleDataGridViewTextBoxColumn.DataPropertyName = "Article"; + articleDataGridViewTextBoxColumn.HeaderText = "Артикул Товара"; + articleDataGridViewTextBoxColumn.Name = "articleDataGridViewTextBoxColumn"; + // + // idProductNameDataGridViewTextBoxColumn + // + idProductNameDataGridViewTextBoxColumn.DataPropertyName = "IdProductName"; + idProductNameDataGridViewTextBoxColumn.DataSource = product_nameSource; + idProductNameDataGridViewTextBoxColumn.DisplayMember = "ProductName1"; + idProductNameDataGridViewTextBoxColumn.HeaderText = "Название"; + idProductNameDataGridViewTextBoxColumn.Name = "idProductNameDataGridViewTextBoxColumn"; + idProductNameDataGridViewTextBoxColumn.Resizable = DataGridViewTriState.True; + idProductNameDataGridViewTextBoxColumn.SortMode = DataGridViewColumnSortMode.Automatic; + idProductNameDataGridViewTextBoxColumn.ValueMember = "IdProductName"; + // + // product_nameSource + // + product_nameSource.DataSource = typeof(ProductName); + // + // Column2 + // + Column2.DataPropertyName = "CountUnit"; + Column2.HeaderText = "Количество"; + Column2.Name = "Column2"; + Column2.ReadOnly = true; + // + // countDataGridViewTextBoxColumn + // + countDataGridViewTextBoxColumn.DataPropertyName = "Count"; + countDataGridViewTextBoxColumn.HeaderText = "Кол-Во"; + countDataGridViewTextBoxColumn.Name = "countDataGridViewTextBoxColumn"; + countDataGridViewTextBoxColumn.Visible = false; + // + // unitDataGridViewTextBoxColumn + // + unitDataGridViewTextBoxColumn.DataPropertyName = "Unit"; + unitDataGridViewTextBoxColumn.HeaderText = "Штук"; + unitDataGridViewTextBoxColumn.Name = "unitDataGridViewTextBoxColumn"; + unitDataGridViewTextBoxColumn.Visible = false; + // + // priceDataGridViewTextBoxColumn + // + priceDataGridViewTextBoxColumn.DataPropertyName = "Price"; + priceDataGridViewTextBoxColumn.HeaderText = "Цена"; + priceDataGridViewTextBoxColumn.Name = "priceDataGridViewTextBoxColumn"; + // + // idSupplierDataGridViewTextBoxColumn + // + idSupplierDataGridViewTextBoxColumn.DataPropertyName = "IdSupplier"; + idSupplierDataGridViewTextBoxColumn.DataSource = SupplierSource; + idSupplierDataGridViewTextBoxColumn.DisplayMember = "SupplierName"; + idSupplierDataGridViewTextBoxColumn.HeaderText = "Поставщик"; + idSupplierDataGridViewTextBoxColumn.Name = "idSupplierDataGridViewTextBoxColumn"; + idSupplierDataGridViewTextBoxColumn.Resizable = DataGridViewTriState.True; + idSupplierDataGridViewTextBoxColumn.SortMode = DataGridViewColumnSortMode.Automatic; + idSupplierDataGridViewTextBoxColumn.ValueMember = "IdSupplier"; + // + // SupplierSource + // + SupplierSource.DataSource = typeof(Supplier); + // + // idManufacturerDataGridViewTextBoxColumn + // + idManufacturerDataGridViewTextBoxColumn.DataPropertyName = "IdManufacturer"; + idManufacturerDataGridViewTextBoxColumn.DataSource = manufacturerSource; + idManufacturerDataGridViewTextBoxColumn.DisplayMember = "ManufacturerName"; + idManufacturerDataGridViewTextBoxColumn.HeaderText = "Производитель"; + idManufacturerDataGridViewTextBoxColumn.Name = "idManufacturerDataGridViewTextBoxColumn"; + idManufacturerDataGridViewTextBoxColumn.Resizable = DataGridViewTriState.True; + idManufacturerDataGridViewTextBoxColumn.SortMode = DataGridViewColumnSortMode.Automatic; + idManufacturerDataGridViewTextBoxColumn.ValueMember = "IdManufacturer"; + // + // manufacturerSource + // + manufacturerSource.DataSource = typeof(Manufacturer); + // + // discountDataGridViewTextBoxColumn + // + discountDataGridViewTextBoxColumn.DataPropertyName = "Discount"; + discountDataGridViewTextBoxColumn.HeaderText = "Скидка (%)"; + discountDataGridViewTextBoxColumn.Name = "discountDataGridViewTextBoxColumn"; + // + // idCategoryDataGridViewTextBoxColumn + // + idCategoryDataGridViewTextBoxColumn.DataPropertyName = "IdCategory"; + idCategoryDataGridViewTextBoxColumn.DataSource = categorySource; + idCategoryDataGridViewTextBoxColumn.DisplayMember = "CategoryName"; + idCategoryDataGridViewTextBoxColumn.HeaderText = "Категория"; + idCategoryDataGridViewTextBoxColumn.Name = "idCategoryDataGridViewTextBoxColumn"; + idCategoryDataGridViewTextBoxColumn.Resizable = DataGridViewTriState.True; + idCategoryDataGridViewTextBoxColumn.SortMode = DataGridViewColumnSortMode.Automatic; + idCategoryDataGridViewTextBoxColumn.ValueMember = "IdCategory"; + // + // descriptionDataGridViewTextBoxColumn + // + descriptionDataGridViewTextBoxColumn.DataPropertyName = "Description"; + descriptionDataGridViewTextBoxColumn.HeaderText = "Описание"; + descriptionDataGridViewTextBoxColumn.Name = "descriptionDataGridViewTextBoxColumn"; + // + // photoDataGridViewTextBoxColumn + // + photoDataGridViewTextBoxColumn.DataPropertyName = "Photo"; + photoDataGridViewTextBoxColumn.HeaderText = "Фото"; + photoDataGridViewTextBoxColumn.Name = "photoDataGridViewTextBoxColumn"; + photoDataGridViewTextBoxColumn.Visible = false; + // + // button2 + // + button2.BackColor = Color.MistyRose; + button2.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + button2.Location = new Point(360, 810); + button2.Name = "button2"; + button2.Size = new Size(149, 38); + button2.TabIndex = 3; + button2.Text = "Редактировать"; + button2.UseVisualStyleBackColor = false; + button2.Click += button2_Click; + // + // buttonDelete + // + buttonDelete.BackColor = Color.MistyRose; + buttonDelete.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + buttonDelete.Location = new Point(588, 810); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(139, 38); + buttonDelete.TabIndex = 5; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = false; + buttonDelete.Click += buttonDelete_Click; + // + // buttonAdd + // + buttonAdd.BackColor = Color.MistyRose; + buttonAdd.DialogResult = DialogResult.OK; + buttonAdd.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + buttonAdd.Location = new Point(807, 810); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(131, 39); + buttonAdd.TabIndex = 6; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = false; + buttonAdd.Click += buttonAdd_Click_1; + // + // Form1 + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.PeachPuff; + ClientSize = new Size(1099, 861); + Controls.Add(buttonAdd); + Controls.Add(buttonDelete); + Controls.Add(button2); + Controls.Add(dataGridView1); + Controls.Add(button1); + Name = "Form1"; + Text = "Самусев ИСП-42 №3,4.5"; + ((System.ComponentModel.ISupportInitialize)bindingSource1).EndInit(); + ((System.ComponentModel.ISupportInitialize)categorySource).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ((System.ComponentModel.ISupportInitialize)product_nameSource).EndInit(); + ((System.ComponentModel.ISupportInitialize)SupplierSource).EndInit(); + ((System.ComponentModel.ISupportInitialize)manufacturerSource).EndInit(); + ResumeLayout(false); + } + + #endregion + + private BindingSource bindingSource1; + private BindingSource categorySource; + private DataGridView dataGridView1; + private BindingSource manufacturerSource; + private BindingSource product_nameSource; + private BindingSource SupplierSource; + private DataGridViewTextBoxColumn idProductDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn articleDataGridViewTextBoxColumn; + private DataGridViewComboBoxColumn idProductNameDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn Column2; + private DataGridViewTextBoxColumn countDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn unitDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn priceDataGridViewTextBoxColumn; + private DataGridViewComboBoxColumn idSupplierDataGridViewTextBoxColumn; + private DataGridViewComboBoxColumn idManufacturerDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn discountDataGridViewTextBoxColumn; + private DataGridViewComboBoxColumn idCategoryDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn descriptionDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn photoDataGridViewTextBoxColumn; + public Button button2; + public Button button1; + private Button buttonDelete; + public Button buttonAdd; + } +} diff --git a/Form1.cs b/Form1.cs new file mode 100644 index 0000000..f568e34 --- /dev/null +++ b/Form1.cs @@ -0,0 +1,124 @@ +using Microsoft.EntityFrameworkCore; +namespace samusev_42 +{ + public partial class Form1 : Form + { + Ispr2522SamusevOvLazarev2Context context; + public Form1() + { + InitializeComponent(); + /// - 0 + dataGridView1.AllowUserToAddRows = false; + + dataGridView1.DataError += (s, e) => { + MessageBox.Show(" ! , .", + " ", MessageBoxButtons.OK, MessageBoxIcon.Warning); + e.ThrowException = false; + }; + + dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically; + } + + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + context = new Ispr2522SamusevOvLazarev2Context(); + context.Products.Include(x => x.IdCategoryNavigation).Load(); + context.Products.Include(x => x.IdManufacturerNavigation).Load(); + context.Products.Include(x => x.IdProductNameNavigation).Load(); + context.Products.Include(x => x.IdSupplierNavigation).Load(); + context.Categories.Load(); + context.Manufacturers.Load(); + context.Database.EnsureCreated(); + bindingSource1.DataSource = context.Products.Local.ToBindingList(); + categorySource.DataSource = context.Categories.Local.ToBindingList(); + manufacturerSource.DataSource = context.Manufacturers.Local.ToBindingList(); + product_nameSource.DataSource = context.ProductNames.Local.ToBindingList(); + SupplierSource.DataSource = context.Suppliers.Local.ToBindingList(); + } + + private void button1_Click(object sender, EventArgs e) + { + context.SaveChanges(); + dataGridView1.Refresh(); + } + + private void button2_Click(object sender, EventArgs e) + { + if (bindingSource1.Current == null) return; + var form = new EditForm(); + form.categoryBindingSource.DataSource = categorySource.DataSource; + form.manufacturerBindingSource.DataSource = manufacturerSource.DataSource; + form.productNameBindingSource.DataSource = product_nameSource.DataSource; + form.supplierBindingSource.DataSource = SupplierSource.DataSource; + form.productBindingSource.DataSource = bindingSource1.Current; + if (form.ShowDialog() == DialogResult.OK) + { + bindingSource1.EndEdit(); + context.SaveChanges(); + dataGridView1.Refresh(); + } + } + + private void SaveEditButton_Click(object sender, EventArgs e) + { + context.SaveChanges(); + dataGridView1.Refresh(); + } + + private void buttonDelete_Click(object sender, EventArgs e) + { + bindingSource1.RemoveCurrent(); + context.SaveChanges(); + dataGridView1.Refresh(); + } + /// + null + private void buttonAdd_Click_1(object sender, EventArgs e) + { + var newProduct = new Product(); + newProduct.Article = ""; + newProduct.Unit = "."; + newProduct.Description = "-"; + newProduct.Photo = ""; + newProduct.Price = 0; + newProduct.Count = 0; + newProduct.Discount = 0; + + var form = new EditForm(); + form.categoryBindingSource.DataSource = categorySource; + form.manufacturerBindingSource.DataSource = manufacturerSource; + form.productNameBindingSource.DataSource = product_nameSource; + form.supplierBindingSource.DataSource = SupplierSource; + form.productBindingSource.DataSource = newProduct; + if (form.ShowDialog() == DialogResult.OK) + { + try + { + if (newProduct.IdProductName <= 0) + throw new System.ComponentModel.DataAnnotations.ValidationException(" !"); + if (string.IsNullOrWhiteSpace(newProduct.Article)) + throw new System.ComponentModel.DataAnnotations.ValidationException(" !"); + if (newProduct.Price < 0) + throw new System.ComponentModel.DataAnnotations.ValidationException(" !"); + + context.Products.Add(newProduct); + context.SaveChanges(); + bindingSource1.DataSource = context.Products.Local.ToBindingList(); + dataGridView1.Refresh(); + MessageBox.Show(" !"); + } + catch (System.ComponentModel.DataAnnotations.ValidationException valEx) + { + MessageBox.Show(valEx.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + catch (Exception ex) + { + string inner = ex.InnerException?.Message ?? ex.Message; + MessageBox.Show($" : {inner}"); + context.Entry(newProduct).State = EntityState.Detached; + } + } + } + } +} \ No newline at end of file diff --git a/Form1.resx b/Form1.resx new file mode 100644 index 0000000..3121a37 --- /dev/null +++ b/Form1.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 154, 17 + + + 452, 17 + + + True + + + 619, 17 + + + 290, 17 + + + 94 + + \ No newline at end of file diff --git a/Ispr2522SamusevOvLazarev2Context.cs b/Ispr2522SamusevOvLazarev2Context.cs new file mode 100644 index 0000000..fa659c8 --- /dev/null +++ b/Ispr2522SamusevOvLazarev2Context.cs @@ -0,0 +1,311 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; +using Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal; + +namespace samusev_42; + +public partial class Ispr2522SamusevOvLazarev2Context : DbContext +{ + public Ispr2522SamusevOvLazarev2Context() + { + } + + public Ispr2522SamusevOvLazarev2Context(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet Categories { get; set; } + + public virtual DbSet Deliveries { get; set; } + + public virtual DbSet Manufacturers { get; set; } + + public virtual DbSet Names { get; set; } + + public virtual DbSet OrdersProducts { get; set; } + + public virtual DbSet PickUpPoints { get; set; } + + public virtual DbSet Products { get; set; } + + public virtual DbSet ProductNames { get; set; } + + public virtual DbSet Roles { get; set; } + + public virtual DbSet Statuses { get; set; } + + public virtual DbSet Suppliers { get; set; } + + public virtual DbSet Users { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) +#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263. + => optionsBuilder.UseMySql("server=cfif31.ru;username=ISPr25-22_SamusevOV;password=ISPr25-22_SamusevOV;database=ISPr25-22_SamusevOV_Lazarev2", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.0.45-mysql")); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder + .UseCollation("utf8mb4_0900_ai_ci") + .HasCharSet("utf8mb4"); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdCategory).HasName("PRIMARY"); + + entity.ToTable("category"); + + entity.Property(e => e.IdCategory).HasColumnName("id_category"); + entity.Property(e => e.CategoryName) + .HasMaxLength(45) + .HasColumnName("category_name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdDelivery).HasName("PRIMARY"); + + entity.ToTable("delivery"); + + entity.HasIndex(e => e.IdPickUpPoint, "fk_delivery_pick-up point_idx"); + + entity.HasIndex(e => e.IdStatus, "fk_delivery_status_idx"); + + entity.HasIndex(e => e.IdUser, "fk_delivery_user_idx"); + + entity.Property(e => e.IdDelivery).HasColumnName("id_delivery"); + entity.Property(e => e.Code).HasColumnName("code"); + entity.Property(e => e.DateDelivery) + .HasColumnType("datetime") + .HasColumnName("date_delivery"); + entity.Property(e => e.DateOrder) + .HasColumnType("datetime") + .HasColumnName("date_order"); + entity.Property(e => e.IdPickUpPoint).HasColumnName("id_pick-up point"); + entity.Property(e => e.IdStatus).HasColumnName("id_status"); + entity.Property(e => e.IdUser).HasColumnName("id_user"); + + entity.HasOne(d => d.IdPickUpPointNavigation).WithMany(p => p.Deliveries) + .HasForeignKey(d => d.IdPickUpPoint) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_delivery_pick-up point"); + + entity.HasOne(d => d.IdStatusNavigation).WithMany(p => p.Deliveries) + .HasForeignKey(d => d.IdStatus) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_delivery_status"); + + entity.HasOne(d => d.IdUserNavigation).WithMany(p => p.Deliveries) + .HasForeignKey(d => d.IdUser) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_delivery_user"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdManufacturer).HasName("PRIMARY"); + + entity.ToTable("manufacturer"); + + entity.Property(e => e.IdManufacturer).HasColumnName("id_manufacturer"); + entity.Property(e => e.ManufacturerName) + .HasMaxLength(45) + .HasColumnName("manufacturer_name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdName).HasName("PRIMARY"); + + entity.ToTable("name"); + + entity.HasIndex(e => e.IdUser, "id_name_user_idx"); + + entity.Property(e => e.IdName).HasColumnName("id_name"); + entity.Property(e => e.IdUser).HasColumnName("id_user"); + entity.Property(e => e.NameFio) + .HasMaxLength(45) + .HasColumnName("name_fio"); + + entity.HasOne(d => d.IdUserNavigation).WithMany(p => p.Names) + .HasForeignKey(d => d.IdUser) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("id_name_user"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdOrdersProducts).HasName("PRIMARY"); + + entity.ToTable("orders_products"); + + entity.HasIndex(e => e.IdDelivery, "fk_order_products_delivery_idx"); + + entity.HasIndex(e => e.IdProduct, "fk_order_products_product_idx"); + + entity.Property(e => e.IdOrdersProducts).HasColumnName("id_orders_products"); + entity.Property(e => e.Count).HasColumnName("count"); + entity.Property(e => e.IdDelivery).HasColumnName("id_delivery"); + entity.Property(e => e.IdProduct).HasColumnName("id_product"); + + entity.HasOne(d => d.IdDeliveryNavigation).WithMany(p => p.OrdersProducts) + .HasForeignKey(d => d.IdDelivery) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_order_products_delivery"); + + entity.HasOne(d => d.IdProductNavigation).WithMany(p => p.OrdersProducts) + .HasForeignKey(d => d.IdProduct) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_order_products_product"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdPickUpPoint).HasName("PRIMARY"); + + entity.ToTable("pick-up point"); + + entity.Property(e => e.IdPickUpPoint).HasColumnName("id_pick-up point"); + entity.Property(e => e.Adress) + .HasMaxLength(45) + .HasColumnName("adress"); + entity.Property(e => e.Index) + .HasMaxLength(45) + .HasColumnName("index"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdProduct).HasName("PRIMARY"); + + entity.ToTable("product"); + + entity.HasIndex(e => e.IdCategory, "fk_product_category_idx"); + + entity.HasIndex(e => e.IdManufacturer, "fk_product_manufacturer_idx"); + + entity.HasIndex(e => e.IdProductName, "fk_product_product_name_idx"); + + entity.HasIndex(e => e.IdSupplier, "fk_product_supplier_idx"); + + entity.Property(e => e.IdProduct).HasColumnName("id_product"); + entity.Property(e => e.Article) + .HasMaxLength(45) + .HasColumnName("article"); + entity.Property(e => e.Count).HasColumnName("count"); + entity.Property(e => e.Description) + .HasColumnType("text") + .HasColumnName("description"); + entity.Property(e => e.Discount).HasColumnName("discount"); + entity.Property(e => e.IdCategory).HasColumnName("id_category"); + entity.Property(e => e.IdManufacturer).HasColumnName("id_manufacturer"); + entity.Property(e => e.IdProductName).HasColumnName("id_product name"); + entity.Property(e => e.IdSupplier).HasColumnName("id_supplier"); + entity.Property(e => e.Photo) + .HasMaxLength(45) + .HasColumnName("photo"); + entity.Property(e => e.Price) + .HasPrecision(5) + .HasColumnName("price"); + entity.Property(e => e.Unit) + .HasMaxLength(45) + .HasColumnName("unit"); + + entity.HasOne(d => d.IdCategoryNavigation).WithMany(p => p.Products) + .HasForeignKey(d => d.IdCategory) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_product_category"); + + entity.HasOne(d => d.IdManufacturerNavigation).WithMany(p => p.Products) + .HasForeignKey(d => d.IdManufacturer) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_product_manufacturer"); + + entity.HasOne(d => d.IdProductNameNavigation).WithMany(p => p.Products) + .HasForeignKey(d => d.IdProductName) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_product_product_name"); + + entity.HasOne(d => d.IdSupplierNavigation).WithMany(p => p.Products) + .HasForeignKey(d => d.IdSupplier) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_product_supplier"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdProductName).HasName("PRIMARY"); + + entity.ToTable("product name"); + + entity.Property(e => e.IdProductName).HasColumnName("id_product name"); + entity.Property(e => e.ProductName1) + .HasMaxLength(45) + .HasColumnName("product name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdRole).HasName("PRIMARY"); + + entity.ToTable("role"); + + entity.Property(e => e.IdRole).HasColumnName("id_role"); + entity.Property(e => e.RoleName) + .HasMaxLength(45) + .HasColumnName("role_name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdStatus).HasName("PRIMARY"); + + entity.ToTable("status"); + + entity.Property(e => e.IdStatus).HasColumnName("id_status"); + entity.Property(e => e.StatusName) + .HasMaxLength(45) + .HasColumnName("status_name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdSupplier).HasName("PRIMARY"); + + entity.ToTable("supplier"); + + entity.Property(e => e.IdSupplier).HasColumnName("id_supplier"); + entity.Property(e => e.SupplierName) + .HasMaxLength(45) + .HasColumnName("supplier_name"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.IdUser).HasName("PRIMARY"); + + entity.ToTable("user"); + + entity.HasIndex(e => e.IdRole, "fk_user_role_idx"); + + entity.Property(e => e.IdUser).HasColumnName("id_user"); + entity.Property(e => e.IdRole).HasColumnName("id_role"); + entity.Property(e => e.Login) + .HasMaxLength(45) + .HasColumnName("login"); + entity.Property(e => e.Password) + .HasMaxLength(45) + .HasColumnName("password"); + + entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.Users) + .HasForeignKey(d => d.IdRole) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_user_role"); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/MainCardForm.Designer.cs b/MainCardForm.Designer.cs new file mode 100644 index 0000000..5175a2e --- /dev/null +++ b/MainCardForm.Designer.cs @@ -0,0 +1,161 @@ +namespace samusev_42 +{ + partial class MainCardForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + flowLayoutPanel1 = new FlowLayoutPanel(); + SaveCardButton = new Button(); + CardEditButton = new Button(); + CardDeleteButton = new Button(); + CardAddButton = new Button(); + productBindingSource = new BindingSource(components); + categorySource = new BindingSource(components); + manufacturerSource = new BindingSource(components); + product_nameSource = new BindingSource(components); + SupplierSource = new BindingSource(components); + ((System.ComponentModel.ISupportInitialize)productBindingSource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)categorySource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)manufacturerSource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)product_nameSource).BeginInit(); + ((System.ComponentModel.ISupportInitialize)SupplierSource).BeginInit(); + SuspendLayout(); + // + // flowLayoutPanel1 + // + flowLayoutPanel1.AutoScroll = true; + flowLayoutPanel1.FlowDirection = FlowDirection.TopDown; + flowLayoutPanel1.Location = new Point(33, 106); + flowLayoutPanel1.Name = "flowLayoutPanel1"; + flowLayoutPanel1.Size = new Size(726, 608); + flowLayoutPanel1.TabIndex = 0; + flowLayoutPanel1.WrapContents = false; + // + // SaveCardButton + // + SaveCardButton.BackColor = Color.Cornsilk; + SaveCardButton.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + SaveCardButton.Location = new Point(69, 25); + SaveCardButton.Name = "SaveCardButton"; + SaveCardButton.Size = new Size(114, 36); + SaveCardButton.TabIndex = 1; + SaveCardButton.Text = "Сохранить"; + SaveCardButton.UseVisualStyleBackColor = false; + SaveCardButton.Click += SaveCardButton_Click; + // + // CardEditButton + // + CardEditButton.BackColor = Color.Cornsilk; + CardEditButton.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + CardEditButton.Location = new Point(242, 25); + CardEditButton.Name = "CardEditButton"; + CardEditButton.Size = new Size(143, 36); + CardEditButton.TabIndex = 2; + CardEditButton.Text = "Редактировать"; + CardEditButton.UseVisualStyleBackColor = false; + CardEditButton.Click += CardEditButton_Click_1; + // + // CardDeleteButton + // + CardDeleteButton.BackColor = Color.Cornsilk; + CardDeleteButton.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + CardDeleteButton.Location = new Point(437, 25); + CardDeleteButton.Name = "CardDeleteButton"; + CardDeleteButton.Size = new Size(119, 36); + CardDeleteButton.TabIndex = 3; + CardDeleteButton.Text = "Удалить"; + CardDeleteButton.UseVisualStyleBackColor = false; + CardDeleteButton.Click += CardDeleteButton_Click_1; + // + // CardAddButton + // + CardAddButton.BackColor = Color.Cornsilk; + CardAddButton.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + CardAddButton.Location = new Point(603, 25); + CardAddButton.Name = "CardAddButton"; + CardAddButton.Size = new Size(123, 36); + CardAddButton.TabIndex = 4; + CardAddButton.Text = "Добавить"; + CardAddButton.UseVisualStyleBackColor = false; + CardAddButton.Click += CardAddButton_Click_1; + // + // productBindingSource + // + productBindingSource.DataSource = typeof(Product); + // + // categorySource + // + categorySource.DataSource = typeof(Category); + // + // manufacturerSource + // + manufacturerSource.DataSource = typeof(Manufacturer); + // + // product_nameSource + // + product_nameSource.DataSource = typeof(ProductName); + // + // SupplierSource + // + SupplierSource.DataSource = typeof(Supplier); + // + // MainCardForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.MistyRose; + ClientSize = new Size(800, 748); + Controls.Add(CardAddButton); + Controls.Add(CardDeleteButton); + Controls.Add(CardEditButton); + Controls.Add(SaveCardButton); + Controls.Add(flowLayoutPanel1); + Name = "MainCardForm"; + Text = "Форма-Карточка"; + ((System.ComponentModel.ISupportInitialize)productBindingSource).EndInit(); + ((System.ComponentModel.ISupportInitialize)categorySource).EndInit(); + ((System.ComponentModel.ISupportInitialize)manufacturerSource).EndInit(); + ((System.ComponentModel.ISupportInitialize)product_nameSource).EndInit(); + ((System.ComponentModel.ISupportInitialize)SupplierSource).EndInit(); + ResumeLayout(false); + } + + #endregion + + private FlowLayoutPanel flowLayoutPanel1; + public BindingSource productBindingSource; + public Button SaveCardButton; + public Button CardEditButton; + public Button CardDeleteButton; + public Button CardAddButton; + public BindingSource categorySource; + public BindingSource manufacturerSource; + public BindingSource product_nameSource; + public BindingSource SupplierSource; + } +} \ No newline at end of file diff --git a/MainCardForm.cs b/MainCardForm.cs new file mode 100644 index 0000000..04034ba --- /dev/null +++ b/MainCardForm.cs @@ -0,0 +1,131 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Windows.Forms; + +namespace samusev_42 +{ + public partial class MainCardForm : Form + { + Ispr2522SamusevOvLazarev2Context context; + + public MainCardForm() + { + InitializeComponent(); + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + context = new Ispr2522SamusevOvLazarev2Context(); + + context.Products.Include(x => x.IdCategoryNavigation).Load(); + context.Products.Include(x => x.IdManufacturerNavigation).Load(); + context.Products.Include(x => x.IdProductNameNavigation).Load(); + context.Products.Include(x => x.IdSupplierNavigation).Load(); + context.Categories.Load(); + context.Manufacturers.Load(); + context.ProductNames.Load(); + context.Suppliers.Load(); + + productBindingSource.DataSource = context.Products.Local.ToBindingList(); + categorySource.DataSource = context.Categories.Local.ToBindingList(); + manufacturerSource.DataSource = context.Manufacturers.Local.ToBindingList(); + product_nameSource.DataSource = context.ProductNames.Local.ToBindingList(); + SupplierSource.DataSource = context.Suppliers.Local.ToBindingList(); + + Populate(); + } + + public void Populate() + { + flowLayoutPanel1.Controls.Clear(); + foreach (var item in productBindingSource) + { + if (item is Product p) + { + CardForm card = new CardForm(p); + card.Click += (s, ev) => { productBindingSource.Position = productBindingSource.IndexOf(p); }; + flowLayoutPanel1.Controls.Add(card); + } + } + } + + + private void SaveCardButton_Click(object sender, EventArgs e) + { + + } + + private void CardEditButton_Click_1(object sender, EventArgs e) + { + if (productBindingSource.Current == null) return; + + var form = new EditForm(); + form.categoryBindingSource.DataSource = categorySource.DataSource; + form.manufacturerBindingSource.DataSource = manufacturerSource.DataSource; + form.productNameBindingSource.DataSource = product_nameSource.DataSource; + form.supplierBindingSource.DataSource = SupplierSource.DataSource; + form.productBindingSource.DataSource = productBindingSource.Current; + + if (form.ShowDialog() == DialogResult.OK) + { + productBindingSource.EndEdit(); + context.SaveChanges(); + Populate(); + } + } + + private void CardDeleteButton_Click_1(object sender, EventArgs e) + { + if (productBindingSource.Current == null) return; + + var result = MessageBox.Show("Удалить этот товар?", "Подтверждение", MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + productBindingSource.RemoveCurrent(); + context.SaveChanges(); + Populate(); + } + } + + private void CardAddButton_Click_1(object sender, EventArgs e) + { + var newProduct = new Product(); + newProduct.Article = ""; + newProduct.Unit = "шт."; + newProduct.Description = "-"; + newProduct.Photo = ""; + newProduct.Price = 0; + newProduct.Count = 0; + newProduct.Discount = 0; + + var form = new EditForm(); + form.categoryBindingSource.DataSource = categorySource; + form.manufacturerBindingSource.DataSource = manufacturerSource; + form.productNameBindingSource.DataSource = product_nameSource; + form.supplierBindingSource.DataSource = SupplierSource; + form.productBindingSource.DataSource = newProduct; + + if (form.ShowDialog() == DialogResult.OK) + { + try + { + if (newProduct.IdProductName <= 0) + throw new System.ComponentModel.DataAnnotations.ValidationException("Выберите название товара!"); + + context.Products.Add(newProduct); + context.SaveChanges(); + + Populate(); + MessageBox.Show("Товар добавлен!"); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + context.Entry(newProduct).State = EntityState.Detached; + } + } + } + } +} \ No newline at end of file diff --git a/MainCardForm.resx b/MainCardForm.resx new file mode 100644 index 0000000..55564d7 --- /dev/null +++ b/MainCardForm.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 190, 17 + + + 315, 20 + + + 459, 18 + + + 618, 17 + + \ No newline at end of file diff --git a/Manufacturer.cs b/Manufacturer.cs new file mode 100644 index 0000000..8334022 --- /dev/null +++ b/Manufacturer.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class Manufacturer +{ + public int IdManufacturer { get; set; } + + public string ManufacturerName { get; set; } = null!; + + public virtual ICollection Products { get; set; } = new List(); +} diff --git a/Name.cs b/Name.cs new file mode 100644 index 0000000..f052c87 --- /dev/null +++ b/Name.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class Name +{ + public int IdName { get; set; } + + public string NameFio { get; set; } = null!; + + public int IdUser { get; set; } + + public virtual User IdUserNavigation { get; set; } = null!; +} diff --git a/OrdersProduct.cs b/OrdersProduct.cs new file mode 100644 index 0000000..74fb81f --- /dev/null +++ b/OrdersProduct.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class OrdersProduct +{ + public int IdOrdersProducts { get; set; } + + public int IdDelivery { get; set; } + + public int IdProduct { get; set; } + + public int Count { get; set; } + + public virtual Delivery IdDeliveryNavigation { get; set; } = null!; + + public virtual Product IdProductNavigation { get; set; } = null!; +} diff --git a/PickUpPoint.cs b/PickUpPoint.cs new file mode 100644 index 0000000..68cd9b9 --- /dev/null +++ b/PickUpPoint.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class PickUpPoint +{ + public int IdPickUpPoint { get; set; } + + public string? Adress { get; set; } + + public string Index { get; set; } = null!; + + public virtual ICollection Deliveries { get; set; } = new List(); +} diff --git a/Product.cs b/Product.cs new file mode 100644 index 0000000..e0ef771 --- /dev/null +++ b/Product.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace samusev_42; + +public partial class Product : IEditableObject +{ + private Ispr2522SamusevOvLazarev2Context context; + + public int IdProduct { get; set; } + public string Article { get; set; } = null!; + public int IdProductName { get; set; } + public string Unit { get; set; } = null!; + public decimal Price { get; set; } + public int IdSupplier { get; set; } + public int IdManufacturer { get; set; } + public int IdCategory { get; set; } + public int Discount { get; set; } + public int Count { get; set; } + public string Description { get; set; } = null!; + public string Photo { get; set; } = null!; + + public virtual Category IdCategoryNavigation { get; set; } = null!; + public virtual Manufacturer IdManufacturerNavigation { get; set; } = null!; + public virtual ProductName IdProductNameNavigation { get; set; } = null!; + public virtual Supplier IdSupplierNavigation { get; set; } = null!; + public virtual ICollection OrdersProducts { get; set; } = new List(); + + // Реализация валидации IEditableObject + + public void BeginEdit() + { + if (context == null) + { + context = new Ispr2522SamusevOvLazarev2Context(); + context.Products.Attach(this); + } + } + + public void CancelEdit() + { + if (context != null) + { + var entry = context.Entry(this); + if (entry.State == EntityState.Modified) + { + entry.Reload(); + } + } + } + + public void EndEdit() + { + // ВАЛИДАЦИЯ + if (string.IsNullOrWhiteSpace(this.Article)) + { + throw new ValidationException("Артикул не может быть пустым!"); + } + + if (this.Price < 0) + { + throw new ValidationException("Цена не может быть отрицательной!"); + } + + if (context != null) + { + context.SaveChanges(); + } + } +} \ No newline at end of file diff --git a/ProductName.cs b/ProductName.cs new file mode 100644 index 0000000..3844008 --- /dev/null +++ b/ProductName.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class ProductName +{ + public int IdProductName { get; set; } + + public string ProductName1 { get; set; } = null!; + + public virtual ICollection Products { get; set; } = new List(); +} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..3462965 --- /dev/null +++ b/Program.cs @@ -0,0 +1,17 @@ +namespace samusev_42 +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new MainCardForm()); + } + } +} \ No newline at end of file diff --git a/Properties/DataSources/Category.datasource b/Properties/DataSources/Category.datasource new file mode 100644 index 0000000..e6bef85 --- /dev/null +++ b/Properties/DataSources/Category.datasource @@ -0,0 +1,10 @@ + + + + samusev_42.Category, samusev-42, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Properties/DataSources/Manufacturer.datasource b/Properties/DataSources/Manufacturer.datasource new file mode 100644 index 0000000..60e1580 --- /dev/null +++ b/Properties/DataSources/Manufacturer.datasource @@ -0,0 +1,10 @@ + + + + samusev_42.Manufacturer, samusev-42, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Properties/DataSources/OrdersProduct.datasource b/Properties/DataSources/OrdersProduct.datasource new file mode 100644 index 0000000..d723727 --- /dev/null +++ b/Properties/DataSources/OrdersProduct.datasource @@ -0,0 +1,10 @@ + + + + samusev_42.OrdersProduct, samusev-42, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Properties/DataSources/Product.datasource b/Properties/DataSources/Product.datasource new file mode 100644 index 0000000..dec72e8 --- /dev/null +++ b/Properties/DataSources/Product.datasource @@ -0,0 +1,10 @@ + + + + samusev_42.Product, samusev-42, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Properties/DataSources/ProductName.datasource b/Properties/DataSources/ProductName.datasource new file mode 100644 index 0000000..28dcbfc --- /dev/null +++ b/Properties/DataSources/ProductName.datasource @@ -0,0 +1,10 @@ + + + + samusev_42.ProductName, samusev-42, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Properties/DataSources/Supplier.datasource b/Properties/DataSources/Supplier.datasource new file mode 100644 index 0000000..05a6e82 --- /dev/null +++ b/Properties/DataSources/Supplier.datasource @@ -0,0 +1,10 @@ + + + + samusev_42.Supplier, samusev-42, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..eb57fc9 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace samusev_42.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("samusev_42.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Role.cs b/Role.cs new file mode 100644 index 0000000..c9a9cec --- /dev/null +++ b/Role.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class Role +{ + public int IdRole { get; set; } + + public string RoleName { get; set; } = null!; + + public virtual ICollection Users { get; set; } = new List(); +} diff --git a/Status.cs b/Status.cs new file mode 100644 index 0000000..8dbdaee --- /dev/null +++ b/Status.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class Status +{ + public int IdStatus { get; set; } + + public string StatusName { get; set; } = null!; + + public virtual ICollection Deliveries { get; set; } = new List(); +} diff --git a/Supplier.cs b/Supplier.cs new file mode 100644 index 0000000..fdb4065 --- /dev/null +++ b/Supplier.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class Supplier +{ + public int IdSupplier { get; set; } + + public string SupplierName { get; set; } = null!; + + public virtual ICollection Products { get; set; } = new List(); +} diff --git a/User.cs b/User.cs new file mode 100644 index 0000000..0123542 --- /dev/null +++ b/User.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace samusev_42; + +public partial class User +{ + public int IdUser { get; set; } + + public string Login { get; set; } = null!; + + public string Password { get; set; } = null!; + + public int IdRole { get; set; } + + public virtual ICollection Deliveries { get; set; } = new List(); + + public virtual Role IdRoleNavigation { get; set; } = null!; + + public virtual ICollection Names { get; set; } = new List(); +} diff --git a/samusev-42.csproj b/samusev-42.csproj new file mode 100644 index 0000000..da0c437 --- /dev/null +++ b/samusev-42.csproj @@ -0,0 +1,39 @@ + + + + WinExe + net8.0-windows + samusev_42 + enable + true + enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/samusev-42.sln b/samusev-42.sln new file mode 100644 index 0000000..2b34a07 --- /dev/null +++ b/samusev-42.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35931.197 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "samusev-42", "samusev-42.csproj", "{ED29084E-1A2F-43BE-ADD8-A4AE71F92783}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ED29084E-1A2F-43BE-ADD8-A4AE71F92783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED29084E-1A2F-43BE-ADD8-A4AE71F92783}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED29084E-1A2F-43BE-ADD8-A4AE71F92783}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED29084E-1A2F-43BE-ADD8-A4AE71F92783}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2743F97A-92F1-4906-80DB-89C4A8873133} + EndGlobalSection +EndGlobal