правки
This commit is contained in:
parent
f1259119a7
commit
cf3e7bd678
@ -1,13 +1,14 @@
|
|||||||
public enum Color
|
[Flags]
|
||||||
|
public enum Color
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Black = 1,
|
Black = 1,
|
||||||
Red = 2,
|
Red = 2,
|
||||||
Blue = 3,
|
Blue = 4,
|
||||||
Green = 4,
|
Green = 8,
|
||||||
Grey = 5,
|
Grey = 16,
|
||||||
Yellow = 6,
|
Yellow = 32,
|
||||||
Pink = 7,
|
Pink = 64,
|
||||||
White = 8,
|
White = 128,
|
||||||
Purple = 9,
|
Purple = 256,
|
||||||
}
|
}
|
||||||
|
@ -18,4 +18,12 @@ public class Model
|
|||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CreateList(IEnumerable<FabricModel> fabricModel)
|
||||||
|
{
|
||||||
|
if (fabricModel != null)
|
||||||
|
{
|
||||||
|
FabricModel = fabricModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,10 @@ namespace Atelier.Forms
|
|||||||
}
|
}
|
||||||
comboBoxModel.SelectedItem = model.ModelType;
|
comboBoxModel.SelectedItem = model.ModelType;
|
||||||
numericUpDownPrice.Value = (decimal)model.Price;
|
numericUpDownPrice.Value = (decimal)model.Price;
|
||||||
|
foreach (var fm in model.FabricModel)
|
||||||
|
{
|
||||||
|
dataGridView1.Rows.Add(new object[] { fm.FabricId, fm.Count });
|
||||||
|
}
|
||||||
_modelId = value;
|
_modelId = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -54,7 +58,7 @@ namespace Atelier.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (numericUpDownPrice.Value < 500 || dataGridView1.RowCount < 1 || comboBoxModel.SelectedIndex < 1)
|
if (numericUpDownPrice.Value < 500 || dataGridView1.RowCount < 1 || comboBoxModel.SelectedIndex < 1 )
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
@ -83,7 +87,7 @@ namespace Atelier.Forms
|
|||||||
|
|
||||||
foreach (DataGridViewRow row in dataGridView1.Rows)
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
@ -91,11 +95,12 @@ namespace Atelier.Forms
|
|||||||
int fabricId = Convert.ToInt32(row.Cells["ColumnFabric"].Value);
|
int fabricId = Convert.ToInt32(row.Cells["ColumnFabric"].Value);
|
||||||
int count = Convert.ToInt32(row.Cells["ColumnCount"].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);
|
return Model.CreateEntity(id, (ModelType)comboBoxModel.SelectedItem!, Convert.ToDouble(numericUpDownPrice.Value), fabricModels);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -63,7 +63,7 @@ namespace Atelier.Forms
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
list.Add(ModelOrder.CreateElement(0,
|
list.Add(ModelOrder.CreateElement(0,
|
||||||
Convert.ToInt32(row.Cells["ColumnFeed"].Value),
|
Convert.ToInt32(row.Cells["ColumnModel"].Value),
|
||||||
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
@ -127,16 +127,22 @@ internal class ModelRepository : IModelRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"SELECT * FROM Models
|
||||||
SELECT * FROM Models
|
WHERE Id = @id";
|
||||||
WHERE Id = @id";
|
|
||||||
var model = connection.QueryFirstOrDefault<Model>(querySelect, new { 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)
|
if (model == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Объект с идентификатором {id} не найден", id);
|
_logger.LogWarning("Объект с идентификатором {id} не найден", id);
|
||||||
throw new KeyNotFoundException($"Модель с идентификатором {id} не найдена");
|
throw new KeyNotFoundException($"Модель с идентификатором {id} не найдена");
|
||||||
}
|
}
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(model));
|
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(model));
|
||||||
|
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -146,6 +152,8 @@ internal class ModelRepository : IModelRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public IEnumerable<Model> ReadModels()
|
public IEnumerable<Model> ReadModels()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
@ -42,7 +42,7 @@ VALUES (@StockMetrage, @FabricId)";
|
|||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"
|
var queryDelete = @"
|
||||||
DELETE FROM Storades
|
DELETE FROM Storages
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
connection.Execute(queryDelete, new { id });
|
connection.Execute(queryDelete, new { id });
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user