diff --git a/ПХД/App.config b/ПХД/App.config index 56efbc7..24c49e7 100644 --- a/ПХД/App.config +++ b/ПХД/App.config @@ -1,6 +1,22 @@ - + - - - + + +
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ПХД/Engines.db b/ПХД/Engines.db new file mode 100644 index 0000000..e69de29 diff --git a/ПХД/Form1.Designer.cs b/ПХД/Form1.Designer.cs index 02ce915..f7d20fc 100644 --- a/ПХД/Form1.Designer.cs +++ b/ПХД/Form1.Designer.cs @@ -28,20 +28,492 @@ /// private void InitializeComponent() { + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.экспортToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.помощьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.datePickerRegistration = new System.Windows.Forms.DateTimePicker(); + this.cmbEngineType = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.txtPower = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.cmbRPM = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.cmbMountingType = new System.Windows.Forms.ComboBox(); + this.label5 = new System.Windows.Forms.Label(); + this.txtUniqueNumber = new System.Windows.Forms.TextBox(); + this.txtFactoryNumber = new System.Windows.Forms.TextBox(); + this.txtPartNumber = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.label9 = new System.Windows.Forms.Label(); + this.txtInstallationSite = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.label10 = new System.Windows.Forms.Label(); + this.datePickerOutOfOrder = new System.Windows.Forms.DateTimePicker(); + this.txtReason = new System.Windows.Forms.TextBox(); + this.chkOutOfOrder = new System.Windows.Forms.CheckBox(); + this.btnSave = new System.Windows.Forms.Button(); + this.btnClear = new System.Windows.Forms.Button(); + this.btnDelete = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.btnSearch = new System.Windows.Forms.Button(); + this.label11 = new System.Windows.Forms.Label(); + this.импортToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.menuStrip1.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.файлToolStripMenuItem, + this.помощьToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(1079, 24); + this.menuStrip1.TabIndex = 1; + this.menuStrip1.Text = "menuStrip1"; + // + // файлToolStripMenuItem + // + this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.экспортToolStripMenuItem, + this.импортToolStripMenuItem}); + this.файлToolStripMenuItem.Name = "файлToolStripMenuItem"; + this.файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20); + this.файлToolStripMenuItem.Text = "Файл"; + // + // экспортToolStripMenuItem + // + this.экспортToolStripMenuItem.Name = "экспортToolStripMenuItem"; + this.экспортToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.экспортToolStripMenuItem.Text = "Экспорт"; + this.экспортToolStripMenuItem.Click += new System.EventHandler(this.экспортToolStripMenuItem_Click); + // + // помощьToolStripMenuItem + // + this.помощьToolStripMenuItem.Name = "помощьToolStripMenuItem"; + this.помощьToolStripMenuItem.Size = new System.Drawing.Size(68, 20); + this.помощьToolStripMenuItem.Text = "Помощь"; + // + // datePickerRegistration + // + this.datePickerRegistration.Location = new System.Drawing.Point(12, 47); + this.datePickerRegistration.Name = "datePickerRegistration"; + this.datePickerRegistration.Size = new System.Drawing.Size(200, 20); + this.datePickerRegistration.TabIndex = 2; + // + // cmbEngineType + // + this.cmbEngineType.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + this.cmbEngineType.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.cmbEngineType.FormattingEnabled = true; + this.cmbEngineType.Items.AddRange(new object[] { + "АИР80S4", + "АИР90S6", + "АДМ112М8", + "АИР315М8"}); + this.cmbEngineType.Location = new System.Drawing.Point(17, 38); + this.cmbEngineType.Name = "cmbEngineType"; + this.cmbEngineType.Size = new System.Drawing.Size(121, 21); + this.cmbEngineType.TabIndex = 3; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label1.Location = new System.Drawing.Point(12, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(94, 13); + this.label1.TabIndex = 4; + this.label1.Text = "Тип двигателя"; + // + // txtPower + // + this.txtPower.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + this.txtPower.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.txtPower.FormattingEnabled = true; + this.txtPower.Items.AddRange(new object[] { + "1,5", + "2", + "4", + "160"}); + this.txtPower.Location = new System.Drawing.Point(198, 38); + this.txtPower.Name = "txtPower"; + this.txtPower.Size = new System.Drawing.Size(121, 21); + this.txtPower.TabIndex = 5; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label2.Location = new System.Drawing.Point(197, 22); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(68, 13); + this.label2.TabIndex = 6; + this.label2.Text = "Мощность"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label3.Location = new System.Drawing.Point(319, 43); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(33, 16); + this.label3.TabIndex = 7; + this.label3.Text = "кВт"; + // + // cmbRPM + // + this.cmbRPM.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + this.cmbRPM.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.cmbRPM.FormattingEnabled = true; + this.cmbRPM.Items.AddRange(new object[] { + "1500", + "1000", + "740"}); + this.cmbRPM.Location = new System.Drawing.Point(404, 38); + this.cmbRPM.Name = "cmbRPM"; + this.cmbRPM.Size = new System.Drawing.Size(121, 21); + this.cmbRPM.TabIndex = 8; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label4.Location = new System.Drawing.Point(404, 22); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(59, 13); + this.label4.TabIndex = 9; + this.label4.Text = "Обороты"; + // + // cmbMountingType + // + this.cmbMountingType.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + this.cmbMountingType.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.cmbMountingType.FormattingEnabled = true; + this.cmbMountingType.Items.AddRange(new object[] { + "1001", + "2081", + "3021", + "1021"}); + this.cmbMountingType.Location = new System.Drawing.Point(604, 38); + this.cmbMountingType.Name = "cmbMountingType"; + this.cmbMountingType.Size = new System.Drawing.Size(165, 21); + this.cmbMountingType.TabIndex = 10; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label5.Location = new System.Drawing.Point(601, 22); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(148, 13); + this.label5.TabIndex = 11; + this.label5.Text = "Монтажное исполнение"; + // + // txtUniqueNumber + // + this.txtUniqueNumber.Location = new System.Drawing.Point(18, 39); + this.txtUniqueNumber.Name = "txtUniqueNumber"; + this.txtUniqueNumber.Size = new System.Drawing.Size(144, 20); + this.txtUniqueNumber.TabIndex = 12; + // + // txtFactoryNumber + // + this.txtFactoryNumber.Location = new System.Drawing.Point(200, 39); + this.txtFactoryNumber.Name = "txtFactoryNumber"; + this.txtFactoryNumber.Size = new System.Drawing.Size(152, 20); + this.txtFactoryNumber.TabIndex = 13; + // + // txtPartNumber + // + this.txtPartNumber.Location = new System.Drawing.Point(404, 39); + this.txtPartNumber.Name = "txtPartNumber"; + this.txtPartNumber.Size = new System.Drawing.Size(149, 20); + this.txtPartNumber.TabIndex = 14; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.cmbEngineType); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.txtPower); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label5); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.cmbMountingType); + this.groupBox1.Controls.Add(this.cmbRPM); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Location = new System.Drawing.Point(12, 73); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(811, 72); + this.groupBox1.TabIndex = 15; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Статичные данные"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.label9); + this.groupBox2.Controls.Add(this.txtInstallationSite); + this.groupBox2.Controls.Add(this.label8); + this.groupBox2.Controls.Add(this.label7); + this.groupBox2.Controls.Add(this.label6); + this.groupBox2.Controls.Add(this.txtPartNumber); + this.groupBox2.Controls.Add(this.txtUniqueNumber); + this.groupBox2.Controls.Add(this.txtFactoryNumber); + this.groupBox2.Location = new System.Drawing.Point(12, 151); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(570, 126); + this.groupBox2.TabIndex = 16; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Динамические данные"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label9.Location = new System.Drawing.Point(14, 73); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(109, 13); + this.label9.TabIndex = 19; + this.label9.Text = "Место установки"; + // + // txtInstallationSite + // + this.txtInstallationSite.Location = new System.Drawing.Point(17, 89); + this.txtInstallationSite.Name = "txtInstallationSite"; + this.txtInstallationSite.Size = new System.Drawing.Size(536, 20); + this.txtInstallationSite.TabIndex = 18; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label8.Location = new System.Drawing.Point(401, 23); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(136, 13); + this.label8.TabIndex = 17; + this.label8.Text = "Номер номенклатуры"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label7.Location = new System.Drawing.Point(197, 23); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(112, 13); + this.label7.TabIndex = 16; + this.label7.Text = "Заводской номер"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label6.Location = new System.Drawing.Point(15, 23); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(122, 13); + this.label6.TabIndex = 15; + this.label6.Text = "Уникальный номер"; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.label10); + this.groupBox3.Controls.Add(this.datePickerOutOfOrder); + this.groupBox3.Controls.Add(this.txtReason); + this.groupBox3.Controls.Add(this.chkOutOfOrder); + this.groupBox3.Location = new System.Drawing.Point(605, 151); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(218, 126); + this.groupBox3.TabIndex = 17; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Неисправность"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label10.Location = new System.Drawing.Point(3, 84); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(140, 13); + this.label10.TabIndex = 3; + this.label10.Text = "Дата выхода из строя"; + // + // datePickerOutOfOrder + // + this.datePickerOutOfOrder.Location = new System.Drawing.Point(6, 100); + this.datePickerOutOfOrder.Name = "datePickerOutOfOrder"; + this.datePickerOutOfOrder.Size = new System.Drawing.Size(200, 20); + this.datePickerOutOfOrder.TabIndex = 2; + // + // txtReason + // + this.txtReason.Location = new System.Drawing.Point(6, 49); + this.txtReason.Name = "txtReason"; + this.txtReason.Size = new System.Drawing.Size(188, 20); + this.txtReason.TabIndex = 1; + this.txtReason.Text = "Причина"; + // + // chkOutOfOrder + // + this.chkOutOfOrder.AutoSize = true; + this.chkOutOfOrder.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.chkOutOfOrder.Location = new System.Drawing.Point(12, 26); + this.chkOutOfOrder.Name = "chkOutOfOrder"; + this.chkOutOfOrder.Size = new System.Drawing.Size(122, 17); + this.chkOutOfOrder.TabIndex = 0; + this.chkOutOfOrder.Text = "Вышел из строя"; + this.chkOutOfOrder.UseVisualStyleBackColor = true; + this.chkOutOfOrder.CheckedChanged += new System.EventHandler(this.chkOutOfOrder_CheckedChanged); + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(12, 283); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(75, 23); + this.btnSave.TabIndex = 18; + this.btnSave.Text = "Сохранить"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // btnClear + // + this.btnClear.Location = new System.Drawing.Point(93, 283); + this.btnClear.Name = "btnClear"; + this.btnClear.Size = new System.Drawing.Size(75, 23); + this.btnClear.TabIndex = 19; + this.btnClear.Text = "Очистить"; + this.btnClear.UseVisualStyleBackColor = true; + this.btnClear.Click += new System.EventHandler(this.btnClear_Click); + // + // btnDelete + // + this.btnDelete.Location = new System.Drawing.Point(174, 283); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(75, 23); + this.btnDelete.TabIndex = 20; + this.btnDelete.Text = "Удалить"; + this.btnDelete.UseVisualStyleBackColor = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Location = new System.Drawing.Point(12, 312); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.Size = new System.Drawing.Size(1055, 328); + this.dataGridView1.TabIndex = 21; + this.dataGridView1.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dataGridView1_CellFormatting); + // + // btnSearch + // + this.btnSearch.Location = new System.Drawing.Point(256, 283); + this.btnSearch.Name = "btnSearch"; + this.btnSearch.Size = new System.Drawing.Size(75, 23); + this.btnSearch.TabIndex = 22; + this.btnSearch.Text = "Поиск"; + this.btnSearch.UseVisualStyleBackColor = true; + this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label11.Location = new System.Drawing.Point(9, 31); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(157, 13); + this.label11.TabIndex = 23; + this.label11.Text = "Дата постановки на учет"; + // + // импортToolStripMenuItem + // + this.импортToolStripMenuItem.Name = "импортToolStripMenuItem"; + this.импортToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.импортToolStripMenuItem.Text = "Импорт"; + this.импортToolStripMenuItem.Click += new System.EventHandler(this.импортToolStripMenuItem_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1375, 652); + this.ClientSize = new System.Drawing.Size(1079, 652); + this.Controls.Add(this.label11); + this.Controls.Add(this.btnSearch); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.btnClear); + this.Controls.Add(this.btnSave); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.datePickerRegistration); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; this.Name = "Form1"; this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem файлToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem помощьToolStripMenuItem; + private System.Windows.Forms.DateTimePicker datePickerRegistration; + private System.Windows.Forms.ComboBox cmbEngineType; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox txtPower; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox cmbRPM; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox cmbMountingType; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox txtUniqueNumber; + private System.Windows.Forms.TextBox txtFactoryNumber; + private System.Windows.Forms.TextBox txtPartNumber; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox txtInstallationSite; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.DateTimePicker datePickerOutOfOrder; + private System.Windows.Forms.TextBox txtReason; + private System.Windows.Forms.CheckBox chkOutOfOrder; + private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.Button btnClear; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Button btnSearch; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.ToolStripMenuItem экспортToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem импортToolStripMenuItem; } } diff --git a/ПХД/Form1.cs b/ПХД/Form1.cs index 1eadad9..0c80d34 100644 --- a/ПХД/Form1.cs +++ b/ПХД/Form1.cs @@ -1,20 +1,591 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; +using System.Data.SQLite; +using System.IO; +using OfficeOpenXml; namespace ПХД { public partial class Form1 : Form { + private DatabaseManager dbManager; + public Form1() { InitializeComponent(); + dbManager = new DatabaseManager(); + SetupDataGridView(); + } + + private void Form1_Load(object sender, EventArgs e) + { + dbManager = new DatabaseManager(); + dbManager.InitializeDatabase(); + LoadEngines(); + txtReason.Enabled = false; + datePickerOutOfOrder.Enabled = false; + } + + private void LoadEngines() + { + try + { + dataGridView1.DataSource = dbManager.GetAllEngines(); + } + catch (Exception ex) + { + MessageBox.Show($"Ошибка загрузки данных: {ex.Message}"); + } + } + + private void btnSave_Click(object sender, EventArgs e) + { + try + { + string registrationDate = datePickerRegistration.Value.ToString("yyyy-MM-dd"); + string engineType = cmbEngineType.Text; + double power = double.Parse(txtPower.Text); + int rpm = int.Parse(cmbRPM.Text); + string mountingType = cmbMountingType.Text; + string uniqueNumber = txtUniqueNumber.Text; + string factoryNumber = txtFactoryNumber.Text; + string partNumber = txtPartNumber.Text; + string installationSite = txtInstallationSite.Text; + bool isOutOfOrder = chkOutOfOrder.Checked; + string reason = isOutOfOrder ? txtReason.Text : null; + string outOfOrderDate = isOutOfOrder ? datePickerOutOfOrder.Value.ToString("yyyy-MM-dd") : null; + + dbManager.AddEngine( + registrationDate, engineType, power, rpm, mountingType, + uniqueNumber, factoryNumber, partNumber, installationSite, + isOutOfOrder, reason, outOfOrderDate + ); + + LoadEngines(); + MessageBox.Show("Запись успешно сохранена!"); + } + catch (Exception ex) + { + MessageBox.Show($"Произошла ошибка: {ex.Message}"); + } + } + + private void SetupDataGridView() + { + dataGridView1.AutoGenerateColumns = false; + dataGridView1.Columns.Clear(); + + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + Name = "Id", + HeaderText = "ID", + DataPropertyName = "Id", + Width = 50 + }); + + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Дата постановки", + DataPropertyName = "RegistrationDate", + Width = 120 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Тип двигателя", + DataPropertyName = "EngineType", + Width = 100 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Мощность (кВт)", + DataPropertyName = "Power", + Width = 100 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Обороты", + DataPropertyName = "RPM", + Width = 100 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Монтажное исполнение", + DataPropertyName = "MountingType", + Width = 150 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Уникальный номер", + DataPropertyName = "UniqueNumber", + Width = 150 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Заводской номер", + DataPropertyName = "FactoryNumber", + Width = 150 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Номер номенклатуры", + DataPropertyName = "PartNumber", + Width = 150 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Место установки", + DataPropertyName = "InstallationSite", + Width = 150 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + Name = "IsOutOfOrder", // Имя столбца в DataGridView + HeaderText = "Вышел из строя", + DataPropertyName = "IsOutOfOrder", // Имя столбца в DataTable/базе данных + Width = 120 + }); + + + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Причина", + DataPropertyName = "Reason", + Width = 150 + }); + dataGridView1.Columns.Add(new DataGridViewTextBoxColumn + { + HeaderText = "Дата выхода из строя", + DataPropertyName = "OutOfOrderDate", + Width = 150 + }); + } + + private void btnDelete_Click(object sender, EventArgs e) + { + try + { + if (dataGridView1.SelectedRows.Count > 0) + { + // Получаем ID выбранной строки + var idCell = dataGridView1.SelectedRows[0].Cells["Id"]; + if (idCell != null && idCell.Value != null) + { + int id = Convert.ToInt32(idCell.Value); + + // Подтверждение удаления + var result = MessageBox.Show("Вы уверены, что хотите удалить эту запись?", + "Подтверждение удаления", + MessageBoxButtons.YesNo, + MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + dbManager.DeleteEngine(id); + LoadEngines(); // Обновляем таблицу + MessageBox.Show("Запись успешно удалена!"); + } + } + else + { + MessageBox.Show("Не удалось определить ID записи."); + } + } + else + { + MessageBox.Show("Пожалуйста, выберите запись для удаления."); + } + } + catch (Exception ex) + { + MessageBox.Show($"Произошла ошибка при удалении записи: {ex.Message}"); + } + } + + private void chkOutOfOrder_CheckedChanged(object sender, EventArgs e) + { + // Поля блокируются, если чекбокс не установлен + bool isEnabled = chkOutOfOrder.Checked; + txtReason.Enabled = isEnabled; + datePickerOutOfOrder.Enabled = isEnabled; + } + private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + if (dataGridView1.Columns[e.ColumnIndex].Name == "IsOutOfOrder") + { + var row = dataGridView1.Rows[e.RowIndex]; + + if (row.Cells["IsOutOfOrder"] != null && row.Cells["IsOutOfOrder"].Value != null) + { + var value = row.Cells["IsOutOfOrder"].Value; + + if (value != DBNull.Value) + { + bool isOutOfOrder = Convert.ToBoolean(value); + + // Подсвечиваем фон ячейки + e.CellStyle.BackColor = isOutOfOrder + ? System.Drawing.Color.LightCoral // Красный фон + : System.Drawing.Color.White; // Белый фон + } + else + { + e.CellStyle.BackColor = System.Drawing.Color.White; + } + } + } + } + + private void btnClear_Click(object sender, EventArgs e) + { + // Очистка текстовых полей + txtPower.Text = string.Empty; + txtUniqueNumber.Text = string.Empty; + txtFactoryNumber.Text = string.Empty; + txtPartNumber.Text = string.Empty; + txtInstallationSite.Text = string.Empty; + txtReason.Text = string.Empty; + + // Сброс выпадающих списков + cmbEngineType.SelectedIndex = -1; // Сбрасывает выбор + cmbRPM.SelectedIndex = -1; + cmbMountingType.SelectedIndex = -1; + + // Сброс чекбоксов + chkOutOfOrder.Checked = false; + + // Сброс дат + datePickerRegistration.Value = DateTime.Now; + datePickerOutOfOrder.Value = DateTime.Now; + + // Блокировка полей "Неисправность" + txtReason.Enabled = false; + datePickerOutOfOrder.Enabled = false; + LoadEngines(); + + } + + private void btnSearch_Click(object sender, EventArgs e) + { + try + { + // Формируем SQL-запрос с фильтрацией + string query = "SELECT * FROM Engines WHERE 1=1"; // Условие 1=1 позволяет добавлять фильтры динамически + + if (!string.IsNullOrWhiteSpace(txtPower.Text)) + { + query += $" AND Power = {txtPower.Text}"; + } + + if (!string.IsNullOrWhiteSpace(cmbEngineType.Text)) + { + query += $" AND EngineType LIKE '%{cmbEngineType.Text}%'"; + } + + if (!string.IsNullOrWhiteSpace(txtUniqueNumber.Text)) + { + query += $" AND UniqueNumber LIKE '%{txtUniqueNumber.Text}%'"; + } + + if (!string.IsNullOrWhiteSpace(txtFactoryNumber.Text)) + { + query += $" AND FactoryNumber LIKE '%{txtFactoryNumber.Text}%'"; + } + + if (!string.IsNullOrWhiteSpace(txtPartNumber.Text)) + { + query += $" AND PartNumber LIKE '%{txtPartNumber.Text}%'"; + } + + if (!string.IsNullOrWhiteSpace(txtInstallationSite.Text)) + { + query += $" AND InstallationSite LIKE '%{txtInstallationSite.Text}%'"; + } + + if (chkOutOfOrder.Checked) + { + query += " AND IsOutOfOrder = 1"; + } + + // Выполняем запрос + DataTable searchResults = dbManager.ExecuteQuery(query); + dataGridView1.DataSource = searchResults; // Отображаем результаты поиска + } + catch (Exception ex) + { + MessageBox.Show($"Произошла ошибка при поиске: {ex.Message}"); + } + } + + private void экспортToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + using (var saveFileDialog = new SaveFileDialog()) + { + saveFileDialog.Filter = "Excel Files|*.xlsx"; + saveFileDialog.Title = "Сохранить таблицу как Excel файл"; + saveFileDialog.FileName = "Engines.xlsx"; + + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + // Получаем данные из DataGridView + DataTable table = (DataTable)dataGridView1.DataSource; + + // Экспортируем в Excel + ExportToExcel(table, saveFileDialog.FileName); + + MessageBox.Show("Данные успешно экспортированы!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + } + catch (Exception ex) + { + MessageBox.Show($"Произошла ошибка при экспорте: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ExportToExcel(DataTable table, string filePath) + { + // Указываем контекст лицензии + ExcelPackage.LicenseContext = LicenseContext.NonCommercial; + + using (var package = new OfficeOpenXml.ExcelPackage()) + { + // Создаем новый лист + var worksheet = package.Workbook.Worksheets.Add("Engines"); + + // Заголовки столбцов из DataGridView + for (int col = 0; col < dataGridView1.Columns.Count; col++) + { + worksheet.Cells[1, col + 1].Value = dataGridView1.Columns[col].HeaderText; // Используем HeaderText + } + + // Данные из DataTable + for (int row = 0; row < table.Rows.Count; row++) + { + for (int col = 0; col < table.Columns.Count; col++) + { + worksheet.Cells[row + 2, col + 1].Value = table.Rows[row][col]; + } + } + + // Авторазмер столбцов + worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); + + // Сохраняем файл + package.SaveAs(new FileInfo(filePath)); + } + } + + private void импортToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + using (var openFileDialog = new OpenFileDialog()) + { + openFileDialog.Filter = "Excel Files|*.xlsx"; + openFileDialog.Title = "Выберите Excel файл для импорта"; + + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + // Импортируем данные из Excel + DataTable importedTable = ImportFromExcel(openFileDialog.FileName); + + // Проверяем, содержит ли таблица строки + if (importedTable.Rows.Count == 0) + { + MessageBox.Show("Файл Excel не содержит данных для импорта.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + // Загружаем данные в DataGridView + dataGridView1.DataSource = importedTable; + + MessageBox.Show("Данные успешно импортированы!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + } + catch (Exception ex) + { + MessageBox.Show($"Произошла ошибка при импорте: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + + private DataTable ImportFromExcel(string filePath) + { + DataTable table = new DataTable(); + + ExcelPackage.LicenseContext = LicenseContext.NonCommercial; + + using (var package = new OfficeOpenXml.ExcelPackage(new FileInfo(filePath))) + { + // Получаем первый лист из файла + var worksheet = package.Workbook.Worksheets[0]; + if (worksheet == null) + { + throw new Exception("В файле отсутствуют листы."); + } + + // Создаем колонки на основе заголовков DataGridView + foreach (DataGridViewColumn column in dataGridView1.Columns) + { + table.Columns.Add(column.DataPropertyName); + } + + // Читаем данные начиная со второй строки + for (int row = 2; row <= worksheet.Dimension.End.Row; row++) + { + DataRow newRow = table.NewRow(); + for (int col = 1; col <= worksheet.Dimension.End.Column; col++) + { + // Сопоставляем заголовки Excel с DataPropertyName + string columnName = worksheet.Cells[1, col].Text.Trim(); + if (table.Columns.Contains(columnName)) + { + newRow[columnName] = worksheet.Cells[row, col].Text.Trim(); + } + } + table.Rows.Add(newRow); + } + } + + return table; + } + + + + + + + + + + + + + + + + + + + + private class DatabaseManager + { + private string connectionString = "Data Source=Engines.db;Version=3;"; + + public void InitializeDatabase() + { + using (var connection = new SQLiteConnection(connectionString)) + { + connection.Open(); + string createTableQuery = @" + CREATE TABLE IF NOT EXISTS Engines ( + Id INTEGER PRIMARY KEY AUTOINCREMENT, + RegistrationDate TEXT NOT NULL, + EngineType TEXT NOT NULL, + Power REAL NOT NULL, + RPM INTEGER NOT NULL, + MountingType TEXT NOT NULL, + UniqueNumber TEXT NOT NULL, + FactoryNumber TEXT NOT NULL, + PartNumber TEXT NOT NULL, + InstallationSite TEXT NOT NULL, + IsOutOfOrder INTEGER NOT NULL, + Reason TEXT, + OutOfOrderDate TEXT + )"; + SQLiteCommand command = new SQLiteCommand(createTableQuery, connection); + command.ExecuteNonQuery(); + } + } + + public void AddEngine( + string registrationDate, string engineType, double power, int rpm, + string mountingType, string uniqueNumber, string factoryNumber, + string partNumber, string installationSite, bool isOutOfOrder, + string reason, string outOfOrderDate) + { + using (var connection = new SQLiteConnection(connectionString)) + { + connection.Open(); + string insertQuery = @" + INSERT INTO Engines + (RegistrationDate, EngineType, Power, RPM, MountingType, + UniqueNumber, FactoryNumber, PartNumber, InstallationSite, + IsOutOfOrder, Reason, OutOfOrderDate) + VALUES + (@RegistrationDate, @EngineType, @Power, @RPM, @MountingType, + @UniqueNumber, @FactoryNumber, @PartNumber, @InstallationSite, + @IsOutOfOrder, @Reason, @OutOfOrderDate)"; + + SQLiteCommand command = new SQLiteCommand(insertQuery, connection); + command.Parameters.AddWithValue("@RegistrationDate", registrationDate); + command.Parameters.AddWithValue("@EngineType", engineType); + command.Parameters.AddWithValue("@Power", power); + command.Parameters.AddWithValue("@RPM", rpm); + command.Parameters.AddWithValue("@MountingType", mountingType); + command.Parameters.AddWithValue("@UniqueNumber", uniqueNumber); + command.Parameters.AddWithValue("@FactoryNumber", factoryNumber); + command.Parameters.AddWithValue("@PartNumber", partNumber); + command.Parameters.AddWithValue("@InstallationSite", installationSite); + command.Parameters.AddWithValue("@IsOutOfOrder", isOutOfOrder ? 1 : 0); + command.Parameters.AddWithValue("@Reason", reason ?? (object)DBNull.Value); + command.Parameters.AddWithValue("@OutOfOrderDate", outOfOrderDate ?? (object)DBNull.Value); + + command.ExecuteNonQuery(); + } + } + + public DataTable GetAllEngines() + { + using (var connection = new SQLiteConnection(connectionString)) + { + connection.Open(); + + string selectQuery = @" + SELECT + Id, RegistrationDate, EngineType, Power, RPM, MountingType, + UniqueNumber, FactoryNumber, PartNumber, InstallationSite, + IsOutOfOrder, Reason, OutOfOrderDate + FROM Engines"; + + + SQLiteDataAdapter adapter = new SQLiteDataAdapter(selectQuery, connection); + DataTable table = new DataTable(); + adapter.Fill(table); + return table; + } + } + + public void DeleteEngine(int id) + { + using (var connection = new SQLiteConnection(connectionString)) + { + connection.Open(); + string deleteQuery = "DELETE FROM Engines WHERE Id = @Id"; + SQLiteCommand command = new SQLiteCommand(deleteQuery, connection); + command.Parameters.AddWithValue("@Id", id); + command.ExecuteNonQuery(); + } + } + + public DataTable ExecuteQuery(string query) + { + using (var connection = new SQLiteConnection(connectionString)) + { + connection.Open(); + SQLiteDataAdapter adapter = new SQLiteDataAdapter(query, connection); + DataTable table = new DataTable(); + adapter.Fill(table); + return table; + } + } + + + } } } diff --git a/ПХД/Form1.resx b/ПХД/Form1.resx index 1af7de1..32fcbfb 100644 --- a/ПХД/Form1.resx +++ b/ПХД/Form1.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 25 + \ No newline at end of file diff --git a/ПХД/packages.config b/ПХД/packages.config new file mode 100644 index 0000000..954be28 --- /dev/null +++ b/ПХД/packages.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ПХД/ПХД.csproj b/ПХД/ПХД.csproj index 34614e5..6b1d15b 100644 --- a/ПХД/ПХД.csproj +++ b/ПХД/ПХД.csproj @@ -1,5 +1,6 @@  + Debug @@ -12,6 +13,8 @@ 512 true true + + AnyCPU @@ -33,8 +36,58 @@ 4 + + ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\EPPlus.7.5.3\lib\net462\EPPlus.dll + + + ..\packages\EPPlus.Interfaces.7.5.0\lib\net462\EPPlus.Interfaces.dll + + + ..\packages\EPPlus.System.Drawing.7.5.0\lib\net462\EPPlus.System.Drawing.dll + + + ..\packages\Microsoft.IO.RecyclableMemoryStream.3.0.1\lib\netstandard2.0\Microsoft.IO.RecyclableMemoryStream.dll + + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll + + + + + ..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\lib\net46\System.Data.SQLite.dll + + + ..\packages\System.Data.SQLite.EF6.1.0.119.0\lib\net46\System.Data.SQLite.EF6.dll + + + ..\packages\System.Data.SQLite.Linq.1.0.119.0\lib\net46\System.Data.SQLite.Linq.dll + + + ..\packages\System.Drawing.Common.8.0.4\lib\net462\System.Drawing.Common.dll + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + @@ -66,6 +119,10 @@ True Resources.resx + + PreserveNewest + + SettingsSingleFileGenerator Settings.Designer.cs @@ -80,4 +137,14 @@ + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + + + + \ No newline at end of file