Измененная первая лаба
This commit is contained in:
parent
121bf60ad9
commit
5c5f741db5
@ -11,14 +11,10 @@ public class Company
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
public int CountryId { get; private set; }
|
public int CountryId { get; private set; }
|
||||||
public IEnumerable<CompanyTrip> CompanyTrip
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
} = [];
|
|
||||||
|
|
||||||
public static Company CreateCompany(int id, string name, int countryId, IEnumerable<CompanyTrip> companyTrip)
|
|
||||||
|
public static Company CreateCompany(int id, string name, int countryId)
|
||||||
{
|
{
|
||||||
return new Company() { Id = id, Name = name, CountryId = countryId, CompanyTrip = companyTrip };
|
return new Company() { Id = id, Name = name, CountryId = countryId};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,14 @@ public class Trip
|
|||||||
public string EndCity { get; private set;} =string.Empty;
|
public string EndCity { get; private set;} =string.Empty;
|
||||||
public int CompanyId { get; private set; }
|
public int CompanyId { get; private set; }
|
||||||
public TravelType TravelType { get; private set; }
|
public TravelType TravelType { get; private set; }
|
||||||
|
|
||||||
public static Trip CreateOpeartion(int id, string title, int price, int humanCapacity, DateTime startDate, DateTime endDate, string startCity, string endCity, TravelType travelType)
|
public IEnumerable<CompanyTrip> CompanyTrip
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
} = [];
|
||||||
|
|
||||||
|
public static Trip CreateOpeartion(int id, string title, int price, int humanCapacity, DateTime startDate, DateTime endDate, string startCity, string endCity, TravelType travelType, IEnumerable<CompanyTrip> companyTrip)
|
||||||
{
|
{
|
||||||
return new Trip
|
return new Trip
|
||||||
{
|
{
|
||||||
@ -33,6 +39,7 @@ public class Trip
|
|||||||
StartCity = startCity,
|
StartCity = startCity,
|
||||||
EndCity = endCity,
|
EndCity = endCity,
|
||||||
TravelType = travelType,
|
TravelType = travelType,
|
||||||
|
CompanyTrip = companyTrip
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,5 +83,6 @@ public partial class FormTourismCompany : Form
|
|||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@
|
|||||||
Controls.Add(dataGridViewChecks);
|
Controls.Add(dataGridViewChecks);
|
||||||
Name = "FormChecks";
|
Name = "FormChecks";
|
||||||
Text = "Чеки";
|
Text = "Чеки";
|
||||||
|
Load += FormChecks_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewChecks).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewChecks).EndInit();
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
Name = "FormClients";
|
Name = "FormClients";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Клиенты";
|
Text = "Клиенты";
|
||||||
|
Load += FormClients_Load;
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewClient).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewClient).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -110,6 +110,7 @@
|
|||||||
Name = "FormCompanies";
|
Name = "FormCompanies";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Компании";
|
Text = "Компании";
|
||||||
|
Load += FormCompanies_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewCompanies).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewCompanies).EndInit();
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -32,14 +32,8 @@
|
|||||||
textBoxName = new TextBox();
|
textBoxName = new TextBox();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
groupBox1 = new GroupBox();
|
|
||||||
dataGridView1 = new DataGridView();
|
|
||||||
ColumnTitle = new DataGridViewComboBoxColumn();
|
|
||||||
ColumnAdditionalPrice = new DataGridViewButtonColumn();
|
|
||||||
comboBoxCountry = new ComboBox();
|
comboBoxCountry = new ComboBox();
|
||||||
label2 = new Label();
|
label2 = new Label();
|
||||||
groupBox1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
@ -62,7 +56,7 @@
|
|||||||
//
|
//
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonCancel.BackColor = Color.IndianRed;
|
buttonCancel.BackColor = Color.IndianRed;
|
||||||
buttonCancel.Location = new Point(305, 318);
|
buttonCancel.Location = new Point(17, 117);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(135, 51);
|
buttonCancel.Size = new Size(135, 51);
|
||||||
buttonCancel.TabIndex = 17;
|
buttonCancel.TabIndex = 17;
|
||||||
@ -74,7 +68,7 @@
|
|||||||
//
|
//
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonSave.BackColor = Color.LimeGreen;
|
buttonSave.BackColor = Color.LimeGreen;
|
||||||
buttonSave.Location = new Point(446, 318);
|
buttonSave.Location = new Point(158, 117);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(135, 51);
|
buttonSave.Size = new Size(135, 51);
|
||||||
buttonSave.TabIndex = 16;
|
buttonSave.TabIndex = 16;
|
||||||
@ -82,44 +76,6 @@
|
|||||||
buttonSave.UseVisualStyleBackColor = false;
|
buttonSave.UseVisualStyleBackColor = false;
|
||||||
buttonSave.Click += ButtonSave_Click;
|
buttonSave.Click += ButtonSave_Click;
|
||||||
//
|
//
|
||||||
// groupBox1
|
|
||||||
//
|
|
||||||
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
groupBox1.Controls.Add(dataGridView1);
|
|
||||||
groupBox1.Location = new Point(283, 6);
|
|
||||||
groupBox1.Name = "groupBox1";
|
|
||||||
groupBox1.Size = new Size(298, 306);
|
|
||||||
groupBox1.TabIndex = 19;
|
|
||||||
groupBox1.TabStop = false;
|
|
||||||
groupBox1.Text = "groupBox1";
|
|
||||||
//
|
|
||||||
// dataGridView1
|
|
||||||
//
|
|
||||||
dataGridView1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { ColumnTitle, ColumnAdditionalPrice });
|
|
||||||
dataGridView1.Location = new Point(3, 23);
|
|
||||||
dataGridView1.MultiSelect = false;
|
|
||||||
dataGridView1.Name = "dataGridView1";
|
|
||||||
dataGridView1.RowHeadersVisible = false;
|
|
||||||
dataGridView1.RowHeadersWidth = 51;
|
|
||||||
dataGridView1.Size = new Size(292, 280);
|
|
||||||
dataGridView1.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ColumnTitle
|
|
||||||
//
|
|
||||||
ColumnTitle.HeaderText = "Название путевки";
|
|
||||||
ColumnTitle.MinimumWidth = 6;
|
|
||||||
ColumnTitle.Name = "ColumnTitle";
|
|
||||||
//
|
|
||||||
// ColumnAdditionalPrice
|
|
||||||
//
|
|
||||||
ColumnAdditionalPrice.HeaderText = "Надбавка фирмы";
|
|
||||||
ColumnAdditionalPrice.MinimumWidth = 6;
|
|
||||||
ColumnAdditionalPrice.Name = "ColumnAdditionalPrice";
|
|
||||||
ColumnAdditionalPrice.Resizable = DataGridViewTriState.True;
|
|
||||||
//
|
|
||||||
// comboBoxCountry
|
// comboBoxCountry
|
||||||
//
|
//
|
||||||
comboBoxCountry.FormattingEnabled = true;
|
comboBoxCountry.FormattingEnabled = true;
|
||||||
@ -141,10 +97,9 @@
|
|||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(593, 381);
|
ClientSize = new Size(305, 180);
|
||||||
Controls.Add(label2);
|
Controls.Add(label2);
|
||||||
Controls.Add(comboBoxCountry);
|
Controls.Add(comboBoxCountry);
|
||||||
Controls.Add(groupBox1);
|
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(textBoxName);
|
Controls.Add(textBoxName);
|
||||||
@ -152,8 +107,6 @@
|
|||||||
Name = "FormCompany";
|
Name = "FormCompany";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Компания";
|
Text = "Компания";
|
||||||
groupBox1.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -164,10 +117,6 @@
|
|||||||
private TextBox textBoxName;
|
private TextBox textBoxName;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private GroupBox groupBox1;
|
|
||||||
private DataGridView dataGridView1;
|
|
||||||
private DataGridViewComboBoxColumn ColumnTitle;
|
|
||||||
private DataGridViewButtonColumn ColumnAdditionalPrice;
|
|
||||||
private ComboBox comboBoxCountry;
|
private ComboBox comboBoxCountry;
|
||||||
private Label label2;
|
private Label label2;
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,6 @@ public partial class FormCompany : Form
|
|||||||
comboBoxCountry.DataSource = countryRepository.ReadCountries();
|
comboBoxCountry.DataSource = countryRepository.ReadCountries();
|
||||||
comboBoxCountry.DisplayMember = "Name";
|
comboBoxCountry.DisplayMember = "Name";
|
||||||
comboBoxCountry.ValueMember = "Id";
|
comboBoxCountry.ValueMember = "Id";
|
||||||
|
|
||||||
ColumnTitle.DataSource = tripRepository.ReadTrips();
|
|
||||||
ColumnTitle.DisplayMember = "Title";
|
|
||||||
ColumnTitle.ValueMember = "Id";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,12 +64,11 @@ public partial class FormCompany : Form
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (dataGridView1.RowCount < 1 ||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
comboBoxCountry.SelectedIndex < 0)
|
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
_companyRepository.CreateCompany(Company.CreateCompany(0, textBoxName.Text, (int)comboBoxCountry.SelectedItem!, CreateListCompanyTripFromDataGrid()));
|
_companyRepository.CreateCompany(Company.CreateCompany(0, textBoxName.Text, (int)comboBoxCountry.SelectedItem!));
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -84,20 +79,5 @@ public partial class FormCompany : Form
|
|||||||
}
|
}
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) =>
|
private void ButtonCancel_Click(object sender, EventArgs e) =>
|
||||||
Close();
|
Close();
|
||||||
private List<CompanyTrip> CreateListCompanyTripFromDataGrid()
|
|
||||||
{
|
|
||||||
var list = new List<CompanyTrip>();
|
|
||||||
foreach (DataGridViewRow row in dataGridView1.Rows)
|
|
||||||
{
|
|
||||||
if (row.Cells["ColumnAdditionalPrice"].Value == null ||
|
|
||||||
row.Cells["ColumnTitle"].Value == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
list.Add(CompanyTrip.CreateCompanyTrip(0, 0,
|
|
||||||
Convert.ToInt32(row.Cells["ColumnTitle"].Value),
|
|
||||||
Convert.ToInt32(row.Cells["ColumnAdditionalPrice"].Value)));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -117,10 +117,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="ColumnTitle.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnAdditionalPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
@ -45,7 +45,6 @@
|
|||||||
dataGridView1.AllowUserToResizeRows = false;
|
dataGridView1.AllowUserToResizeRows = false;
|
||||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView1.ColumnHeadersVisible = false;
|
|
||||||
dataGridView1.Dock = DockStyle.Fill;
|
dataGridView1.Dock = DockStyle.Fill;
|
||||||
dataGridView1.Location = new Point(0, 0);
|
dataGridView1.Location = new Point(0, 0);
|
||||||
dataGridView1.MultiSelect = false;
|
dataGridView1.MultiSelect = false;
|
||||||
@ -53,7 +52,7 @@
|
|||||||
dataGridView1.ReadOnly = true;
|
dataGridView1.ReadOnly = true;
|
||||||
dataGridView1.RowHeadersWidth = 51;
|
dataGridView1.RowHeadersWidth = 51;
|
||||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView1.Size = new Size(800, 450);
|
dataGridView1.Size = new Size(642, 450);
|
||||||
dataGridView1.TabIndex = 0;
|
dataGridView1.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
@ -105,11 +104,12 @@
|
|||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(panel1);
|
|
||||||
Controls.Add(dataGridView1);
|
Controls.Add(dataGridView1);
|
||||||
|
Controls.Add(panel1);
|
||||||
Name = "FormCountries";
|
Name = "FormCountries";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Страны";
|
Text = "Страны";
|
||||||
|
Load += FormCountries_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -24,9 +24,10 @@ public partial class FormCountries : Form
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
_countryRepository = countryRepository ?? throw new ArgumentNullException(nameof(countryRepository));
|
_countryRepository = countryRepository ?? throw new ArgumentNullException(nameof(countryRepository));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormCompanies_Load(object sender, EventArgs e)
|
private void FormCountries_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -46,8 +46,14 @@
|
|||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
textBoxTitle = new TextBox();
|
textBoxTitle = new TextBox();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
dataGridView1 = new DataGridView();
|
||||||
|
columnCompanyName = new DataGridViewComboBoxColumn();
|
||||||
|
ColumnAdditionalPrice = new DataGridViewTextBoxColumn();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownHumanCapacity).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownHumanCapacity).BeginInit();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelPrice
|
// labelPrice
|
||||||
@ -172,7 +178,7 @@
|
|||||||
//
|
//
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonCancel.BackColor = Color.IndianRed;
|
buttonCancel.BackColor = Color.IndianRed;
|
||||||
buttonCancel.Location = new Point(214, 512);
|
buttonCancel.Location = new Point(605, 512);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(135, 51);
|
buttonCancel.Size = new Size(135, 51);
|
||||||
buttonCancel.TabIndex = 15;
|
buttonCancel.TabIndex = 15;
|
||||||
@ -184,7 +190,7 @@
|
|||||||
//
|
//
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonSave.BackColor = Color.LimeGreen;
|
buttonSave.BackColor = Color.LimeGreen;
|
||||||
buttonSave.Location = new Point(361, 512);
|
buttonSave.Location = new Point(796, 512);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(135, 51);
|
buttonSave.Size = new Size(135, 51);
|
||||||
buttonSave.TabIndex = 14;
|
buttonSave.TabIndex = 14;
|
||||||
@ -208,11 +214,57 @@
|
|||||||
textBoxTitle.Size = new Size(220, 27);
|
textBoxTitle.Size = new Size(220, 27);
|
||||||
textBoxTitle.TabIndex = 17;
|
textBoxTitle.TabIndex = 17;
|
||||||
//
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
groupBox1.Controls.Add(dataGridView1);
|
||||||
|
groupBox1.Location = new Point(499, 12);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(432, 476);
|
||||||
|
groupBox1.TabIndex = 20;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "groupBox1";
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
dataGridView1.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView1.AllowUserToResizeColumns = false;
|
||||||
|
dataGridView1.AllowUserToResizeRows = false;
|
||||||
|
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { columnCompanyName, ColumnAdditionalPrice });
|
||||||
|
dataGridView1.Dock = DockStyle.Fill;
|
||||||
|
dataGridView1.Location = new Point(3, 23);
|
||||||
|
dataGridView1.MultiSelect = false;
|
||||||
|
dataGridView1.Name = "dataGridView1";
|
||||||
|
dataGridView1.ReadOnly = true;
|
||||||
|
dataGridView1.RowHeadersVisible = false;
|
||||||
|
dataGridView1.RowHeadersWidth = 51;
|
||||||
|
dataGridView1.Size = new Size(426, 450);
|
||||||
|
dataGridView1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// columnCompanyName
|
||||||
|
//
|
||||||
|
columnCompanyName.HeaderText = "Название компании";
|
||||||
|
columnCompanyName.MinimumWidth = 6;
|
||||||
|
columnCompanyName.Name = "columnCompanyName";
|
||||||
|
columnCompanyName.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnAdditionalPrice
|
||||||
|
//
|
||||||
|
ColumnAdditionalPrice.HeaderText = "Добавочная стоимость";
|
||||||
|
ColumnAdditionalPrice.MinimumWidth = 6;
|
||||||
|
ColumnAdditionalPrice.Name = "ColumnAdditionalPrice";
|
||||||
|
ColumnAdditionalPrice.ReadOnly = true;
|
||||||
|
ColumnAdditionalPrice.Resizable = DataGridViewTriState.True;
|
||||||
|
ColumnAdditionalPrice.SortMode = DataGridViewColumnSortMode.NotSortable;
|
||||||
|
//
|
||||||
// FormTrip
|
// FormTrip
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(508, 573);
|
ClientSize = new Size(943, 573);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
Controls.Add(textBoxTitle);
|
Controls.Add(textBoxTitle);
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
@ -236,6 +288,8 @@
|
|||||||
Text = "Туры";
|
Text = "Туры";
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownHumanCapacity).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownHumanCapacity).EndInit();
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -260,5 +314,9 @@
|
|||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private TextBox textBoxTitle;
|
private TextBox textBoxTitle;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private DataGridView dataGridView1;
|
||||||
|
private DataGridViewComboBoxColumn columnCompanyName;
|
||||||
|
private DataGridViewTextBoxColumn ColumnAdditionalPrice;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using ProjectTourismCompany.Entities;
|
using ProjectTourismCompany.Entities;
|
||||||
using ProjectTourismCompany.Entities.Enums;
|
using ProjectTourismCompany.Entities.Enums;
|
||||||
using ProjectTourismCompany.Repositories;
|
using ProjectTourismCompany.Repositories;
|
||||||
|
using ProjectTourismCompany.Repositories.Implementations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -56,7 +57,7 @@ Enum.GetValues(typeof(TravelType)))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public FormTrip(ITripRepository tripRepository)
|
public FormTrip(ITripRepository tripRepository, ICompanyRepository companyRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_tripRepository = tripRepository ?? throw new ArgumentNullException(nameof(tripRepository));
|
_tripRepository = tripRepository ?? throw new ArgumentNullException(nameof(tripRepository));
|
||||||
@ -64,14 +65,16 @@ Enum.GetValues(typeof(TravelType)))
|
|||||||
{
|
{
|
||||||
checkedListBoxTravelType.Items.Add(elem);
|
checkedListBoxTravelType.Items.Add(elem);
|
||||||
}
|
}
|
||||||
|
columnCompanyName.DataSource = companyRepository.ReadCompanies();
|
||||||
|
columnCompanyName.DisplayMember = "Name";
|
||||||
|
columnCompanyName.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(textBoxStartCity.Text) ||
|
if (string.IsNullOrWhiteSpace(textBoxStartCity.Text) ||
|
||||||
string.IsNullOrWhiteSpace(textBoxEndCity.Text))
|
string.IsNullOrWhiteSpace(textBoxEndCity.Text) || dataGridView1.RowCount < 1)
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
@ -105,6 +108,24 @@ Enum.GetValues(typeof(TravelType)))
|
|||||||
}
|
}
|
||||||
return Trip.CreateOpeartion(0, textBoxTitle.Text, (int)numericUpDownPrice.Value,
|
return Trip.CreateOpeartion(0, textBoxTitle.Text, (int)numericUpDownPrice.Value,
|
||||||
(int)numericUpDownHumanCapacity.Value, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value,
|
(int)numericUpDownHumanCapacity.Value, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value,
|
||||||
textBoxStartCity.Text, textBoxEndCity.Text, tr);
|
textBoxStartCity.Text, textBoxEndCity.Text, tr, CreateListCompanyTripFromDataGrid());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<CompanyTrip> CreateListCompanyTripFromDataGrid()
|
||||||
|
{
|
||||||
|
var list = new List<CompanyTrip>();
|
||||||
|
foreach (DataGridViewRow row in dataGridView1.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["ColumnAdditionalPrice"].Value == null ||
|
||||||
|
row.Cells["ColumnCompanyName"].Value == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.Add(CompanyTrip.CreateCompanyTrip(0, 0,
|
||||||
|
Convert.ToInt32(row.Cells["ColumnCompanyName"].Value),
|
||||||
|
Convert.ToInt32(row.Cells["ColumnAdditionalPrice"].Value)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,10 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="columnCompanyName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnAdditionalPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -43,7 +43,6 @@
|
|||||||
dataGridView1.AllowUserToResizeRows = false;
|
dataGridView1.AllowUserToResizeRows = false;
|
||||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView1.ColumnHeadersVisible = false;
|
|
||||||
dataGridView1.Dock = DockStyle.Fill;
|
dataGridView1.Dock = DockStyle.Fill;
|
||||||
dataGridView1.Location = new Point(0, 0);
|
dataGridView1.Location = new Point(0, 0);
|
||||||
dataGridView1.MultiSelect = false;
|
dataGridView1.MultiSelect = false;
|
||||||
@ -51,7 +50,7 @@
|
|||||||
dataGridView1.ReadOnly = true;
|
dataGridView1.ReadOnly = true;
|
||||||
dataGridView1.RowHeadersWidth = 51;
|
dataGridView1.RowHeadersWidth = 51;
|
||||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView1.Size = new Size(800, 450);
|
dataGridView1.Size = new Size(645, 450);
|
||||||
dataGridView1.TabIndex = 0;
|
dataGridView1.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
@ -79,11 +78,12 @@
|
|||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(panel1);
|
|
||||||
Controls.Add(dataGridView1);
|
Controls.Add(dataGridView1);
|
||||||
|
Controls.Add(panel1);
|
||||||
Name = "FormTrips";
|
Name = "FormTrips";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Туры";
|
Text = "Туры";
|
||||||
|
Load += FormTrips_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -28,7 +28,7 @@ public partial class FormTrips : Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void FormChecks_Load(object sender, EventArgs e)
|
private void FormTrips_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -60,5 +60,6 @@ public partial class FormTrips : Form
|
|||||||
|
|
||||||
private void LoadList() => dataGridView1.DataSource =
|
private void LoadList() => dataGridView1.DataSource =
|
||||||
_tripRepository.ReadTrips();
|
_tripRepository.ReadTrips();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ internal class CompanyRepository : ICompanyRepository
|
|||||||
|
|
||||||
public Company ReadCompanyById(int id)
|
public Company ReadCompanyById(int id)
|
||||||
{
|
{
|
||||||
return Company.CreateCompany(1, "randomName", 73, []);
|
return Company.CreateCompany(1, "randomName", 73);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateCompany(Company company)
|
public void UpdateCompany(Company company)
|
||||||
|
@ -16,7 +16,7 @@ internal class TripRepository : ITripRepository
|
|||||||
|
|
||||||
public Trip ReadTripById(int id)
|
public Trip ReadTripById(int id)
|
||||||
{
|
{
|
||||||
return Trip.CreateOpeartion(0, "a", 0, 0, DateTime.Now, DateTime.Now, "Moscow", "Piter", Entities.Enums.TravelType.None);
|
return Trip.CreateOpeartion(0, "a", 0, 0, DateTime.Now, DateTime.Now, "Moscow", "Piter", Entities.Enums.TravelType.None, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Trip> ReadTrips(DateTime? dateForm = null, DateTime? dateTo = null, int? tripId = null, int? companyId = null, int? countryId = null)
|
public IEnumerable<Trip> ReadTrips(DateTime? dateForm = null, DateTime? dateTo = null, int? tripId = null, int? companyId = null, int? countryId = null)
|
||||||
|
Loading…
Reference in New Issue
Block a user