Готовая ЛР
This commit is contained in:
parent
526bd53521
commit
2f1dbeee40
@ -58,6 +58,16 @@ namespace BeautySaloonBusinessLogic
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ReportViewModel>? ReadMostPopular()
|
||||||
|
{
|
||||||
|
var list = _serviceStorage.ReadMostPopular();
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Update(ServiceBindingModel model)
|
public bool Update(ServiceBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
|
@ -15,5 +15,7 @@ namespace BeautySaloonContracts.BusinessLogicsContracts
|
|||||||
bool Update(ServiceBindingModel model);
|
bool Update(ServiceBindingModel model);
|
||||||
|
|
||||||
bool Delete(ServiceBindingModel model);
|
bool Delete(ServiceBindingModel model);
|
||||||
|
|
||||||
|
List<ReportViewModel>? ReadMostPopular();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ namespace BeautySaloonContracts.StoragesContracts
|
|||||||
public interface IServiceStorage
|
public interface IServiceStorage
|
||||||
{
|
{
|
||||||
List<ServiceViewModel> GetFullList();
|
List<ServiceViewModel> GetFullList();
|
||||||
|
List<ReportViewModel> ReadMostPopular();
|
||||||
List<ServiceViewModel> GetFilteredList(ServiceSearchModel model);
|
List<ServiceViewModel> GetFilteredList(ServiceSearchModel model);
|
||||||
ServiceViewModel? GetElement(ServiceSearchModel model);
|
ServiceViewModel? GetElement(ServiceSearchModel model);
|
||||||
ServiceViewModel? Insert(ServiceBindingModel model);
|
ServiceViewModel? Insert(ServiceBindingModel model);
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace BeautySaloonContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportViewModel
|
||||||
|
{
|
||||||
|
[DisplayName("Услуга")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
//[DisplayName("Кол-во")]
|
||||||
|
//public decimal Count { get; set; }
|
||||||
|
[DisplayName("Сумма")]
|
||||||
|
public decimal Sum { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -49,21 +49,21 @@ namespace BeautySaloonDatabaseImplement.Implements
|
|||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Where(x => x.ClientId == model.ClientId)
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList().OrderByDescending(x => x.Date).ToList();
|
||||||
if (model.EmployeeId.HasValue)
|
if (model.EmployeeId.HasValue)
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Employee)
|
.Include(x => x.Employee)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Where(x => x.EmployeeId == model.EmployeeId)
|
.Where(x => x.EmployeeId == model.EmployeeId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList().OrderByDescending(x => x.Date).ToList();
|
||||||
if (model.Date.HasValue)
|
if (model.Date.HasValue)
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Employee)
|
.Include(x => x.Employee)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Where(x => x.Date == model.Date)
|
.Where(x => x.Date == model.Date)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList().OrderByDescending(x => x.Date).ToList();
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ namespace BeautySaloonDatabaseImplement.Implements
|
|||||||
.Include(x => x.Employee)
|
.Include(x => x.Employee)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList().OrderByDescending(x => x.Date).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
using BeautySaloonContracts.SearchModels;
|
using BeautySaloonContracts.SearchModels;
|
||||||
using BeautySaloonContracts.StoragesContracts;
|
using BeautySaloonContracts.StoragesContracts;
|
||||||
using BeautySaloonContracts.ViewModels;
|
using BeautySaloonContracts.ViewModels;
|
||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace BeautySaloonDatabaseImplement.Implements
|
namespace BeautySaloonDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
@ -71,6 +74,25 @@ namespace BeautySaloonDatabaseImplement.Implements
|
|||||||
return newService.GetViewModel;
|
return newService.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ReportViewModel> ReadMostPopular()
|
||||||
|
{
|
||||||
|
using var context = new NewdbContext();
|
||||||
|
/*var temp = context.Services
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();*/
|
||||||
|
return context.ServiceOrders
|
||||||
|
.Include(x => x.Service)
|
||||||
|
.GroupBy(x => x.Service.Name)
|
||||||
|
.Select(x => new ReportViewModel()
|
||||||
|
{
|
||||||
|
Name = x.Key,
|
||||||
|
Sum = x.Sum(x => x.Service.Price)
|
||||||
|
})
|
||||||
|
.OrderByDescending(x => x.Sum)
|
||||||
|
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public ServiceViewModel? Update(ServiceBindingModel model)
|
public ServiceViewModel? Update(ServiceBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new NewdbContext();
|
using var context = new NewdbContext();
|
||||||
|
@ -27,7 +27,7 @@ public partial class NewdbContext : DbContext
|
|||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
|
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
|
||||||
=> optionsBuilder.UseNpgsql("Host=192.168.0.103;Port=5432;Database=newdb;Username=username123;Password=12345");
|
=> optionsBuilder.UseNpgsql("Host=192.168.56.102;Port=5432;Database=newdb;Username=username123;Password=12345");
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
22
BeautySaloon/BeautySaloonView/FormMain.Designer.cs
generated
22
BeautySaloon/BeautySaloonView/FormMain.Designer.cs
generated
@ -37,6 +37,8 @@
|
|||||||
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||||
this.buttonTest = new System.Windows.Forms.Button();
|
this.buttonTest = new System.Windows.Forms.Button();
|
||||||
|
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.услугиToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -56,7 +58,8 @@
|
|||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.справочникиToolStripMenuItem});
|
this.справочникиToolStripMenuItem,
|
||||||
|
this.отчетыToolStripMenuItem});
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(1037, 24);
|
this.menuStrip1.Size = new System.Drawing.Size(1037, 24);
|
||||||
@ -124,6 +127,21 @@
|
|||||||
this.buttonTest.UseVisualStyleBackColor = true;
|
this.buttonTest.UseVisualStyleBackColor = true;
|
||||||
this.buttonTest.Click += new System.EventHandler(this.ButtonTest_Click);
|
this.buttonTest.Click += new System.EventHandler(this.ButtonTest_Click);
|
||||||
//
|
//
|
||||||
|
// отчетыToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.услугиToolStripMenuItem1});
|
||||||
|
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
|
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
|
||||||
|
this.отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
|
//
|
||||||
|
// услугиToolStripMenuItem1
|
||||||
|
//
|
||||||
|
this.услугиToolStripMenuItem1.Name = "услугиToolStripMenuItem1";
|
||||||
|
this.услугиToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.услугиToolStripMenuItem1.Text = "Услуги";
|
||||||
|
this.услугиToolStripMenuItem1.Click += new System.EventHandler(this.ReportServicesToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
@ -157,5 +175,7 @@
|
|||||||
private Button buttonUpdate;
|
private Button buttonUpdate;
|
||||||
private Button buttonCreateOrder;
|
private Button buttonCreateOrder;
|
||||||
private Button buttonTest;
|
private Button buttonTest;
|
||||||
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem услугиToolStripMenuItem1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -81,5 +81,14 @@ namespace BeautySaloonView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ReportServicesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportServices));
|
||||||
|
if (service is FormReportServices form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
66
BeautySaloon/BeautySaloonView/FormReportServices.Designer.cs
generated
Normal file
66
BeautySaloon/BeautySaloonView/FormReportServices.Designer.cs
generated
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
namespace BeautySaloonView
|
||||||
|
{
|
||||||
|
partial class FormReportServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.dataGridView.GridColor = System.Drawing.Color.White;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(800, 450);
|
||||||
|
this.dataGridView.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// FormReportServices
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormReportServices";
|
||||||
|
this.Text = "Отчет по услугам";
|
||||||
|
this.Load += new System.EventHandler(this.FormReportServices_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
36
BeautySaloon/BeautySaloonView/FormReportServices.cs
Normal file
36
BeautySaloon/BeautySaloonView/FormReportServices.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using BeautySaloonContracts.BusinessLogicsContracts;
|
||||||
|
using BeautySaloonContracts.SearchModels;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace BeautySaloonView
|
||||||
|
{
|
||||||
|
public partial class FormReportServices : Form
|
||||||
|
{
|
||||||
|
private readonly IServiceLogic _logic;
|
||||||
|
public FormReportServices(IServiceLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
private void FormReportServices_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadMostPopular();
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
BeautySaloon/BeautySaloonView/FormReportServices.resx
Normal file
60
BeautySaloon/BeautySaloonView/FormReportServices.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<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>
|
@ -4,7 +4,6 @@ using BeautySaloonContracts.SearchModels;
|
|||||||
using BeautySaloonContracts.ViewModels;
|
using BeautySaloonContracts.ViewModels;
|
||||||
using BeautySaloonDataModels;
|
using BeautySaloonDataModels;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BeautySaloonView
|
namespace BeautySaloonView
|
||||||
|
@ -54,6 +54,7 @@ namespace BeautySaloonView
|
|||||||
services.AddTransient<FormService>();
|
services.AddTransient<FormService>();
|
||||||
services.AddTransient<FormServices>();
|
services.AddTransient<FormServices>();
|
||||||
services.AddTransient<FormTest>();
|
services.AddTransient<FormTest>();
|
||||||
|
services.AddTransient<FormReportServices>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user