From 02770a46913495725f09b8212661391b3b486795 Mon Sep 17 00:00:00 2001 From: student Date: Wed, 16 Apr 2025 13:28:21 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=D1=82?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 22 + DbManager.cs | 333 +++++++++++++ Form1.Designer.cs | 816 +++++++++++++++++++++++++++++++ Form1.cs | 327 +++++++++++++ Form1.resx | 120 +++++ LoginForm.Designer.cs | 129 +++++ LoginForm.cs | 61 +++ LoginForm.resx | 120 +++++ Models.cs | 55 +++ Program.cs | 20 + Properties/AssemblyInfo.cs | 33 ++ Properties/Resources.Designer.cs | 71 +++ Properties/Resources.resx | 117 +++++ Properties/Settings.Designer.cs | 30 ++ Properties/Settings.settings | 7 + packages.config | 10 + Учет вещей.csproj | 133 +++++ Учет вещей.sln | 25 + 18 files changed, 2429 insertions(+) create mode 100644 App.config create mode 100644 DbManager.cs create mode 100644 Form1.Designer.cs create mode 100644 Form1.cs create mode 100644 Form1.resx create mode 100644 LoginForm.Designer.cs create mode 100644 LoginForm.cs create mode 100644 LoginForm.resx create mode 100644 Models.cs create mode 100644 Program.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings create mode 100644 packages.config create mode 100644 Учет вещей.csproj create mode 100644 Учет вещей.sln diff --git a/App.config b/App.config new file mode 100644 index 0000000..24c49e7 --- /dev/null +++ b/App.config @@ -0,0 +1,22 @@ + + + + +
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DbManager.cs b/DbManager.cs new file mode 100644 index 0000000..d124555 --- /dev/null +++ b/DbManager.cs @@ -0,0 +1,333 @@ +using System; +using System.Collections.Generic; +using System.Data.SQLite; +using System.IO; +using System.Linq; +using System.Text; + +namespace Учет_вещей +{ + public static class DbManager + { + private const string DbFileName = "inventory.db"; + private static readonly string ConnectionString = $"Data Source={DbFileName};Version=3;"; + + // Инициализация базы данных + public static void InitializeDatabase() + { + // Проверяем существование файла базы данных + bool isNewDatabase = !File.Exists(DbFileName); + + if (isNewDatabase) + { + // Создаем базу данных и необходимые таблицы + SQLiteConnection.CreateFile(DbFileName); + + using (var connection = new SQLiteConnection(ConnectionString)) + { + connection.Open(); + + // Создаем таблицы + string createUsersTable = @" + CREATE TABLE Users ( + Username TEXT PRIMARY KEY, + Password TEXT NOT NULL, + Role INTEGER NOT NULL + )"; + + string createDevicesTable = @" + CREATE TABLE Devices ( + Id INTEGER PRIMARY KEY AUTOINCREMENT, + Name TEXT NOT NULL, + InventoryNumber TEXT NOT NULL, + Type INTEGER NOT NULL, + Location TEXT, + ResponsiblePerson TEXT, + State INTEGER NOT NULL, + RegistrationDate TEXT NOT NULL + )"; + + using (var command = new SQLiteCommand(createUsersTable, connection)) + { + command.ExecuteNonQuery(); + } + + using (var command = new SQLiteCommand(createDevicesTable, connection)) + { + command.ExecuteNonQuery(); + } + + // Добавляем предустановленных пользователей + string insertDefaultUsers = @" + INSERT INTO Users (Username, Password, Role) VALUES + ('admin', 'admin', 1), + ('user', 'user', 0)"; + + using (var command = new SQLiteCommand(insertDefaultUsers, connection)) + { + command.ExecuteNonQuery(); + } + } + } + } + + #region Пользователи + + // Авторизация пользователя + public static User Authenticate(string username, string password) + { + using (var connection = new SQLiteConnection(ConnectionString)) + { + connection.Open(); + string query = "SELECT Username, Password, Role FROM Users WHERE Username = @Username AND Password = @Password"; + + using (var command = new SQLiteCommand(query, connection)) + { + command.Parameters.AddWithValue("@Username", username); + command.Parameters.AddWithValue("@Password", password); + + using (var reader = command.ExecuteReader()) + { + if (reader.Read()) + { + return new User + { + Username = reader["Username"].ToString(), + Password = reader["Password"].ToString(), + Role = (UserRole)Convert.ToInt32(reader["Role"]) + }; + } + } + } + } + + return null; + } + + #endregion + + #region Устройства + + // Получение всех устройств + public static List GetAllDevices() + { + List devices = new List(); + + using (var connection = new SQLiteConnection(ConnectionString)) + { + connection.Open(); + string query = "SELECT * FROM Devices"; + + using (var command = new SQLiteCommand(query, connection)) + { + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + { + devices.Add(ReadDeviceFromDb(reader)); + } + } + } + } + + return devices; + } + + // Добавление нового устройства + public static void AddDevice(Device device) + { + using (var connection = new SQLiteConnection(ConnectionString)) + { + connection.Open(); + string query = @" + INSERT INTO Devices (Name, InventoryNumber, Type, Location, ResponsiblePerson, State, RegistrationDate) + VALUES (@Name, @InventoryNumber, @Type, @Location, @ResponsiblePerson, @State, @RegistrationDate); + SELECT last_insert_rowid();"; + + using (var command = new SQLiteCommand(query, connection)) + { + SetDeviceParameters(command, device); + device.Id = Convert.ToInt32(command.ExecuteScalar()); + } + } + } + + // Обновление существующего устройства + public static void UpdateDevice(Device device) + { + using (var connection = new SQLiteConnection(ConnectionString)) + { + connection.Open(); + string query = @" + UPDATE Devices + SET Name = @Name, + InventoryNumber = @InventoryNumber, + Type = @Type, + Location = @Location, + ResponsiblePerson = @ResponsiblePerson, + State = @State, + RegistrationDate = @RegistrationDate + WHERE Id = @Id"; + + using (var command = new SQLiteCommand(query, connection)) + { + command.Parameters.AddWithValue("@Id", device.Id); + SetDeviceParameters(command, device); + command.ExecuteNonQuery(); + } + } + } + + // Удаление устройства + public static void DeleteDevice(int id) + { + using (var connection = new SQLiteConnection(ConnectionString)) + { + connection.Open(); + string query = "DELETE FROM Devices WHERE Id = @Id"; + + using (var command = new SQLiteCommand(query, connection)) + { + command.Parameters.AddWithValue("@Id", id); + command.ExecuteNonQuery(); + } + } + } + + // Фильтрация устройств + public static List FilterDevices(DeviceType? type = null, DeviceState? state = null, + string location = null, string searchText = null) + { + List devices = new List(); + StringBuilder queryBuilder = new StringBuilder("SELECT * FROM Devices WHERE 1=1"); + Dictionary parameters = new Dictionary(); + + if (type.HasValue) + { + queryBuilder.Append(" AND Type = @Type"); + parameters.Add("@Type", (int)type.Value); + } + + if (state.HasValue) + { + queryBuilder.Append(" AND State = @State"); + parameters.Add("@State", (int)state.Value); + } + + if (!string.IsNullOrEmpty(location)) + { + queryBuilder.Append(" AND Location LIKE @Location"); + parameters.Add("@Location", "%" + location + "%"); + } + + if (!string.IsNullOrEmpty(searchText)) + { + queryBuilder.Append(" AND (Name LIKE @SearchText OR InventoryNumber LIKE @SearchText)"); + parameters.Add("@SearchText", "%" + searchText.ToLower() + "%"); + } + + using (var connection = new SQLiteConnection(ConnectionString)) + { + connection.Open(); + + using (var command = new SQLiteCommand(queryBuilder.ToString(), connection)) + { + foreach (var param in parameters) + { + command.Parameters.AddWithValue(param.Key, param.Value); + } + + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + { + devices.Add(ReadDeviceFromDb(reader)); + } + } + } + } + + return devices; + } + + // Статистика по типам устройств + public static Dictionary GetDeviceTypeStats() + { + var result = new Dictionary(); + + using (var connection = new SQLiteConnection(ConnectionString)) + { + connection.Open(); + string query = "SELECT Type, COUNT(*) as Count FROM Devices GROUP BY Type"; + + using (var command = new SQLiteCommand(query, connection)) + { + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + { + DeviceType type = (DeviceType)Convert.ToInt32(reader["Type"]); + int count = Convert.ToInt32(reader["Count"]); + result[type] = count; + } + } + } + } + + return result; + } + + // Экспорт данных в CSV + public static void ExportToCsv(string filePath) + { + var devices = GetAllDevices(); + + var lines = new List + { + "ID;Наименование;Инвентарный номер;Тип;Местоположение;Ответственное лицо;Состояние;Дата постановки на учёт" + }; + + foreach (var device in devices) + { + lines.Add($"{device.Id};{device.Name};{device.InventoryNumber};{device.TypeString};" + + $"{device.Location};{device.ResponsiblePerson};{device.StateString};{device.RegistrationDate:dd.MM.yyyy}"); + } + + File.WriteAllLines(filePath, lines, Encoding.UTF8); + } + + #endregion + + #region Вспомогательные методы + + // Чтение устройства из базы данных + private static Device ReadDeviceFromDb(SQLiteDataReader reader) + { + return new Device + { + Id = Convert.ToInt32(reader["Id"]), + Name = reader["Name"].ToString(), + InventoryNumber = reader["InventoryNumber"].ToString(), + Type = (DeviceType)Convert.ToInt32(reader["Type"]), + Location = reader["Location"].ToString(), + ResponsiblePerson = reader["ResponsiblePerson"].ToString(), + State = (DeviceState)Convert.ToInt32(reader["State"]), + RegistrationDate = Convert.ToDateTime(reader["RegistrationDate"]) + }; + } + + // Установка параметров устройства для команды SQLite + private static void SetDeviceParameters(SQLiteCommand command, Device device) + { + command.Parameters.AddWithValue("@Name", device.Name); + command.Parameters.AddWithValue("@InventoryNumber", device.InventoryNumber); + command.Parameters.AddWithValue("@Type", (int)device.Type); + command.Parameters.AddWithValue("@Location", device.Location ?? string.Empty); + command.Parameters.AddWithValue("@ResponsiblePerson", device.ResponsiblePerson ?? string.Empty); + command.Parameters.AddWithValue("@State", (int)device.State); + command.Parameters.AddWithValue("@RegistrationDate", device.RegistrationDate.ToString("yyyy-MM-dd HH:mm:ss")); + } + + #endregion + } +} diff --git a/Form1.Designer.cs b/Form1.Designer.cs new file mode 100644 index 0000000..b9e726b --- /dev/null +++ b/Form1.Designer.cs @@ -0,0 +1,816 @@ +using MetroFramework.Controls; +using MetroFramework.Forms; + +namespace Учет_вещей +{ + partial class Form1 + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle(); + this.dgvDevices = new MetroFramework.Controls.MetroGrid(); + this.panelControls = new System.Windows.Forms.Panel(); + this.btnExport = new MetroFramework.Controls.MetroButton(); + this.btnResetFilter = new MetroFramework.Controls.MetroButton(); + this.btnFilter = new MetroFramework.Controls.MetroButton(); + this.txtSearch = new MetroFramework.Controls.MetroTextBox(); + this.label10 = new MetroFramework.Controls.MetroLabel(); + this.txtFilterLocation = new MetroFramework.Controls.MetroTextBox(); + this.label9 = new MetroFramework.Controls.MetroLabel(); + this.cmbFilterState = new MetroFramework.Controls.MetroComboBox(); + this.label8 = new MetroFramework.Controls.MetroLabel(); + this.cmbFilterType = new MetroFramework.Controls.MetroComboBox(); + this.label7 = new MetroFramework.Controls.MetroLabel(); + this.panelDeviceDetails = new System.Windows.Forms.Panel(); + this.dtpRegistrationDate = new MetroFramework.Controls.MetroDateTime(); + this.label6 = new MetroFramework.Controls.MetroLabel(); + this.cmbDeviceState = new MetroFramework.Controls.MetroComboBox(); + this.label5 = new MetroFramework.Controls.MetroLabel(); + this.txtResponsiblePerson = new MetroFramework.Controls.MetroTextBox(); + this.label4 = new MetroFramework.Controls.MetroLabel(); + this.txtLocation = new MetroFramework.Controls.MetroTextBox(); + this.label3 = new MetroFramework.Controls.MetroLabel(); + this.cmbDeviceType = new MetroFramework.Controls.MetroComboBox(); + this.label2 = new MetroFramework.Controls.MetroLabel(); + this.txtInventoryNumber = new MetroFramework.Controls.MetroTextBox(); + this.label1 = new MetroFramework.Controls.MetroLabel(); + this.txtDeviceName = new MetroFramework.Controls.MetroTextBox(); + this.lblDeviceName = new MetroFramework.Controls.MetroLabel(); + this.btnSave = new MetroFramework.Controls.MetroButton(); + this.btnDelete = new MetroFramework.Controls.MetroButton(); + this.btnEdit = new MetroFramework.Controls.MetroButton(); + this.btnAdd = new MetroFramework.Controls.MetroButton(); + this.tabControl1 = new MetroFramework.Controls.MetroTabControl(); + this.tabPageDevices = new MetroFramework.Controls.MetroTabPage(); + this.tabPageStatistics = new MetroFramework.Controls.MetroTabPage(); + this.lvStatistics = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + ((System.ComponentModel.ISupportInitialize)(this.dgvDevices)).BeginInit(); + this.panelControls.SuspendLayout(); + this.panelDeviceDetails.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPageDevices.SuspendLayout(); + this.tabPageStatistics.SuspendLayout(); + this.SuspendLayout(); + // + // dgvDevices + // + this.dgvDevices.AllowUserToAddRows = false; + this.dgvDevices.AllowUserToDeleteRows = false; + this.dgvDevices.AllowUserToResizeRows = false; + this.dgvDevices.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dgvDevices.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dgvDevices.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.dgvDevices.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgvDevices.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + this.dgvDevices.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; + dataGridViewCellStyle19.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle19.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(174)))), ((int)(((byte)(219))))); + dataGridViewCellStyle19.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + dataGridViewCellStyle19.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + dataGridViewCellStyle19.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(198)))), ((int)(((byte)(247))))); + dataGridViewCellStyle19.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); + dataGridViewCellStyle19.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgvDevices.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle19; + this.dgvDevices.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle20.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + dataGridViewCellStyle20.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + dataGridViewCellStyle20.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(136)))), ((int)(((byte)(136)))), ((int)(((byte)(136))))); + dataGridViewCellStyle20.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(198)))), ((int)(((byte)(247))))); + dataGridViewCellStyle20.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); + dataGridViewCellStyle20.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvDevices.DefaultCellStyle = dataGridViewCellStyle20; + this.dgvDevices.EnableHeadersVisualStyles = false; + this.dgvDevices.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.dgvDevices.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.dgvDevices.Location = new System.Drawing.Point(10, 62); + this.dgvDevices.Margin = new System.Windows.Forms.Padding(10); + this.dgvDevices.MultiSelect = false; + this.dgvDevices.Name = "dgvDevices"; + this.dgvDevices.ReadOnly = true; + this.dgvDevices.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; + dataGridViewCellStyle21.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle21.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(174)))), ((int)(((byte)(219))))); + dataGridViewCellStyle21.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + dataGridViewCellStyle21.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + dataGridViewCellStyle21.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(198)))), ((int)(((byte)(247))))); + dataGridViewCellStyle21.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); + dataGridViewCellStyle21.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgvDevices.RowHeadersDefaultCellStyle = dataGridViewCellStyle21; + this.dgvDevices.RowHeadersVisible = false; + this.dgvDevices.RowHeadersWidth = 51; + this.dgvDevices.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + this.dgvDevices.RowTemplate.Height = 24; + this.dgvDevices.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvDevices.Size = new System.Drawing.Size(916, 225); + this.dgvDevices.TabIndex = 0; + // + // panelControls + // + this.panelControls.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panelControls.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(255))))); + this.panelControls.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelControls.Controls.Add(this.btnExport); + this.panelControls.Controls.Add(this.btnResetFilter); + this.panelControls.Controls.Add(this.btnFilter); + this.panelControls.Controls.Add(this.txtSearch); + this.panelControls.Controls.Add(this.label10); + this.panelControls.Controls.Add(this.txtFilterLocation); + this.panelControls.Controls.Add(this.label9); + this.panelControls.Controls.Add(this.cmbFilterState); + this.panelControls.Controls.Add(this.label8); + this.panelControls.Controls.Add(this.cmbFilterType); + this.panelControls.Controls.Add(this.label7); + this.panelControls.Location = new System.Drawing.Point(10, 10); + this.panelControls.Margin = new System.Windows.Forms.Padding(10); + this.panelControls.Name = "panelControls"; + this.panelControls.Size = new System.Drawing.Size(916, 42); + this.panelControls.TabIndex = 1; + // + // btnExport + // + this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnExport.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(177)))), ((int)(((byte)(89))))); + this.btnExport.ForeColor = System.Drawing.Color.White; + this.btnExport.Highlight = true; + this.btnExport.Location = new System.Drawing.Point(838, 9); + this.btnExport.Margin = new System.Windows.Forms.Padding(2); + this.btnExport.Name = "btnExport"; + this.btnExport.Size = new System.Drawing.Size(70, 23); + this.btnExport.TabIndex = 10; + this.btnExport.Text = "Экспорт"; + this.btnExport.UseCustomBackColor = true; + this.btnExport.UseCustomForeColor = true; + this.btnExport.UseSelectable = true; + this.btnExport.Click += new System.EventHandler(this.btnExport_Click); + // + // btnResetFilter + // + this.btnResetFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnResetFilter.BackColor = System.Drawing.Color.Silver; + this.btnResetFilter.ForeColor = System.Drawing.Color.White; + this.btnResetFilter.Location = new System.Drawing.Point(763, 9); + this.btnResetFilter.Margin = new System.Windows.Forms.Padding(2); + this.btnResetFilter.Name = "btnResetFilter"; + this.btnResetFilter.Size = new System.Drawing.Size(71, 23); + this.btnResetFilter.TabIndex = 9; + this.btnResetFilter.Text = "Сбросить"; + this.btnResetFilter.UseCustomBackColor = true; + this.btnResetFilter.UseCustomForeColor = true; + this.btnResetFilter.UseSelectable = true; + this.btnResetFilter.Click += new System.EventHandler(this.btnResetFilter_Click); + // + // btnFilter + // + this.btnFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnFilter.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(174)))), ((int)(((byte)(219))))); + this.btnFilter.ForeColor = System.Drawing.Color.White; + this.btnFilter.Highlight = true; + this.btnFilter.Location = new System.Drawing.Point(711, 9); + this.btnFilter.Margin = new System.Windows.Forms.Padding(2); + this.btnFilter.Name = "btnFilter"; + this.btnFilter.Size = new System.Drawing.Size(48, 23); + this.btnFilter.TabIndex = 8; + this.btnFilter.Text = "Поиск"; + this.btnFilter.UseCustomBackColor = true; + this.btnFilter.UseCustomForeColor = true; + this.btnFilter.UseSelectable = true; + this.btnFilter.Click += new System.EventHandler(this.btnFilter_Click); + // + // txtSearch + // + this.txtSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + // + // + // + this.txtSearch.CustomButton.Image = null; + this.txtSearch.CustomButton.Location = new System.Drawing.Point(74, 1); + this.txtSearch.CustomButton.Name = ""; + this.txtSearch.CustomButton.Size = new System.Drawing.Size(21, 21); + this.txtSearch.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.txtSearch.CustomButton.TabIndex = 1; + this.txtSearch.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.txtSearch.CustomButton.UseSelectable = true; + this.txtSearch.CustomButton.Visible = false; + this.txtSearch.Lines = new string[0]; + this.txtSearch.Location = new System.Drawing.Point(601, 9); + this.txtSearch.Margin = new System.Windows.Forms.Padding(2); + this.txtSearch.MaxLength = 32767; + this.txtSearch.Name = "txtSearch"; + this.txtSearch.PasswordChar = '\0'; + this.txtSearch.PromptText = "Поиск..."; + this.txtSearch.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.txtSearch.SelectedText = ""; + this.txtSearch.SelectionLength = 0; + this.txtSearch.SelectionStart = 0; + this.txtSearch.ShortcutsEnabled = true; + this.txtSearch.Size = new System.Drawing.Size(104, 23); + this.txtSearch.TabIndex = 7; + this.txtSearch.UseSelectable = true; + this.txtSearch.WaterMark = "Поиск..."; + this.txtSearch.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.txtSearch.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // label10 + // + this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(560, 10); + this.label10.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(43, 19); + this.label10.TabIndex = 6; + this.label10.Text = "Текст:"; + // + // txtFilterLocation + // + // + // + // + this.txtFilterLocation.CustomButton.Image = null; + this.txtFilterLocation.CustomButton.Location = new System.Drawing.Point(54, 1); + this.txtFilterLocation.CustomButton.Name = ""; + this.txtFilterLocation.CustomButton.Size = new System.Drawing.Size(21, 21); + this.txtFilterLocation.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.txtFilterLocation.CustomButton.TabIndex = 1; + this.txtFilterLocation.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.txtFilterLocation.CustomButton.UseSelectable = true; + this.txtFilterLocation.CustomButton.Visible = false; + this.txtFilterLocation.Lines = new string[0]; + this.txtFilterLocation.Location = new System.Drawing.Point(439, 9); + this.txtFilterLocation.Margin = new System.Windows.Forms.Padding(2); + this.txtFilterLocation.MaxLength = 32767; + this.txtFilterLocation.Name = "txtFilterLocation"; + this.txtFilterLocation.PasswordChar = '\0'; + this.txtFilterLocation.PromptText = "Кабинет..."; + this.txtFilterLocation.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.txtFilterLocation.SelectedText = ""; + this.txtFilterLocation.SelectionLength = 0; + this.txtFilterLocation.SelectionStart = 0; + this.txtFilterLocation.ShortcutsEnabled = true; + this.txtFilterLocation.Size = new System.Drawing.Size(104, 23); + this.txtFilterLocation.TabIndex = 5; + this.txtFilterLocation.UseSelectable = true; + this.txtFilterLocation.WaterMark = "Кабинет..."; + this.txtFilterLocation.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.txtFilterLocation.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(378, 10); + this.label9.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(62, 19); + this.label9.TabIndex = 4; + this.label9.Text = "Кабинет:"; + // + // cmbFilterState + // + this.cmbFilterState.FormattingEnabled = true; + this.cmbFilterState.ItemHeight = 23; + this.cmbFilterState.Location = new System.Drawing.Point(242, 6); + this.cmbFilterState.Margin = new System.Windows.Forms.Padding(2); + this.cmbFilterState.Name = "cmbFilterState"; + this.cmbFilterState.PromptText = "Состояние"; + this.cmbFilterState.Size = new System.Drawing.Size(120, 29); + this.cmbFilterState.TabIndex = 3; + this.cmbFilterState.UseSelectable = true; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(164, 10); + this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(78, 19); + this.label8.TabIndex = 2; + this.label8.Text = "Состояние:"; + // + // cmbFilterType + // + this.cmbFilterType.FormattingEnabled = true; + this.cmbFilterType.ItemHeight = 23; + this.cmbFilterType.Location = new System.Drawing.Point(43, 6); + this.cmbFilterType.Margin = new System.Windows.Forms.Padding(2); + this.cmbFilterType.Name = "cmbFilterType"; + this.cmbFilterType.PromptText = "Тип"; + this.cmbFilterType.Size = new System.Drawing.Size(104, 29); + this.cmbFilterType.TabIndex = 1; + this.cmbFilterType.UseSelectable = true; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(8, 10); + this.label7.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(35, 19); + this.label7.TabIndex = 0; + this.label7.Text = "Тип:"; + // + // panelDeviceDetails + // + this.panelDeviceDetails.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panelDeviceDetails.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(255))))); + this.panelDeviceDetails.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelDeviceDetails.Controls.Add(this.dtpRegistrationDate); + this.panelDeviceDetails.Controls.Add(this.label6); + this.panelDeviceDetails.Controls.Add(this.cmbDeviceState); + this.panelDeviceDetails.Controls.Add(this.label5); + this.panelDeviceDetails.Controls.Add(this.txtResponsiblePerson); + this.panelDeviceDetails.Controls.Add(this.label4); + this.panelDeviceDetails.Controls.Add(this.txtLocation); + this.panelDeviceDetails.Controls.Add(this.label3); + this.panelDeviceDetails.Controls.Add(this.cmbDeviceType); + this.panelDeviceDetails.Controls.Add(this.label2); + this.panelDeviceDetails.Controls.Add(this.txtInventoryNumber); + this.panelDeviceDetails.Controls.Add(this.label1); + this.panelDeviceDetails.Controls.Add(this.txtDeviceName); + this.panelDeviceDetails.Controls.Add(this.lblDeviceName); + this.panelDeviceDetails.Controls.Add(this.btnSave); + this.panelDeviceDetails.Controls.Add(this.btnDelete); + this.panelDeviceDetails.Controls.Add(this.btnEdit); + this.panelDeviceDetails.Controls.Add(this.btnAdd); + this.panelDeviceDetails.Location = new System.Drawing.Point(10, 306); + this.panelDeviceDetails.Margin = new System.Windows.Forms.Padding(20); + this.panelDeviceDetails.Name = "panelDeviceDetails"; + this.panelDeviceDetails.Size = new System.Drawing.Size(916, 96); + this.panelDeviceDetails.TabIndex = 2; + // + // dtpRegistrationDate + // + this.dtpRegistrationDate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.dtpRegistrationDate.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dtpRegistrationDate.Location = new System.Drawing.Point(806, 45); + this.dtpRegistrationDate.Margin = new System.Windows.Forms.Padding(2); + this.dtpRegistrationDate.MinimumSize = new System.Drawing.Size(0, 29); + this.dtpRegistrationDate.Name = "dtpRegistrationDate"; + this.dtpRegistrationDate.Size = new System.Drawing.Size(102, 29); + this.dtpRegistrationDate.TabIndex = 17; + // + // label6 + // + this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(765, 50); + this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(40, 19); + this.label6.TabIndex = 16; + this.label6.Text = "Дата:"; + // + // cmbDeviceState + // + this.cmbDeviceState.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.cmbDeviceState.FormattingEnabled = true; + this.cmbDeviceState.ItemHeight = 23; + this.cmbDeviceState.Location = new System.Drawing.Point(806, 8); + this.cmbDeviceState.Margin = new System.Windows.Forms.Padding(2); + this.cmbDeviceState.Name = "cmbDeviceState"; + this.cmbDeviceState.PromptText = "Состояние"; + this.cmbDeviceState.Size = new System.Drawing.Size(102, 29); + this.cmbDeviceState.TabIndex = 15; + this.cmbDeviceState.UseSelectable = true; + // + // label5 + // + this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(728, 12); + this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(78, 19); + this.label5.TabIndex = 14; + this.label5.Text = "Состояние:"; + // + // txtResponsiblePerson + // + this.txtResponsiblePerson.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + // + // + // + this.txtResponsiblePerson.CustomButton.Image = null; + this.txtResponsiblePerson.CustomButton.Location = new System.Drawing.Point(273, 1); + this.txtResponsiblePerson.CustomButton.Name = ""; + this.txtResponsiblePerson.CustomButton.Size = new System.Drawing.Size(21, 21); + this.txtResponsiblePerson.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.txtResponsiblePerson.CustomButton.TabIndex = 1; + this.txtResponsiblePerson.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.txtResponsiblePerson.CustomButton.UseSelectable = true; + this.txtResponsiblePerson.CustomButton.Visible = false; + this.txtResponsiblePerson.Lines = new string[0]; + this.txtResponsiblePerson.Location = new System.Drawing.Point(509, 48); + this.txtResponsiblePerson.Margin = new System.Windows.Forms.Padding(2); + this.txtResponsiblePerson.MaxLength = 32767; + this.txtResponsiblePerson.Name = "txtResponsiblePerson"; + this.txtResponsiblePerson.PasswordChar = '\0'; + this.txtResponsiblePerson.PromptText = "Отв. лицо"; + this.txtResponsiblePerson.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.txtResponsiblePerson.SelectedText = ""; + this.txtResponsiblePerson.SelectionLength = 0; + this.txtResponsiblePerson.SelectionStart = 0; + this.txtResponsiblePerson.ShortcutsEnabled = true; + this.txtResponsiblePerson.Size = new System.Drawing.Size(212, 23); + this.txtResponsiblePerson.TabIndex = 13; + this.txtResponsiblePerson.UseSelectable = true; + this.txtResponsiblePerson.WaterMark = "Отв. лицо"; + this.txtResponsiblePerson.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.txtResponsiblePerson.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(429, 50); + this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(73, 19); + this.label4.TabIndex = 12; + this.label4.Text = "Отв. лицо:"; + // + // txtLocation + // + this.txtLocation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + // + // + // + this.txtLocation.CustomButton.Image = null; + this.txtLocation.CustomButton.Location = new System.Drawing.Point(273, 1); + this.txtLocation.CustomButton.Name = ""; + this.txtLocation.CustomButton.Size = new System.Drawing.Size(21, 21); + this.txtLocation.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.txtLocation.CustomButton.TabIndex = 1; + this.txtLocation.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.txtLocation.CustomButton.UseSelectable = true; + this.txtLocation.CustomButton.Visible = false; + this.txtLocation.Lines = new string[0]; + this.txtLocation.Location = new System.Drawing.Point(509, 12); + this.txtLocation.Margin = new System.Windows.Forms.Padding(2); + this.txtLocation.MaxLength = 32767; + this.txtLocation.Name = "txtLocation"; + this.txtLocation.PasswordChar = '\0'; + this.txtLocation.PromptText = "Кабинет"; + this.txtLocation.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.txtLocation.SelectedText = ""; + this.txtLocation.SelectionLength = 0; + this.txtLocation.SelectionStart = 0; + this.txtLocation.ShortcutsEnabled = true; + this.txtLocation.Size = new System.Drawing.Size(212, 23); + this.txtLocation.TabIndex = 11; + this.txtLocation.UseSelectable = true; + this.txtLocation.WaterMark = "Кабинет"; + this.txtLocation.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.txtLocation.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(439, 12); + this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(62, 19); + this.label3.TabIndex = 10; + this.label3.Text = "Кабинет:"; + // + // cmbDeviceType + // + this.cmbDeviceType.FormattingEnabled = true; + this.cmbDeviceType.ItemHeight = 23; + this.cmbDeviceType.Location = new System.Drawing.Point(336, 8); + this.cmbDeviceType.Margin = new System.Windows.Forms.Padding(2); + this.cmbDeviceType.Name = "cmbDeviceType"; + this.cmbDeviceType.PromptText = "Тип"; + this.cmbDeviceType.Size = new System.Drawing.Size(76, 29); + this.cmbDeviceType.TabIndex = 9; + this.cmbDeviceType.UseSelectable = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(294, 12); + this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(35, 19); + this.label2.TabIndex = 8; + this.label2.Text = "Тип:"; + // + // txtInventoryNumber + // + // + // + // + this.txtInventoryNumber.CustomButton.Image = null; + this.txtInventoryNumber.CustomButton.Location = new System.Drawing.Point(54, 1); + this.txtInventoryNumber.CustomButton.Name = ""; + this.txtInventoryNumber.CustomButton.Size = new System.Drawing.Size(21, 21); + this.txtInventoryNumber.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.txtInventoryNumber.CustomButton.TabIndex = 1; + this.txtInventoryNumber.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.txtInventoryNumber.CustomButton.UseSelectable = true; + this.txtInventoryNumber.CustomButton.Visible = false; + this.txtInventoryNumber.Lines = new string[0]; + this.txtInventoryNumber.Location = new System.Drawing.Point(336, 48); + this.txtInventoryNumber.Margin = new System.Windows.Forms.Padding(2); + this.txtInventoryNumber.MaxLength = 32767; + this.txtInventoryNumber.Name = "txtInventoryNumber"; + this.txtInventoryNumber.PasswordChar = '\0'; + this.txtInventoryNumber.PromptText = "Инв. №"; + this.txtInventoryNumber.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.txtInventoryNumber.SelectedText = ""; + this.txtInventoryNumber.SelectionLength = 0; + this.txtInventoryNumber.SelectionStart = 0; + this.txtInventoryNumber.ShortcutsEnabled = true; + this.txtInventoryNumber.Size = new System.Drawing.Size(76, 23); + this.txtInventoryNumber.TabIndex = 7; + this.txtInventoryNumber.UseSelectable = true; + this.txtInventoryNumber.WaterMark = "Инв. №"; + this.txtInventoryNumber.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.txtInventoryNumber.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(270, 50); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(60, 19); + this.label1.TabIndex = 6; + this.label1.Text = "Инв. №:"; + // + // txtDeviceName + // + // + // + // + this.txtDeviceName.CustomButton.Image = null; + this.txtDeviceName.CustomButton.Location = new System.Drawing.Point(86, 1); + this.txtDeviceName.CustomButton.Name = ""; + this.txtDeviceName.CustomButton.Size = new System.Drawing.Size(21, 21); + this.txtDeviceName.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.txtDeviceName.CustomButton.TabIndex = 1; + this.txtDeviceName.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.txtDeviceName.CustomButton.UseSelectable = true; + this.txtDeviceName.CustomButton.Visible = false; + this.txtDeviceName.Lines = new string[0]; + this.txtDeviceName.Location = new System.Drawing.Point(168, 12); + this.txtDeviceName.Margin = new System.Windows.Forms.Padding(2); + this.txtDeviceName.MaxLength = 32767; + this.txtDeviceName.Name = "txtDeviceName"; + this.txtDeviceName.PasswordChar = '\0'; + this.txtDeviceName.PromptText = "Название устройства"; + this.txtDeviceName.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.txtDeviceName.SelectedText = ""; + this.txtDeviceName.SelectionLength = 0; + this.txtDeviceName.SelectionStart = 0; + this.txtDeviceName.ShortcutsEnabled = true; + this.txtDeviceName.Size = new System.Drawing.Size(108, 23); + this.txtDeviceName.TabIndex = 5; + this.txtDeviceName.UseSelectable = true; + this.txtDeviceName.WaterMark = "Название устройства"; + this.txtDeviceName.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.txtDeviceName.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // lblDeviceName + // + this.lblDeviceName.AutoSize = true; + this.lblDeviceName.Location = new System.Drawing.Point(96, 12); + this.lblDeviceName.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblDeviceName.Name = "lblDeviceName"; + this.lblDeviceName.Size = new System.Drawing.Size(71, 19); + this.lblDeviceName.TabIndex = 4; + this.lblDeviceName.Text = "Название:"; + this.lblDeviceName.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // btnSave + // + this.btnSave.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(177)))), ((int)(((byte)(89))))); + this.btnSave.ForeColor = System.Drawing.Color.White; + this.btnSave.Highlight = true; + this.btnSave.Location = new System.Drawing.Point(10, 69); + this.btnSave.Margin = new System.Windows.Forms.Padding(4); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(82, 17); + this.btnSave.TabIndex = 3; + this.btnSave.Text = "Сохранить"; + this.btnSave.UseCustomBackColor = true; + this.btnSave.UseCustomForeColor = true; + this.btnSave.UseSelectable = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // btnDelete + // + this.btnDelete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(209)))), ((int)(((byte)(17)))), ((int)(((byte)(65))))); + this.btnDelete.ForeColor = System.Drawing.Color.White; + this.btnDelete.Location = new System.Drawing.Point(10, 49); + this.btnDelete.Margin = new System.Windows.Forms.Padding(4); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(82, 17); + this.btnDelete.TabIndex = 2; + this.btnDelete.Text = "Удалить"; + this.btnDelete.UseCustomBackColor = true; + this.btnDelete.UseCustomForeColor = true; + this.btnDelete.UseSelectable = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // btnEdit + // + this.btnEdit.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(174)))), ((int)(((byte)(219))))); + this.btnEdit.ForeColor = System.Drawing.Color.White; + this.btnEdit.Location = new System.Drawing.Point(10, 30); + this.btnEdit.Margin = new System.Windows.Forms.Padding(4); + this.btnEdit.Name = "btnEdit"; + this.btnEdit.Size = new System.Drawing.Size(82, 17); + this.btnEdit.TabIndex = 1; + this.btnEdit.Text = "Изменить"; + this.btnEdit.UseCustomBackColor = true; + this.btnEdit.UseCustomForeColor = true; + this.btnEdit.UseSelectable = true; + this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click); + // + // btnAdd + // + this.btnAdd.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(174)))), ((int)(((byte)(219))))); + this.btnAdd.ForeColor = System.Drawing.Color.White; + this.btnAdd.Highlight = true; + this.btnAdd.Location = new System.Drawing.Point(10, 10); + this.btnAdd.Margin = new System.Windows.Forms.Padding(4); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(82, 17); + this.btnAdd.TabIndex = 0; + this.btnAdd.Text = "Очистить"; + this.btnAdd.UseCustomBackColor = true; + this.btnAdd.UseCustomForeColor = true; + this.btnAdd.UseSelectable = true; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // tabControl1 + // + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.Controls.Add(this.tabPageDevices); + this.tabControl1.Controls.Add(this.tabPageStatistics); + this.tabControl1.Location = new System.Drawing.Point(10, 42); + this.tabControl1.Margin = new System.Windows.Forms.Padding(10); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(943, 444); + this.tabControl1.TabIndex = 4; + this.tabControl1.UseSelectable = true; + // + // tabPageDevices + // + this.tabPageDevices.Controls.Add(this.dgvDevices); + this.tabPageDevices.Controls.Add(this.panelControls); + this.tabPageDevices.Controls.Add(this.panelDeviceDetails); + this.tabPageDevices.HorizontalScrollbarBarColor = true; + this.tabPageDevices.HorizontalScrollbarHighlightOnWheel = false; + this.tabPageDevices.HorizontalScrollbarSize = 8; + this.tabPageDevices.Location = new System.Drawing.Point(4, 38); + this.tabPageDevices.Margin = new System.Windows.Forms.Padding(2); + this.tabPageDevices.Name = "tabPageDevices"; + this.tabPageDevices.Padding = new System.Windows.Forms.Padding(2); + this.tabPageDevices.Size = new System.Drawing.Size(935, 402); + this.tabPageDevices.TabIndex = 0; + this.tabPageDevices.Text = "Оборудование"; + this.tabPageDevices.VerticalScrollbarBarColor = true; + this.tabPageDevices.VerticalScrollbarHighlightOnWheel = false; + this.tabPageDevices.VerticalScrollbarSize = 8; + // + // tabPageStatistics + // + this.tabPageStatistics.Controls.Add(this.lvStatistics); + this.tabPageStatistics.HorizontalScrollbarBarColor = true; + this.tabPageStatistics.HorizontalScrollbarHighlightOnWheel = false; + this.tabPageStatistics.HorizontalScrollbarSize = 8; + this.tabPageStatistics.Location = new System.Drawing.Point(4, 38); + this.tabPageStatistics.Margin = new System.Windows.Forms.Padding(2); + this.tabPageStatistics.Name = "tabPageStatistics"; + this.tabPageStatistics.Padding = new System.Windows.Forms.Padding(2); + this.tabPageStatistics.Size = new System.Drawing.Size(935, 402); + this.tabPageStatistics.TabIndex = 1; + this.tabPageStatistics.Text = "Статистика"; + this.tabPageStatistics.VerticalScrollbarBarColor = true; + this.tabPageStatistics.VerticalScrollbarHighlightOnWheel = false; + this.tabPageStatistics.VerticalScrollbarSize = 8; + // + // lvStatistics + // + this.lvStatistics.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lvStatistics.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); + this.lvStatistics.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.lvStatistics.FullRowSelect = true; + this.lvStatistics.GridLines = true; + this.lvStatistics.HideSelection = false; + this.lvStatistics.Location = new System.Drawing.Point(10, 10); + this.lvStatistics.Margin = new System.Windows.Forms.Padding(10); + this.lvStatistics.Name = "lvStatistics"; + this.lvStatistics.Size = new System.Drawing.Size(915, 382); + this.lvStatistics.TabIndex = 0; + this.lvStatistics.UseCompatibleStateImageBehavior = false; + this.lvStatistics.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "Тип техники"; + this.columnHeader1.Width = 200; + // + // columnHeader2 + // + this.columnHeader2.Text = "Количество"; + this.columnHeader2.Width = 120; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(979, 535); + this.Controls.Add(this.tabControl1); + this.DisplayHeader = false; + this.Margin = new System.Windows.Forms.Padding(2); + this.MinimumSize = new System.Drawing.Size(776, 535); + this.Name = "Form1"; + this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20); + this.Text = "Учёт техники в организации"; + this.Load += new System.EventHandler(this.Form1_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvDevices)).EndInit(); + this.panelControls.ResumeLayout(false); + this.panelControls.PerformLayout(); + this.panelDeviceDetails.ResumeLayout(false); + this.panelDeviceDetails.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.tabPageDevices.ResumeLayout(false); + this.tabPageStatistics.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private MetroFramework.Controls.MetroGrid dgvDevices; + private System.Windows.Forms.Panel panelControls; + private System.Windows.Forms.Panel panelDeviceDetails; + private MetroFramework.Controls.MetroButton btnSave; + private MetroFramework.Controls.MetroButton btnDelete; + private MetroFramework.Controls.MetroButton btnEdit; + private MetroFramework.Controls.MetroButton btnAdd; + private MetroFramework.Controls.MetroLabel lblDeviceName; + private MetroFramework.Controls.MetroTextBox txtDeviceName; + private MetroFramework.Controls.MetroTextBox txtInventoryNumber; + private MetroFramework.Controls.MetroLabel label1; + private MetroFramework.Controls.MetroComboBox cmbDeviceType; + private MetroFramework.Controls.MetroLabel label2; + private MetroFramework.Controls.MetroTextBox txtResponsiblePerson; + private MetroFramework.Controls.MetroLabel label4; + private MetroFramework.Controls.MetroTextBox txtLocation; + private MetroFramework.Controls.MetroLabel label3; + private MetroFramework.Controls.MetroDateTime dtpRegistrationDate; + private MetroFramework.Controls.MetroLabel label6; + private MetroFramework.Controls.MetroComboBox cmbDeviceState; + private MetroFramework.Controls.MetroLabel label5; + private MetroFramework.Controls.MetroComboBox cmbFilterType; + private MetroFramework.Controls.MetroLabel label7; + private MetroFramework.Controls.MetroComboBox cmbFilterState; + private MetroFramework.Controls.MetroLabel label8; + private MetroFramework.Controls.MetroTextBox txtFilterLocation; + private MetroFramework.Controls.MetroLabel label9; + private MetroFramework.Controls.MetroTextBox txtSearch; + private MetroFramework.Controls.MetroLabel label10; + private MetroFramework.Controls.MetroButton btnExport; + private MetroFramework.Controls.MetroButton btnResetFilter; + private MetroFramework.Controls.MetroButton btnFilter; + private MetroFramework.Controls.MetroTabControl tabControl1; + private MetroFramework.Controls.MetroTabPage tabPageDevices; + private MetroFramework.Controls.MetroTabPage tabPageStatistics; + private System.Windows.Forms.ListView lvStatistics; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + } +} diff --git a/Form1.cs b/Form1.cs new file mode 100644 index 0000000..e84143e --- /dev/null +++ b/Form1.cs @@ -0,0 +1,327 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using MetroFramework; +using MetroFramework.Forms; + +namespace Учет_вещей +{ + public partial class Form1 : MetroForm + { + private User _currentUser; + private Device _selectedDevice; + + public Form1() + { + InitializeComponent(); + this.Theme = MetroFramework.MetroThemeStyle.Light; + this.Style = MetroFramework.MetroColorStyle.Blue; + this.BorderStyle = MetroFormBorderStyle.FixedSingle; + this.ShadowType = MetroFormShadowType.AeroShadow; + + this.Text = "Учет оборудования"; + } + + private void Form1_Load(object sender, EventArgs e) + { + // Показываем форму логина + using (var loginForm = new LoginForm()) + { + if (loginForm.ShowDialog() == DialogResult.OK) + { + _currentUser = loginForm.CurrentUser; + ConfigureFormForUser(); + RefreshDevicesGrid(); + } + else + { + Close(); // Выход, если пользователь отменил вход + } + } + + // Настройка ComboBox для типов устройств и состояний + cmbFilterType.Items.Add("Все типы"); + foreach (DeviceType type in Enum.GetValues(typeof(DeviceType))) + { + cmbFilterType.Items.Add(type.ToString()); + cmbDeviceType.Items.Add(type.ToString()); + } + cmbFilterType.SelectedIndex = 0; + + cmbFilterState.Items.Add("Все состояния"); + foreach (DeviceState state in Enum.GetValues(typeof(DeviceState))) + { + cmbFilterState.Items.Add(state.ToString()); + cmbDeviceState.Items.Add(state.ToString()); + } + cmbFilterState.SelectedIndex = 0; + + // Текущая дата для нового устройства + dtpRegistrationDate.Value = DateTime.Today; + + // Обработчик выбора строки в DataGridView + dgvDevices.SelectionChanged += DgvDevices_SelectionChanged; + } + + private void ConfigureFormForUser() + { + Text = $"Учёт техники в организации - {_currentUser.Username} ({_currentUser.Role})"; + + bool isAdmin = _currentUser.Role == UserRole.Admin; + btnAdd.Enabled = isAdmin; + btnEdit.Enabled = isAdmin; + btnDelete.Enabled = isAdmin; + btnSave.Enabled = isAdmin; + panelDeviceDetails.Enabled = isAdmin; + } + + private void RefreshDevicesGrid(List devices = null) + { + devices = devices ?? DbManager.GetAllDevices(); + + dgvDevices.DataSource = null; + dgvDevices.DataSource = devices; + + // Настройка столбцов + if (dgvDevices.Columns.Count > 0) + { + dgvDevices.Columns["Id"].HeaderText = "ID"; + dgvDevices.Columns["Id"].Width = 40; + dgvDevices.Columns["Name"].HeaderText = "Наименование"; + dgvDevices.Columns["Name"].Width = 150; + dgvDevices.Columns["InventoryNumber"].HeaderText = "Инв. номер"; + dgvDevices.Columns["InventoryNumber"].Width = 80; + dgvDevices.Columns["TypeString"].HeaderText = "Тип"; + dgvDevices.Columns["Type"].Visible = false; + dgvDevices.Columns["Location"].HeaderText = "Местоположение"; + dgvDevices.Columns["ResponsiblePerson"].HeaderText = "Отв. лицо"; + dgvDevices.Columns["StateString"].HeaderText = "Состояние"; + dgvDevices.Columns["State"].Visible = false; + dgvDevices.Columns["RegistrationDate"].HeaderText = "Дата регистрации"; + dgvDevices.Columns["RegistrationDate"].DefaultCellStyle.Format = "dd.MM.yyyy"; + } + + // Обновляем статистику + UpdateStatistics(); + } + + private void UpdateStatistics() + { + Dictionary stats = DbManager.GetDeviceTypeStats(); + lvStatistics.Items.Clear(); + + foreach (var item in stats) + { + ListViewItem lvi = new ListViewItem(item.Key.ToString()); + lvi.SubItems.Add(item.Value.ToString()); + lvStatistics.Items.Add(lvi); + } + + // Общее количество устройств + int totalDevices = stats.Values.Sum(); + ListViewItem totalItem = new ListViewItem("ВСЕГО"); + totalItem.SubItems.Add(totalDevices.ToString()); + totalItem.Font = new Font(lvStatistics.Font, FontStyle.Bold); + lvStatistics.Items.Add(totalItem); + } + + private void ClearDeviceForm() + { + txtDeviceName.Text = ""; + txtInventoryNumber.Text = ""; + txtLocation.Text = ""; + txtResponsiblePerson.Text = ""; + cmbDeviceType.SelectedIndex = -1; + cmbDeviceState.SelectedIndex = -1; + dtpRegistrationDate.Value = DateTime.Today; + _selectedDevice = null; + } + + private void FillDeviceForm(Device device) + { + if (device == null) return; + + txtDeviceName.Text = device.Name; + txtInventoryNumber.Text = device.InventoryNumber; + txtLocation.Text = device.Location; + txtResponsiblePerson.Text = device.ResponsiblePerson; + cmbDeviceType.SelectedItem = device.Type.ToString(); + cmbDeviceState.SelectedItem = device.State.ToString(); + dtpRegistrationDate.Value = device.RegistrationDate; + _selectedDevice = device; + } + + private Device GetDeviceFromForm() + { + if (string.IsNullOrEmpty(txtDeviceName.Text) || + string.IsNullOrEmpty(txtInventoryNumber.Text) || + cmbDeviceType.SelectedIndex == -1 || + cmbDeviceState.SelectedIndex == -1) + { + MetroMessageBox.Show(this, + "Пожалуйста, заполните все обязательные поля", + "Ошибка", + MessageBoxButtons.OK, + MessageBoxIcon.Warning); + return null; + } + + Device device = new Device + { + Name = txtDeviceName.Text, + InventoryNumber = txtInventoryNumber.Text, + Type = (DeviceType)Enum.Parse(typeof(DeviceType), cmbDeviceType.SelectedItem.ToString()), + Location = txtLocation.Text, + ResponsiblePerson = txtResponsiblePerson.Text, + State = (DeviceState)Enum.Parse(typeof(DeviceState), cmbDeviceState.SelectedItem.ToString()), + RegistrationDate = dtpRegistrationDate.Value + }; + + if (_selectedDevice != null) + device.Id = _selectedDevice.Id; + + return device; + } + + private void DgvDevices_SelectionChanged(object sender, EventArgs e) + { + if (dgvDevices.SelectedRows.Count > 0 && dgvDevices.SelectedRows[0].DataBoundItem is Device selectedDevice) + { + FillDeviceForm(selectedDevice); + } + } + + private void btnAdd_Click(object sender, EventArgs e) + { + ClearDeviceForm(); + } + + private void btnEdit_Click(object sender, EventArgs e) + { + if (dgvDevices.SelectedRows.Count == 0) + { + MetroMessageBox.Show(this, + "Выберите устройство для редактирования", + "Информация", + MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + + if (dgvDevices.SelectedRows[0].DataBoundItem is Device selectedDevice) + { + FillDeviceForm(selectedDevice); + } + } + + private void btnDelete_Click(object sender, EventArgs e) + { + if (dgvDevices.SelectedRows.Count == 0) + { + MetroMessageBox.Show(this, + "Выберите устройство для удаления", + "Информация", + MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + + if (dgvDevices.SelectedRows[0].DataBoundItem is Device selectedDevice) + { + if (MetroMessageBox.Show(this, + $"Вы действительно хотите удалить устройство \"{selectedDevice.Name}\"?", + "Подтверждение удаления", + MessageBoxButtons.YesNo, + MessageBoxIcon.Question) == DialogResult.Yes) + { + DbManager.DeleteDevice(selectedDevice.Id); + RefreshDevicesGrid(); + ClearDeviceForm(); + } + } + } + + private void btnSave_Click(object sender, EventArgs e) + { + Device device = GetDeviceFromForm(); + if (device == null) return; + + if (_selectedDevice == null) + { + // Добавление нового устройства + DbManager.AddDevice(device); + } + else + { + // Обновление существующего устройства + DbManager.UpdateDevice(device); + } + + RefreshDevicesGrid(); + ClearDeviceForm(); + } + + private void btnFilter_Click(object sender, EventArgs e) + { + DeviceType? filterType = null; + if (cmbFilterType.SelectedIndex > 0) + { + filterType = (DeviceType)Enum.Parse(typeof(DeviceType), cmbFilterType.SelectedItem.ToString()); + } + + DeviceState? filterState = null; + if (cmbFilterState.SelectedIndex > 0) + { + filterState = (DeviceState)Enum.Parse(typeof(DeviceState), cmbFilterState.SelectedItem.ToString()); + } + + string location = txtFilterLocation.Text; + string searchText = txtSearch.Text; + + var filteredDevices = DbManager.FilterDevices(filterType, filterState, location, searchText); + RefreshDevicesGrid(filteredDevices); + } + + private void btnResetFilter_Click(object sender, EventArgs e) + { + cmbFilterType.SelectedIndex = 0; + cmbFilterState.SelectedIndex = 0; + txtFilterLocation.Text = ""; + txtSearch.Text = ""; + RefreshDevicesGrid(); + } + + private void btnExport_Click(object sender, EventArgs e) + { + try + { + SaveFileDialog saveDialog = new SaveFileDialog + { + Filter = "CSV файлы (*.csv)|*.csv|Текстовые файлы (*.txt)|*.txt|Все файлы (*.*)|*.*", + Title = "Экспорт данных", + FileName = "Учет_техники_" + DateTime.Now.ToString("dd_MM_yyyy") + }; + + if (saveDialog.ShowDialog() == DialogResult.OK) + { + DbManager.ExportToCsv(saveDialog.FileName); + MetroMessageBox.Show(this, + "Данные успешно экспортированы", + "Экспорт", + MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } + catch (Exception ex) + { + MetroMessageBox.Show(this, + "Ошибка при экспорте данных: " + ex.Message, + "Ошибка", + MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } +} diff --git a/Form1.resx b/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LoginForm.Designer.cs b/LoginForm.Designer.cs new file mode 100644 index 0000000..04ce237 --- /dev/null +++ b/LoginForm.Designer.cs @@ -0,0 +1,129 @@ +using MetroFramework.Controls; +using MetroFramework.Forms; + +namespace Учет_вещей +{ + partial class LoginForm + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + private void InitializeComponent() + { + this.label1 = new MetroFramework.Controls.MetroLabel(); + this.txtUsername = new MetroFramework.Controls.MetroTextBox(); + this.label2 = new MetroFramework.Controls.MetroLabel(); + this.txtPassword = new MetroFramework.Controls.MetroTextBox(); + this.btnLogin = new MetroFramework.Controls.MetroButton(); + this.btnCancel = new MetroFramework.Controls.MetroButton(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(25, 70); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(47, 19); + this.label1.TabIndex = 0; + this.label1.Text = "Логин:"; + // + // txtUsername + // + this.txtUsername.Location = new System.Drawing.Point(80, 70); + this.txtUsername.Name = "txtUsername"; + this.txtUsername.Size = new System.Drawing.Size(171, 23); + this.txtUsername.TabIndex = 1; + this.txtUsername.WaterMark = "Имя пользователя"; + this.txtUsername.UseSelectable = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(25, 110); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(54, 19); + this.label2.TabIndex = 2; + this.label2.Text = "Пароль:"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(80, 110); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.PasswordChar = '●'; + this.txtPassword.Size = new System.Drawing.Size(171, 23); + this.txtPassword.TabIndex = 3; + this.txtPassword.UseSystemPasswordChar = true; + this.txtPassword.WaterMark = "Пароль"; + this.txtPassword.UseSelectable = true; + // + // btnLogin + // + this.btnLogin.Location = new System.Drawing.Point(60, 150); + this.btnLogin.Name = "btnLogin"; + this.btnLogin.Size = new System.Drawing.Size(86, 32); + this.btnLogin.TabIndex = 4; + this.btnLogin.Text = "Войти"; + this.btnLogin.UseCustomBackColor = true; + this.btnLogin.UseCustomForeColor = true; + this.btnLogin.BackColor = System.Drawing.Color.FromArgb(0, 174, 219); + this.btnLogin.ForeColor = System.Drawing.Color.White; + this.btnLogin.UseSelectable = true; + this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click); + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(160, 150); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(86, 32); + this.btnCancel.TabIndex = 5; + this.btnCancel.Text = "Отмена"; + this.btnCancel.UseCustomBackColor = true; + this.btnCancel.BackColor = System.Drawing.Color.FromArgb(204, 204, 204); + this.btnCancel.UseSelectable = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // LoginForm + // + this.AcceptButton = this.btnLogin; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(280, 200); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnLogin); + this.Controls.Add(this.txtPassword); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtUsername); + this.Controls.Add(this.label1); + this.DisplayHeader = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "LoginForm"; + this.Padding = new System.Windows.Forms.Padding(20, 60, 20, 20); + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Авторизация"; + this.Style = MetroFramework.MetroColorStyle.Blue; + this.Theme = MetroFramework.MetroThemeStyle.Light; + this.ResumeLayout(false); + this.PerformLayout(); + } + + #endregion + + private MetroFramework.Controls.MetroLabel label1; + private MetroFramework.Controls.MetroTextBox txtUsername; + private MetroFramework.Controls.MetroLabel label2; + private MetroFramework.Controls.MetroTextBox txtPassword; + private MetroFramework.Controls.MetroButton btnLogin; + private MetroFramework.Controls.MetroButton btnCancel; + } +} diff --git a/LoginForm.cs b/LoginForm.cs new file mode 100644 index 0000000..3a912f7 --- /dev/null +++ b/LoginForm.cs @@ -0,0 +1,61 @@ +using System; +using System.Windows.Forms; +using MetroFramework.Forms; + +namespace Учет_вещей +{ + public partial class LoginForm : MetroForm + { + public User CurrentUser { get; private set; } + + public LoginForm() + { + InitializeComponent(); + + // Настройка темы и стиля + this.Theme = MetroFramework.MetroThemeStyle.Light; + this.Style = MetroFramework.MetroColorStyle.Blue; + this.Text = "Авторизация"; + } + + private void btnLogin_Click(object sender, EventArgs e) + { + string username = txtUsername.Text; + string password = txtPassword.Text; + + if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) + { + MetroFramework.MetroMessageBox.Show(this, + "Пожалуйста, заполните все поля", + "Ошибка", + MessageBoxButtons.OK, + MessageBoxIcon.Warning); + return; + } + + CurrentUser = DbManager.Authenticate(username, password); + + if (CurrentUser != null) + { + DialogResult = DialogResult.OK; + Close(); + } + else + { + MetroFramework.MetroMessageBox.Show(this, + "Неверное имя пользователя или пароль", + "Ошибка авторизации", + MessageBoxButtons.OK, + MessageBoxIcon.Error); + txtPassword.Clear(); + txtUsername.Focus(); + } + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/LoginForm.resx b/LoginForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/LoginForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Models.cs b/Models.cs new file mode 100644 index 0000000..8385015 --- /dev/null +++ b/Models.cs @@ -0,0 +1,55 @@ +using System; + +namespace Учет_вещей +{ + // Перечисление для типов оборудования + public enum DeviceType + { + Компьютер, + Ноутбук, + Монитор, + Принтер, + Сканер, + МФУ, + Проектор, + Другое + } + + // Перечисление для состояния техники + public enum DeviceState + { + Исправен, + Ремонт, + Списан + } + + // Класс для хранения данных о технике + public class Device + { + public int Id { get; set; } + public string Name { get; set; } + public string InventoryNumber { get; set; } + public DeviceType Type { get; set; } + public string Location { get; set; } + public string ResponsiblePerson { get; set; } + public DeviceState State { get; set; } + public DateTime RegistrationDate { get; set; } + + public string TypeString => Type.ToString(); + public string StateString => State.ToString(); + } + + // Класс для пользователей + public enum UserRole + { + User, + Admin + } + + public class User + { + public string Username { get; set; } + public string Password { get; set; } + public UserRole Role { get; set; } + } +} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..6d23aab --- /dev/null +++ b/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Windows.Forms; + +namespace Учет_вещей +{ + static class Program + { + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + // Инициализируем базу данных при запуске приложения + DbManager.InitializeDatabase(); + + Application.Run(new Form1()); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3e9b765 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанных со сборкой. +[assembly: AssemblyTitle("Учет вещей")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Учет вещей")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, следует установить атрибут ComVisible в TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("434c186d-c95a-4abf-ac2c-b33cd21b0f50")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b0e71c0 --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программным средством. +// Версия среды выполнения: 4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если +// код создан повторно. +// +//------------------------------------------------------------------------------ + +namespace Учет_вещей.Properties +{ + + + /// + /// Класс ресурсов со строгим типом для поиска локализованных строк и пр. + /// + // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder + // класс с помощью таких средств, как ResGen или Visual Studio. + // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen + // с параметром /str или заново постройте свой VS-проект. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Учет_вещей.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Переопределяет свойство CurrentUICulture текущего потока для всех + /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..f55acbe --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Учет_вещей.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..993d5a6 --- /dev/null +++ b/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Учет вещей.csproj b/Учет вещей.csproj new file mode 100644 index 0000000..1783611 --- /dev/null +++ b/Учет вещей.csproj @@ -0,0 +1,133 @@ + + + + + + Debug + AnyCPU + {434C186D-C95A-4ABF-AC2C-B33CD21B0F50} + WinExe + Учет_вещей + Учет вещей + v4.7.2 + 512 + true + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll + + + packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll + + + packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.dll + + + packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Design.dll + + + packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Fonts.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 + + + + + + + + + + + + + + + Form + + + Form1.cs + + + Form + + + LoginForm.cs + + + + + + Form1.cs + + + LoginForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + + + + + \ No newline at end of file diff --git a/Учет вещей.sln b/Учет вещей.sln new file mode 100644 index 0000000..e284396 --- /dev/null +++ b/Учет вещей.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35828.75 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Учет вещей", "Учет вещей.csproj", "{434C186D-C95A-4ABF-AC2C-B33CD21B0F50}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {434C186D-C95A-4ABF-AC2C-B33CD21B0F50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {434C186D-C95A-4ABF-AC2C-B33CD21B0F50}.Debug|Any CPU.Build.0 = Debug|Any CPU + {434C186D-C95A-4ABF-AC2C-B33CD21B0F50}.Release|Any CPU.ActiveCfg = Release|Any CPU + {434C186D-C95A-4ABF-AC2C-B33CD21B0F50}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4C9ECF4C-F9F0-4D09-AFFF-0E7E5B855495} + EndGlobalSection +EndGlobal