PIbd-22. Stroev V.M. Lab Work 04 #4
@ -95,6 +95,7 @@
|
|||||||
компонентыПоРаботамToolStripMenuItem.Name = "компонентыПоРаботамToolStripMenuItem";
|
компонентыПоРаботамToolStripMenuItem.Name = "компонентыПоРаботамToolStripMenuItem";
|
||||||
компонентыПоРаботамToolStripMenuItem.Size = new Size(268, 26);
|
компонентыПоРаботамToolStripMenuItem.Size = new Size(268, 26);
|
||||||
компонентыПоРаботамToolStripMenuItem.Text = "Компоненты по работам";
|
компонентыПоРаботамToolStripMenuItem.Text = "Компоненты по работам";
|
||||||
|
компонентыПоРаботамToolStripMenuItem.Click += компонентыПоРаботамToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// списокЗаказовToolStripMenuItem
|
// списокЗаказовToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
@ -204,5 +204,14 @@ namespace PlumbingRepairView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void компонентыПоРаботамToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportWorkComponents));
|
||||||
|
if (service is FormReportWorkComponents form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
button1.TabIndex = 1;
|
button1.TabIndex = 1;
|
||||||
button1.Text = "Сохранить в Excel";
|
button1.Text = "Сохранить в Excel";
|
||||||
button1.UseVisualStyleBackColor = true;
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += ButtonSaveToExcel_Click;
|
||||||
//
|
//
|
||||||
// FormReportWorkComponents
|
// FormReportWorkComponents
|
||||||
//
|
//
|
||||||
@ -84,6 +85,7 @@
|
|||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Name = "FormReportWorkComponents";
|
Name = "FormReportWorkComponents";
|
||||||
Text = "FormReportWorkComponent";
|
Text = "FormReportWorkComponent";
|
||||||
|
Load += FormReportProductComponents_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,14 @@ namespace PlumbingRepairView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dict = _logic.GetProductComponent();
|
var dict = _logic.GetWorkComponent();
|
||||||
if (dict != null)
|
if (dict != null)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Clear();
|
dataGridView.Rows.Clear();
|
||||||
foreach (var elem in dict)
|
foreach (var elem in dict)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
|
dataGridView.Rows.Add(new object[] { elem.WorkName, "", "" });
|
||||||
foreach (var listElem in elem.Works)
|
foreach (var listElem in elem.Components)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ namespace PlumbingRepairView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logic.SaveProductComponentToExcelFile(new ReportBindingModel
|
_logic.SaveWorkComponentToExcelFile(new ReportBindingModel
|
||||||
{
|
{
|
||||||
FileName = dialog.FileName
|
FileName = dialog.FileName
|
||||||
});
|
});
|
||||||
|
@ -126,13 +126,4 @@
|
|||||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="ComponentName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="WorkName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
@ -2,6 +2,8 @@ using PlumbingRepairContracts.BusinessLogicsContracts;
|
|||||||
using PlumbingRepairBusinessLogic.OfficePackage.Implements;
|
using PlumbingRepairBusinessLogic.OfficePackage.Implements;
|
||||||
using PlumbingRepairBusinessLogic.OfficePackage;
|
using PlumbingRepairBusinessLogic.OfficePackage;
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
|
using PlumbingRepairBusinessLogic.OfficePackage.Implements;
|
||||||
|
using PlumbingRepairBusinessLogic.OfficePackage;
|
||||||
using PlumbingRepairDataBaseImplement.Implements;
|
using PlumbingRepairDataBaseImplement.Implements;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
@ -33,15 +33,15 @@
|
|||||||
<DataField>Sum</DataField>
|
<DataField>Sum</DataField>
|
||||||
<rd:TypeName>System.Decimal</rd:TypeName>
|
<rd:TypeName>System.Decimal</rd:TypeName>
|
||||||
</Field>
|
</Field>
|
||||||
<Field Name="Status">
|
<Field Name="OrderStatus">
|
||||||
<DataField>Status</DataField>
|
<DataField>OrderStatus</DataField>
|
||||||
<rd:TypeName>PlumbingRepairDataModels.Status</rd:TypeName>
|
<rd:TypeName>PlumbingRepairDataModels.OrderStatus</rd:TypeName>
|
||||||
</Field>
|
</Field>
|
||||||
</Fields>
|
</Fields>
|
||||||
<rd:DataSetInfo>
|
<rd:DataSetInfo>
|
||||||
<rd:DataSetName>PlumbingRepairContracts.ViewModels</rd:DataSetName>
|
<rd:DataSetName>PlumbingRepairContracts.ViewModels</rd:DataSetName>
|
||||||
<rd:TableName>ReportOrderViewModel</rd:TableName>
|
<rd:TableName>ReportOrdersViewModel</rd:TableName>
|
||||||
<rd:ObjectDataSourceType>PlumbingRepairContracts.ViewModels.ReportOrderViewModel, PlumbingRepairContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
<rd:ObjectDataSourceType>PlumbingRepairContracts.ViewModels.ReportOrdersViewModel, PlumbingRepairContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||||
</rd:DataSetInfo>
|
</rd:DataSetInfo>
|
||||||
</DataSet>
|
</DataSet>
|
||||||
</DataSets>
|
</DataSets>
|
||||||
@ -398,21 +398,21 @@
|
|||||||
</TablixCell>
|
</TablixCell>
|
||||||
<TablixCell>
|
<TablixCell>
|
||||||
<CellContents>
|
<CellContents>
|
||||||
<Textbox Name="Status">
|
<Textbox Name="OrderStatus">
|
||||||
<CanGrow>true</CanGrow>
|
<CanGrow>true</CanGrow>
|
||||||
<KeepTogether>true</KeepTogether>
|
<KeepTogether>true</KeepTogether>
|
||||||
<Paragraphs>
|
<Paragraphs>
|
||||||
<Paragraph>
|
<Paragraph>
|
||||||
<TextRuns>
|
<TextRuns>
|
||||||
<TextRun>
|
<TextRun>
|
||||||
<Value>=Fields!Status.Value</Value>
|
<Value>=Fields!OrderStatus.Value</Value>
|
||||||
<Style />
|
<Style />
|
||||||
</TextRun>
|
</TextRun>
|
||||||
</TextRuns>
|
</TextRuns>
|
||||||
<Style />
|
<Style />
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</Paragraphs>
|
</Paragraphs>
|
||||||
<rd:DefaultName>Status</rd:DefaultName>
|
<rd:DefaultName>OrderStatus</rd:DefaultName>
|
||||||
<Style>
|
<Style>
|
||||||
<Border>
|
<Border>
|
||||||
<Color>LightGrey</Color>
|
<Color>LightGrey</Color>
|
||||||
|
@ -15,7 +15,6 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
public class ReportLogic : IReportLogic
|
public class ReportLogic : IReportLogic
|
||||||
{
|
{
|
||||||
private readonly IComponentStorage _componentStorage;
|
|
||||||
private readonly IWorkStorage _workStorage;
|
private readonly IWorkStorage _workStorage;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
private readonly AbstractSaveToExcel _saveToExcel;
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
@ -27,72 +26,66 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
AbstractSaveToPdf saveToPdf)
|
AbstractSaveToPdf saveToPdf)
|
||||||
{
|
{
|
||||||
_workStorage = workStorage;
|
_workStorage = workStorage;
|
||||||
_componentStorage = componentStorage;
|
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
_saveToPdf = saveToPdf;
|
_saveToPdf = saveToPdf;
|
||||||
}
|
}
|
||||||
public List<ReportWorkComponentViewModel> GetProductComponent()
|
public List<ReportWorkComponentViewModel> GetWorkComponent()
|
||||||
{
|
{
|
||||||
var components = _componentStorage.GetFullList();
|
var Works = _workStorage.GetFullList();
|
||||||
var products = _workStorage.GetFullList();
|
|
||||||
var list = new List<ReportWorkComponentViewModel>();
|
var list = new List<ReportWorkComponentViewModel>();
|
||||||
foreach (var component in components)
|
|
||||||
|
foreach (var work in Works)
|
||||||
{
|
{
|
||||||
var record = new ReportWorkComponentViewModel
|
var record = new ReportWorkComponentViewModel
|
||||||
{
|
{
|
||||||
ComponentName = component.ComponentName,
|
WorkName = work.WorkName,
|
||||||
Works = new List<Tuple<string, int>>(),
|
Components = new List<(string Component, int Count)>(),
|
||||||
TotalCount = 0
|
TotalCount = 0,
|
||||||
};
|
};
|
||||||
foreach (var product in products)
|
foreach (var component in work.WorkComponents)
|
||||||
{
|
{
|
||||||
if (product.WorkComponents.ContainsKey(component.Id))
|
record.Components.Add(new(component.Value.Item1.ComponentName, component.Value.Item2));
|
||||||
{
|
record.TotalCount += component.Value.Item2;
|
||||||
record.Works.Add(new Tuple<string,
|
|
||||||
int>(product.WorkName, product.WorkComponents[component.Id].Item2));
|
|
||||||
record.TotalCount +=
|
|
||||||
product.WorkComponents[component.Id].Item2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
list.Add(record);
|
list.Add(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
return _orderStorage.GetFilteredList(new OrderSearchModel
|
return _orderStorage.GetFilteredList(new OrderSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo })
|
||||||
{
|
|
||||||
DateFrom
|
|
||||||
= model.DateFrom,
|
|
||||||
DateTo = model.DateTo
|
|
||||||
})
|
|
||||||
.Select(x => new ReportOrdersViewModel
|
.Select(x => new ReportOrdersViewModel
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
DateCreate = x.DateCreate,
|
DateCreate = x.DateCreate,
|
||||||
WorkName = x.WorkName,
|
WorkName = x.WorkName,
|
||||||
|
OrderStatus = x.Status.ToString(),
|
||||||
Sum = x.Sum
|
Sum = x.Sum
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
public void SaveComponentsToWordFile(ReportBindingModel model)
|
public void SaveWorksToWordFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToWord.CreateDoc(new WordInfo
|
_saveToWord.CreateDoc(new WordInfo
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileName = model.FileName,
|
||||||
Title = "Список компонент",
|
Title = "Список компонент",
|
||||||
Components = _componentStorage.GetFullList()
|
Works = _workStorage.GetFullList()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public void SaveProductComponentToExcelFile(ReportBindingModel model)
|
public void SaveWorkComponentToExcelFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToExcel.CreateReport(new ExcelInfo
|
_saveToExcel.CreateReport(new ExcelInfo
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileName = model.FileName,
|
||||||
Title = "Список компонент",
|
Title = "Список компонент",
|
||||||
WorkComponents = GetProductComponent()
|
WorkComponents = GetWorkComponent()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
@ -26,23 +26,23 @@ namespace PlumbingRepairBusinessLogic.OfficePackage
|
|||||||
CellToName = "C1"
|
CellToName = "C1"
|
||||||
});
|
});
|
||||||
uint rowIndex = 2;
|
uint rowIndex = 2;
|
||||||
foreach (var pc in info.WorkComponents)
|
foreach (var wk in info.WorkComponents)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = pc.ComponentName,
|
Text = wk.WorkName,
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
foreach (var product in pc.Works)
|
foreach (var (Component, Count) in wk.Components)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "B",
|
ColumnName = "B",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = product.Item1,
|
Text = Component,
|
||||||
StyleInfo =
|
StyleInfo =
|
||||||
ExcelStyleInfoType.TextWithBroder
|
ExcelStyleInfoType.TextWithBroder
|
||||||
});
|
});
|
||||||
@ -50,7 +50,7 @@ namespace PlumbingRepairBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "C",
|
ColumnName = "C",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = product.Item2.ToString(),
|
Text = Count.ToString(),
|
||||||
StyleInfo =
|
StyleInfo =
|
||||||
ExcelStyleInfoType.TextWithBroder
|
ExcelStyleInfoType.TextWithBroder
|
||||||
});
|
});
|
||||||
@ -67,7 +67,7 @@ namespace PlumbingRepairBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "C",
|
ColumnName = "C",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = pc.TotalCount.ToString(),
|
Text = wk.TotalCount.ToString(),
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
|
@ -23,12 +23,12 @@ WordTextProperties { Bold = true, Size = "24", }) },
|
|||||||
JustificationType = WordJustificationType.Center
|
JustificationType = WordJustificationType.Center
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
foreach (var component in info.Components)
|
foreach (var work in info.Works)
|
||||||
{
|
{
|
||||||
CreateParagraph(new WordParagraph
|
CreateParagraph(new WordParagraph
|
||||||
{
|
{
|
||||||
Texts = new List<(string, WordTextProperties)> {
|
Texts = new List<(string, WordTextProperties)> {
|
||||||
(component.ComponentName, new WordTextProperties { Size = "24", }) },
|
(work.WorkName, new WordTextProperties { Size = "24", }) },
|
||||||
TextProperties = new WordTextProperties
|
TextProperties = new WordTextProperties
|
||||||
{
|
{
|
||||||
Size = "24",
|
Size = "24",
|
||||||
|
@ -11,6 +11,6 @@ namespace PlumbingRepairBusinessLogic.OfficePackage.HelperModels
|
|||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
public List<ComponentViewModel> Components { get; set; } = new();
|
public List<WorkViewModel> Works { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace PlumbingRepairContracts.BindingModels
|
|||||||
public class ReportBindingModel
|
public class ReportBindingModel
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; } = DateTime.SpecifyKind(, DateTimeKind.Utc);
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ namespace PlumbingRepairContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
public interface IReportLogic
|
public interface IReportLogic
|
||||||
{
|
{
|
||||||
List<ReportWorkComponentViewModel> GetProductComponent();
|
List<ReportWorkComponentViewModel> GetWorkComponent();
|
||||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||||
void SaveComponentsToWordFile(ReportBindingModel model);
|
void SaveWorksToWordFile(ReportBindingModel model);
|
||||||
void SaveProductComponentToExcelFile(ReportBindingModel model);
|
void SaveWorkComponentToExcelFile(ReportBindingModel model);
|
||||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace PlumbingRepairContracts.ViewModels
|
|||||||
[DisplayName("Статус")]
|
[DisplayName("Статус")]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
[DisplayName("Дата создания")]
|
[DisplayName("Дата создания")]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
[DisplayName("Дата выполнения")]
|
[DisplayName("Дата выполнения")]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ namespace PlumbingRepairContracts.ViewModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
public string WorkName { get; set; } = string.Empty;
|
public string WorkName { get; set; } = string.Empty;
|
||||||
|
public string OrderStatus { get; set; } = string.Empty;
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ namespace PlumbingRepairContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ReportWorkComponentViewModel
|
public class ReportWorkComponentViewModel
|
||||||
{
|
{
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string WorkName { get; set; } = string.Empty;
|
||||||
public int TotalCount { get; set; }
|
public int TotalCount { get; set; }
|
||||||
public List<Tuple<string, int>> Works { get; set; } = new();
|
public List<(string Component, int Count)> Components { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using PlumbingRepairContracts.BindingModels;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
using PlumbingRepairContracts.SearchModels;
|
using PlumbingRepairContracts.SearchModels;
|
||||||
using PlumbingRepairContracts.StoragesContracts;
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
using PlumbingRepairContracts.ViewModels;
|
using PlumbingRepairContracts.ViewModels;
|
||||||
@ -22,13 +23,22 @@ namespace PlumbingRepairDataBaseImplement.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue && !model.DateFrom.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
using var context = new PlumbingRepairDataBase();
|
using var context = new PlumbingRepairDataBase();
|
||||||
|
|
||||||
|
if (model.DateFrom.HasValue)
|
||||||
|
{
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Work)
|
||||||
|
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace PlumbingRepairDataBaseImplement.Models
|
|||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
|
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ namespace PlumbingRepairFileImplement.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue && !model.DateFrom.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ namespace PlumbingRepairFileImplement.Models
|
|||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
|
@ -18,7 +18,7 @@ namespace PlumbingRepairListImplement.Models
|
|||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
public OrderStatus Status { get; private set; }
|
public OrderStatus Status { get; private set; }
|
||||||
public DateTime DateCreate { get; private set; }
|
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user