2 правка
This commit is contained in:
parent
87a199d096
commit
dcde585e86
@ -1,4 +1,5 @@
|
||||
using AbstractLawFirmDataBaseImplement.Models;
|
||||
using AbstractLawFirmDatabaseImplement.Models;
|
||||
using AbstractLawFirmDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -8,7 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractLawFirmDataBaseImplement
|
||||
{
|
||||
public class AbstractLawFirmDataBase : DbContext
|
||||
public class AbstractLawFirmDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
public List<ComponentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
return context.Components
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -27,7 +27,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
return context.Components
|
||||
.Where(x => x.ComponentName.Contains(model.ComponentName))
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -39,7 +39,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
return context.Components
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id)) ?.GetViewModel;
|
||||
@ -51,14 +51,14 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
context.Components.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
var component = context.Components.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
@ -70,7 +70,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
}
|
||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
var element = context.Components.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
|
@ -1,16 +1,16 @@
|
||||
using AbstractLawFirmContracts.BindingModels;
|
||||
using AbstractLawFirmContracts.BindingModels.BindingModels;
|
||||
using AbstractLawFirmContracts.SearchModels;
|
||||
using AbstractLawFirmContracts.StoragesContracts;
|
||||
using AbstractLawFirmContracts.ViewModels;
|
||||
using AbstractLawFirmDataBaseImplement;
|
||||
using AbstractLawFirmDataBaseImplement.Models;
|
||||
using AbstractLawFirmDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AbstractLawFirmDatabaseImplement.Models;
|
||||
|
||||
namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
@ -18,7 +18,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
public List<DocumentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
return context.Documents
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
@ -32,7 +32,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
return context.Documents
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
@ -48,10 +48,8 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
return context.Documents
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
return context.Documents.Include(x => x.Components).ThenInclude(x => x.Component)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.DocumentName) &&
|
||||
x.DocumentName == model.DocumentName) ||
|
||||
(model.Id.HasValue && x.Id ==
|
||||
@ -60,7 +58,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
}
|
||||
public DocumentViewModel? Insert(DocumentBindingModel model)
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
var newDocument = Document.Create(context, model);
|
||||
if (newDocument == null)
|
||||
{
|
||||
@ -72,21 +70,21 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
}
|
||||
public DocumentViewModel? Update(DocumentBindingModel model)
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var product = context.Documents.FirstOrDefault(rec =>
|
||||
var document = context.Documents.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (product == null)
|
||||
if (document == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
product.Update(model);
|
||||
document.Update(model);
|
||||
context.SaveChanges();
|
||||
product.UpdateComponents(context, model);
|
||||
document.UpdateComponents(context, model);
|
||||
transaction.Commit();
|
||||
return product.GetViewModel;
|
||||
return document.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -96,10 +94,8 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
}
|
||||
public DocumentViewModel? Delete(DocumentBindingModel model)
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
var element = context.Documents
|
||||
.Include(x => x.Components)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
var element = context.Documents.Include(x => x.Components).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Documents.Remove(element);
|
||||
|
@ -10,6 +10,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AbstractLawFirmDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using AbstractLawFirmDatabaseImplement.Models;
|
||||
|
||||
namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
@ -17,7 +18,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
@ -34,7 +35,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
return context.Orders
|
||||
.FirstOrDefault(x =>
|
||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
@ -46,7 +47,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
return context.Orders
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -55,7 +56,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
return context.Orders
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -68,7 +69,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return newOrder.GetViewModel;
|
||||
@ -76,7 +77,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
using var context = new AbstractLawFirmDatabase();
|
||||
var component = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace AbstractLawFirmDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AbstractLawFirmDataBase))]
|
||||
[DbContext(typeof(AbstractLawFirmDatabase))]
|
||||
[Migration("20240325152423_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace AbstractLawFirmDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AbstractLawFirmDataBase))]
|
||||
[DbContext(typeof(AbstractLawFirmDatabase))]
|
||||
partial class AbstractLawFirmDataBaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
|
@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AbstractLawFirmDataBaseImplement.Models;
|
||||
using AbstractLawFirmDatabaseImplement.Models;
|
||||
|
||||
namespace AbstractLawFirmDataBaseImplement.Models
|
||||
{
|
||||
|
@ -9,8 +9,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AbstractLawFirmDataBaseImplement.Models;
|
||||
using AbstractLawFirmDataBaseImplement;
|
||||
|
||||
namespace AbstractLawFirmDataBaseImplement.Models
|
||||
namespace AbstractLawFirmDatabaseImplement.Models
|
||||
{
|
||||
public class Document : IDocumentModel
|
||||
{
|
||||
@ -19,34 +20,36 @@ namespace AbstractLawFirmDataBaseImplement.Models
|
||||
public string DocumentName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
private Dictionary<int, (IComponentModel, int)>? _productComponents =
|
||||
private Dictionary<int, (IComponentModel, int)>? _documentComponents =
|
||||
null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> DocumentComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_productComponents == null)
|
||||
if (_documentComponents == null)
|
||||
{
|
||||
_productComponents = Components
|
||||
_documentComponents = Components
|
||||
.ToDictionary(recPC => recPC.ComponentId, recPC =>
|
||||
(recPC.Component as IComponentModel, recPC.Count));
|
||||
}
|
||||
return _productComponents;
|
||||
return _documentComponents;
|
||||
}
|
||||
}
|
||||
[ForeignKey("DocumentId")]
|
||||
public virtual List<DocumentComponent> Components { get; set; } = new();
|
||||
[ForeignKey("DocumentId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
public static Document Create(AbstractLawFirmDataBase context, DocumentBindingModel model)
|
||||
public static Document Create(AbstractLawFirmDatabase context,
|
||||
DocumentBindingModel model)
|
||||
{
|
||||
return new Document()
|
||||
{
|
||||
Id = model.Id,
|
||||
DocumentName = model.DocumentName,
|
||||
Price = model.Price,
|
||||
Components = model.DocumentComponents.Select(x => new DocumentComponent
|
||||
Components = model.DocumentComponents.Select(x => new
|
||||
DocumentComponent
|
||||
{
|
||||
Component = context.Components.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
@ -65,12 +68,14 @@ namespace AbstractLawFirmDataBaseImplement.Models
|
||||
Price = Price,
|
||||
DocumentComponents = DocumentComponents
|
||||
};
|
||||
public void UpdateComponents(AbstractLawFirmDataBase context, DocumentBindingModel model)
|
||||
public void UpdateComponents(AbstractLawFirmDatabase context,
|
||||
DocumentBindingModel model)
|
||||
{
|
||||
var documentComponents = context.DocumentComponents.Where(rec => rec.DocumentId == model.Id).ToList();
|
||||
if (documentComponents != null && documentComponents.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.DocumentComponents.RemoveRange(documentComponents.Where(rec => !model.DocumentComponents.ContainsKey(rec.ComponentId)));
|
||||
context.DocumentComponents.RemoveRange(documentComponents.Where(rec
|
||||
=> !model.DocumentComponents.ContainsKey(rec.ComponentId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateComponent in documentComponents)
|
||||
@ -80,18 +85,18 @@ namespace AbstractLawFirmDataBaseImplement.Models
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var product = context.Documents.First(x => x.Id == Id);
|
||||
var document = context.Documents.First(x => x.Id == Id);
|
||||
foreach (var pc in model.DocumentComponents)
|
||||
{
|
||||
context.DocumentComponents.Add(new DocumentComponent
|
||||
{
|
||||
Document = product,
|
||||
Document = document,
|
||||
Component = context.Components.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_productComponents = null;
|
||||
_documentComponents = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
using AbstractLawFirmDataBaseImplement.Models;
|
||||
using AbstractLawFirmDatabaseImplement.Models;
|
||||
using AbstractLawFirmDataBaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractLawFirmDataBaseImplement.Models
|
||||
namespace AbstractLawFirmDatabaseImplement.Models
|
||||
{
|
||||
public class DocumentComponent
|
||||
{
|
||||
|
@ -4,62 +4,68 @@ using AbstractLawFirmDataModels.Enums;
|
||||
using AbstractLawFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractLawFirmDataBaseImplement.Models
|
||||
namespace AbstractLawFirmDatabaseImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int DocumentId { get; private set; }
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
public OrderStatus Status { get; private set; }
|
||||
public DateTime DateCreate { get; private set; }
|
||||
[Required]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public virtual Document Document { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order()
|
||||
return new Order
|
||||
{
|
||||
Id = model.Id,
|
||||
DocumentId = model.DocumentId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Id = model.Id,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Id = model.Id;
|
||||
DocumentId = model.DocumentId;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
|
||||
public OrderViewModel GetViewModel => new OrderViewModel
|
||||
{
|
||||
Id = Id,
|
||||
DocumentId = DocumentId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
Id = Id,
|
||||
Status = Status,
|
||||
DocumentName = Document?.DocumentName ?? string.Empty // Безопасное использование DocumentName
|
||||
};
|
||||
|
||||
}
|
||||
}
|
@ -3,15 +3,7 @@ using AbstractLawFirmContracts.BindingModels;
|
||||
using AbstractLawFirmContracts.BusinessLogicsContracts;
|
||||
using AbstractLawFirmDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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;
|
||||
using AbstractLawFirmBusinessLogic.BusinessLogic;
|
||||
|
||||
namespace LawFirmView
|
||||
{
|
||||
@ -211,7 +203,7 @@ namespace LawFirmView
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
/* private void списокПакетовДокументовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void списокПакетовДокументовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
@ -224,7 +216,6 @@ namespace LawFirmView
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private void компонентыПоПакетамДокументовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
32
LawFirm/LawFirmView/FormMain.designer.cs
generated
32
LawFirm/LawFirmView/FormMain.designer.cs
generated
@ -33,13 +33,15 @@
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
пакетыДокументовToolStripMenuItem = new ToolStripMenuItem();
|
||||
формированиеОтчётовToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыПоПакетамДокументовToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateOrder = new Button();
|
||||
buttonTakeOrderInWork = new Button();
|
||||
buttonOrderReady = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonRef = new Button();
|
||||
компонентыПоПакетамДокументовToolStripMenuItem = new ToolStripMenuItem();
|
||||
списокПакетовДокументовToolStripMenuItem = new ToolStripMenuItem();
|
||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -78,11 +80,18 @@
|
||||
//
|
||||
// формированиеОтчётовToolStripMenuItem
|
||||
//
|
||||
формированиеОтчётовToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыПоПакетамДокументовToolStripMenuItem });
|
||||
формированиеОтчётовToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыПоПакетамДокументовToolStripMenuItem, списокПакетовДокументовToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
||||
формированиеОтчётовToolStripMenuItem.Name = "формированиеОтчётовToolStripMenuItem";
|
||||
формированиеОтчётовToolStripMenuItem.Size = new Size(259, 26);
|
||||
формированиеОтчётовToolStripMenuItem.Text = "Формирование отчётов";
|
||||
//
|
||||
// компонентыПоПакетамДокументовToolStripMenuItem
|
||||
//
|
||||
компонентыПоПакетамДокументовToolStripMenuItem.Name = "компонентыПоПакетамДокументовToolStripMenuItem";
|
||||
компонентыПоПакетамДокументовToolStripMenuItem.Size = new Size(351, 26);
|
||||
компонентыПоПакетамДокументовToolStripMenuItem.Text = "Компоненты по пакетам документов";
|
||||
компонентыПоПакетамДокументовToolStripMenuItem.Click += компонентыПоПакетамДокументовToolStripMenuItem_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
@ -149,12 +158,19 @@
|
||||
buttonRef.UseVisualStyleBackColor = true;
|
||||
buttonRef.Click += buttonRef_Click;
|
||||
//
|
||||
// компонентыПоПакетамДокументовToolStripMenuItem
|
||||
// списокПакетовДокументовToolStripMenuItem
|
||||
//
|
||||
компонентыПоПакетамДокументовToolStripMenuItem.Name = "компонентыПоПакетамДокументовToolStripMenuItem";
|
||||
компонентыПоПакетамДокументовToolStripMenuItem.Size = new Size(357, 26);
|
||||
компонентыПоПакетамДокументовToolStripMenuItem.Text = "Компоненты По Пакетам Документов";
|
||||
компонентыПоПакетамДокументовToolStripMenuItem.Click += компонентыПоПакетамДокументовToolStripMenuItem_Click;
|
||||
списокПакетовДокументовToolStripMenuItem.Name = "списокПакетовДокументовToolStripMenuItem";
|
||||
списокПакетовДокументовToolStripMenuItem.Size = new Size(351, 26);
|
||||
списокПакетовДокументовToolStripMenuItem.Text = "Список пакетов документов";
|
||||
списокПакетовДокументовToolStripMenuItem.Click += списокПакетовДокументовToolStripMenuItem_Click;
|
||||
//
|
||||
// списокЗаказовToolStripMenuItem
|
||||
//
|
||||
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
||||
списокЗаказовToolStripMenuItem.Size = new Size(351, 26);
|
||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
@ -194,5 +210,7 @@
|
||||
private Button buttonRef;
|
||||
private ToolStripMenuItem формированиеОтчётовToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыПоПакетамДокументовToolStripMenuItem;
|
||||
private ToolStripMenuItem списокПакетовДокументовToolStripMenuItem;
|
||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -34,7 +34,6 @@ namespace LawFirmView
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in dict)
|
||||
{
|
||||
// проверить ComponentName Document (поменять местами)
|
||||
dataGridView.Rows.Add(new object[] { elem.DocumentName, "", "" });
|
||||
foreach (var listElem in elem.Components)
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using AbstractLawFirmContracts.BindingModels;
|
||||
using AbstractLawFirmContracts.BusinessLogicsContracts;
|
||||
using AbstractLawFirmContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Reporting.WinForms;
|
||||
using System;
|
||||
@ -11,6 +10,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AbstractLawFirmContracts.BindingModels;
|
||||
|
||||
namespace LawFirmView
|
||||
{
|
||||
@ -19,8 +19,7 @@ namespace LawFirmView
|
||||
private readonly ReportViewer reportViewer;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
public FormReportOrders(ILogger<FormReportOrders> logger, IReportLogic
|
||||
logic)
|
||||
public FormReportOrders(ILogger<FormReportOrders> logger, IReportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
@ -29,13 +28,14 @@ namespace LawFirmView
|
||||
{
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
reportViewer.LocalReport.LoadReportDefinition(new
|
||||
FileStream("ReportOrders.rdlc", FileMode.Open));
|
||||
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open));
|
||||
Controls.Clear();
|
||||
Controls.Add(reportViewer);
|
||||
Controls.Add(panel);
|
||||
|
||||
}
|
||||
private void ButtonMake_Click(object sender, EventArgs e)
|
||||
|
||||
private void buttonMake_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
|
||||
{
|
||||
@ -53,9 +53,12 @@ namespace LawFirmView
|
||||
var source = new ReportDataSource("DataSetOrders", dataSource);
|
||||
reportViewer.LocalReport.DataSources.Clear();
|
||||
reportViewer.LocalReport.DataSources.Add(source);
|
||||
var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c {dateTimePickerFrom.Value.ToShortDateString()} по{dateTimePickerTo.Value.ToShortDateString()}") }; reportViewer.LocalReport.SetParameters(parameters);
|
||||
var parameters = new[] { new ReportParameter("ReportParameterPeriod",
|
||||
$"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
|
||||
reportViewer.LocalReport.SetParameters(parameters);
|
||||
reportViewer.RefreshReport();
|
||||
_logger.LogInformation("Загрузка списка заказов на период {From}- { To} ", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
|
||||
_logger.LogInformation("Загрузка списка заказов на период {From}- { To} ", dateTimePickerFrom.Value.ToShortDateString(),
|
||||
dateTimePickerTo.Value.ToShortDateString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -63,8 +66,10 @@ namespace LawFirmView
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
private void ButtonToPdf_Click(object sender, EventArgs e)
|
||||
|
||||
private void buttonToPdf_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
|
||||
{
|
||||
@ -86,7 +91,8 @@ namespace LawFirmView
|
||||
DateFrom = dateTimePickerFrom.Value,
|
||||
DateTo = dateTimePickerTo.Value
|
||||
});
|
||||
_logger.LogInformation("Сохранение списка заказов на период { From} -{ To} ", dateTimePickerFrom.Value.ToShortDateString(),
|
||||
_logger.LogInformation("Сохранение списка заказов на период { From} -{ To} ",
|
||||
dateTimePickerFrom.Value.ToShortDateString(),
|
||||
dateTimePickerTo.Value.ToShortDateString());
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
@ -94,10 +100,12 @@ namespace LawFirmView
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,9 @@
|
||||
<ProjectReference Include="..\AbstractLawFirmListImplement\AbstractLawFirmListImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="ReportOrders.rdlc">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -595,5 +595,5 @@
|
||||
</GridLayoutDefinition>
|
||||
</ReportParametersLayout>
|
||||
<rd:ReportUnitType>Cm</rd:ReportUnitType>
|
||||
<rd:ReportID>0450af05-3af7-4c1a-9e54-1c474b4807b8</rd:ReportID>
|
||||
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
|
||||
</Report>
|
Loading…
Reference in New Issue
Block a user