теперь все работает

This commit is contained in:
VictoriaPresnyakova 2023-05-05 17:16:52 +04:00
parent 3b98ee933a
commit fd475481ef
2 changed files with 32 additions and 25 deletions

View File

@ -33,30 +33,6 @@ namespace TransportGuide
private void FormRoute_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logic.ReadElement(new RouteSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.Name;
textBoxIP.Text = view.IP.ToString();
_RouteStops = view.StopRoutes ?? new
Dictionary<int, (IStopModel, int)>();
LoadData();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
try
{
var list = _logicTT.ReadList(null);
@ -75,6 +51,36 @@ namespace TransportGuide
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (_id.HasValue)
{
try
{
var view = _logic.ReadElement(new RouteSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.Name;
textBoxIP.Text = view.IP.ToString();
comboBoxTransportType.Text = view.TransportTypeName;
_RouteStops = view.StopRoutes ?? new Dictionary<int, (IStopModel, int)>();
LoadData();
//foreach (var el in view.StopRoutes.Values)
//{
// dataGridView.Rows.Add(new object[] {el.Item1.Name, el.Item2});
//}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void LoadData()
{
@ -87,7 +93,6 @@ namespace TransportGuide
{
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.Name, pc.Value.Item2 });
}
//textBoxIP.Text = CalcIP().ToString();
}
}
catch (Exception ex)

View File

@ -66,6 +66,7 @@ namespace TransportGuideDatabaseImplements.Models
{
Name = model.Name;
IP = model.IP;
TransportTypeId = model.TransportTypeId;
}
public RouteViewModel GetViewModel
@ -80,6 +81,7 @@ namespace TransportGuideDatabaseImplements.Models
IP = IP,
Name = Name,
TransportTypeName = context.TransportTypes.FirstOrDefault(x => x.Id == TransportTypeId)?.Name ?? string.Empty,
StopRoutes = StopRoutes
};
}
}