Убрал лишнее перечисление
This commit is contained in:
parent
8f35937785
commit
07835de7ef
@ -8,15 +8,15 @@ public class Bus
|
||||
|
||||
public string LicensePlate { get; private set; } = string.Empty;
|
||||
|
||||
public BusType Type { get; private set; }
|
||||
public string Model { get; private set; } = string.Empty;
|
||||
|
||||
public static Bus CreateEntity(int id, string licensePlate, BusType type)
|
||||
public static Bus CreateEntity(int id, string licensePlate, string model)
|
||||
{
|
||||
return new Bus
|
||||
{
|
||||
Id = id,
|
||||
LicensePlate = licensePlate,
|
||||
Type = type
|
||||
Model = model
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
namespace ProjectPassengerTransportation.Entities.Enums;
|
||||
|
||||
public enum BusType
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Bus = 1,
|
||||
|
||||
Minibus = 2
|
||||
}
|
@ -33,7 +33,7 @@
|
||||
labelBusTypeName = new Label();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
comboBoxBusType = new ComboBox();
|
||||
textBoxModel = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelLicensePlate
|
||||
@ -84,21 +84,20 @@
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// comboBoxBusType
|
||||
// textBoxModel
|
||||
//
|
||||
comboBoxBusType.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxBusType.FormattingEnabled = true;
|
||||
comboBoxBusType.Location = new Point(231, 96);
|
||||
comboBoxBusType.Name = "comboBoxBusType";
|
||||
comboBoxBusType.Size = new Size(240, 38);
|
||||
comboBoxBusType.TabIndex = 8;
|
||||
textBoxModel.Location = new Point(231, 96);
|
||||
textBoxModel.MaxLength = 10;
|
||||
textBoxModel.Name = "textBoxModel";
|
||||
textBoxModel.Size = new Size(240, 35);
|
||||
textBoxModel.TabIndex = 8;
|
||||
//
|
||||
// FormBus
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(12F, 30F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(506, 226);
|
||||
Controls.Add(comboBoxBusType);
|
||||
Controls.Add(textBoxModel);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(labelBusTypeName);
|
||||
@ -118,6 +117,6 @@
|
||||
private Label labelBusTypeName;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private ComboBox comboBoxBusType;
|
||||
private TextBox textBoxModel;
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ namespace ProjectPassengerTransportation.Forms
|
||||
}
|
||||
|
||||
textBoxLicensePlate.Text = bus.LicensePlate;
|
||||
comboBoxBusType.SelectedItem = bus.Type;
|
||||
comboBoxBusType.SelectedItem = bus.Model;
|
||||
_busId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -38,14 +38,13 @@ namespace ProjectPassengerTransportation.Forms
|
||||
{
|
||||
InitializeComponent();
|
||||
_busRepository = busRepository ?? throw new ArgumentNullException(nameof(busRepository));
|
||||
comboBoxBusType.DataSource = Enum.GetValues(typeof(BusType));
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxLicensePlate.Text) || comboBoxBusType.SelectedIndex < 1)
|
||||
if (string.IsNullOrWhiteSpace(textBoxLicensePlate.Text) || string.IsNullOrWhiteSpace(textBoxModel.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
@ -69,6 +68,6 @@ namespace ProjectPassengerTransportation.Forms
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Bus CreateBus(int id) => Bus.CreateEntity(id, textBoxLicensePlate.Text, (BusType)comboBoxBusType.SelectedItem!);
|
||||
private Bus CreateBus(int id) => Bus.CreateEntity(id, textBoxLicensePlate.Text, textBoxModel.Text);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user