Лабараторная 1 V2.1

This commit is contained in:
RomaEredavkin 2024-12-10 12:31:06 +04:00
parent 9d4c05a076
commit d30d0181c9
12 changed files with 94 additions and 67 deletions

View File

@ -5,11 +5,12 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities.Enums; namespace PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
[Flags]
public enum EmployeePost public enum EmployeePost
{ {
None = 0, None = 0,
Conductor = 1, Conductor = 1,
Driver = 2, Driver = 2,
Mechanic = 3 Mechanic = 4,
Boss = 8,
} }

View File

@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities.Enums; namespace PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
[Flags]
public enum ModelType public enum ModelType
{ {
None = 0, None = 0,
@ -14,7 +14,7 @@ public enum ModelType
Gaz = 2, Gaz = 2,
Mercedes = 4, Mercedes = 3,
Ford = 8 Ford = 4
} }

View File

@ -32,12 +32,12 @@
labelNZ = new Label(); labelNZ = new Label();
labelMileage = new Label(); labelMileage = new Label();
labelCpacity = new Label(); labelCpacity = new Label();
textBoxtModel = new TextBox();
textBoxNZ = new TextBox(); textBoxNZ = new TextBox();
Mileage = new NumericUpDown(); Mileage = new NumericUpDown();
numericUpDownCapacity = new NumericUpDown(); numericUpDownCapacity = new NumericUpDown();
buttonSave = new Button(); buttonSave = new Button();
buttonleave = new Button(); buttonleave = new Button();
comboBoxBus = new ComboBox();
((System.ComponentModel.ISupportInitialize)Mileage).BeginInit(); ((System.ComponentModel.ISupportInitialize)Mileage).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).BeginInit();
SuspendLayout(); SuspendLayout();
@ -78,18 +78,11 @@
labelCpacity.TabIndex = 3; labelCpacity.TabIndex = 3;
labelCpacity.Text = "Максимально Количество пассажиров"; labelCpacity.Text = "Максимально Количество пассажиров";
// //
// textBoxtModel
//
textBoxtModel.Location = new Point(182, 21);
textBoxtModel.Name = "textBoxtModel";
textBoxtModel.Size = new Size(405, 23);
textBoxtModel.TabIndex = 4;
//
// textBoxNZ // textBoxNZ
// //
textBoxNZ.Location = new Point(182, 59); textBoxNZ.Location = new Point(182, 59);
textBoxNZ.Name = "textBoxNZ"; textBoxNZ.Name = "textBoxNZ";
textBoxNZ.Size = new Size(285, 23); textBoxNZ.Size = new Size(386, 23);
textBoxNZ.TabIndex = 5; textBoxNZ.TabIndex = 5;
// //
// Mileage // Mileage
@ -102,6 +95,7 @@
// //
// numericUpDownCapacity // numericUpDownCapacity
// //
numericUpDownCapacity.DecimalPlaces = 2;
numericUpDownCapacity.Location = new Point(267, 145); numericUpDownCapacity.Location = new Point(267, 145);
numericUpDownCapacity.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); numericUpDownCapacity.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownCapacity.Name = "numericUpDownCapacity"; numericUpDownCapacity.Name = "numericUpDownCapacity";
@ -128,17 +122,26 @@
buttonleave.UseVisualStyleBackColor = true; buttonleave.UseVisualStyleBackColor = true;
buttonleave.Click += buttonleave_Click; buttonleave.Click += buttonleave_Click;
// //
// comboBoxBus
//
comboBoxBus.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxBus.FormattingEnabled = true;
comboBoxBus.Location = new Point(182, 16);
comboBoxBus.Name = "comboBoxBus";
comboBoxBus.Size = new Size(386, 23);
comboBoxBus.TabIndex = 16;
//
// FormBus // FormBus
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(601, 307); ClientSize = new Size(601, 307);
Controls.Add(comboBoxBus);
Controls.Add(buttonleave); Controls.Add(buttonleave);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(numericUpDownCapacity); Controls.Add(numericUpDownCapacity);
Controls.Add(Mileage); Controls.Add(Mileage);
Controls.Add(textBoxNZ); Controls.Add(textBoxNZ);
Controls.Add(textBoxtModel);
Controls.Add(labelCpacity); Controls.Add(labelCpacity);
Controls.Add(labelMileage); Controls.Add(labelMileage);
Controls.Add(labelNZ); Controls.Add(labelNZ);
@ -158,11 +161,11 @@
private Label labelNZ; private Label labelNZ;
private Label labelMileage; private Label labelMileage;
private Label labelCpacity; private Label labelCpacity;
private TextBox textBoxtModel;
private TextBox textBoxNZ; private TextBox textBoxNZ;
private NumericUpDown Mileage; private NumericUpDown Mileage;
private NumericUpDown numericUpDownCapacity; private NumericUpDown numericUpDownCapacity;
private Button buttonSave; private Button buttonSave;
private Button buttonleave; private Button buttonleave;
private ComboBox comboBoxBus;
} }
} }

View File

@ -28,7 +28,7 @@ public partial class FormBus : Form
{ {
throw new InvalidDataException(nameof(bus)); throw new InvalidDataException(nameof(bus));
} }
textBoxtModel.Text = bus.Model; comboBoxBus.Text = bus.Model;
textBoxNZ.Text = bus.N_Z; textBoxNZ.Text = bus.N_Z;
Mileage.Value = bus.Bus_mileage; Mileage.Value = bus.Bus_mileage;
numericUpDownCapacity.Value = bus.Capacity; numericUpDownCapacity.Value = bus.Capacity;
@ -54,7 +54,7 @@ public partial class FormBus : Form
{ {
try try
{ {
if (string.IsNullOrWhiteSpace(textBoxtModel.Text) ||string.IsNullOrWhiteSpace(textBoxNZ.Text)) if (string.IsNullOrWhiteSpace(comboBoxBus.Text) ||string.IsNullOrWhiteSpace(textBoxNZ.Text))
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
@ -78,7 +78,7 @@ public partial class FormBus : Form
private void buttonleave_Click(object sender, EventArgs e) => Close(); private void buttonleave_Click(object sender, EventArgs e) => Close();
private Bus CreateBus(int id) => Bus.CreateEntity(id, private Bus CreateBus(int id) => Bus.CreateEntity(id,
textBoxtModel.Text, comboBoxBus.Text,
textBoxNZ.Text, textBoxNZ.Text,
Convert.ToInt32(Mileage.Value), Convert.ToInt32(Mileage.Value),
Convert.ToInt32(numericUpDownCapacity.Value)); Convert.ToInt32(numericUpDownCapacity.Value));

View File

@ -79,17 +79,20 @@
dataGridViewRoutSheet.Columns.AddRange(new DataGridViewColumn[] { ColumnBus }); dataGridViewRoutSheet.Columns.AddRange(new DataGridViewColumn[] { ColumnBus });
dataGridViewRoutSheet.Dock = DockStyle.Fill; dataGridViewRoutSheet.Dock = DockStyle.Fill;
dataGridViewRoutSheet.Location = new Point(3, 19); dataGridViewRoutSheet.Location = new Point(3, 19);
dataGridViewRoutSheet.MultiSelect = false;
dataGridViewRoutSheet.Name = "dataGridViewRoutSheet"; dataGridViewRoutSheet.Name = "dataGridViewRoutSheet";
dataGridViewRoutSheet.RowHeadersVisible = false;
dataGridViewRoutSheet.Size = new Size(244, 365); dataGridViewRoutSheet.Size = new Size(244, 365);
dataGridViewRoutSheet.TabIndex = 0; dataGridViewRoutSheet.TabIndex = 0;
// //
// ColumnBus // ColumnBus
// //
ColumnBus.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; ColumnBus.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnBus.DisplayStyleForCurrentCellOnly = true;
ColumnBus.HeaderText = "Автобус"; ColumnBus.HeaderText = "Автобус";
ColumnBus.Name = "ColumnBus"; ColumnBus.Name = "ColumnBus";
ColumnBus.Resizable = DataGridViewTriState.True; ColumnBus.Resizable = DataGridViewTriState.True;
ColumnBus.SortMode = DataGridViewColumnSortMode.Automatic; ColumnBus.Sorted = true;
// //
// label1 // label1
// //

View File

@ -30,16 +30,16 @@
{ {
panel1 = new Panel(); panel1 = new Panel();
buttonadd = new Button(); buttonadd = new Button();
dataGridView1 = new DataGridView(); dataGridViewData = new DataGridView();
panel1.SuspendLayout(); panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// panel1 // panel1
// //
panel1.Controls.Add(buttonadd); panel1.Controls.Add(buttonadd);
panel1.Dock = DockStyle.Right; panel1.Dock = DockStyle.Right;
panel1.Location = new Point(640, 0); panel1.Location = new Point(656, 0);
panel1.Name = "panel1"; panel1.Name = "panel1";
panel1.Size = new Size(160, 450); panel1.Size = new Size(160, 450);
panel1.TabIndex = 0; panel1.TabIndex = 0;
@ -55,37 +55,43 @@
buttonadd.UseVisualStyleBackColor = true; buttonadd.UseVisualStyleBackColor = true;
buttonadd.Click += buttonadd_Click; buttonadd.Click += buttonadd_Click;
// //
// dataGridView1 // dataGridViewData
// //
dataGridView1.AllowUserToAddRows = false; dataGridViewData.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false; dataGridViewData.AllowUserToDeleteRows = false;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewData.AllowUserToResizeColumns = false;
dataGridView1.Dock = DockStyle.Fill; dataGridViewData.AllowUserToResizeRows = false;
dataGridView1.Location = new Point(0, 0); dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.Name = "dataGridView1"; dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.ReadOnly = true; dataGridViewData.Dock = DockStyle.Fill;
dataGridView1.Size = new Size(640, 450); dataGridViewData.Location = new Point(0, 0);
dataGridView1.TabIndex = 1; dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(656, 450);
dataGridViewData.TabIndex = 2;
// //
// FormRoutSheetes // FormRoutSheetes
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(816, 450);
Controls.Add(dataGridView1); Controls.Add(dataGridViewData);
Controls.Add(panel1); Controls.Add(panel1);
Name = "FormRoutSheetes"; Name = "FormRoutSheetes";
Text = "Путевой лист"; Text = "Путевой лист";
Load += FormRoutSheetes_Load; Load += FormRoutSheetes_Load;
panel1.ResumeLayout(false); panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }
#endregion #endregion
private Panel panel1; private Panel panel1;
private DataGridView dataGridView1;
private Button buttonadd; private Button buttonadd;
private DataGridView dataGridViewData;
} }
} }

View File

@ -47,7 +47,7 @@ public partial class FormRoutSheetes : Form
} }
} }
private void LoadList() => dataGridView1.DataSource = _routSheetRepository.ReadRoutSheet(); private void LoadList() => dataGridViewData.DataSource = _routSheetRepository.ReadRoutSheet();
} }

View File

@ -52,7 +52,7 @@
dataGridViewData.ReadOnly = true; dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false; dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(800, 450); dataGridViewData.Size = new Size(840, 450);
dataGridViewData.TabIndex = 2; dataGridViewData.TabIndex = 2;
// //
// panel1 // panel1
@ -61,7 +61,7 @@
panel1.Controls.Add(buttonUpd); panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd); panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right; panel1.Dock = DockStyle.Right;
panel1.Location = new Point(650, 0); panel1.Location = new Point(690, 0);
panel1.Name = "panel1"; panel1.Name = "panel1";
panel1.Size = new Size(150, 450); panel1.Size = new Size(150, 450);
panel1.TabIndex = 3; panel1.TabIndex = 3;
@ -103,7 +103,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(840, 450);
Controls.Add(panel1); Controls.Add(panel1);
Controls.Add(dataGridViewData); Controls.Add(dataGridViewData);
Name = "FormRoutes"; Name = "FormRoutes";

View File

@ -28,7 +28,6 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
comboBoxPost = new ComboBox();
textBoxLastName = new TextBox(); textBoxLastName = new TextBox();
textBoxFirstName = new TextBox(); textBoxFirstName = new TextBox();
label1 = new Label(); label1 = new Label();
@ -36,17 +35,9 @@
label3 = new Label(); label3 = new Label();
buttoтSave = new Button(); buttoтSave = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
checkedListBoxStaff = new CheckedListBox();
SuspendLayout(); SuspendLayout();
// //
// comboBoxPost
//
comboBoxPost.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxPost.FormattingEnabled = true;
comboBoxPost.Location = new Point(132, 121);
comboBoxPost.Name = "comboBoxPost";
comboBoxPost.Size = new Size(228, 23);
comboBoxPost.TabIndex = 0;
//
// textBoxLastName // textBoxLastName
// //
textBoxLastName.Location = new Point(132, 12); textBoxLastName.Location = new Point(132, 12);
@ -90,7 +81,7 @@
// //
// buttoтSave // buttoтSave
// //
buttoтSave.Location = new Point(52, 178); buttoтSave.Location = new Point(21, 277);
buttoтSave.Name = "buttoтSave"; buttoтSave.Name = "buttoтSave";
buttoтSave.Size = new Size(75, 23); buttoтSave.Size = new Size(75, 23);
buttoтSave.TabIndex = 6; buttoтSave.TabIndex = 6;
@ -100,7 +91,7 @@
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(228, 178); buttonCancel.Location = new Point(341, 277);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23); buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 7; buttonCancel.TabIndex = 7;
@ -108,11 +99,20 @@
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click; buttonCancel.Click += buttonCancel_Click;
// //
// checkedListBoxStaff
//
checkedListBoxStaff.FormattingEnabled = true;
checkedListBoxStaff.Location = new Point(132, 124);
checkedListBoxStaff.Name = "checkedListBoxStaff";
checkedListBoxStaff.Size = new Size(228, 148);
checkedListBoxStaff.TabIndex = 8;
//
// FormStaff // FormStaff
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(363, 213); ClientSize = new Size(439, 312);
Controls.Add(checkedListBoxStaff);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttoтSave); Controls.Add(buttoтSave);
Controls.Add(label3); Controls.Add(label3);
@ -120,7 +120,6 @@
Controls.Add(label1); Controls.Add(label1);
Controls.Add(textBoxFirstName); Controls.Add(textBoxFirstName);
Controls.Add(textBoxLastName); Controls.Add(textBoxLastName);
Controls.Add(comboBoxPost);
Name = "FormStaff"; Name = "FormStaff";
Text = "FormStaff"; Text = "FormStaff";
ResumeLayout(false); ResumeLayout(false);
@ -128,8 +127,6 @@
} }
#endregion #endregion
private ComboBox comboBoxPost;
private TextBox textBoxLastName; private TextBox textBoxLastName;
private TextBox textBoxFirstName; private TextBox textBoxFirstName;
private Label label1; private Label label1;
@ -137,5 +134,6 @@
private Label label3; private Label label3;
private Button buttoтSave; private Button buttoтSave;
private Button buttonCancel; private Button buttonCancel;
private CheckedListBox checkedListBoxStaff;
} }
} }

View File

@ -21,9 +21,16 @@ public partial class FormStaff : Form
throw new throw new
InvalidDataException(nameof(staff)); InvalidDataException(nameof(staff));
} }
foreach (EmployeePost elem in Enum.GetValues(typeof(EmployeePost)))
{
if ((elem & staff.EmployeePost) != 0)
{
checkedListBoxStaff.SetItemChecked(checkedListBoxStaff.Items.IndexOf(elem), true);
}
}
textBoxFirstName.Text = staff.FirstName; textBoxFirstName.Text = staff.FirstName;
textBoxLastName.Text = staff.LastName; textBoxLastName.Text = staff.LastName;
comboBoxPost.SelectedItem = staff.EmployeePost;
_staffId = value; _staffId = value;
} }
catch (Exception ex) catch (Exception ex)
@ -40,14 +47,17 @@ public partial class FormStaff : Form
InitializeComponent(); InitializeComponent();
_staffRepository = staffRepositories ?? _staffRepository = staffRepositories ??
throw new ArgumentNullException(nameof(staffRepositories)); throw new ArgumentNullException(nameof(staffRepositories));
comboBoxPost.DataSource = Enum.GetValues(typeof(EmployeePost)); foreach (var elem in Enum.GetValues(typeof(EmployeePost)))
{
checkedListBoxStaff.Items.Add(elem);
}
} }
private void buttoтSave_Click(object sender, EventArgs e) private void buttoтSave_Click(object sender, EventArgs e)
{ {
try try
{ {
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) ||string.IsNullOrWhiteSpace(textBoxLastName.Text) || comboBoxPost.SelectedIndex < 1) if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) ||string.IsNullOrWhiteSpace(textBoxLastName.Text) || checkedListBoxStaff.CheckedItems.Count == 1)
{ {
throw new Exception("Имеются незаполненныеполя"); throw new Exception("Имеются незаполненныеполя");
} }
@ -69,10 +79,15 @@ public partial class FormStaff : Form
} }
private void buttonCancel_Click(object sender, EventArgs e) => Close(); private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Staff CreateStaff(int id) => Staff.CreatEntity(id, private Staff CreateStaff(int id)
textBoxFirstName.Text, {
textBoxLastName.Text, EmployeePost employeePost = EmployeePost.None;
(EmployeePost)comboBoxPost.SelectedItem!); foreach (var elem in checkedListBoxStaff.CheckedItems)
{
employeePost |= (EmployeePost)elem;
}
return Staff.CreatEntity(id, textBoxFirstName.Text, textBoxLastName.Text, employeePost);
}

View File

@ -116,6 +116,7 @@
// //
// numericUpDownCost // numericUpDownCost
// //
numericUpDownCost.DecimalPlaces = 2;
numericUpDownCost.Location = new Point(105, 334); numericUpDownCost.Location = new Point(105, 334);
numericUpDownCost.Name = "numericUpDownCost"; numericUpDownCost.Name = "numericUpDownCost";
numericUpDownCost.Size = new Size(238, 23); numericUpDownCost.Size = new Size(238, 23);

View File

@ -51,7 +51,7 @@
dataGridViewData.ReadOnly = true; dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false; dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(800, 450); dataGridViewData.Size = new Size(1241, 450);
dataGridViewData.TabIndex = 2; dataGridViewData.TabIndex = 2;
// //
// panel1 // panel1
@ -59,7 +59,7 @@
panel1.Controls.Add(buttonDel); panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonAdd); panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right; panel1.Dock = DockStyle.Right;
panel1.Location = new Point(650, 0); panel1.Location = new Point(1091, 0);
panel1.Name = "panel1"; panel1.Name = "panel1";
panel1.Size = new Size(150, 450); panel1.Size = new Size(150, 450);
panel1.TabIndex = 3; panel1.TabIndex = 3;
@ -90,7 +90,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(1241, 450);
Controls.Add(panel1); Controls.Add(panel1);
Controls.Add(dataGridViewData); Controls.Add(dataGridViewData);
Name = "FormTOes"; Name = "FormTOes";