This commit is contained in:
kamilia 2024-05-18 13:01:50 +04:00
parent 843569550f
commit 81a061363e
14 changed files with 42 additions and 41 deletions

View File

@ -27,7 +27,7 @@ namespace RouteDirectoryContracts.BindingModels
/// <summary> /// <summary>
/// Периодичность движения транспорта /// Периодичность движения транспорта
/// </summary> /// </summary>
public DateTime TrafficInterval { get; set; } = DateTime.MinValue; public int TrafficInterval { get; set; }
/// <summary> /// <summary>
/// Идентификатор маршрута /// Идентификатор маршрута

View File

@ -36,6 +36,11 @@ namespace RouteDirectoryContracts.ViewModels
/// </summary> /// </summary>
public int TransportId { get; set; } public int TransportId { get; set; }
public RouteViewModel()
{
Fare = 30;
}
/// <summary> /// <summary>
/// Коллекция остановок маршрута /// Коллекция остановок маршрута
/// </summary> /// </summary>

View File

@ -31,7 +31,7 @@ namespace RouteDirectoryContracts.ViewModels
/// Периодичность движения транспорта /// Периодичность движения транспорта
/// </summary> /// </summary>
[DisplayName("Периодичность движения транспорта")] [DisplayName("Периодичность движения транспорта")]
public DateTime TrafficInterval { get; set; } = DateTime.MinValue; public int TrafficInterval { get; set; }
/// <summary> /// <summary>
/// Идентификатор маршрута /// Идентификатор маршрута

View File

@ -21,7 +21,7 @@ namespace RouteDirectoryDataModels.Models
/// <summary> /// <summary>
/// Периодичность движения транспорта /// Периодичность движения транспорта
/// </summary> /// </summary>
DateTime TrafficInterval { get; } int TrafficInterval { get; }
/// <summary> /// <summary>
/// Идентификатор маршрута /// Идентификатор маршрута

View File

@ -12,7 +12,7 @@ using RouteDirectoryDatabaseImplement;
namespace RouteDirectoryDatabaseImplement.Migrations namespace RouteDirectoryDatabaseImplement.Migrations
{ {
[DbContext(typeof(RouteDirectoryDatabase))] [DbContext(typeof(RouteDirectoryDatabase))]
[Migration("20240514183729_InitMigration")] [Migration("20240515054308_InitMigration")]
partial class InitMigration partial class InitMigration
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -96,8 +96,8 @@ namespace RouteDirectoryDatabaseImplement.Migrations
b.Property<DateTime>("StartTime") b.Property<DateTime>("StartTime")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<DateTime>("TrafficInterval") b.Property<int>("TrafficInterval")
.HasColumnType("datetime2"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");

View File

@ -97,7 +97,7 @@ namespace RouteDirectoryDatabaseImplement.Migrations
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
StartTime = table.Column<DateTime>(type: "datetime2", nullable: false), StartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
EndTime = table.Column<DateTime>(type: "datetime2", nullable: false), EndTime = table.Column<DateTime>(type: "datetime2", nullable: false),
TrafficInterval = table.Column<DateTime>(type: "datetime2", nullable: false), TrafficInterval = table.Column<int>(type: "int", nullable: false),
RouteId = table.Column<int>(type: "int", nullable: false) RouteId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>

View File

@ -93,8 +93,8 @@ namespace RouteDirectoryDatabaseImplement.Migrations
b.Property<DateTime>("StartTime") b.Property<DateTime>("StartTime")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<DateTime>("TrafficInterval") b.Property<int>("TrafficInterval")
.HasColumnType("datetime2"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");

View File

@ -37,7 +37,7 @@ namespace RouteDirectoryDatabaseImplement.Models
/// Периодичность движения транспорта /// Периодичность движения транспорта
/// </summary> /// </summary>
[Required] [Required]
public DateTime TrafficInterval { get; private set; } = DateTime.MinValue; public int TrafficInterval { get; private set; }
/// <summary> /// <summary>
/// Идентификатор маршрута /// Идентификатор маршрута

View File

@ -8,22 +8,13 @@ using System.Threading.Tasks;
namespace RouteDirectoryDatabaseImplement namespace RouteDirectoryDatabaseImplement
{ {
public class RouteGuideDatabase : DbContext public class RouteDirectoryDatabase : DbContext
{ {
/// <summary>
/// Параметры подключения к базе данных
/// </summary>
private string _dbConnectionString = "Host=192.168.56.102;Port=5432;Database=postgres;Username=postgres;Password=зщыепкуы";
/// <summary>
/// Подключение к базе данных
/// </summary>
/// <param name="optionsBuilder"></param>
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseNpgsql(_dbConnectionString); optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-6QDRI0N\SQLEXPRESS;Initial Catalog=NewRouteDirectoryDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -67,21 +67,21 @@
// транспортToolStripMenuItem // транспортToolStripMenuItem
// //
транспортToolStripMenuItem.Name = ранспортToolStripMenuItem"; транспортToolStripMenuItem.Name = ранспортToolStripMenuItem";
транспортToolStripMenuItem.Size = new Size(224, 26); транспортToolStripMenuItem.Size = new Size(167, 26);
транспортToolStripMenuItem.Text = "Транспорт"; транспортToolStripMenuItem.Text = "Транспорт";
транспортToolStripMenuItem.Click += TransportToolStripMenuItem_Click; транспортToolStripMenuItem.Click += TransportToolStripMenuItem_Click;
// //
// маршрутыToolStripMenuItem // маршрутыToolStripMenuItem
// //
маршрутыToolStripMenuItem.Name = аршрутыToolStripMenuItem"; маршрутыToolStripMenuItem.Name = аршрутыToolStripMenuItem";
маршрутыToolStripMenuItem.Size = new Size(224, 26); маршрутыToolStripMenuItem.Size = new Size(167, 26);
маршрутыToolStripMenuItem.Text = "Маршруты"; маршрутыToolStripMenuItem.Text = "Маршруты";
маршрутыToolStripMenuItem.Click += RoutesToolStripMenuItem_Click; маршрутыToolStripMenuItem.Click += RoutesToolStripMenuItem_Click;
// //
// остановкиToolStripMenuItem // остановкиToolStripMenuItem
// //
остановкиToolStripMenuItem.Name = "остановкиToolStripMenuItem"; остановкиToolStripMenuItem.Name = "остановкиToolStripMenuItem";
остановкиToolStripMenuItem.Size = new Size(224, 26); остановкиToolStripMenuItem.Size = new Size(167, 26);
остановкиToolStripMenuItem.Text = "Остановки"; остановкиToolStripMenuItem.Text = "Остановки";
остановкиToolStripMenuItem.Click += StopsToolStripMenuItem_Click; остановкиToolStripMenuItem.Click += StopsToolStripMenuItem_Click;
// //
@ -95,28 +95,28 @@
// транспортToolStripMenuItem1 // транспортToolStripMenuItem1
// //
транспортToolStripMenuItem1.Name = ранспортToolStripMenuItem1"; транспортToolStripMenuItem1.Name = ранспортToolStripMenuItem1";
транспортToolStripMenuItem1.Size = new Size(224, 26); транспортToolStripMenuItem1.Size = new Size(174, 26);
транспортToolStripMenuItem1.Text = "Транспорт"; транспортToolStripMenuItem1.Text = "Транспорт";
транспортToolStripMenuItem1.Click += TransportTestsToolStripMenuItem_Click; транспортToolStripMenuItem1.Click += TransportTestsToolStripMenuItem_Click;
// //
// маршрутыToolStripMenuItem1 // маршрутыToolStripMenuItem1
// //
маршрутыToolStripMenuItem1.Name = аршрутыToolStripMenuItem1"; маршрутыToolStripMenuItem1.Name = аршрутыToolStripMenuItem1";
маршрутыToolStripMenuItem1.Size = new Size(224, 26); маршрутыToolStripMenuItem1.Size = new Size(174, 26);
маршрутыToolStripMenuItem1.Text = "Маршруты"; маршрутыToolStripMenuItem1.Text = "Маршруты";
маршрутыToolStripMenuItem1.Click += RoutesTestsToolStripMenuItem_Click; маршрутыToolStripMenuItem1.Click += RoutesTestsToolStripMenuItem_Click;
// //
// остановкиToolStripMenuItem1 // остановкиToolStripMenuItem1
// //
остановкиToolStripMenuItem1.Name = "остановкиToolStripMenuItem1"; остановкиToolStripMenuItem1.Name = "остановкиToolStripMenuItem1";
остановкиToolStripMenuItem1.Size = new Size(224, 26); остановкиToolStripMenuItem1.Size = new Size(174, 26);
остановкиToolStripMenuItem1.Text = "Остановки"; остановкиToolStripMenuItem1.Text = "Остановки";
остановкиToolStripMenuItem1.Click += StopsTestsToolStripMenuItem_Click; остановкиToolStripMenuItem1.Click += StopsTestsToolStripMenuItem_Click;
// //
// расписанияToolStripMenuItem // расписанияToolStripMenuItem
// //
расписанияToolStripMenuItem.Name = "расписанияToolStripMenuItem"; расписанияToolStripMenuItem.Name = "расписанияToolStripMenuItem";
расписанияToolStripMenuItem.Size = new Size(224, 26); расписанияToolStripMenuItem.Size = new Size(174, 26);
расписанияToolStripMenuItem.Text = "Расписания"; расписанияToolStripMenuItem.Text = "Расписания";
расписанияToolStripMenuItem.Click += SchedulesTestsToolStripMenuItem_Click; расписанияToolStripMenuItem.Click += SchedulesTestsToolStripMenuItem_Click;
// //

View File

@ -120,4 +120,7 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root> </root>

View File

@ -35,9 +35,10 @@
comboBoxRoute = new ComboBox(); comboBoxRoute = new ComboBox();
dateTimePickerStart = new DateTimePicker(); dateTimePickerStart = new DateTimePicker();
dateTimePickerEnd = new DateTimePicker(); dateTimePickerEnd = new DateTimePicker();
dateTimePickerTrafficInterval = new DateTimePicker();
buttonSave = new Button(); buttonSave = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
numericUpDown = new NumericUpDown();
((System.ComponentModel.ISupportInitialize)numericUpDown).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// labelRoute // labelRoute
@ -98,13 +99,6 @@
dateTimePickerEnd.Size = new Size(250, 27); dateTimePickerEnd.Size = new Size(250, 27);
dateTimePickerEnd.TabIndex = 6; dateTimePickerEnd.TabIndex = 6;
// //
// dateTimePickerTrafficInterval
//
dateTimePickerTrafficInterval.Location = new Point(200, 179);
dateTimePickerTrafficInterval.Name = "dateTimePickerTrafficInterval";
dateTimePickerTrafficInterval.Size = new Size(250, 27);
dateTimePickerTrafficInterval.TabIndex = 7;
//
// buttonSave // buttonSave
// //
buttonSave.Location = new Point(243, 235); buttonSave.Location = new Point(243, 235);
@ -125,14 +119,21 @@
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click; buttonCancel.Click += buttonCancel_Click;
// //
// numericUpDown
//
numericUpDown.Location = new Point(200, 179);
numericUpDown.Name = "numericUpDown";
numericUpDown.Size = new Size(250, 27);
numericUpDown.TabIndex = 10;
//
// FormSchedule // FormSchedule
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(469, 275); ClientSize = new Size(469, 275);
Controls.Add(numericUpDown);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(dateTimePickerTrafficInterval);
Controls.Add(dateTimePickerEnd); Controls.Add(dateTimePickerEnd);
Controls.Add(dateTimePickerStart); Controls.Add(dateTimePickerStart);
Controls.Add(comboBoxRoute); Controls.Add(comboBoxRoute);
@ -143,6 +144,7 @@
Name = "FormSchedule"; Name = "FormSchedule";
Text = "FormSchedule"; Text = "FormSchedule";
Load += FormSchedule_Load; Load += FormSchedule_Load;
((System.ComponentModel.ISupportInitialize)numericUpDown).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
@ -156,8 +158,8 @@
private ComboBox comboBoxRoute; private ComboBox comboBoxRoute;
private DateTimePicker dateTimePickerStart; private DateTimePicker dateTimePickerStart;
private DateTimePicker dateTimePickerEnd; private DateTimePicker dateTimePickerEnd;
private DateTimePicker dateTimePickerTrafficInterval;
private Button buttonSave; private Button buttonSave;
private Button buttonCancel; private Button buttonCancel;
private NumericUpDown numericUpDown;
} }
} }

View File

@ -99,7 +99,7 @@ namespace RouteDirectoryView
comboBoxRoute.SelectedItem = view.RouteId; comboBoxRoute.SelectedItem = view.RouteId;
dateTimePickerStart.Value = view.StartTime; dateTimePickerStart.Value = view.StartTime;
dateTimePickerEnd.Value = view.EndTime; dateTimePickerEnd.Value = view.EndTime;
dateTimePickerTrafficInterval.Value = view.TrafficInterval; numericUpDown.Value = view.TrafficInterval;
} }
} }
catch (Exception ex1) catch (Exception ex1)
@ -135,7 +135,7 @@ namespace RouteDirectoryView
Id = _id ?? 0, Id = _id ?? 0,
StartTime = dateTimePickerStart.Value, StartTime = dateTimePickerStart.Value,
EndTime = dateTimePickerEnd.Value, EndTime = dateTimePickerEnd.Value,
TrafficInterval = dateTimePickerTrafficInterval.Value, TrafficInterval = (int)numericUpDown.Value,
RouteId = Convert.ToInt32(comboBoxRoute.SelectedValue) RouteId = Convert.ToInt32(comboBoxRoute.SelectedValue)
}; };

View File

@ -75,7 +75,7 @@ namespace RouteDirectoryView
Id = 0, Id = 0,
StartTime = DateTime.MinValue, StartTime = DateTime.MinValue,
EndTime = DateTime.MaxValue, EndTime = DateTime.MaxValue,
TrafficInterval = DateTime.MinValue, TrafficInterval = int.MinValue,
RouteId = routeId RouteId = routeId
}; };