177 lines
6.2 KiB
C#
177 lines
6.2 KiB
C#
|
|
using Subd_4.BindingModels;
|
|
using Subd_4.BusinessLogicContracts;
|
|
|
|
namespace viewmodel
|
|
{
|
|
public partial class FormMain : Form
|
|
{
|
|
|
|
private readonly IProjectLogic _logic;
|
|
|
|
public FormMain(IProjectLogic logic)
|
|
{
|
|
InitializeComponent();
|
|
_logic = logic;
|
|
}
|
|
|
|
private void buyerToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
|
if (service is FormClients form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void cookToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormTeams));
|
|
if (service is FormTeams form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void placeToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormEmployees));
|
|
if (service is FormEmployees form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void menuToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormConstructionMaterials));
|
|
if (service is FormConstructionMaterials form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void FormMain_Load(object sender, EventArgs e)
|
|
{
|
|
LoadData();
|
|
}
|
|
|
|
private void LoadData()
|
|
{
|
|
var _list = _logic.ReadList(null);
|
|
if (_list != null)
|
|
{
|
|
dataGridView.DataSource = _list;
|
|
dataGridView.Columns["CliendId"].Visible = false;
|
|
dataGridView.Columns["EmployeeId"].Visible = false;
|
|
dataGridView.Columns["ConstructionMaterialProjects"].Visible = false;
|
|
dataGridView.Columns["TeamProject"].Visible = false;
|
|
|
|
}
|
|
}
|
|
|
|
private void buttonCreateTask_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateProject));
|
|
if (service is FormCreateProject form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
|
|
private void buttonTakeTaskInWork_Click(object sender, EventArgs e)
|
|
{
|
|
if (dataGridView.SelectedRows.Count == 1)
|
|
{
|
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
try
|
|
{
|
|
var operationResult = _logic.TakeProjectInWork(new ProjectBindingModel
|
|
{
|
|
Id = id,
|
|
Status = Enum.Parse<ConstructionFirmDataModels.Enum.TaskStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
|
});
|
|
if (!operationResult)
|
|
{
|
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
}
|
|
LoadData();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void buttonTaskReady_Click(object sender, EventArgs e)
|
|
{
|
|
if (dataGridView.SelectedRows.Count == 1)
|
|
{
|
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
try
|
|
{
|
|
var operationResult = _logic.FinishProject(new ProjectBindingModel
|
|
{
|
|
Id = id,
|
|
Status = Enum.Parse<ConstructionFirmDataModels.Enum.TaskStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
|
});
|
|
if (!operationResult)
|
|
{
|
|
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
|
}
|
|
LoadData();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void buttonIssuedTask_Click(object sender, EventArgs e)
|
|
{
|
|
if (dataGridView.SelectedRows.Count == 1)
|
|
{
|
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
try
|
|
{
|
|
var operationResult = _logic.DeliveryProject(new ProjectBindingModel
|
|
{
|
|
Id = id,
|
|
Status = Enum.Parse<ConstructionFirmDataModels.Enum.TaskStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
|
});
|
|
if (!operationResult)
|
|
{
|
|
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
|
}
|
|
LoadData();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void buttonTest_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
//CookBindingModel model = new CookBindingModel()
|
|
//{
|
|
// Id = 2,
|
|
// CookName = "Иван",
|
|
// CookSurname = "dssfsdfs",
|
|
// Experience = 2,
|
|
// PhoneNumber = "+79054324312",
|
|
// Passport = "123124"
|
|
//};
|
|
|
|
//DateTime start = DateTime.Now;
|
|
//_CLogic.Delete(model);
|
|
//DateTime stop = DateTime.Now;
|
|
//MessageBox.Show((start - stop).ToString(), "Test", MessageBoxButtons.OK);
|
|
}
|
|
}
|
|
} |