fix
This commit is contained in:
parent
4a88074155
commit
2e62277509
@ -52,7 +52,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
model.DateImplement = viewModel.DateImplement;
|
model.DateImplement = viewModel.DateImplement;
|
||||||
}
|
}
|
||||||
CheckModel(model);
|
CheckModel(model, false);
|
||||||
if (_orderStorage.Update(model) == null)
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
model.Status--;
|
model.Status--;
|
||||||
|
@ -50,8 +50,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
if (document.DocumentBlanks.ContainsKey(blank.Id))
|
if (document.DocumentBlanks.ContainsKey(blank.Id))
|
||||||
{
|
{
|
||||||
record.Blanks.Add(new Tuple<string, int>(blank.BlankName, document.DocumentBlanks[blank.Id].Item2));
|
record.Blanks.Add(new Tuple<string, int>(blank.BlankName, document.DocumentBlanks[blank.Id].Item2));
|
||||||
record.TotalCount +=
|
record.TotalCount += document.DocumentBlanks[blank.Id].Item2;
|
||||||
document.DocumentBlanks[blank.Id].Item2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.Add(record);
|
list.Add(record);
|
||||||
|
@ -23,10 +23,10 @@ namespace LawFirmBusinessLogic.OfficePackage
|
|||||||
= "Normal",
|
= "Normal",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" });
|
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма" },
|
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус", "Сумма" },
|
||||||
Style = "NormalTitle",
|
Style = "NormalTitle",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
@ -34,7 +34,7 @@ namespace LawFirmBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.DocumentName, order.Sum.ToString() },
|
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.DocumentName, order.OrderStatus, order.Sum.ToString() },
|
||||||
Style = "Normal",
|
Style = "Normal",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
});
|
});
|
||||||
|
@ -70,17 +70,17 @@ namespace LawFirmDatabaseImplement.Implements
|
|||||||
using var transaction = context.Database.BeginTransaction();
|
using var transaction = context.Database.BeginTransaction();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var product = context.Documents.FirstOrDefault(rec =>
|
var document = context.Documents.FirstOrDefault(rec =>
|
||||||
rec.Id == model.Id);
|
rec.Id == model.Id);
|
||||||
if (product == null)
|
if (document == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
product.Update(model);
|
document.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
product.UpdateBlanks(context, model);
|
document.UpdateBlanks(context, model);
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
return product.GetViewModel;
|
return document.GetViewModel;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -13,19 +13,19 @@ namespace LawFirmDatabaseImplement.Models
|
|||||||
public string DocumentName { get; set; } = string.Empty;
|
public string DocumentName { get; set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
private Dictionary<int, (IBlankModel, int)>? _productBlanks = null;
|
private Dictionary<int, (IBlankModel, int)>? _documentBlanks = null;
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, (IBlankModel, int)> DocumentBlanks
|
public Dictionary<int, (IBlankModel, int)> DocumentBlanks
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_productBlanks == null)
|
if (_documentBlanks == null)
|
||||||
{
|
{
|
||||||
_productBlanks = Blanks
|
_documentBlanks = Blanks
|
||||||
.ToDictionary(recPC => recPC.BlankId, recPC =>
|
.ToDictionary(recPC => recPC.BlankId, recPC =>
|
||||||
(recPC.Blank as IBlankModel, recPC.Count));
|
(recPC.Blank as IBlankModel, recPC.Count));
|
||||||
}
|
}
|
||||||
return _productBlanks;
|
return _documentBlanks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[ForeignKey("DocumentId")]
|
[ForeignKey("DocumentId")]
|
||||||
@ -61,15 +61,15 @@ namespace LawFirmDatabaseImplement.Models
|
|||||||
public void UpdateBlanks(LawFirmDatabase context,
|
public void UpdateBlanks(LawFirmDatabase context,
|
||||||
DocumentBindingModel model)
|
DocumentBindingModel model)
|
||||||
{
|
{
|
||||||
var productBlanks = context.DocumentBlanks.Where(rec =>
|
var documentBlanks = context.DocumentBlanks.Where(rec =>
|
||||||
rec.DocumentId == model.Id).ToList();
|
rec.DocumentId == model.Id).ToList();
|
||||||
if (productBlanks != null && productBlanks.Count > 0)
|
if (documentBlanks != null && documentBlanks.Count > 0)
|
||||||
{ // удалили те, которых нет в модели
|
{ // удалили те, которых нет в модели
|
||||||
context.DocumentBlanks.RemoveRange(productBlanks.Where(rec
|
context.DocumentBlanks.RemoveRange(documentBlanks.Where(rec
|
||||||
=> !model.DocumentBlanks.ContainsKey(rec.BlankId)));
|
=> !model.DocumentBlanks.ContainsKey(rec.BlankId)));
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
// обновили количество у существующих записей
|
// обновили количество у существующих записей
|
||||||
foreach (var updateBlank in productBlanks)
|
foreach (var updateBlank in documentBlanks)
|
||||||
{
|
{
|
||||||
updateBlank.Count =
|
updateBlank.Count =
|
||||||
model.DocumentBlanks[updateBlank.BlankId].Item2;
|
model.DocumentBlanks[updateBlank.BlankId].Item2;
|
||||||
@ -77,18 +77,18 @@ namespace LawFirmDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
context.SaveChanges();
|
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.DocumentBlanks)
|
foreach (var pc in model.DocumentBlanks)
|
||||||
{
|
{
|
||||||
context.DocumentBlanks.Add(new DocumentBlank
|
context.DocumentBlanks.Add(new DocumentBlank
|
||||||
{
|
{
|
||||||
Document = product,
|
Document = document,
|
||||||
Blank = context.Blanks.First(x => x.Id == pc.Key),
|
Blank = context.Blanks.First(x => x.Id == pc.Key),
|
||||||
Count = pc.Value.Item2
|
Count = pc.Value.Item2
|
||||||
});
|
});
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
_productBlanks = null;
|
_documentBlanks = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ namespace LawFirmFileImplement
|
|||||||
{
|
{
|
||||||
Blanks = LoadData(BlankFileName, "Blank", x => Blank.Create(x)!)!;
|
Blanks = LoadData(BlankFileName, "Blank", x => Blank.Create(x)!)!;
|
||||||
Documents = LoadData(DocumentFileName, "Document", x => Document.Create(x)!)!;
|
Documents = LoadData(DocumentFileName, "Document", x => Document.Create(x)!)!;
|
||||||
Orders = new List<Order>();
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||||
Func<XElement, T> selectFunction)
|
Func<XElement, T> selectFunction)
|
||||||
{
|
{
|
||||||
|
@ -50,14 +50,14 @@ namespace LawFirmFileImplement.Implements
|
|||||||
}
|
}
|
||||||
public DocumentViewModel? Update(DocumentBindingModel model)
|
public DocumentViewModel? Update(DocumentBindingModel model)
|
||||||
{
|
{
|
||||||
var ship = source.Documents.FirstOrDefault(x => x.Id == model.Id);
|
var document = source.Documents.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (ship == null)
|
if (document == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ship.Update(model);
|
document.Update(model);
|
||||||
source.SaveDocuments();
|
source.SaveDocuments();
|
||||||
return ship.GetViewModel;
|
return document.GetViewModel;
|
||||||
}
|
}
|
||||||
public DocumentViewModel? Delete(DocumentBindingModel model)
|
public DocumentViewModel? Delete(DocumentBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -38,10 +38,10 @@ namespace LawFirmFileImplement.Implements
|
|||||||
private OrderViewModel GetViewModel(Order order)
|
private OrderViewModel GetViewModel(Order order)
|
||||||
{
|
{
|
||||||
var viewModel = order.GetViewModel;
|
var viewModel = order.GetViewModel;
|
||||||
var ship = source.Documents.FirstOrDefault(x => x.Id == order.DocumentId);
|
var document = source.Documents.FirstOrDefault(x => x.Id == order.DocumentId);
|
||||||
if (ship != null)
|
if (document != null)
|
||||||
{
|
{
|
||||||
viewModel.DocumentName = ship.DocumentName;
|
viewModel.DocumentName = document.DocumentName;
|
||||||
}
|
}
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
@ -11,20 +11,20 @@ namespace LawFirmFileImplement.Models
|
|||||||
public string DocumentName { get; private set; } = string.Empty;
|
public string DocumentName { get; private set; } = string.Empty;
|
||||||
public double Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
public Dictionary<int, int> Blanks { get; private set; } = new();
|
public Dictionary<int, int> Blanks { get; private set; } = new();
|
||||||
private Dictionary<int, (IBlankModel, int)>? _productBlanks =
|
private Dictionary<int, (IBlankModel, int)>? _documentBlanks =
|
||||||
null;
|
null;
|
||||||
public Dictionary<int, (IBlankModel, int)> DocumentBlanks
|
public Dictionary<int, (IBlankModel, int)> DocumentBlanks
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_productBlanks == null)
|
if (_documentBlanks == null)
|
||||||
{
|
{
|
||||||
var source = DataFileSingleton.GetInstance();
|
var source = DataFileSingleton.GetInstance();
|
||||||
_productBlanks = Blanks.ToDictionary(x => x.Key, y =>
|
_documentBlanks = Blanks.ToDictionary(x => x.Key, y =>
|
||||||
((source.Blanks.FirstOrDefault(z => z.Id == y.Key) as IBlankModel)!,
|
((source.Blanks.FirstOrDefault(z => z.Id == y.Key) as IBlankModel)!,
|
||||||
y.Value));
|
y.Value));
|
||||||
}
|
}
|
||||||
return _productBlanks;
|
return _documentBlanks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static Document? Create(DocumentBindingModel model)
|
public static Document? Create(DocumentBindingModel model)
|
||||||
@ -70,7 +70,7 @@ namespace LawFirmFileImplement.Models
|
|||||||
Price = model.Price;
|
Price = model.Price;
|
||||||
Blanks = model.DocumentBlanks.ToDictionary(x => x.Key, x =>
|
Blanks = model.DocumentBlanks.ToDictionary(x => x.Key, x =>
|
||||||
x.Value.Item2);
|
x.Value.Item2);
|
||||||
_productBlanks = null;
|
_documentBlanks = null;
|
||||||
}
|
}
|
||||||
public DocumentViewModel GetViewModel => new()
|
public DocumentViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
|
@ -45,12 +45,12 @@ namespace LawFirmView
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(comboBoxDocument.SelectedValue);
|
int id = Convert.ToInt32(comboBoxDocument.SelectedValue);
|
||||||
var product = _logicD.ReadElement(new DocumentSearchModel
|
var document = _logicD.ReadElement(new DocumentSearchModel
|
||||||
{
|
{
|
||||||
Id = id
|
Id = id
|
||||||
});
|
});
|
||||||
int count = Convert.ToInt32(textBoxCount.Text);
|
int count = Convert.ToInt32(textBoxCount.Text);
|
||||||
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
|
textBoxSum.Text = Math.Round(count * (document?.Price ?? 0), 2).ToString();
|
||||||
_logger.LogInformation("Расчет суммы заказа");
|
_logger.LogInformation("Расчет суммы заказа");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
2
LawFirm/LawFirmView/FormMain.Designer.cs
generated
2
LawFirm/LawFirmView/FormMain.Designer.cs
generated
@ -95,7 +95,7 @@
|
|||||||
this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
|
this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
|
||||||
this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
|
this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
|
||||||
this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
|
this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
|
||||||
this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.BlanksReportToolStripMenuItem_Click);
|
this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.DocumentsReportToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// компонентыПоИзделиямToolStripMenuItem
|
// компонентыПоИзделиямToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
@ -167,7 +167,7 @@ namespace LawFirmView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BlanksReportToolStripMenuItem_Click(object sender, EventArgs
|
private void DocumentsReportToolStripMenuItem_Click(object sender, EventArgs
|
||||||
e)
|
e)
|
||||||
{
|
{
|
||||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||||
|
@ -31,11 +31,9 @@ namespace LawFirmView
|
|||||||
dataGridView.Rows.Add(new object[] { elem.DocumentName, "", "" });
|
dataGridView.Rows.Add(new object[] { elem.DocumentName, "", "" });
|
||||||
foreach (var listElem in elem.Blanks)
|
foreach (var listElem in elem.Blanks)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { "",
|
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||||
listElem.Item1, listElem.Item2 });
|
|
||||||
}
|
}
|
||||||
dataGridView.Rows.Add(new object[] { "Итого", "",
|
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
|
||||||
elem.TotalCount });
|
|
||||||
dataGridView.Rows.Add(Array.Empty<object>());
|
dataGridView.Rows.Add(Array.Empty<object>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,4 +27,10 @@
|
|||||||
<ProjectReference Include="..\LawFirmListImplement\LawFirmListImplement.csproj" />
|
<ProjectReference Include="..\LawFirmListImplement\LawFirmListImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="ReportOrders.rdlc">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user