немного надо переделать 3 лабу, поэотму удаляем то, что сделали, потом вернем
This commit is contained in:
parent
9dee2a7027
commit
9b07eaa4c8
@ -18,10 +18,10 @@ public class MaterialReplenishment
|
|||||||
public DateTime DataTime { get; private set; }
|
public DateTime DataTime { get; private set; }
|
||||||
|
|
||||||
[DisplayName("Название")]
|
[DisplayName("Название")]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public int IDMaterial { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public static MaterialReplenishment CreateOperation(int id, int count, DateTime dataTime, string name)
|
public static MaterialReplenishment CreateOperation(int id, int count, DateTime dataTime, int idmaterial)
|
||||||
{
|
{
|
||||||
return new MaterialReplenishment
|
return new MaterialReplenishment
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ public class MaterialReplenishment
|
|||||||
|
|
||||||
Count = count,
|
Count = count,
|
||||||
DataTime = dataTime,
|
DataTime = dataTime,
|
||||||
Name = name
|
IDMaterial = idmaterial
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,10 +31,9 @@ namespace ProjectAtelier.Forms
|
|||||||
throw new InvalidDataException(nameof(materialReplenishment));
|
throw new InvalidDataException(nameof(materialReplenishment));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
textBoxName.Text = materialReplenishment.Name;
|
|
||||||
comboBoxMaterial.Text = materialReplenishment.Name;
|
|
||||||
numericUpDownCount.Value = materialReplenishment.Count;
|
numericUpDownCount.Value = materialReplenishment.Count;
|
||||||
|
comboBoxMaterial.SelectedValue = materialReplenishment.IDMaterial; // Устанавливаем выбранный материал
|
||||||
|
dateTimePicker.Value = materialReplenishment.DataTime; // Устанавливаем выбранную дату и время
|
||||||
_materialReplenishmentId = value;
|
_materialReplenishmentId = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -59,11 +58,12 @@ namespace ProjectAtelier.Forms
|
|||||||
|
|
||||||
private MaterialReplenishment CreateMaterialReplenishment(int id)
|
private MaterialReplenishment CreateMaterialReplenishment(int id)
|
||||||
{
|
{
|
||||||
|
int selectedMaterialId = (int)comboBoxMaterial.SelectedValue;
|
||||||
DateTime selectedDateTime = dateTimePicker.Value;
|
DateTime selectedDateTime = dateTimePicker.Value;
|
||||||
return MaterialReplenishment.CreateOperation(id, Convert.ToInt32(numericUpDownCount.Value), selectedDateTime, textBoxName.Text);
|
return MaterialReplenishment.CreateOperation(id, Convert.ToInt32(numericUpDownCount.Value), selectedDateTime, selectedMaterialId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ButtonAdd_Click_1(object sender, EventArgs e)
|
private void ButtonAdd_Click_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -9,7 +9,7 @@ namespace ProjectAtelier.REPOSITORY;
|
|||||||
|
|
||||||
public interface IMaterialReplenishmentRepository
|
public interface IMaterialReplenishmentRepository
|
||||||
{
|
{
|
||||||
IEnumerable<MaterialReplenishment> ReadMaterialsSpent(DateTime? dateForm = null, DateTime? dateTo = null, string? nameMaterial = null);
|
IEnumerable<MaterialReplenishment> ReadMaterialsSpent(DateTime? dateForm = null, DateTime? dateTo = null, int? idmaterial = null);
|
||||||
MaterialReplenishment ReadMaterialSpentById(int id);
|
MaterialReplenishment ReadMaterialSpentById(int id);
|
||||||
void CreateMaterialSpent(MaterialReplenishment material);
|
void CreateMaterialSpent(MaterialReplenishment material);
|
||||||
void UpdateMaterialSpent(MaterialReplenishment material);
|
void UpdateMaterialSpent(MaterialReplenishment material);
|
||||||
|
@ -30,8 +30,8 @@ public class MaterialReplenishmentRepository : IMaterialReplenishmentRepository
|
|||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO MaterialReplenishment (Count, DataTime, Name)
|
INSERT INTO MaterialReplenishment (Count, DataTime, IDMaterial)
|
||||||
VALUES (@Count, @DataTime, @Name)";
|
VALUES (@Count, @DataTime, @IDMaterial)";
|
||||||
connection.Execute(queryInsert, material);
|
connection.Execute(queryInsert, material);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -64,7 +64,7 @@ public class MaterialReplenishmentRepository : IMaterialReplenishmentRepository
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IEnumerable<MaterialReplenishment> ReadMaterialsSpent(DateTime? dateForm = null, DateTime? dateTo = null, string? nameMaterial = null)
|
public IEnumerable<MaterialReplenishment> ReadMaterialsSpent(DateTime? dateForm = null, DateTime? dateTo = null, int? idmaterial = null)
|
||||||
{
|
{
|
||||||
var builder = new QueryBuilder();
|
var builder = new QueryBuilder();
|
||||||
if (dateForm.HasValue)
|
if (dateForm.HasValue)
|
||||||
@ -75,9 +75,9 @@ public class MaterialReplenishmentRepository : IMaterialReplenishmentRepository
|
|||||||
{
|
{
|
||||||
builder.AddCondition("DataTime <= @dateTo");
|
builder.AddCondition("DataTime <= @dateTo");
|
||||||
}
|
}
|
||||||
if (nameMaterial != null)
|
if (idmaterial != null)
|
||||||
{
|
{
|
||||||
builder.AddCondition("Name = @nameMaterial");
|
builder.AddCondition("IDMaterial = @idmaterial");
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
@ -87,7 +87,7 @@ public class MaterialReplenishmentRepository : IMaterialReplenishmentRepository
|
|||||||
var querySelect = @$"
|
var querySelect = @$"
|
||||||
SELECT * FROM MaterialReplenishment
|
SELECT * FROM MaterialReplenishment
|
||||||
{builder.Build()}";
|
{builder.Build()}";
|
||||||
var materials = connection.Query<MaterialReplenishment>(querySelect, new { dateForm, dateTo, nameMaterial });
|
var materials = connection.Query<MaterialReplenishment>(querySelect, new { dateForm, dateTo, idmaterial });
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(materials));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(materials));
|
||||||
return materials;
|
return materials;
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class MaterialReplenishmentRepository : IMaterialReplenishmentRepository
|
|||||||
SET
|
SET
|
||||||
Count=@Count,
|
Count=@Count,
|
||||||
DataTime=@DataTime,
|
DataTime=@DataTime,
|
||||||
Name=@Name
|
IDMaterial=@IDMaterial
|
||||||
WHERE Id=@Id";
|
WHERE Id=@Id";
|
||||||
connection.Execute(queryUpdate, material);
|
connection.Execute(queryUpdate, material);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class ChartReport
|
|||||||
{
|
{
|
||||||
return _materialReplenishmentRepository
|
return _materialReplenishmentRepository
|
||||||
.ReadMaterialsSpent(dateForm: dateTime.Date, dateTo: dateTime.Date.AddDays(1))
|
.ReadMaterialsSpent(dateForm: dateTime.Date, dateTo: dateTime.Date.AddDays(1))
|
||||||
.GroupBy(x => x.Name, (key, group) => new { Id = key, Count = group.Sum(x => x.Count) })
|
.GroupBy(x => x.IDMaterial, (key, group) => new { Id = key, Count = group.Sum(x => x.Count) })
|
||||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ internal class TableReport
|
|||||||
private List<string[]> GetData(int materialId, DateTime startDate, DateTime endDate)
|
private List<string[]> GetData(int materialId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = _materialReplenishmentRepository
|
var data = _materialReplenishmentRepository
|
||||||
.ReadMaterialsSpent(dateForm: startDate, dateTo: endDate, nameMaterial: _materialRepository.ReadMaterialById(materialId).Name)
|
.ReadMaterialsSpent(dateForm: startDate, dateTo: endDate, idmaterial: _materialRepository.ReadMaterialById(materialId).Id)
|
||||||
.Select(x => new { Date = x.DataTime, CountIn = (int?)x.Count, CountOut = (int?)null })
|
.Select(x => new { Date = x.DataTime, CountIn = (int?)x.Count, CountOut = (int?)null })
|
||||||
.Union(
|
.Union(
|
||||||
_orderMaterialsRepository
|
_orderMaterialsRepository
|
||||||
|
@ -16,7 +16,7 @@ public class OrderMaterialsRepository : IOrderMaterialsRepository
|
|||||||
_connectionString = connectionString;
|
_connectionString = connectionString;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
//orders.datatime AS DataOrder,
|
||||||
public IEnumerable<TempOrder> ReadOrders(DateTime? dateForm = null, DateTime? dateTo = null, int? matid = null)
|
public IEnumerable<TempOrder> ReadOrders(DateTime? dateForm = null, DateTime? dateTo = null, int? matid = null)
|
||||||
{
|
{
|
||||||
var builder = new QueryBuilder();
|
var builder = new QueryBuilder();
|
||||||
@ -35,7 +35,7 @@ public class OrderMaterialsRepository : IOrderMaterialsRepository
|
|||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @$"
|
var querySelect = @$"
|
||||||
SELECT
|
SELECT
|
||||||
orders.datatime AS DataOrder,
|
|
||||||
orders.*,
|
orders.*,
|
||||||
materials.id AS materialid,
|
materials.id AS materialid,
|
||||||
pm.count*op.count AS count
|
pm.count*op.count AS count
|
||||||
|
Loading…
Reference in New Issue
Block a user