Лабараторная 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;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
[Flags]
public enum EmployeePost
{
None = 0,
Conductor = 1,
Driver = 2,
Mechanic = 3
Mechanic = 4,
Boss = 8,
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,9 +21,16 @@ public partial class FormStaff : Form
throw new
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;
textBoxLastName.Text = staff.LastName;
comboBoxPost.SelectedItem = staff.EmployeePost;
_staffId = value;
}
catch (Exception ex)
@ -40,14 +47,17 @@ public partial class FormStaff : Form
InitializeComponent();
_staffRepository = 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)
{
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("Имеются незаполненныеполя");
}
@ -69,10 +79,15 @@ public partial class FormStaff : Form
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Staff CreateStaff(int id) => Staff.CreatEntity(id,
textBoxFirstName.Text,
textBoxLastName.Text,
(EmployeePost)comboBoxPost.SelectedItem!);
private Staff CreateStaff(int id)
{
EmployeePost employeePost = EmployeePost.None;
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.DecimalPlaces = 2;
numericUpDownCost.Location = new Point(105, 334);
numericUpDownCost.Name = "numericUpDownCost";
numericUpDownCost.Size = new Size(238, 23);

View File

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