edit Forms
This commit is contained in:
parent
8fdc5bc1cc
commit
324abc8c74
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
@ -78,13 +79,7 @@ namespace SushiBar
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Load components");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
@ -29,7 +30,6 @@ namespace SushiBar
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
if (service == null) return;
|
||||
service.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (service.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -82,13 +82,7 @@ namespace SushiBar
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFio"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Load implementers");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace SushiBar
|
||||
@ -20,14 +21,7 @@ namespace SushiBar
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["MessageId"].Visible = false;
|
||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Load mails");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
8
SushiBar/SushiBar/FormMain.Designer.cs
generated
8
SushiBar/SushiBar/FormMain.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
this.componentsOnSushiToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.listOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.startWorkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.createBackUpMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonSubmit = new System.Windows.Forms.Button();
|
||||
this.buttonReady = new System.Windows.Forms.Button();
|
||||
@ -65,6 +66,7 @@
|
||||
this.directoryToolStripMenuItem,
|
||||
this.reportsToolStripMenuItem,
|
||||
this.startWorkToolStripMenuItem,
|
||||
this.createBackUpMenuItem,
|
||||
this.mailsToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
@ -148,6 +150,11 @@
|
||||
this.startWorkToolStripMenuItem.Size = new System.Drawing.Size(72, 20);
|
||||
this.startWorkToolStripMenuItem.Text = "Start work";
|
||||
this.startWorkToolStripMenuItem.Click += new System.EventHandler(this.StartWorkToolStripMenuItem_Click);
|
||||
|
||||
this.createBackUpMenuItem.Name = "createBackUpMenuItem";
|
||||
this.createBackUpMenuItem.Size = new System.Drawing.Size(72, 20);
|
||||
this.createBackUpMenuItem.Text = "Create backup";
|
||||
this.createBackUpMenuItem.Click += new System.EventHandler(this.CreateBackupStripMenuItem_Click);
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
@ -248,6 +255,7 @@
|
||||
private ToolStripMenuItem listOrdersToolStripMenuItem;
|
||||
private ToolStripMenuItem clientsToolStripMenuItem;
|
||||
private ToolStripMenuItem startWorkToolStripMenuItem;
|
||||
private ToolStripMenuItem createBackUpMenuItem;
|
||||
private ToolStripMenuItem implementersToolStripMenuItem;
|
||||
private ToolStripMenuItem mailsToolStripMenuItem;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ namespace SushiBar
|
||||
SushiComponents = _sushiComponents
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) :
|
||||
_logic.Create(model);
|
||||
_logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Error on saving. Additional info below.");
|
||||
|
@ -10,14 +10,8 @@ namespace SushiBar
|
||||
private readonly List<ComponentViewModel>? _list;
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxComponent.SelectedValue = value;
|
||||
}
|
||||
get => Convert.ToInt32(comboBoxComponent.SelectedValue);
|
||||
set => comboBoxComponent.SelectedValue = value;
|
||||
}
|
||||
public IComponentModel? ComponentModel
|
||||
{
|
||||
@ -39,21 +33,19 @@ namespace SushiBar
|
||||
}
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||
set { textBoxCount.Text = value.ToString(); }
|
||||
get => Convert.ToInt32(textBoxCount.Text);
|
||||
set => textBoxCount.Text = value.ToString();
|
||||
}
|
||||
|
||||
public FormSushiComponent(IComponentLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_list = logic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
comboBoxComponent.DisplayMember = "ComponentName";
|
||||
comboBoxComponent.ValueMember = "Id";
|
||||
comboBoxComponent.DataSource = _list;
|
||||
comboBoxComponent.SelectedItem = null;
|
||||
}
|
||||
if (_list == null) return;
|
||||
comboBoxComponent.DisplayMember = "ComponentName";
|
||||
comboBoxComponent.ValueMember = "Id";
|
||||
comboBoxComponent.DataSource = _list;
|
||||
comboBoxComponent.SelectedItem = null;
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.Attributes;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.DI;
|
||||
@ -20,14 +21,7 @@ namespace SushiBar
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["SushiName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["SushiComponents"].Visible = false;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Load sushi");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -40,53 +34,42 @@ namespace SushiBar
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormSushi>();
|
||||
if (service is FormSushi form)
|
||||
if (service.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
var service = DependencyManager.Instance.Resolve<FormSushi>();
|
||||
service.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (service.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormSushi>();
|
||||
if (service is FormSushi form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (dataGridView.SelectedRows.Count != 1) return;
|
||||
if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
|
||||
DialogResult.Yes) return;
|
||||
var id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Delete sushi");
|
||||
try
|
||||
{
|
||||
if (MessageBox.Show("Delete record?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
if (!_logic.Delete(new SushiBindingModel { Id = id }))
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Delete sushi");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new SushiBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Error on deleting. Additional info below.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error delete sushi");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
throw new Exception("Error on deleting. Additional info below.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error delete sushi");
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,25 +22,23 @@ namespace SushiBar
|
||||
{
|
||||
Filter = "xlsx|*.xlsx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
if (dialog.ShowDialog() != DialogResult.OK) return;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveProductComponentToExcelFile(new
|
||||
_logic.SaveProductComponentToExcelFile(new
|
||||
ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
_logger.LogInformation("Saving list sushi on components");
|
||||
_logger.LogInformation("Saving list sushi on components");
|
||||
|
||||
MessageBox.Show("Success", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
||||
MessageBox.Show("Success", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
||||
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
@ -50,19 +48,16 @@ namespace SushiBar
|
||||
try
|
||||
{
|
||||
var dict = _logic.GetSushi();
|
||||
if (dict != null)
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in dict)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in dict)
|
||||
dataGridView.Rows.Add(elem.SushiName, "", "");
|
||||
foreach (var listElem in elem.Components)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { elem.SushiName, "", "" });
|
||||
foreach (var listElem in elem.Components)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||
}
|
||||
dataGridView.Rows.Add(new object[] { "Count", "", elem.TotalCount });
|
||||
dataGridView.Rows.Add(Array.Empty<object>());
|
||||
dataGridView.Rows.Add("", listElem.Item1, listElem.Item2);
|
||||
}
|
||||
dataGridView.Rows.Add("Count", "", elem.TotalCount);
|
||||
dataGridView.Rows.Add(Array.Empty<object>());
|
||||
}
|
||||
_logger.LogInformation("Load list sushi on components");
|
||||
}
|
||||
|
@ -82,11 +82,6 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
{
|
||||
_logger.LogInformation("ReadList .Id:{Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
using SushiBarContracts.DI;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarDatabaseImplement.Implements;
|
||||
|
||||
namespace SushiBarDatabaseImplement;
|
||||
|
||||
public class DatabaseImplementationExtension : IImplementationExtension
|
||||
{
|
||||
public int Priority => 2;
|
||||
|
||||
public void RegisterServices()
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageStorage>();
|
||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
@ -19,4 +19,8 @@
|
||||
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(targetDir)*.dll" "$(solutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user