правки

This commit is contained in:
vettaql 2024-12-20 20:48:44 +04:00
parent f1259119a7
commit cf3e7bd678
6 changed files with 40 additions and 18 deletions

View File

@ -1,13 +1,14 @@
public enum Color
[Flags]
public enum Color
{
None = 0,
Black = 1,
Red = 2,
Blue = 3,
Green = 4,
Grey = 5,
Yellow = 6,
Pink = 7,
White = 8,
Purple = 9,
Blue = 4,
Green = 8,
Grey = 16,
Yellow = 32,
Pink = 64,
White = 128,
Purple = 256,
}

View File

@ -18,4 +18,12 @@ public class Model
};
}
public void CreateList(IEnumerable<FabricModel> fabricModel)
{
if (fabricModel != null)
{
FabricModel = fabricModel;
}
}
}

View File

@ -30,6 +30,10 @@ namespace Atelier.Forms
}
comboBoxModel.SelectedItem = model.ModelType;
numericUpDownPrice.Value = (decimal)model.Price;
foreach (var fm in model.FabricModel)
{
dataGridView1.Rows.Add(new object[] { fm.FabricId, fm.Count });
}
_modelId = value;
}
catch (Exception ex)
@ -83,7 +87,7 @@ namespace Atelier.Forms
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells["ColumnFabric"].Value == null || row.Cells["ColumnCount"].Value == null || !(bool)row.Cells["CheckBoxColumn"].Value)
if (row.Cells["ColumnFabric"].Value == null || row.Cells["ColumnCount"].Value == null)
{
continue;
}
@ -91,11 +95,12 @@ namespace Atelier.Forms
int fabricId = Convert.ToInt32(row.Cells["ColumnFabric"].Value);
int count = Convert.ToInt32(row.Cells["ColumnCount"].Value);
fabricModels.Add(FabricModel.CreateElement(0, fabricId, count));
fabricModels.Add(FabricModel.CreateElement(fabricId, 0, count));
}
return Model.CreateEntity(id, (ModelType)comboBoxModel.SelectedItem!, Convert.ToDouble(numericUpDownPrice.Value), fabricModels);
}
}
}
}

View File

@ -63,7 +63,7 @@ namespace Atelier.Forms
continue;
}
list.Add(ModelOrder.CreateElement(0,
Convert.ToInt32(row.Cells["ColumnFeed"].Value),
Convert.ToInt32(row.Cells["ColumnModel"].Value),
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;

View File

@ -127,16 +127,22 @@ internal class ModelRepository : IModelRepository
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Models
var querySelect = @"SELECT * FROM Models
WHERE Id = @id";
var model = connection.QueryFirstOrDefault<Model>(querySelect, new { id });
var querySelectSub = @$"SELECT *
FROM FabricModel fm
WHERE ModelId = {id}";
var fabricModel = connection.Query<FabricModel>(querySelectSub);
model.CreateList(fabricModel);
if (model == null)
{
_logger.LogWarning("Объект с идентификатором {id} не найден", id);
throw new KeyNotFoundException($"Модель с идентификатором {id} не найдена");
}
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(model));
return model;
}
catch (Exception ex)
@ -146,6 +152,8 @@ internal class ModelRepository : IModelRepository
}
}
public IEnumerable<Model> ReadModels()
{
_logger.LogInformation("Получение всех объектов");

View File

@ -42,7 +42,7 @@ VALUES (@StockMetrage, @FabricId)";
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Storades
DELETE FROM Storages
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}