добавил 1 формочкку переименовал папку

This commit is contained in:
Timourka 2024-03-26 22:18:20 +04:00
parent f12b7f6c38
commit bf1de313ae
9 changed files with 263 additions and 43 deletions

View File

@ -28,12 +28,186 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormCarModel";
dataGridView = new DataGridView();
label1 = new Label();
label2 = new Label();
label3 = new Label();
label4 = new Label();
label5 = new Label();
textBoxBrand = new TextBox();
textBoxModel = new TextBox();
textBoxYear = new TextBox();
textBoxSeats = new TextBox();
comboBoxBodyType = new ComboBox();
buttonCreate = new Button();
buttonUpdate = new Button();
buttonDelete = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 12);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(603, 426);
dataGridView.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(621, 12);
label1.Name = "label1";
label1.Size = new Size(38, 15);
label1.TabIndex = 1;
label1.Text = "Brand";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(621, 41);
label2.Name = "label2";
label2.Size = new Size(41, 15);
label2.TabIndex = 2;
label2.Text = "Model";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(621, 70);
label3.Name = "label3";
label3.Size = new Size(29, 15);
label3.TabIndex = 3;
label3.Text = "Year";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(621, 99);
label4.Name = "label4";
label4.Size = new Size(60, 15);
label4.TabIndex = 4;
label4.Text = "Body type";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(621, 128);
label5.Name = "label5";
label5.Size = new Size(34, 15);
label5.TabIndex = 5;
label5.Text = "Seats";
//
// textBoxBrand
//
textBoxBrand.Location = new Point(687, 9);
textBoxBrand.Name = "textBoxBrand";
textBoxBrand.Size = new Size(100, 23);
textBoxBrand.TabIndex = 6;
//
// textBoxModel
//
textBoxModel.Location = new Point(687, 38);
textBoxModel.Name = "textBoxModel";
textBoxModel.Size = new Size(100, 23);
textBoxModel.TabIndex = 7;
//
// textBoxYear
//
textBoxYear.Location = new Point(687, 67);
textBoxYear.Name = "textBoxYear";
textBoxYear.Size = new Size(100, 23);
textBoxYear.TabIndex = 8;
//
// textBoxSeats
//
textBoxSeats.Location = new Point(687, 125);
textBoxSeats.Name = "textBoxSeats";
textBoxSeats.Size = new Size(100, 23);
textBoxSeats.TabIndex = 10;
//
// comboBoxBodyType
//
comboBoxBodyType.FormattingEnabled = true;
comboBoxBodyType.Location = new Point(687, 96);
comboBoxBodyType.Name = "comboBoxBodyType";
comboBoxBodyType.Size = new Size(100, 23);
comboBoxBodyType.TabIndex = 11;
//
// buttonCreate
//
buttonCreate.Location = new Point(687, 154);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(75, 23);
buttonCreate.TabIndex = 12;
buttonCreate.Text = "create";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += buttonCreate_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(687, 183);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 13;
buttonUpdate.Text = "update";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(687, 212);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 14;
buttonDelete.Text = "delete";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += buttonDelete_Click;
//
// FormCarModel
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonDelete);
Controls.Add(buttonUpdate);
Controls.Add(buttonCreate);
Controls.Add(comboBoxBodyType);
Controls.Add(textBoxSeats);
Controls.Add(textBoxYear);
Controls.Add(textBoxModel);
Controls.Add(textBoxBrand);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(dataGridView);
Name = "FormCarModel";
Text = "FormCarModel";
Load += FormCarModel_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private DataGridView dataGridView;
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private TextBox textBoxBrand;
private TextBox textBoxModel;
private TextBox textBoxYear;
private TextBox textBoxSeats;
private ComboBox comboBoxBodyType;
private Button buttonCreate;
private Button buttonUpdate;
private Button buttonDelete;
}
}

View File

@ -1,4 +1,5 @@
using database;
using System.Windows.Forms;
namespace Forms
{
@ -10,5 +11,50 @@ namespace Forms
InitializeComponent();
bd = _bd;
}
private void loadData()
{
List<CarModel> carModels = bd.GetCarModels();
// Очищаем dataGridView перед заполнением новыми данными
dataGridView.Rows.Clear();
// Предварительно определяем столбцы, если это не было сделано ранее
if (dataGridView.ColumnCount == 0)
{
dataGridView.Columns.Add("Id", "ID");
dataGridView.Columns.Add("Brand", "Brand");
dataGridView.Columns.Add("Model", "Model");
dataGridView.Columns.Add("Year", "Year");
dataGridView.Columns.Add("BodyType", "Body type");
dataGridView.Columns.Add("Seats", "Seats");
}
// Заполняем dataGridView данными из списка моделей автомобилей
foreach (CarModel carModel in carModels)
{
dataGridView.Rows.Add(carModel.Id, carModel.Brand, carModel.Model, carModel.Year, bd.GetBodyTypeById(carModel.BodyTypeId).Title, carModel.Seats);
}
}
private void buttonCreate_Click(object sender, EventArgs e)
{
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
}
private void buttonDelete_Click(object sender, EventArgs e)
{
}
private void FormCarModel_Load(object sender, EventArgs e)
{
loadData();
}
}
}

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -13,7 +13,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\databaseAbstractions\database.csproj" />
<ProjectReference Include="..\database\database.csproj" />
</ItemGroup>
</Project>

View File

@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "database", "databaseAbstractions\database.csproj", "{874A3D9B-6051-4823-9A3B-725C71FDC245}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Forms", "Forms\Forms.csproj", "{318E26AF-A4DC-4863-B829-DBD4B63DC0D7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forms", "Forms\Forms.csproj", "{318E26AF-A4DC-4863-B829-DBD4B63DC0D7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "database", "database\database.csproj", "{4CD0F569-0037-400E-B6CB-5F553650C6DA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -13,14 +13,14 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{874A3D9B-6051-4823-9A3B-725C71FDC245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{874A3D9B-6051-4823-9A3B-725C71FDC245}.Debug|Any CPU.Build.0 = Debug|Any CPU
{874A3D9B-6051-4823-9A3B-725C71FDC245}.Release|Any CPU.ActiveCfg = Release|Any CPU
{874A3D9B-6051-4823-9A3B-725C71FDC245}.Release|Any CPU.Build.0 = Release|Any CPU
{318E26AF-A4DC-4863-B829-DBD4B63DC0D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{318E26AF-A4DC-4863-B829-DBD4B63DC0D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{318E26AF-A4DC-4863-B829-DBD4B63DC0D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{318E26AF-A4DC-4863-B829-DBD4B63DC0D7}.Release|Any CPU.Build.0 = Release|Any CPU
{4CD0F569-0037-400E-B6CB-5F553650C6DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CD0F569-0037-400E-B6CB-5F553650C6DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CD0F569-0037-400E-B6CB-5F553650C6DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CD0F569-0037-400E-B6CB-5F553650C6DA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -16,7 +16,7 @@ namespace database
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO car (id, model_id, branch_id, year, mileage, status_id) VALUES ({car.Id}, {car.ModelId}, {car.BranchId}, {car.Year}, {car.Mileage}, {car.StatusId})", conn);
using var cmd = new NpgsqlCommand($"INSERT INTO car (model_id, branch_id, year, mileage, status_id) VALUES ({car.ModelId}, {car.BranchId}, {car.Year}, {car.Mileage}, {car.StatusId})", conn);
cmd.ExecuteNonQuery();
}
@ -84,7 +84,7 @@ namespace database
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO client (id, name, surname, address, phone, email) VALUES ({client.Id}, '{client.Name}', '{client.Surname}', '{client.Address}', '{client.Phone}', '{client.Email}')", conn);
using var cmd = new NpgsqlCommand($"INSERT INTO client (name, surname, address, phone, email) VALUES ('{client.Name}', '{client.Surname}', '{client.Address}', '{client.Phone}', '{client.Email}')", conn);
cmd.ExecuteNonQuery();
}
@ -152,7 +152,7 @@ namespace database
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO rental (id, car_id, client_id, start_date, end_date, cost) VALUES ({rental.Id}, {rental.CarId}, {rental.ClientId}, '{rental.StartDate}', '{rental.EndDate}', {rental.Cost})", conn);
using var cmd = new NpgsqlCommand($"INSERT INTO rental (car_id, client_id, start_date, end_date, cost) VALUES ({rental.CarId}, {rental.ClientId}, '{rental.StartDate}', '{rental.EndDate}', {rental.Cost})", conn);
cmd.ExecuteNonQuery();
}
@ -220,7 +220,7 @@ namespace database
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO car_model (id, brand, model, year, body_type_id, seats) VALUES ({carModel.Id}, '{carModel.Brand}', '{carModel.Model}', {carModel.Year}, {carModel.BodyTypeId}, {carModel.Seats})", conn);
using var cmd = new NpgsqlCommand($"INSERT INTO car_model (brand, model, year, body_type_id, seats) VALUES ('{carModel.Brand}', '{carModel.Model}', {carModel.Year}, {carModel.BodyTypeId}, {carModel.Seats})", conn);
cmd.ExecuteNonQuery();
}
@ -287,7 +287,7 @@ namespace database
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO branch (id, name, address, phone, working_hours) VALUES ({branch.Id}, '{branch.Name}', '{branch.Address}', '{branch.Phone}', '{branch.WorkingHours}')", conn);
using var cmd = new NpgsqlCommand($"INSERT INTO branch (name, address, phone, working_hours) VALUES ('{branch.Name}', '{branch.Address}', '{branch.Phone}', '{branch.WorkingHours}')", conn);
cmd.ExecuteNonQuery();
}
@ -353,7 +353,7 @@ namespace database
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO status (id, title) VALUES ({status.Id}, '{status.Title}')", conn);
using var cmd = new NpgsqlCommand($"INSERT INTO status (title) VALUES ('{status.Title}')", conn);
cmd.ExecuteNonQuery();
}
@ -413,7 +413,7 @@ namespace database
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO body_type (id, title) VALUES ({bodyType.Id}, '{bodyType.Title}')", conn);
using var cmd = new NpgsqlCommand($"INSERT INTO body_type (title) VALUES ('{bodyType.Title}')", conn);
cmd.ExecuteNonQuery();
}