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