commit 7a2c13872cb2e4ab35bd2ef7b390274421b9667a Author: Ilya Date: Thu May 14 15:24:29 2026 +0400 merkylov_isp_41 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9b29e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/ +bin/ +obj/ \ No newline at end of file diff --git a/DUMP_UML_ER/MerkylovISP41_Dump.sql b/DUMP_UML_ER/MerkylovISP41_Dump.sql new file mode 100644 index 0000000..dd2b3e4 --- /dev/null +++ b/DUMP_UML_ER/MerkylovISP41_Dump.sql @@ -0,0 +1,333 @@ +-- MySQL dump 10.13 Distrib 8.0.42, for Win64 (x86_64) +-- +-- Host: 85.239.57.125 Database: Merkylov_Sportmag +-- ------------------------------------------------------ +-- Server version 8.0.45-0ubuntu0.24.04.1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `Category` +-- + +DROP TABLE IF EXISTS `Category`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `Category` ( + `idCategory` int NOT NULL AUTO_INCREMENT, + `CategoryName` varchar(45) NOT NULL, + PRIMARY KEY (`idCategory`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Category` +-- + +LOCK TABLES `Category` WRITE; +/*!40000 ALTER TABLE `Category` DISABLE KEYS */; +INSERT INTO `Category` VALUES (1,'Единоборства'),(2,'Кардио'),(3,'Лыжный спорт'),(4,'Мячи'),(5,'Обувь'),(6,'Одежда'),(7,'Плавание'),(8,'Силовые'),(9,'Теннис'),(10,'Тренажеры'),(11,'Туризм'),(12,'Фитнес'),(13,'Экипировка'); +/*!40000 ALTER TABLE `Category` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `Clients` +-- + +DROP TABLE IF EXISTS `Clients`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `Clients` ( + `idClients` int NOT NULL AUTO_INCREMENT, + `Login` varchar(45) NOT NULL, + `Password` varchar(45) NOT NULL, + `FIO` varchar(45) NOT NULL, + `Email` varchar(45) NOT NULL, + `Phone` bigint NOT NULL, + `Role_id` int NOT NULL, + PRIMARY KEY (`idClients`), + KEY `From clients to role_idx` (`Role_id`), + CONSTRAINT `From clients to role` FOREIGN KEY (`Role_id`) REFERENCES `Role` (`idRole`) +) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Clients` +-- + +LOCK TABLES `Clients` WRITE; +/*!40000 ALTER TABLE `Clients` DISABLE KEYS */; +INSERT INTO `Clients` VALUES (1,'client_001','hash45678','Сидоров Алексей Михайлович','sidorov@mail.ru',79110001122,1),(2,'client_002','hash56789','Кузнецова Елена Владимировна','kuz_el@ya.ru',89120002233,1),(3,'client_003','hash67890','Попов Дмитрий Николаевич','popov_d@gmail.com',89140004455,1),(4,'client_004','hash78901','Васильева Мария Александровна','vasya_m@mail.ru',79150005566,1),(5,'client_005','hash89012','Соколов Максим Андреевич','sokol_max@ya.ru',79160006677,1),(6,'client_006','hash90123','Михайлова Дарья Юрьевна','mikh_d@gmail.com',89170007788,1),(7,'client_007','hash01234','Федоров Артем Викторович','fedorov_a@mail.ru',89190009900,1),(8,'client_008','hash11234','Морозова Екатерина Олеговна','moroz_e@ya.ru',79200001111,1),(9,'client_009','hash22345','Волков Илья','volkov_i@gmail.com',89210002222,1),(10,'client_010','hash33456','Алексеева Анастасия Денисовна','alekseeva@mail.ru',89220003333,1),(11,'client_011','hash44567','Лебедев Никита Павлович','lebedev_n@ya.ru',792304444,1),(12,'client_012','hash55678','Семенова Ольга Константиновна','semenova_o@gmail.com',79240005555,1),(13,'client_013','hash66789','Егоров Павел','egorov_p@mail.ru',79250006666,1),(14,'client_014','hash77890','Павлова Татьяна Евгеньевна','pavlova_t@ya.ru',89260007777,1),(15,'client_015','hash88901','Козлов Роман Борисович','kozlov_r@gmail.com',79270008888,1),(16,'client_016','hash99012','Степанова Юлия Аркадьевна','stepanova_y@mail.ru',89280009999,1),(17,'client_017','hash00123','Николаев Глеб Степанович','nikolaev_g@ya.ru',792901234,1),(18,'client_018','hash11122','Орлова Виктория','orlova_v@gmail.com',79300002345,1),(19,'client_019','hash22233','Макаров Даниил Антонович','makarov_d@mail.ru',89310003456,1),(20,'client_020','hash33344','Андреева Полина Вячеславовна','andreeva_p@ya.ru',89320004567,1),(21,'client_021','hash44455','Захаров Кирилл Леонидович','zaharov_k@gmail.com',79330005678,1),(22,'client_022','hash55566','Зайцева Алина Федоровна','zaitseva_a@mail.ru',793406789,1),(23,'client_023','hash66677','Соловьев Владислав Игоревич','soloviev_v@ya.ru',89350007890,1),(24,'client_024','hash77788','Борисова Яна Станиславовна','borisova_y@gmail.com',79360008901,1),(25,'client_025','hash88899','Яковлев Арсений Максимович','yakovlev_a@mail.ru',89370009012,1),(26,'client_026','hash99900','Григорьева Вера Руслановна','grigorieva_v@ya.ru',79001112233,1),(27,'client_027','hash00011','Романов Вадим','romanov_v@gmail.com',89002223344,1),(28,'1','1','Проверка имени Админ','1',1,1),(29,'2','2','Проверка имени Авторизованный','2',2,3),(30,'3','3','Проверка имени Менеджер','3',3,2); +/*!40000 ALTER TABLE `Clients` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `Manufacturer` +-- + +DROP TABLE IF EXISTS `Manufacturer`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `Manufacturer` ( + `idManufacturer` int NOT NULL AUTO_INCREMENT, + `ManufacturerName` varchar(45) NOT NULL, + PRIMARY KEY (`idManufacturer`) +) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Manufacturer` +-- + +LOCK TABLES `Manufacturer` WRITE; +/*!40000 ALTER TABLE `Manufacturer` DISABLE KEYS */; +INSERT INTO `Manufacturer` VALUES (1,'Adidas'),(2,'Barbell'),(3,'Demix'),(4,'Deuter'),(5,'Everlast'),(6,'Fischer'),(7,'Head'),(8,'Joss'),(9,'Kettler'),(10,'Mikasa'),(11,'Nike'),(12,'Nordway'),(13,'Outventure'),(14,'Puma'),(15,'Reebok'),(16,'Spalding'),(17,'Speedo'),(18,'Stanley'),(19,'Torneo'),(20,'Under Armour'),(21,'Venum'),(22,'Wilson'),(23,'СпортМастер'); +/*!40000 ALTER TABLE `Manufacturer` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `OrderItems` +-- + +DROP TABLE IF EXISTS `OrderItems`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `OrderItems` ( + `idOrderItems` int NOT NULL AUTO_INCREMENT, + `Orders_id` int NOT NULL, + `Products_id` int NOT NULL, + `QuanityInOrder` int NOT NULL, + PRIMARY KEY (`idOrderItems`), + KEY `From orderItem to order_idx` (`Orders_id`), + KEY `from orderItem to products_idx` (`Products_id`), + CONSTRAINT `From orderItem to order` FOREIGN KEY (`Orders_id`) REFERENCES `Orders` (`idOrders`), + CONSTRAINT `from orderItem to products` FOREIGN KEY (`Products_id`) REFERENCES `Products` (`idProducts`) +) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `OrderItems` +-- + +LOCK TABLES `OrderItems` WRITE; +/*!40000 ALTER TABLE `OrderItems` DISABLE KEYS */; +INSERT INTO `OrderItems` VALUES (1,1,1,2),(2,1,11,1),(3,2,8,1),(4,3,14,1),(5,3,18,2),(6,4,4,1),(7,5,20,1),(8,5,21,2),(9,5,23,1),(10,6,2,1),(11,7,6,1),(12,7,7,4),(13,8,24,1),(14,8,25,1),(15,9,27,1),(16,9,28,3),(17,10,10,1),(18,11,15,1),(19,12,19,1),(20,13,13,5),(21,14,12,2),(22,15,3,1),(23,16,22,1),(24,17,17,2),(25,18,29,1),(26,18,30,2),(27,19,1,10),(28,20,16,1),(29,21,26,1),(30,22,9,1),(31,23,5,2),(32,24,6,1),(33,25,11,3),(34,26,12,1),(35,27,24,2),(36,28,29,2),(37,29,20,1); +/*!40000 ALTER TABLE `OrderItems` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `Orders` +-- + +DROP TABLE IF EXISTS `Orders`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `Orders` ( + `idOrders` int NOT NULL AUTO_INCREMENT, + `Article` varchar(45) NOT NULL, + `Clients_id` int NOT NULL, + `Status_id` int NOT NULL, + `PickUp_id` int NOT NULL, + `Order_date` date NOT NULL, + `Delivery_date` date DEFAULT NULL, + PRIMARY KEY (`idOrders`), + KEY `From order to clients_idx` (`Clients_id`), + KEY `From order to status_idx` (`Status_id`), + KEY `From order to pickup_idx` (`PickUp_id`), + CONSTRAINT `From order to clients` FOREIGN KEY (`Clients_id`) REFERENCES `Clients` (`idClients`), + CONSTRAINT `From order to pickup` FOREIGN KEY (`PickUp_id`) REFERENCES `PickUp` (`idPickUp`), + CONSTRAINT `From order to status` FOREIGN KEY (`Status_id`) REFERENCES `Status` (`idStatus`) +) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Orders` +-- + +LOCK TABLES `Orders` WRITE; +/*!40000 ALTER TABLE `Orders` DISABLE KEYS */; +INSERT INTO `Orders` VALUES (1,'ORD-1011',1,1,11,'2023-09-18','2023-09-22'),(2,'ORD-1022',2,2,13,'2023-10-10',NULL),(3,'ORD-1005',3,3,5,'2023-10-24','2023-10-29'),(4,'ORD-1010',3,2,10,'2023-09-15',NULL),(5,'ORD-1024',3,3,15,'2023-10-24','2023-10-29'),(6,'ORD-1017',4,1,17,'2023-09-25','2023-09-28'),(7,'ORD-1002',4,2,2,'2023-09-02',NULL),(8,'ORD-1012',6,1,12,'2023-09-20','2023-09-25'),(9,'ORD-1026',6,1,17,'2023-10-15','2023-10-18'),(10,'ORD-1016',6,2,16,'2023-10-01',NULL),(11,'ORD-1007',7,1,7,'2023-09-11','2023-09-14'),(12,'ORD-1028',7,3,12,'2023-10-25','2023-10-30'),(13,'ORD-1013',7,4,13,'2023-10-26','2023-10-31'),(14,'ORD-1018',7,4,18,'2023-10-26','2023-11-02'),(15,'ORD-1023',7,4,15,'2023-10-26','2023-11-01'),(16,'ORD-1009',8,3,9,'2023-10-23','2023-10-28'),(17,'ORD-1019',9,3,19,'2023-10-22','2023-10-27'),(18,'ORD-1020',10,1,1,'2023-10-05','2023-10-09'),(19,'ORD-1015',1,1,15,'2023-09-22','2023-09-26'),(20,'ORD-1003',12,3,3,'2023-09-05','2023-09-08'),(21,'ORD-1029',13,1,4,'2023-10-18','2023-10-22'),(22,'ORD-1001',14,1,1,'2023-09-01','2023-09-05'),(23,'ORD-1004',14,4,4,'2023-10-25','2023-10-30'),(24,'ORD-1006',15,1,6,'2023-09-10','2023-09-15'),(25,'ORD-1025',17,1,6,'2023-10-12','2023-10-16'),(26,'ORD-1021',18,1,7,'2023-10-08','2023-10-12'),(27,'ORD-1030',18,2,8,'2023-10-20',NULL),(28,'ORD-1014',18,3,14,'2023-10-25','2023-10-29'),(29,'ORD-1008',18,4,8,'2023-10-26','2023-11-01'),(30,'ORD-1027',18,4,11,'2023-10-26','2023-11-03'); +/*!40000 ALTER TABLE `Orders` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `PickUp` +-- + +DROP TABLE IF EXISTS `PickUp`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `PickUp` ( + `idPickUp` int NOT NULL AUTO_INCREMENT, + `PickUpPoint` varchar(45) NOT NULL, + PRIMARY KEY (`idPickUp`) +) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `PickUp` +-- + +LOCK TABLES `PickUp` WRITE; +/*!40000 ALTER TABLE `PickUp` DISABLE KEYS */; +INSERT INTO `PickUp` VALUES (1,'пер. Тихий, 4'),(2,'пер. Школьный, 1'),(3,'пр. Ленина, 100'),(4,'Пр. Мира, 42'),(5,'пр. Победы, 50'),(6,'пр. Строителей, 1'),(7,'ул. Гагарина, 8'),(8,'ул. Зеленая, 8'),(9,'ул. Кирова, 12'),(10,'ул. Ленина, 15'),(11,'ул. Новая, 2'),(12,'ул. Пушкина, 10'),(13,'ул. Садовая, 19'),(14,'ул. Северная, 9'),(15,'ул. Советская, 3'),(16,'ул. Труда, 14'),(17,'ул. Цветочная, 5'),(18,'ул. Чехова, 33'),(19,'ул. Южная, 11'); +/*!40000 ALTER TABLE `PickUp` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `Products` +-- + +DROP TABLE IF EXISTS `Products`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `Products` ( + `idProducts` int NOT NULL AUTO_INCREMENT, + `Article` varchar(45) NOT NULL, + `ProductName` varchar(45) NOT NULL, + `Category_id` int NOT NULL, + `ProductDescryption` varchar(90) NOT NULL, + `Manufacturer_id` int NOT NULL, + `Supplier_id` int NOT NULL, + `Price` decimal(10,2) NOT NULL, + `Discount` varchar(45) DEFAULT NULL, + `QuantityStock` int NOT NULL, + `UnitType_id` int NOT NULL, + `Image` mediumblob, + PRIMARY KEY (`idProducts`), + KEY `From prod to category_idx` (`Category_id`), + KEY `From prod to manufacturer_idx` (`Manufacturer_id`), + KEY `From prod to supplier_idx` (`Supplier_id`), + KEY `From prod to unittype_idx` (`UnitType_id`), + CONSTRAINT `From prod to category` FOREIGN KEY (`Category_id`) REFERENCES `Category` (`idCategory`), + CONSTRAINT `From prod to manufacturer` FOREIGN KEY (`Manufacturer_id`) REFERENCES `Manufacturer` (`idManufacturer`), + CONSTRAINT `From prod to supplier` FOREIGN KEY (`Supplier_id`) REFERENCES `Supplier` (`idSupplier`), + CONSTRAINT `From prod to unittype` FOREIGN KEY (`UnitType_id`) REFERENCES `UnitType` (`idUnitType`) +) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Products` +-- + +LOCK TABLES `Products` WRITE; +/*!40000 ALTER TABLE `Products` DISABLE KEYS */; +INSERT INTO `Products` VALUES (1,'P-001','Мяч футбольный Pro',4,'Профессиональный мяч',1,8,4500.00,'10%',15,5,''),(2,'P-002','Кроссовки беговые X1',5,'Для бега по асфальту',11,2,8990.50,NULL,42,3,_binary 'cross x1.jpg'),(3,'P-003','Велотренажер Fit-3',10,'Домашний велотренажер',9,8,25000.00,'25%',5,5,_binary 'bike fit.png'),(4,'P-004','Лыжи беговые Skate',1,'Коньковый ход',1,1,12500.00,'5%',0,1,_binary 'ski skate.jpg'),(5,'P-005','Гантели разборные 15кг',10,'Стальные гантели',23,4,3200.75,'30%',20,3,''),(6,'P-006','Спортивный костюм',13,'Хлопок 100%',1,8,6500.00,'15%',8,5,_binary 'suit.jpg'),(7,'P-007','Мяч баскетбольный',4,'Для игры в зале',11,8,3100.00,NULL,12,5,_binary 'basket.png'),(8,'P-008','Беговая дорожка RunMax',10,'Складная конструкция',9,2,45900.00,'5%',0,5,''),(9,'P-009','Бутсы футбольные',5,'Шиповки',11,8,7500.00,'25%',30,3,_binary 'boots.jpg'),(10,'P-010','Палки лыжные',3,'Карбоновые',6,2,4100.50,'10%',18,3,_binary 'poles.jpg'),(11,'P-011','Эспандер трубчатый',10,'Набор 5 шт',23,4,950.00,'50%',100,1,''),(12,'P-012','Футболка спортивная',13,'Дышащая ткань',1,8,1800.00,NULL,50,5,_binary 'tshirt.jpg'),(13,'P-013','Мяч волейбольный',4,'Тренировочный',23,4,2200.00,'15%',25,5,_binary 'volley.png'),(14,'P-014','Перчатки для фитнеса',13,'Кожа/текстиль',11,2,1250.00,'25%',0,3,_binary 'gloves.jpg'),(15,'P-015','Мяч футбольный',4,'Профессиональный мяч для игр на газоне',1,8,4500.50,'10%',50,5,_binary 'adidas_ball.jpg'),(16,'P-016','Мяч баскетбольный',4,'Мяч для зала и улицы, размер 7',16,1,3200.00,NULL,30,5,_binary 'bball_spalding.png'),(17,'P-017','Мяч волейбольный',4,'Мяч для классического волейбола',10,8,3800.75,'5%',120,5,_binary 'mikasa_vol.jpg'),(18,'P-018','Гантели разборные 15кг',8,'Набор гантелей в кейсе',3,3,2500.00,'25%',15,2,_binary 'dumbbell_15.png'),(19,'P-019','Гантели литые 5кг',8,'Неопреновое покрытие',19,3,900.00,NULL,0,3,_binary 'dumbbell_5.jpg'),(20,'P-020','Штанга олимпийская',8,'Гриф 20кг + замки',9,1,15000.00,'15%',8,5,_binary 'barbell.png'),(21,'P-021','Блины для штанги 10кг',8,'Обрезиненные диски',2,1,2100.50,NULL,40,5,_binary 'disk_10.jpg'),(22,'P-022','Беговая дорожка',2,'Складная, до 15 км/ч',9,11,45000.00,'30%',5,5,_binary 'treadmill.jpg'),(23,'P-023','Эллиптический тренажер',2,'Магнитная система нагрузки',19,11,32000.00,'10%',0,5,_binary 'elliptic.png'),(24,'P-024','Велотренажер',2,'Вертикальная посадка',9,11,28000.00,'5%',12,5,_binary 'bike.jpg'),(25,'P-025','Коврик для йоги',12,'Толщина 6мм, TPE',11,8,1200.00,'15%',200,5,_binary 'yoga_mat.jpg'),(26,'P-026','Фитнес-резинки',12,'Набор из 5 эспандеров',3,3,600.00,'25%',150,2,_binary 'bands.png'),(27,'P-027','Скакалка скоростная',12,'Металлический трос',15,1,850.50,NULL,80,5,_binary 'rope.jpg'),(28,'P-028','Кроссовки беговые',5,'Амортизирующая подошва',11,6,8900.00,'20%',45,3,_binary 'nike_run.jpg'),(29,'P-029','Бутсы футбольные',5,'Шиповки для натурального газона',14,6,7500.00,'35%',25,3,_binary 'puma_boots.png'),(30,'P-030','Штангетки',5,'Обувь для тяжелой атлетики',1,6,12000.00,NULL,10,3,_binary 'adipower.jpg'),(31,'P-031','Футболка компрессионная',6,'Отводит влагу',20,9,2500.00,'10%',60,5,_binary 'ua_shirt.png'),(32,'P-032','Шорты спортивные',6,'Легкие дышащие шорты',11,9,1800.00,NULL,85,5,_binary 'nike_shorts.jpg'),(33,'P-033','Костюм спортивный',6,'Хлопок + полиэстер',14,9,5500.00,'15%',30,5,_binary 'puma_suit.jpg'),(34,'P-034','Палатка 3-местная',11,'Водостойкость 3000мм',13,10,8500.00,'25%',20,5,_binary 'tent_3.png'),(35,'P-035','Спальный мешок',11,'До -5 градусов комфорт',12,10,3200.50,'5%',40,5,_binary 'sleeping_bag.jpg'),(36,'P-036','Рюкзак туристический',11,'Объем 60 литров',4,1,11000.00,NULL,15,5,_binary 'backpack.png'),(37,'P-037','Термос 1 литр',11,'Держит тепло 24 часа',18,10,2800.00,'10%',50,5,_binary 'thermos.jpg'),(38,'P-038','Боксерские перчатки',1,'Натуральная кожа, 12 унций',5,7,4500.00,NULL,35,3,_binary 'gloves.png'),(39,'P-039','Капа одночелюстная',1,'Термопластичная',21,7,500.00,NULL,100,5,_binary 'mouthguard.jpg'),(40,'P-040','Шлем боксерский',1,'С защитой скул',5,7,3500.00,'15%',18,5,_binary 'helmet.jpg'),(41,'P-041','Ракетка для тенниса',9,'Легкий графит',22,1,9500.00,'20%',12,5,_binary 'racket.png'),(43,'P-043','Очки для плавания',7,'Антифог, защита от УФ',17,5,1800.00,'5%',80,5,_binary 'goggles.png'); +/*!40000 ALTER TABLE `Products` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `Role` +-- + +DROP TABLE IF EXISTS `Role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `Role` ( + `idRole` int NOT NULL AUTO_INCREMENT, + `Role_name` varchar(45) NOT NULL, + PRIMARY KEY (`idRole`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Role` +-- + +LOCK TABLES `Role` WRITE; +/*!40000 ALTER TABLE `Role` DISABLE KEYS */; +INSERT INTO `Role` VALUES (1,'Клиент'),(2,'Менеджер'),(3,'Админ'),(4,'Гость'); +/*!40000 ALTER TABLE `Role` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `Status` +-- + +DROP TABLE IF EXISTS `Status`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `Status` ( + `idStatus` int NOT NULL AUTO_INCREMENT, + `StatusName` varchar(45) NOT NULL, + PRIMARY KEY (`idStatus`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Status` +-- + +LOCK TABLES `Status` WRITE; +/*!40000 ALTER TABLE `Status` DISABLE KEYS */; +INSERT INTO `Status` VALUES (1,'Доставлен'),(2,'Отменен'),(3,'Отправлен'),(4,'Формируется'); +/*!40000 ALTER TABLE `Status` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `Supplier` +-- + +DROP TABLE IF EXISTS `Supplier`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `Supplier` ( + `idSupplier` int NOT NULL AUTO_INCREMENT, + `SupplierName` varchar(45) NOT NULL, + PRIMARY KEY (`idSupplier`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Supplier` +-- + +LOCK TABLES `Supplier` WRITE; +/*!40000 ALTER TABLE `Supplier` DISABLE KEYS */; +INSERT INTO `Supplier` VALUES (1,'ЗАО Актив'),(2,'ЗАО АктивЛайф'),(3,'ИП Иванов'),(4,'ИП Смирнов'),(5,'ООО ВодаСпорт'),(6,'ООО ОбувьПро'),(7,'ООО Ринг'),(8,'ООО СпортОпт'),(9,'ООО Текстиль'),(10,'ООО ТурСнаб'),(11,'ООО ФитнесПро'); +/*!40000 ALTER TABLE `Supplier` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `UnitType` +-- + +DROP TABLE IF EXISTS `UnitType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `UnitType` ( + `idUnitType` int NOT NULL AUTO_INCREMENT, + `UnitTypeName` varchar(45) NOT NULL, + PRIMARY KEY (`idUnitType`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `UnitType` +-- + +LOCK TABLES `UnitType` WRITE; +/*!40000 ALTER TABLE `UnitType` DISABLE KEYS */; +INSERT INTO `UnitType` VALUES (1,'компл.'),(2,'набор'),(3,'пара'),(4,'туба'),(5,'шт.'); +/*!40000 ALTER TABLE `UnitType` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2026-05-14 14:59:47 diff --git a/DUMP_UML_ER/MerkylovISP41_ER.pdf b/DUMP_UML_ER/MerkylovISP41_ER.pdf new file mode 100644 index 0000000..4888724 Binary files /dev/null and b/DUMP_UML_ER/MerkylovISP41_ER.pdf differ diff --git a/DUMP_UML_ER/UML.jpg b/DUMP_UML_ER/UML.jpg new file mode 100644 index 0000000..d9bc9ac Binary files /dev/null and b/DUMP_UML_ER/UML.jpg differ diff --git a/WinFormsApp1.sln b/WinFormsApp1.sln new file mode 100644 index 0000000..205c711 --- /dev/null +++ b/WinFormsApp1.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36915.13 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsApp1", "WinFormsApp1\WinFormsApp1.csproj", "{640976E5-3DC4-421F-A6E5-BD05DD9D08BC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {640976E5-3DC4-421F-A6E5-BD05DD9D08BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {640976E5-3DC4-421F-A6E5-BD05DD9D08BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {640976E5-3DC4-421F-A6E5-BD05DD9D08BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {640976E5-3DC4-421F-A6E5-BD05DD9D08BC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2F0041A0-7308-4BD5-AB23-38ED95B9D881} + EndGlobalSection +EndGlobal diff --git a/WinFormsApp1/AddForm.Designer.cs b/WinFormsApp1/AddForm.Designer.cs new file mode 100644 index 0000000..1c6842d --- /dev/null +++ b/WinFormsApp1/AddForm.Designer.cs @@ -0,0 +1,370 @@ +namespace WinFormsApp1 +{ + partial class AddForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + comboBoxSupplier = new ComboBox(); + textBoxArticle = new TextBox(); + textBoxProdName = new TextBox(); + textBoxDesc = new TextBox(); + comboBoxUnitType = new ComboBox(); + comboBoxManufacturer = new ComboBox(); + button1 = new Button(); + comboBoxCategories = new ComboBox(); + textBoxPrice = new TextBox(); + textBoxSale = new TextBox(); + textBoxStockQuan = new TextBox(); + imageList1 = new ImageList(components); + button2 = new Button(); + label11 = new Label(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + label5 = new Label(); + label6 = new Label(); + label7 = new Label(); + label8 = new Label(); + label9 = new Label(); + label10 = new Label(); + button3 = new Button(); + SuspendLayout(); + // + // comboBoxSupplier + // + comboBoxSupplier.BackColor = Color.FromArgb(133, 242, 189); + comboBoxSupplier.Font = new Font("Comic Sans MS", 9F); + comboBoxSupplier.FormattingEnabled = true; + comboBoxSupplier.Location = new Point(160, 258); + comboBoxSupplier.Name = "comboBoxSupplier"; + comboBoxSupplier.Size = new Size(208, 25); + comboBoxSupplier.TabIndex = 0; + // + // textBoxArticle + // + textBoxArticle.BackColor = Color.FromArgb(133, 242, 189); + textBoxArticle.Font = new Font("Comic Sans MS", 9F); + textBoxArticle.Location = new Point(160, 113); + textBoxArticle.Name = "textBoxArticle"; + textBoxArticle.Size = new Size(208, 24); + textBoxArticle.TabIndex = 1; + // + // textBoxProdName + // + textBoxProdName.BackColor = Color.FromArgb(133, 242, 189); + textBoxProdName.Font = new Font("Comic Sans MS", 9F); + textBoxProdName.Location = new Point(160, 142); + textBoxProdName.Name = "textBoxProdName"; + textBoxProdName.Size = new Size(208, 24); + textBoxProdName.TabIndex = 2; + // + // textBoxDesc + // + textBoxDesc.BackColor = Color.FromArgb(133, 242, 189); + textBoxDesc.Font = new Font("Comic Sans MS", 9F); + textBoxDesc.Location = new Point(160, 200); + textBoxDesc.Name = "textBoxDesc"; + textBoxDesc.Size = new Size(208, 24); + textBoxDesc.TabIndex = 3; + // + // comboBoxUnitType + // + comboBoxUnitType.BackColor = Color.FromArgb(133, 242, 189); + comboBoxUnitType.Font = new Font("Comic Sans MS", 9F); + comboBoxUnitType.FormattingEnabled = true; + comboBoxUnitType.Location = new Point(160, 374); + comboBoxUnitType.Name = "comboBoxUnitType"; + comboBoxUnitType.Size = new Size(208, 25); + comboBoxUnitType.TabIndex = 4; + // + // comboBoxManufacturer + // + comboBoxManufacturer.BackColor = Color.FromArgb(133, 242, 189); + comboBoxManufacturer.Font = new Font("Comic Sans MS", 9F); + comboBoxManufacturer.FormattingEnabled = true; + comboBoxManufacturer.Location = new Point(160, 229); + comboBoxManufacturer.Name = "comboBoxManufacturer"; + comboBoxManufacturer.Size = new Size(208, 25); + comboBoxManufacturer.TabIndex = 5; + // + // button1 + // + button1.BackColor = Color.Red; + button1.Font = new Font("Comic Sans MS", 9F); + button1.Location = new Point(447, 12); + button1.Name = "button1"; + button1.Size = new Size(36, 31); + button1.TabIndex = 6; + button1.Text = "X"; + button1.UseVisualStyleBackColor = false; + button1.Click += button1_Click; + // + // comboBoxCategories + // + comboBoxCategories.BackColor = Color.FromArgb(133, 242, 189); + comboBoxCategories.Font = new Font("Comic Sans MS", 9F); + comboBoxCategories.FormattingEnabled = true; + comboBoxCategories.Location = new Point(160, 171); + comboBoxCategories.Name = "comboBoxCategories"; + comboBoxCategories.Size = new Size(208, 25); + comboBoxCategories.TabIndex = 7; + // + // textBoxPrice + // + textBoxPrice.BackColor = Color.FromArgb(133, 242, 189); + textBoxPrice.Font = new Font("Comic Sans MS", 9F); + textBoxPrice.Location = new Point(160, 287); + textBoxPrice.Name = "textBoxPrice"; + textBoxPrice.Size = new Size(208, 24); + textBoxPrice.TabIndex = 8; + // + // textBoxSale + // + textBoxSale.BackColor = Color.FromArgb(133, 242, 189); + textBoxSale.Font = new Font("Comic Sans MS", 9F); + textBoxSale.Location = new Point(160, 316); + textBoxSale.Name = "textBoxSale"; + textBoxSale.Size = new Size(208, 24); + textBoxSale.TabIndex = 9; + // + // textBoxStockQuan + // + textBoxStockQuan.BackColor = Color.FromArgb(133, 242, 189); + textBoxStockQuan.Font = new Font("Comic Sans MS", 9F); + textBoxStockQuan.Location = new Point(160, 345); + textBoxStockQuan.Name = "textBoxStockQuan"; + textBoxStockQuan.Size = new Size(208, 24); + textBoxStockQuan.TabIndex = 10; + // + // imageList1 + // + imageList1.ColorDepth = ColorDepth.Depth32Bit; + imageList1.ImageSize = new Size(16, 16); + imageList1.TransparentColor = Color.Transparent; + // + // button2 + // + button2.BackColor = Color.Red; + button2.Font = new Font("Comic Sans MS", 9F); + button2.Location = new Point(219, 405); + button2.Name = "button2"; + button2.Size = new Size(98, 23); + button2.TabIndex = 11; + button2.Text = "Добавить"; + button2.UseVisualStyleBackColor = false; + button2.Click += btnAdd_Click; + // + // label11 + // + label11.AutoSize = true; + label11.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label11.Location = new Point(69, 378); + label11.Name = "label11"; + label11.Size = new Size(91, 17); + label11.TabIndex = 21; + label11.Text = "Ед. измерения"; + // + // label1 + // + label1.AutoSize = true; + label1.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label1.Location = new Point(69, 116); + label1.Name = "label1"; + label1.Size = new Size(56, 17); + label1.TabIndex = 22; + label1.Text = "Артикул"; + // + // label2 + // + label2.AutoSize = true; + label2.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label2.Location = new Point(69, 174); + label2.Name = "label2"; + label2.Size = new Size(67, 17); + label2.TabIndex = 23; + label2.Text = "Категория"; + // + // label3 + // + label3.AutoSize = true; + label3.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label3.Location = new Point(69, 348); + label3.Name = "label3"; + label3.Size = new Size(76, 17); + label3.TabIndex = 24; + label3.Text = "Количество"; + // + // label4 + // + label4.AutoSize = true; + label4.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label4.Location = new Point(69, 319); + label4.Name = "label4"; + label4.Size = new Size(48, 17); + label4.TabIndex = 25; + label4.Text = "Скидка"; + // + // label5 + // + label5.AutoSize = true; + label5.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label5.Location = new Point(69, 290); + label5.Name = "label5"; + label5.Size = new Size(36, 17); + label5.TabIndex = 26; + label5.Text = "Цена"; + // + // label6 + // + label6.AutoSize = true; + label6.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label6.Location = new Point(69, 261); + label6.Name = "label6"; + label6.Size = new Size(74, 17); + label6.TabIndex = 27; + label6.Text = "Поставщик"; + // + // label7 + // + label7.AutoSize = true; + label7.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label7.Location = new Point(61, 232); + label7.Name = "label7"; + label7.Size = new Size(99, 17); + label7.TabIndex = 28; + label7.Text = "Производитель"; + // + // label8 + // + label8.AutoSize = true; + label8.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label8.Location = new Point(69, 203); + label8.Name = "label8"; + label8.Size = new Size(67, 17); + label8.TabIndex = 29; + label8.Text = "Описание"; + // + // label9 + // + label9.AutoSize = true; + label9.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label9.Location = new Point(69, 145); + label9.Name = "label9"; + label9.Size = new Size(61, 17); + label9.TabIndex = 30; + label9.Text = "Название"; + // + // label10 + // + label10.AutoSize = true; + label10.Font = new Font("Comic Sans MS", 26.25F, FontStyle.Regular, GraphicsUnit.Point, 204); + label10.Location = new Point(121, 9); + label10.Name = "label10"; + label10.Size = new Size(269, 49); + label10.TabIndex = 31; + label10.Text = "ДОБАВЛЕНИЕ"; + // + // button3 + // + button3.BackColor = Color.Red; + button3.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + button3.Location = new Point(408, 415); + button3.Name = "button3"; + button3.Size = new Size(75, 23); + button3.TabIndex = 37; + button3.Text = "Назад"; + button3.UseVisualStyleBackColor = false; + button3.Click += button3_Click; + // + // AddForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(192, 237, 215); + ClientSize = new Size(495, 450); + Controls.Add(button3); + Controls.Add(label10); + Controls.Add(label9); + Controls.Add(label8); + Controls.Add(label7); + Controls.Add(label6); + Controls.Add(label5); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(label11); + Controls.Add(button2); + Controls.Add(textBoxStockQuan); + Controls.Add(textBoxSale); + Controls.Add(textBoxPrice); + Controls.Add(comboBoxCategories); + Controls.Add(button1); + Controls.Add(comboBoxManufacturer); + Controls.Add(comboBoxUnitType); + Controls.Add(textBoxDesc); + Controls.Add(textBoxProdName); + Controls.Add(textBoxArticle); + Controls.Add(comboBoxSupplier); + FormBorderStyle = FormBorderStyle.None; + Name = "AddForm"; + Text = "AddForm"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxSupplier; + private TextBox textBoxArticle; + private TextBox textBoxProdName; + private TextBox textBoxDesc; + private ComboBox comboBoxUnitType; + private ComboBox comboBoxManufacturer; + private Button button1; + private ComboBox comboBoxCategories; + private TextBox textBoxPrice; + private TextBox textBoxSale; + private TextBox textBoxStockQuan; + private ImageList imageList1; + private Button button2; + private Label label11; + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private Label label5; + private Label label6; + private Label label7; + private Label label8; + private Label label9; + private Label label10; + private Button button3; + } +} \ No newline at end of file diff --git a/WinFormsApp1/AddForm.cs b/WinFormsApp1/AddForm.cs new file mode 100644 index 0000000..0dd6037 --- /dev/null +++ b/WinFormsApp1/AddForm.cs @@ -0,0 +1,198 @@ +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 MySql.Data.MySqlClient; + +namespace WinFormsApp1 +{ + public partial class AddForm : Form + { + public AddForm() + { + InitializeComponent(); + LoadCategories(); + LoadManufacteries(); + LoadUnitType(); + LoadSuppliers(); + } + private void LoadCategories() + { + DB db = new DB(); + DataTable categories = new DataTable(); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + MySqlCommand command = new MySqlCommand("SELECT idCategory, CategoryName FROM Category", db.getConnection()); + + try + { + db.openConnection(); + adapter.SelectCommand = command; + adapter.Fill(categories); + + comboBoxCategories.DataSource = categories; + comboBoxCategories.DisplayMember = "CategoryName"; + comboBoxCategories.ValueMember = "idCategory"; + } + catch (Exception ex) + { + MessageBox.Show("Ошибка загрузки категорий " + ex.Message); + } + finally + { + db.closeConnection(); + } + } + private void LoadManufacteries() + { + DB db = new DB(); + DataTable manufacturer = new DataTable(); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + MySqlCommand command = new MySqlCommand("SELECT idManufacturer, ManufacturerName FROM Manufacturer", db.getConnection()); + + try + { + db.openConnection(); + adapter.SelectCommand = command; + adapter.Fill(manufacturer); + + comboBoxManufacturer.DataSource = manufacturer; + comboBoxManufacturer.DisplayMember = "ManufacturerName"; + comboBoxManufacturer.ValueMember = "idManufacturer"; + } + catch (Exception ex) + { + MessageBox.Show("Ошибка загрузки категорий " + ex.Message); + } + finally + { + db.closeConnection(); + } + } + private void LoadUnitType() + { + DB db = new DB(); + DataTable UnitType = new DataTable(); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + MySqlCommand command = new MySqlCommand("SELECT idUnitType, UnitTypeName FROM UnitType", db.getConnection()); + + try + { + db.openConnection(); + adapter.SelectCommand = command; + adapter.Fill(UnitType); + + comboBoxUnitType.DataSource = UnitType; + comboBoxUnitType.DisplayMember = "UnitTypeName"; + comboBoxUnitType.ValueMember = "idUnitType"; + } + catch (Exception ex) + { + MessageBox.Show("Ошибка загрузки категорий " + ex.Message); + } + finally + { + db.closeConnection(); + } + } + private void LoadSuppliers() + { + DB db = new DB(); + DataTable suppliers = new DataTable(); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + MySqlCommand command = new MySqlCommand("SELECT idSupplier, SupplierName FROM Supplier", db.getConnection()); + + try + { + db.openConnection(); + adapter.SelectCommand = command; + adapter.Fill(suppliers); + + comboBoxSupplier.DataSource = suppliers; + comboBoxSupplier.DisplayMember = "SupplierName"; + comboBoxSupplier.ValueMember = "idSupplier"; + } + catch (Exception ex) + { + MessageBox.Show("Ошибка загрузки категорий " + ex.Message); + } + finally + { + db.closeConnection(); + } + } + private async void btnAdd_Click(object sender, EventArgs e) + { + + DB db = new DB(); + + try + { + db.openConnection(); + + string query = "INSERT INTO Products (Article, ProductName, Category_id, ProductDescryption, Manufacturer_id, Supplier_id, Price, Discount, QuantityStock, UnitType_id)" + + "VALUES (@art, @prodname, @cat, @des, @manu, @supp, @price, @sale, @quan, @Unit)"; + + using (MySqlCommand command = new MySqlCommand(query, db.getConnection())) + { + command.Parameters.AddWithValue("@art", textBoxArticle.Text); + command.Parameters.AddWithValue("@prodname", textBoxProdName.Text); + command.Parameters.AddWithValue("@cat", comboBoxCategories.SelectedValue.ToString()); + command.Parameters.AddWithValue("@des", textBoxDesc.Text); + command.Parameters.AddWithValue("@manu", comboBoxManufacturer.SelectedValue.ToString()); + command.Parameters.AddWithValue("@supp", comboBoxSupplier.SelectedValue.ToString()); + command.Parameters.AddWithValue("@price", textBoxPrice.Text); + command.Parameters.AddWithValue("@sale", textBoxSale.Text); + command.Parameters.AddWithValue("@quan", textBoxStockQuan.Text); + command.Parameters.AddWithValue("@Unit", comboBoxUnitType.SelectedValue.ToString()); + + + int rowsAffected = await command.ExecuteNonQueryAsync(); + + if (rowsAffected > 0) + { + MessageBox.Show("Заказ успешно добавлен!"); + DialogResult = DialogResult.OK; + this.Close(); + AdmMainForm ado = new AdmMainForm(); + ado.Show(); + } + else + { + MessageBox.Show("Ошибка при добавлении заказа."); + } + } + } + catch (MySqlException ex) + { + MessageBox.Show("Ошибка базы данных: " + ex.Message); + } + catch (Exception ex) + { + MessageBox.Show("Произошла: " + ex.Message); + } + finally + { + db.closeConnection(); + } + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + AdmMainForm Adm = new AdmMainForm(); + Adm.Show(); + } + + private void button3_Click(object sender, EventArgs e) + { + this.Hide(); + AdmMainForm af = new AdmMainForm(); + af.Show(); + } + } +} diff --git a/WinFormsApp1/AddForm.resx b/WinFormsApp1/AddForm.resx new file mode 100644 index 0000000..d610c39 --- /dev/null +++ b/WinFormsApp1/AddForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/WinFormsApp1/AdmMainForm.Designer.cs b/WinFormsApp1/AdmMainForm.Designer.cs new file mode 100644 index 0000000..7f8447b --- /dev/null +++ b/WinFormsApp1/AdmMainForm.Designer.cs @@ -0,0 +1,359 @@ +namespace WinFormsApp1 +{ + partial class AdmMainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewProduct = new DataGridView(); + NameLabel = new Label(); + CategoryLabel = new Label(); + comboBoxSort = new ComboBox(); + comboBoxFilter = new ComboBox(); + textBoxSearch = new TextBox(); + button1 = new Button(); + button2 = new Button(); + delete = new Button(); + labelFIO = new Label(); + ExitButton = new Button(); + panel1 = new Panel(); + panel2 = new Panel(); + CountLabel = new Label(); + PriceLabel = new Label(); + pictureBox1 = new PictureBox(); + panel3 = new Panel(); + Descyption = new Label(); + SupplierLabel = new Label(); + ManufacturerLabel = new Label(); + label10 = new Label(); + button3 = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).BeginInit(); + panel1.SuspendLayout(); + panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + panel3.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewProduct + // + dataGridViewProduct.AllowUserToAddRows = false; + dataGridViewProduct.AllowUserToDeleteRows = false; + dataGridViewProduct.AllowUserToResizeColumns = false; + dataGridViewProduct.AllowUserToResizeRows = false; + dataGridViewProduct.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + dataGridViewProduct.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; + dataGridViewProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewProduct.Location = new Point(12, 112); + dataGridViewProduct.Name = "dataGridViewProduct"; + dataGridViewProduct.Size = new Size(764, 245); + dataGridViewProduct.TabIndex = 0; + dataGridViewProduct.Click += dataGridViewProd_Click; + // + // NameLabel + // + NameLabel.AutoSize = true; + NameLabel.Font = new Font("Comic Sans MS", 15F, FontStyle.Bold); + NameLabel.Location = new Point(162, -1); + NameLabel.Name = "NameLabel"; + NameLabel.Size = new Size(157, 29); + NameLabel.TabIndex = 4; + NameLabel.Text = "Наименование"; + // + // CategoryLabel + // + CategoryLabel.AutoSize = true; + CategoryLabel.Font = new Font("Comic Sans MS", 13F); + CategoryLabel.Location = new Point(162, 28); + CategoryLabel.Name = "CategoryLabel"; + CategoryLabel.Size = new Size(97, 24); + CategoryLabel.TabIndex = 5; + CategoryLabel.Text = "Категория"; + // + // comboBoxSort + // + comboBoxSort.BackColor = Color.FromArgb(133, 242, 189); + comboBoxSort.Font = new Font("Comic Sans MS", 9F); + comboBoxSort.FormattingEnabled = true; + comboBoxSort.Location = new Point(12, 83); + comboBoxSort.Name = "comboBoxSort"; + comboBoxSort.Size = new Size(121, 25); + comboBoxSort.TabIndex = 6; + comboBoxSort.SelectedIndexChanged += comboBoxSort_SelectedIndexChanged; + // + // comboBoxFilter + // + comboBoxFilter.BackColor = Color.FromArgb(133, 242, 189); + comboBoxFilter.Font = new Font("Comic Sans MS", 9F); + comboBoxFilter.FormattingEnabled = true; + comboBoxFilter.Location = new Point(200, 83); + comboBoxFilter.Name = "comboBoxFilter"; + comboBoxFilter.Size = new Size(121, 25); + comboBoxFilter.TabIndex = 7; + comboBoxFilter.SelectedIndexChanged += comboBoxFilter_SelectedIndexChanged; + // + // textBoxSearch + // + textBoxSearch.BackColor = Color.FromArgb(133, 242, 189); + textBoxSearch.Font = new Font("Comic Sans MS", 9F); + textBoxSearch.Location = new Point(378, 83); + textBoxSearch.Name = "textBoxSearch"; + textBoxSearch.Size = new Size(141, 24); + textBoxSearch.TabIndex = 8; + textBoxSearch.TextChanged += textBoxSearch_TextChanged; + // + // button1 + // + button1.BackColor = Color.Red; + button1.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + button1.Location = new Point(681, 376); + button1.Name = "button1"; + button1.Size = new Size(107, 23); + button1.TabIndex = 9; + button1.Text = "Добавить"; + button1.UseVisualStyleBackColor = false; + button1.Click += button1_Click; + // + // button2 + // + button2.BackColor = Color.Red; + button2.Font = new Font("Comic Sans MS", 9F); + button2.Location = new Point(681, 463); + button2.Name = "button2"; + button2.Size = new Size(107, 23); + button2.TabIndex = 10; + button2.Text = "Редактировать"; + button2.UseVisualStyleBackColor = false; + button2.Click += button2_Click; + // + // delete + // + delete.BackColor = Color.Red; + delete.Font = new Font("Comic Sans MS", 9F); + delete.Location = new Point(681, 419); + delete.Name = "delete"; + delete.Size = new Size(107, 23); + delete.TabIndex = 11; + delete.Text = "Удалить"; + delete.UseVisualStyleBackColor = false; + delete.Click += btnDelete_Click; + // + // labelFIO + // + labelFIO.AutoSize = true; + labelFIO.Font = new Font("Comic Sans MS", 9F); + labelFIO.Location = new Point(547, 87); + labelFIO.Name = "labelFIO"; + labelFIO.Size = new Size(35, 17); + labelFIO.TabIndex = 12; + labelFIO.Text = "ФИО"; + // + // ExitButton + // + ExitButton.BackColor = Color.Red; + ExitButton.Location = new Point(757, 9); + ExitButton.Name = "ExitButton"; + ExitButton.Size = new Size(31, 26); + ExitButton.TabIndex = 13; + ExitButton.Text = "X"; + ExitButton.UseVisualStyleBackColor = false; + ExitButton.Click += ExitButton_Click; + // + // panel1 + // + panel1.BackColor = Color.FromArgb(133, 242, 189); + panel1.BorderStyle = BorderStyle.FixedSingle; + panel1.Controls.Add(panel2); + panel1.Controls.Add(pictureBox1); + panel1.Controls.Add(panel3); + panel1.Controls.Add(SupplierLabel); + panel1.Controls.Add(ManufacturerLabel); + panel1.Controls.Add(NameLabel); + panel1.Controls.Add(CategoryLabel); + panel1.Location = new Point(66, 363); + panel1.Name = "panel1"; + panel1.Size = new Size(609, 150); + panel1.TabIndex = 14; + // + // panel2 + // + panel2.BorderStyle = BorderStyle.FixedSingle; + panel2.Controls.Add(CountLabel); + panel2.Controls.Add(PriceLabel); + panel2.Location = new Point(444, -1); + panel2.Name = "panel2"; + panel2.Size = new Size(164, 150); + panel2.TabIndex = 15; + // + // CountLabel + // + CountLabel.AutoSize = true; + CountLabel.Font = new Font("Comic Sans MS", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 204); + CountLabel.Location = new Point(58, 43); + CountLabel.Name = "CountLabel"; + CountLabel.Size = new Size(82, 18); + CountLabel.TabIndex = 1; + CountLabel.Text = "Количество"; + // + // PriceLabel + // + PriceLabel.AutoSize = true; + PriceLabel.Font = new Font("Comic Sans MS", 12F, FontStyle.Regular, GraphicsUnit.Point, 204); + PriceLabel.Location = new Point(35, 10); + PriceLabel.Name = "PriceLabel"; + PriceLabel.Size = new Size(0, 23); + PriceLabel.TabIndex = 0; + // + // pictureBox1 + // + pictureBox1.BorderStyle = BorderStyle.FixedSingle; + pictureBox1.Location = new Point(19, 10); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new Size(137, 127); + pictureBox1.TabIndex = 19; + pictureBox1.TabStop = false; + // + // panel3 + // + panel3.BorderStyle = BorderStyle.FixedSingle; + panel3.Controls.Add(Descyption); + panel3.Location = new Point(162, 55); + panel3.Name = "panel3"; + panel3.Size = new Size(276, 44); + panel3.TabIndex = 18; + // + // Descyption + // + Descyption.AutoSize = true; + Descyption.Font = new Font("Comic Sans MS", 9.5F); + Descyption.Location = new Point(-1, -1); + Descyption.Name = "Descyption"; + Descyption.Size = new Size(70, 18); + Descyption.TabIndex = 15; + Descyption.Text = "Описание"; + // + // SupplierLabel + // + SupplierLabel.AutoSize = true; + SupplierLabel.Font = new Font("Comic Sans MS", 10F); + SupplierLabel.Location = new Point(162, 99); + SupplierLabel.Name = "SupplierLabel"; + SupplierLabel.Size = new Size(119, 19); + SupplierLabel.TabIndex = 17; + SupplierLabel.Text = "Производитель:"; + // + // ManufacturerLabel + // + ManufacturerLabel.AutoSize = true; + ManufacturerLabel.Font = new Font("Comic Sans MS", 10F); + ManufacturerLabel.Location = new Point(162, 118); + ManufacturerLabel.Name = "ManufacturerLabel"; + ManufacturerLabel.Size = new Size(89, 19); + ManufacturerLabel.TabIndex = 16; + ManufacturerLabel.Text = "Поставщик:"; + // + // label10 + // + label10.AutoSize = true; + label10.Font = new Font("Comic Sans MS", 26.25F, FontStyle.Regular, GraphicsUnit.Point, 204); + label10.Location = new Point(67, 9); + label10.Name = "label10"; + label10.Size = new Size(684, 49); + label10.TabIndex = 32; + label10.Text = "ГЛАВНАЯ ФОРМА АДМИНИСТРАТОРА"; + // + // button3 + // + button3.BackColor = Color.Red; + button3.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + button3.Location = new Point(701, 504); + button3.Name = "button3"; + button3.Size = new Size(75, 23); + button3.TabIndex = 37; + button3.Text = "Назад"; + button3.UseVisualStyleBackColor = false; + button3.Click += button3_Click; + // + // AdmMainForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(192, 237, 215); + ClientSize = new Size(800, 539); + Controls.Add(button3); + Controls.Add(label10); + Controls.Add(panel1); + Controls.Add(ExitButton); + Controls.Add(button1); + Controls.Add(labelFIO); + Controls.Add(delete); + Controls.Add(button2); + Controls.Add(textBoxSearch); + Controls.Add(comboBoxFilter); + Controls.Add(comboBoxSort); + Controls.Add(dataGridViewProduct); + FormBorderStyle = FormBorderStyle.None; + Name = "AdmMainForm"; + StartPosition = FormStartPosition.CenterScreen; + Text = "AdmMainForm"; + Load += AdmMainForm_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).EndInit(); + panel1.ResumeLayout(false); + panel1.PerformLayout(); + panel2.ResumeLayout(false); + panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + panel3.ResumeLayout(false); + panel3.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private DataGridView dataGridViewProduct; + private Label NameLabel; + private Label CategoryLabel; + private ComboBox comboBoxSort; + private ComboBox comboBoxFilter; + private TextBox textBoxSearch; + private Button button1; + private Button button2; + private Button delete; + private Label labelFIO; + private Button ExitButton; + private Panel panel1; + private Label Descyption; + private Panel panel2; + private Label SupplierLabel; + private Label ManufacturerLabel; + private Label CountLabel; + private Label PriceLabel; + private Panel panel3; + private PictureBox pictureBox1; + private Label label10; + private Button button3; + } +} \ No newline at end of file diff --git a/WinFormsApp1/AdmMainForm.cs b/WinFormsApp1/AdmMainForm.cs new file mode 100644 index 0000000..1969de3 --- /dev/null +++ b/WinFormsApp1/AdmMainForm.cs @@ -0,0 +1,290 @@ +using MySql.Data.MySqlClient; +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 WinFormsApp1; + +namespace WinFormsApp1 +{ + public partial class AdmMainForm : Form + { + public AdmMainForm() + { + InitializeComponent(); + LoadProdData(); + LoadSortOptions(); + LoadFilterOptions(); + } + private MySqlDataAdapter dataAdapter; + private DataTable prodTable; + private BindingSource bindingSource = new BindingSource(); + private void LoadProdData() + { + try + { + DB db = new DB(); + using (MySqlConnection connection = db.getConnection()) + { + connection.Open(); + string query = "SELECT idProducts, Article AS `Артикул`, ProductName AS `название товара`, CategoryName AS `Категория`, ProductDescryption AS `Описание`, ManufacturerName AS `Производитель`, SupplierName AS `Поставщик`, Price AS `Цена`, Discount AS `Возможная скидка`, QuantityStock AS `Количество на складе`, UnitTypeName AS `Единица измерения` FROM Products LEFT JOIN Category ON Products.Category_id = Category.idCategory JOIN Manufacturer ON Products.Manufacturer_id = Manufacturer.idManufacturer JOIN Supplier ON Products.Supplier_id = Supplier.idSupplier JOIN UnitType ON Products.UnitType_id = UnitType.idUnitType"; + + dataAdapter = new MySqlDataAdapter(query, connection); + prodTable = new DataTable(); + dataAdapter.Fill(prodTable); + dataGridViewProduct.RowTemplate.Height = 60; + bindingSource.DataSource = prodTable; + dataGridViewProduct.DataSource = bindingSource; + + + } + } + catch (MySqlException ex) + { + MessageBox.Show("Ошибка при подключении к базе данных или выполнении запроса: " + ex.Message); + } + catch (Exception ex) + { + MessageBox.Show("Произошла общая ошибка: " + ex.Message); + } + } + private void dataGridViewProd_Click(object sender, EventArgs e) + { + CategoryLabel.Text = dataGridViewProduct.CurrentRow.Cells[3].Value.ToString(); + NameLabel.Text = dataGridViewProduct.CurrentRow.Cells[2].Value.ToString(); + Descyption.Text = dataGridViewProduct.CurrentRow.Cells[4].Value.ToString(); + PriceLabel.Text = dataGridViewProduct.CurrentRow.Cells[7].Value.ToString(); + CountLabel.Text = dataGridViewProduct.CurrentRow.Cells[9].Value.ToString(); + ManufacturerLabel.Text = dataGridViewProduct.CurrentRow.Cells[5].Value.ToString(); + SupplierLabel.Text = dataGridViewProduct.CurrentRow.Cells[6].Value.ToString(); + } + private void LoadSortOptions() + { + comboBoxSort.Items.Add("По умолчанию"); + comboBoxSort.Items.Add("Цена (возрастающая)"); + comboBoxSort.Items.Add("Цена (убывающая)"); + comboBoxSort.SelectedIndex = 0; + } + + private void comboBoxSort_SelectedIndexChanged(object sender, EventArgs e) + { + string sortOption = comboBoxSort.SelectedItem.ToString(); + + switch (sortOption) + { + case "По умолчанию": + bindingSource.Sort = ""; + break; + case "Цена (возрастающая)": + bindingSource.Sort = "Цена ASC"; + break; + case "Цена (убывающая)": + bindingSource.Sort = "Цена DESC"; + break; + } + } + private void LoadFilterOptions() + { + comboBoxFilter.Items.Add("Все производители"); + comboBoxFilter.Items.Add("Adidas"); + comboBoxFilter.Items.Add("Barbell"); + comboBoxFilter.Items.Add("Demix"); + comboBoxFilter.Items.Add("Deuter"); + comboBoxFilter.Items.Add("Everlast"); + comboBoxFilter.Items.Add("Fischer"); + comboBoxFilter.Items.Add("Head"); + comboBoxFilter.Items.Add("Joss"); + comboBoxFilter.Items.Add("Kettler"); + comboBoxFilter.Items.Add("Mikasa"); + comboBoxFilter.Items.Add("Nike"); + comboBoxFilter.Items.Add("Nordway"); + comboBoxFilter.Items.Add("Outventure"); + comboBoxFilter.Items.Add("Puma"); + comboBoxFilter.Items.Add("Reebok"); + comboBoxSort.SelectedIndex = 0; + } + private void comboBoxFilter_SelectedIndexChanged(object sender, EventArgs e) + { + string filterOption = comboBoxFilter.SelectedItem.ToString().Trim(); + switch (filterOption) + { + case "Все производители": + bindingSource.Filter = ""; + break; + + case "Adidas": + bindingSource.Filter = "[Производитель] = 'Adidas'"; + break; + + case "Barbell": + bindingSource.Filter = "[Производитель] = 'Barbell'"; + break; + + case "Demix": + bindingSource.Filter = "[Производитель] = 'Demix'"; + break; + + case "Deuter": + bindingSource.Filter = "[Производитель] = 'Deuter'"; + break; + + case "Everlast": + bindingSource.Filter = "[Производитель] = 'Everlast'"; + break; + + case "Fischer": + bindingSource.Filter = "[Производитель] = 'Fischer'"; + break; + + case "Head": + bindingSource.Filter = "[Производитель] = 'Head'"; + break; + + case "Joss": + bindingSource.Filter = "[Производитель] = 'Joss'"; + break; + + case "Kettler": + bindingSource.Filter = "[Производитель] = 'Kettler'"; + break; + + case "Mikasa": + bindingSource.Filter = "[Производитель] = 'Mikasa'"; + break; + + case "Nike": + bindingSource.Filter = "[Производитель] = 'Nike'"; + break; + + case "Nordway": + bindingSource.Filter = "[Производитель] = 'Nordway'"; + break; + + case "Outventure": + bindingSource.Filter = "[Производитель] = 'Outventure'"; + break; + + case "Puma": + bindingSource.Filter = "[Производитель] = 'Puma'"; + break; + + case "Reebok": + bindingSource.Filter = "[Производитель] = 'Reebok'"; + break; + } + } + private void textBoxSearch_TextChanged(object sender, EventArgs e) + { + var value = textBoxSearch.Text.Trim().Replace("'", "''"); + + bindingSource.Filter = string.IsNullOrWhiteSpace(value) + ? "" + : $"[Артикул] LIKE '%{value}%' OR " + + $"[Производитель] LIKE '%{value}%' OR " + + $"[Поставщик] LIKE '%{value}%' OR " + + $"[Категория] LIKE '%{value}%' OR " + + $"Convert([Цена], 'System.String') LIKE '%{value}%' OR " + + $"Convert([Возможная скидка], 'System.String') LIKE '%{value}%'"; + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + AddForm adm = new AddForm(); + adm.Show(); + } + private void button2_Click(object sender, EventArgs e) + { + if (dataGridViewProduct.SelectedRows.Count > 0) + { + string articleToEdit = Convert.ToString(dataGridViewProduct.SelectedRows[0].Cells["idProducts"].Value); + + this.Hide(); + + Reduct2 editProductForm = new Reduct2(articleToEdit); + + DialogResult result = editProductForm.ShowDialog(); + + + if (result == DialogResult.OK) + { + LoadProdData(); + } + } + else + { + MessageBox.Show("Пожалуйста, выберите строку для редактирования."); + } + } + private void btnDelete_Click(object sender, EventArgs e) + { + if (dataGridViewProduct.SelectedRows.Count > 0) + { + int rowIndex = dataGridViewProduct.SelectedRows[0].Index; + int idToDelete = Convert.ToInt32(dataGridViewProduct.SelectedRows[0].Cells["idProducts"].Value); + DeleteData(idToDelete); + } + else + { + MessageBox.Show("Пожалуйста, выберите строку для удаления."); + } + } + private void DeleteData(int idToDelete) + { + try + { + DB db = new DB(); + using (MySqlConnection connection = db.getConnection()) + { + connection.Open(); + string query = "DELETE FROM Products WHERE idProducts = @id"; + using (MySqlCommand command = new MySqlCommand(query, connection)) + { + command.Parameters.AddWithValue("@id", idToDelete); + + int rowsAffected = command.ExecuteNonQuery(); + + if (rowsAffected > 0) + { + MessageBox.Show("Запись успешно удалена."); + LoadProdData(); + } + else + { + MessageBox.Show("Не удалось удалить запись."); + } + } + } + } + catch (MySqlException ex) when (ex.Number == 1451) + { + MessageBox.Show("Невозможно удалить товар который находится в заказе."); + } + catch (MySqlException ex) + { + MessageBox.Show("Произошла общая ошибка при удалении: " + ex.Message); + } + } + + private void ExitButton_Click(object sender, EventArgs e) + { + Application.Exit(); + } + private void AdmMainForm_Load(object sender, EventArgs e) + { + labelFIO.Text = loginForm.FIO; + } + + private void button3_Click(object sender, EventArgs e) + { + this.Hide(); + loginForm lf = new loginForm(); + lf.Show(); + } + } +} \ No newline at end of file diff --git a/WinFormsApp1/AdmMainForm.resx b/WinFormsApp1/AdmMainForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/WinFormsApp1/AdmMainForm.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/WinFormsApp1/AdmOrderForm.Designer.cs b/WinFormsApp1/AdmOrderForm.Designer.cs new file mode 100644 index 0000000..fb7c42a --- /dev/null +++ b/WinFormsApp1/AdmOrderForm.Designer.cs @@ -0,0 +1,110 @@ +namespace WinFormsApp1 +{ + partial class AdmOrderForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + button1 = new Button(); + label10 = new Label(); + dataGridViewProduct = new DataGridView(); + ExitButton = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).BeginInit(); + SuspendLayout(); + // + // button1 + // + button1.BackColor = Color.Red; + button1.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + button1.Location = new Point(713, 415); + button1.Name = "button1"; + button1.Size = new Size(75, 23); + button1.TabIndex = 37; + button1.Text = "Назад"; + button1.UseVisualStyleBackColor = false; + button1.Click += button1_Click; + // + // label10 + // + label10.AutoSize = true; + label10.Font = new Font("Comic Sans MS", 26.25F, FontStyle.Regular, GraphicsUnit.Point, 204); + label10.Location = new Point(62, 9); + label10.Name = "label10"; + label10.Size = new Size(679, 49); + label10.TabIndex = 39; + label10.Text = "ФОРМА ЗАКАЗОВ АДМИНИСТРАТОРА"; + // + // dataGridViewProduct + // + dataGridViewProduct.AllowUserToAddRows = false; + dataGridViewProduct.AllowUserToDeleteRows = false; + dataGridViewProduct.AllowUserToResizeColumns = false; + dataGridViewProduct.AllowUserToResizeRows = false; + dataGridViewProduct.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + dataGridViewProduct.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; + dataGridViewProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewProduct.Location = new Point(12, 84); + dataGridViewProduct.Name = "dataGridViewProduct"; + dataGridViewProduct.Size = new Size(776, 308); + dataGridViewProduct.TabIndex = 38; + // + // ExitButton + // + ExitButton.BackColor = Color.Red; + ExitButton.Location = new Point(758, 9); + ExitButton.Name = "ExitButton"; + ExitButton.Size = new Size(30, 27); + ExitButton.TabIndex = 40; + ExitButton.Text = "X"; + ExitButton.UseVisualStyleBackColor = false; + ExitButton.Click += ExitButton_Click; + // + // AdmOrderForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(192, 237, 215); + ClientSize = new Size(800, 450); + Controls.Add(ExitButton); + Controls.Add(label10); + Controls.Add(dataGridViewProduct); + Controls.Add(button1); + FormBorderStyle = FormBorderStyle.None; + Name = "AdmOrderForm"; + Text = "AdmOrderForm"; + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button button1; + private Label label10; + private DataGridView dataGridViewProduct; + private Button ExitButton; + } +} \ No newline at end of file diff --git a/WinFormsApp1/AdmOrderForm.cs b/WinFormsApp1/AdmOrderForm.cs new file mode 100644 index 0000000..a3af8e7 --- /dev/null +++ b/WinFormsApp1/AdmOrderForm.cs @@ -0,0 +1,32 @@ +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; + +namespace WinFormsApp1 +{ + public partial class AdmOrderForm : Form + { + public AdmOrderForm() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + AdmMainForm af = new AdmMainForm(); + af.Show(); + } + + private void ExitButton_Click(object sender, EventArgs e) + { + Application.Exit(); + } + } +} diff --git a/WinFormsApp1/AdmOrderForm.resx b/WinFormsApp1/AdmOrderForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/WinFormsApp1/AdmOrderForm.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/WinFormsApp1/DB.cs b/WinFormsApp1/DB.cs new file mode 100644 index 0000000..a2b741e --- /dev/null +++ b/WinFormsApp1/DB.cs @@ -0,0 +1,29 @@ +using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + using MySql.Data.MySqlClient; + + namespace WinFormsApp1 + { + internal class DB + { + MySqlConnection connection = new MySqlConnection("server=85.239.57.125;port=3306;username=ISP41_Merkylov;password=ISP41_Merkylov;database=Merkylov_Sportmag"); + public void openConnection() + { + if (connection.State == System.Data.ConnectionState.Closed) + connection.Open(); + } + public void closeConnection() + { + if (connection.State == System.Data.ConnectionState.Open) + connection.Close(); + } + public MySqlConnection getConnection() + { + return connection; + } + } + } + \ No newline at end of file diff --git a/WinFormsApp1/GuestForm.Designer.cs b/WinFormsApp1/GuestForm.Designer.cs new file mode 100644 index 0000000..9444fc7 --- /dev/null +++ b/WinFormsApp1/GuestForm.Designer.cs @@ -0,0 +1,251 @@ +namespace WinFormsApp1 +{ + partial class GuestForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + ExitButton = new Button(); + dataGridViewGuest = new DataGridView(); + panel1 = new Panel(); + panel2 = new Panel(); + CountLabel = new Label(); + PriceLabel = new Label(); + pictureBox1 = new PictureBox(); + panel3 = new Panel(); + Descyption = new Label(); + SupplierLabel = new Label(); + ManufacturerLabel = new Label(); + NameLabel = new Label(); + CategoryLabel = new Label(); + label10 = new Label(); + button1 = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewGuest).BeginInit(); + panel1.SuspendLayout(); + panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + panel3.SuspendLayout(); + SuspendLayout(); + // + // ExitButton + // + ExitButton.BackColor = Color.Red; + ExitButton.Location = new Point(758, 12); + ExitButton.Name = "ExitButton"; + ExitButton.Size = new Size(30, 27); + ExitButton.TabIndex = 0; + ExitButton.Text = "X"; + ExitButton.UseVisualStyleBackColor = false; + ExitButton.Click += ExitButton_Click; + // + // dataGridViewGuest + // + dataGridViewGuest.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewGuest.Location = new Point(91, 71); + dataGridViewGuest.Name = "dataGridViewGuest"; + dataGridViewGuest.Size = new Size(643, 259); + dataGridViewGuest.TabIndex = 1; + dataGridViewGuest.Click += dataGridViewGuest_Click; + // + // panel1 + // + panel1.BorderStyle = BorderStyle.FixedSingle; + panel1.Controls.Add(panel2); + panel1.Controls.Add(pictureBox1); + panel1.Controls.Add(panel3); + panel1.Controls.Add(SupplierLabel); + panel1.Controls.Add(ManufacturerLabel); + panel1.Controls.Add(NameLabel); + panel1.Controls.Add(CategoryLabel); + panel1.Location = new Point(107, 347); + panel1.Name = "panel1"; + panel1.Size = new Size(609, 150); + panel1.TabIndex = 15; + // + // panel2 + // + panel2.BorderStyle = BorderStyle.FixedSingle; + panel2.Controls.Add(CountLabel); + panel2.Controls.Add(PriceLabel); + panel2.Location = new Point(444, -1); + panel2.Name = "panel2"; + panel2.Size = new Size(164, 150); + panel2.TabIndex = 15; + // + // CountLabel + // + CountLabel.AutoSize = true; + CountLabel.Font = new Font("Comic Sans MS", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 204); + CountLabel.Location = new Point(44, 44); + CountLabel.Name = "CountLabel"; + CountLabel.Size = new Size(82, 18); + CountLabel.TabIndex = 1; + CountLabel.Text = "Количество"; + // + // PriceLabel + // + PriceLabel.AutoSize = true; + PriceLabel.Font = new Font("Comic Sans MS", 12F, FontStyle.Regular, GraphicsUnit.Point, 204); + PriceLabel.Location = new Point(35, 10); + PriceLabel.Name = "PriceLabel"; + PriceLabel.Size = new Size(0, 23); + PriceLabel.TabIndex = 0; + // + // pictureBox1 + // + pictureBox1.BorderStyle = BorderStyle.FixedSingle; + pictureBox1.Location = new Point(19, 10); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new Size(137, 127); + pictureBox1.TabIndex = 19; + pictureBox1.TabStop = false; + // + // panel3 + // + panel3.BorderStyle = BorderStyle.FixedSingle; + panel3.Controls.Add(Descyption); + panel3.Location = new Point(162, 55); + panel3.Name = "panel3"; + panel3.Size = new Size(276, 44); + panel3.TabIndex = 18; + // + // Descyption + // + Descyption.AutoSize = true; + Descyption.Font = new Font("Comic Sans MS", 9.5F); + Descyption.Location = new Point(-1, -1); + Descyption.Name = "Descyption"; + Descyption.Size = new Size(70, 18); + Descyption.TabIndex = 15; + Descyption.Text = "Описание"; + // + // SupplierLabel + // + SupplierLabel.AutoSize = true; + SupplierLabel.Font = new Font("Comic Sans MS", 10F); + SupplierLabel.Location = new Point(162, 99); + SupplierLabel.Name = "SupplierLabel"; + SupplierLabel.Size = new Size(119, 19); + SupplierLabel.TabIndex = 17; + SupplierLabel.Text = "Производитель:"; + // + // ManufacturerLabel + // + ManufacturerLabel.AutoSize = true; + ManufacturerLabel.Font = new Font("Comic Sans MS", 10F); + ManufacturerLabel.Location = new Point(162, 118); + ManufacturerLabel.Name = "ManufacturerLabel"; + ManufacturerLabel.Size = new Size(89, 19); + ManufacturerLabel.TabIndex = 16; + ManufacturerLabel.Text = "Поставщик:"; + // + // NameLabel + // + NameLabel.AutoSize = true; + NameLabel.Font = new Font("Comic Sans MS", 15F, FontStyle.Bold); + NameLabel.Location = new Point(162, -1); + NameLabel.Name = "NameLabel"; + NameLabel.Size = new Size(157, 29); + NameLabel.TabIndex = 4; + NameLabel.Text = "Наименование"; + // + // CategoryLabel + // + CategoryLabel.AutoSize = true; + CategoryLabel.Font = new Font("Comic Sans MS", 13F); + CategoryLabel.Location = new Point(162, 28); + CategoryLabel.Name = "CategoryLabel"; + CategoryLabel.Size = new Size(97, 24); + CategoryLabel.TabIndex = 5; + CategoryLabel.Text = "Категория"; + // + // label10 + // + label10.AutoSize = true; + label10.Font = new Font("Comic Sans MS", 26.25F, FontStyle.Regular, GraphicsUnit.Point, 204); + label10.Location = new Point(160, 9); + label10.Name = "label10"; + label10.Size = new Size(524, 49); + label10.TabIndex = 32; + label10.Text = "ГЛАВНАЯ ГОСТЕВАЯ ФОРМА"; + // + // button1 + // + button1.BackColor = Color.Red; + button1.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + button1.Location = new Point(713, 503); + button1.Name = "button1"; + button1.Size = new Size(75, 23); + button1.TabIndex = 37; + button1.Text = "Назад"; + button1.UseVisualStyleBackColor = false; + button1.Click += button1_Click; + // + // GuestForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(192, 237, 215); + ClientSize = new Size(800, 539); + Controls.Add(button1); + Controls.Add(label10); + Controls.Add(panel1); + Controls.Add(dataGridViewGuest); + Controls.Add(ExitButton); + FormBorderStyle = FormBorderStyle.None; + Name = "GuestForm"; + Text = "GuestForm"; + ((System.ComponentModel.ISupportInitialize)dataGridViewGuest).EndInit(); + panel1.ResumeLayout(false); + panel1.PerformLayout(); + panel2.ResumeLayout(false); + panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + panel3.ResumeLayout(false); + panel3.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button ExitButton; + private DataGridView dataGridViewGuest; + private Panel panel1; + private Panel panel2; + private Label CountLabel; + private Label PriceLabel; + private PictureBox pictureBox1; + private Panel panel3; + private Label Descyption; + private Label SupplierLabel; + private Label ManufacturerLabel; + private Label NameLabel; + private Label CategoryLabel; + private Label label10; + private Button button1; + } +} \ No newline at end of file diff --git a/WinFormsApp1/GuestForm.cs b/WinFormsApp1/GuestForm.cs new file mode 100644 index 0000000..5e8688f --- /dev/null +++ b/WinFormsApp1/GuestForm.cs @@ -0,0 +1,76 @@ +using MySql.Data.MySqlClient; +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; + +namespace WinFormsApp1 +{ + public partial class GuestForm : Form + { + public GuestForm() + { + InitializeComponent(); + LoadGuestData(); + } + + private void ExitButton_Click(object sender, EventArgs e) + { + Application.Exit(); + } + + private MySqlDataAdapter dataAdapter; + private DataTable prodTable; + private BindingSource bindingSource = new BindingSource(); + private void LoadGuestData() + { + try + { + DB db = new DB(); + using (MySqlConnection connection = db.getConnection()) + { + connection.Open(); + string query = "SELECT idProducts, Article AS `Артикул`, ProductName AS `название товара`, CategoryName AS `Название категории`, ProductDescryption AS `Описание`, ManufacturerName AS `Производитель`, SupplierName AS `Поставщик`, Price AS `Цена`, Discount AS `Процент скидки`, QuantityStock AS `Количество на складе`, UnitTypeName AS `Единица измерения` FROM Products LEFT JOIN Category ON Products.Category_id = Category.idCategory JOIN Manufacturer ON Products.Manufacturer_id = Manufacturer.idManufacturer JOIN Supplier ON Products.Supplier_id = Supplier.idSupplier JOIN UnitType ON Products.UnitType_id = UnitType.idUnitType"; + + dataAdapter = new MySqlDataAdapter(query, connection); + prodTable = new DataTable(); + dataAdapter.Fill(prodTable); + dataGridViewGuest.RowTemplate.Height = 60; + bindingSource.DataSource = prodTable; + dataGridViewGuest.DataSource = bindingSource; + + } + } + catch (MySqlException ex) + { + MessageBox.Show("Ошибка при подключении к базе данных или выполнении запроса: " + ex.Message); + } + catch (Exception ex) + { + MessageBox.Show("Произошла общая ошибка: " + ex.Message); + } + } + private void dataGridViewGuest_Click(object sender, EventArgs e) + { + CategoryLabel.Text = dataGridViewGuest.CurrentRow.Cells[3].Value.ToString(); + NameLabel.Text = dataGridViewGuest.CurrentRow.Cells[2].Value.ToString(); + Descyption.Text = dataGridViewGuest.CurrentRow.Cells[4].Value.ToString(); + PriceLabel.Text = dataGridViewGuest.CurrentRow.Cells[7].Value.ToString(); + CountLabel.Text = dataGridViewGuest.CurrentRow.Cells[9].Value.ToString(); + ManufacturerLabel.Text = dataGridViewGuest.CurrentRow.Cells[5].Value.ToString(); + SupplierLabel.Text = dataGridViewGuest.CurrentRow.Cells[6].Value.ToString(); + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + loginForm loginForm = new loginForm(); + loginForm.Show(); + } + } +} diff --git a/WinFormsApp1/GuestForm.resx b/WinFormsApp1/GuestForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/WinFormsApp1/GuestForm.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/WinFormsApp1/LoginForm.Designer.cs b/WinFormsApp1/LoginForm.Designer.cs new file mode 100644 index 0000000..e9786f5 --- /dev/null +++ b/WinFormsApp1/LoginForm.Designer.cs @@ -0,0 +1,129 @@ +namespace WinFormsApp1 +{ + partial class loginForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + passField = new TextBox(); + loginField = new TextBox(); + button1 = new Button(); + button2 = new Button(); + button3 = new Button(); + label1 = new Label(); + SuspendLayout(); + // + // passField + // + passField.BackColor = Color.FromArgb(133, 242, 189); + passField.Font = new Font("Comic Sans MS", 9F); + passField.Location = new Point(158, 229); + passField.Name = "passField"; + passField.Size = new Size(170, 24); + passField.TabIndex = 0; + // + // loginField + // + loginField.BackColor = Color.FromArgb(133, 242, 189); + loginField.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + loginField.Location = new Point(158, 174); + loginField.Name = "loginField"; + loginField.Size = new Size(170, 24); + loginField.TabIndex = 1; + // + // button1 + // + button1.BackColor = Color.Red; + button1.Font = new Font("Comic Sans MS", 9F); + button1.Location = new Point(202, 271); + button1.Name = "button1"; + button1.Size = new Size(75, 23); + button1.TabIndex = 2; + button1.Text = "Войти"; + button1.UseVisualStyleBackColor = false; + button1.Click += ButtonLogin_Click; + // + // button2 + // + button2.Location = new Point(427, 12); + button2.Name = "button2"; + button2.Size = new Size(32, 23); + button2.TabIndex = 3; + button2.Text = "X"; + button2.UseVisualStyleBackColor = true; + button2.Click += button2_Click; + // + // button3 + // + button3.BackColor = Color.Red; + button3.Font = new Font("Comic Sans MS", 9F); + button3.Location = new Point(202, 375); + button3.Name = "button3"; + button3.Size = new Size(75, 23); + button3.TabIndex = 4; + button3.Text = "Гость"; + button3.UseVisualStyleBackColor = false; + button3.Click += button3_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Font = new Font("Comic Sans MS", 18F, FontStyle.Regular, GraphicsUnit.Point, 204); + label1.Location = new Point(142, 23); + label1.Name = "label1"; + label1.Size = new Size(196, 33); + label1.TabIndex = 5; + label1.Text = "АВТОРИЗАЦИЯ"; + // + // loginForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(192, 237, 215); + ClientSize = new Size(471, 433); + Controls.Add(label1); + Controls.Add(button3); + Controls.Add(button2); + Controls.Add(button1); + Controls.Add(loginField); + Controls.Add(passField); + FormBorderStyle = FormBorderStyle.None; + Name = "loginForm"; + Text = "LoginForm"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox passField; + private TextBox loginField; + private Button button1; + private Button button2; + private Button button3; + private Label label1; + } +} \ No newline at end of file diff --git a/WinFormsApp1/LoginForm.cs b/WinFormsApp1/LoginForm.cs new file mode 100644 index 0000000..7dada06 --- /dev/null +++ b/WinFormsApp1/LoginForm.cs @@ -0,0 +1,121 @@ +using MySql.Data.MySqlClient; +using System.Data; +using WinFormsApp1; + using MySql.Data.MySqlClient; + 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 WinFormsApp1; + + namespace WinFormsApp1 +{ + public partial class loginForm : Form + { + public loginForm() + { + InitializeComponent(); + } + public static string FIO { get; private set; } + + private void ButtonLogin_Click(object sender, EventArgs e) + { + string loginUser = loginField.Text; + string passUser = passField.Text; + + if (string.IsNullOrWhiteSpace(loginField.Text)) + { + MessageBox.Show("Введите логин.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + + if (string.IsNullOrWhiteSpace(passField.Text)) + { + MessageBox.Show("Введите пароль.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + + DB db = new DB(); + + using (MySqlConnection connection = db.getConnection()) + { + DataTable table = new DataTable(); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + MySqlCommand command = new MySqlCommand("SELECT idClients, Login, FIO, Role_id FROM Clients WHERE Login = @uL AND Password = @uP", connection); + command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = loginUser; + command.Parameters.Add("@uP", MySqlDbType.VarChar).Value = passUser; + adapter.SelectCommand = command; + + try + { + connection.Open(); + adapter.Fill(table); + + if (table.Rows.Count == 1) + { + string roleID = table.Rows[0]["Role_id"].ToString(); + string userLogin = table.Rows[0]["Login"].ToString(); + + FIO = Convert.ToString(table.Rows[0]["FIO"]); + + switch (roleID) + { + case "1": + MessageBox.Show("Авторизация успешна, добро пожаловать! Вы авторизовались под ролью: Admin"); + this.Hide(); + AdmMainForm adm = new AdmMainForm(); + adm.Show(); + break; + + case "2": + MessageBox.Show("Авторизация успешна, добро пожаловать! Вы авторизовались под ролью: Manager"); + this.Hide(); + ManagerMainForm usManager = new ManagerMainForm(); + usManager.Show(); + break; + + case "3": + MessageBox.Show("Авторизация успешна, добро пожаловать! Вы авторизовались под ролью: Authorized Client"); + this.Hide(); + UserForm usClient = new UserForm(); + usClient.Show(); + break; + default: + MessageBox.Show("У вашего пользователя указана неизвестная роль: " + roleID); + break; + } + } + else + { + MessageBox.Show("Введен неверный логин или пароль", "Ошибка авторизации", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + catch (MySqlException ex) + { + MessageBox.Show("Ошибка подключения к базе данных или выполнения запроса: " + ex.Message, "Ошибка БД", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + finally + { + db.closeConnection(); + } + } + } + + private void button2_Click(object sender, EventArgs e) + { + Application.Exit(); + } + + private void button3_Click(object sender, EventArgs e) + { + this.Hide(); + GuestForm guest = new GuestForm(); + guest.Show(); + } + } +} \ No newline at end of file diff --git a/WinFormsApp1/LoginForm.resx b/WinFormsApp1/LoginForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/WinFormsApp1/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/WinFormsApp1/ManagerMainForm.Designer.cs b/WinFormsApp1/ManagerMainForm.Designer.cs new file mode 100644 index 0000000..01006c4 --- /dev/null +++ b/WinFormsApp1/ManagerMainForm.Designer.cs @@ -0,0 +1,328 @@ +namespace WinFormsApp1 +{ + partial class ManagerMainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + panel2 = new Panel(); + CountLabel = new Label(); + PriceLabel = new Label(); + pictureBox1 = new PictureBox(); + panel3 = new Panel(); + Descyption = new Label(); + SupplierLabel = new Label(); + ManufacturerLabel = new Label(); + NameLabel = new Label(); + CategoryLabel = new Label(); + ExitButton = new Button(); + labelFIO = new Label(); + textBoxSearch = new TextBox(); + comboBoxFilter = new ComboBox(); + comboBoxSort = new ComboBox(); + dataGridViewProduct = new DataGridView(); + Orders = new Button(); + label10 = new Label(); + button1 = new Button(); + panel1.SuspendLayout(); + panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + panel3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.BackColor = Color.FromArgb(133, 242, 189); + panel1.BorderStyle = BorderStyle.FixedSingle; + panel1.Controls.Add(panel2); + panel1.Controls.Add(pictureBox1); + panel1.Controls.Add(panel3); + panel1.Controls.Add(SupplierLabel); + panel1.Controls.Add(ManufacturerLabel); + panel1.Controls.Add(NameLabel); + panel1.Controls.Add(CategoryLabel); + panel1.Location = new Point(81, 340); + panel1.Name = "panel1"; + panel1.Size = new Size(609, 150); + panel1.TabIndex = 24; + // + // panel2 + // + panel2.BorderStyle = BorderStyle.FixedSingle; + panel2.Controls.Add(CountLabel); + panel2.Controls.Add(PriceLabel); + panel2.Location = new Point(444, -1); + panel2.Name = "panel2"; + panel2.Size = new Size(164, 150); + panel2.TabIndex = 15; + // + // CountLabel + // + CountLabel.AutoSize = true; + CountLabel.Font = new Font("Comic Sans MS", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 204); + CountLabel.Location = new Point(58, 43); + CountLabel.Name = "CountLabel"; + CountLabel.Size = new Size(82, 18); + CountLabel.TabIndex = 1; + CountLabel.Text = "Количество"; + // + // PriceLabel + // + PriceLabel.AutoSize = true; + PriceLabel.Font = new Font("Comic Sans MS", 12F, FontStyle.Regular, GraphicsUnit.Point, 204); + PriceLabel.Location = new Point(35, 10); + PriceLabel.Name = "PriceLabel"; + PriceLabel.Size = new Size(0, 23); + PriceLabel.TabIndex = 0; + // + // pictureBox1 + // + pictureBox1.BorderStyle = BorderStyle.FixedSingle; + pictureBox1.Location = new Point(19, 10); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new Size(137, 127); + pictureBox1.TabIndex = 19; + pictureBox1.TabStop = false; + // + // panel3 + // + panel3.BorderStyle = BorderStyle.FixedSingle; + panel3.Controls.Add(Descyption); + panel3.Location = new Point(162, 55); + panel3.Name = "panel3"; + panel3.Size = new Size(276, 44); + panel3.TabIndex = 18; + // + // Descyption + // + Descyption.AutoSize = true; + Descyption.Font = new Font("Comic Sans MS", 9.5F); + Descyption.Location = new Point(-1, -1); + Descyption.Name = "Descyption"; + Descyption.Size = new Size(70, 18); + Descyption.TabIndex = 15; + Descyption.Text = "Описание"; + // + // SupplierLabel + // + SupplierLabel.AutoSize = true; + SupplierLabel.Font = new Font("Comic Sans MS", 10F); + SupplierLabel.Location = new Point(162, 99); + SupplierLabel.Name = "SupplierLabel"; + SupplierLabel.Size = new Size(119, 19); + SupplierLabel.TabIndex = 17; + SupplierLabel.Text = "Производитель:"; + // + // ManufacturerLabel + // + ManufacturerLabel.AutoSize = true; + ManufacturerLabel.Font = new Font("Comic Sans MS", 10F); + ManufacturerLabel.Location = new Point(162, 118); + ManufacturerLabel.Name = "ManufacturerLabel"; + ManufacturerLabel.Size = new Size(89, 19); + ManufacturerLabel.TabIndex = 16; + ManufacturerLabel.Text = "Поставщик:"; + // + // NameLabel + // + NameLabel.AutoSize = true; + NameLabel.Font = new Font("Comic Sans MS", 15F, FontStyle.Bold); + NameLabel.Location = new Point(162, -1); + NameLabel.Name = "NameLabel"; + NameLabel.Size = new Size(157, 29); + NameLabel.TabIndex = 4; + NameLabel.Text = "Наименование"; + // + // CategoryLabel + // + CategoryLabel.AutoSize = true; + CategoryLabel.Font = new Font("Comic Sans MS", 13F); + CategoryLabel.Location = new Point(162, 28); + CategoryLabel.Name = "CategoryLabel"; + CategoryLabel.Size = new Size(97, 24); + CategoryLabel.TabIndex = 5; + CategoryLabel.Text = "Категория"; + // + // ExitButton + // + ExitButton.BackColor = Color.Red; + ExitButton.Location = new Point(766, 59); + ExitButton.Name = "ExitButton"; + ExitButton.Size = new Size(31, 26); + ExitButton.TabIndex = 23; + ExitButton.Text = "X"; + ExitButton.UseVisualStyleBackColor = false; + ExitButton.Click += button1_Click; + // + // labelFIO + // + labelFIO.AutoSize = true; + labelFIO.Font = new Font("Comic Sans MS", 9F); + labelFIO.Location = new Point(547, 64); + labelFIO.Name = "labelFIO"; + labelFIO.Size = new Size(35, 17); + labelFIO.TabIndex = 22; + labelFIO.Text = "ФИО"; + // + // textBoxSearch + // + textBoxSearch.BackColor = Color.FromArgb(133, 242, 189); + textBoxSearch.Font = new Font("Comic Sans MS", 9F); + textBoxSearch.Location = new Point(378, 60); + textBoxSearch.Name = "textBoxSearch"; + textBoxSearch.Size = new Size(141, 24); + textBoxSearch.TabIndex = 18; + textBoxSearch.TextChanged += textBoxSearch_TextChanged; + // + // comboBoxFilter + // + comboBoxFilter.BackColor = Color.FromArgb(133, 242, 189); + comboBoxFilter.Font = new Font("Comic Sans MS", 9F); + comboBoxFilter.FormattingEnabled = true; + comboBoxFilter.Location = new Point(200, 60); + comboBoxFilter.Name = "comboBoxFilter"; + comboBoxFilter.Size = new Size(121, 25); + comboBoxFilter.TabIndex = 17; + comboBoxFilter.SelectedIndexChanged += comboBoxFilter_SelectedIndexChanged; + // + // comboBoxSort + // + comboBoxSort.BackColor = Color.FromArgb(133, 242, 189); + comboBoxSort.Font = new Font("Comic Sans MS", 9F); + comboBoxSort.FormattingEnabled = true; + comboBoxSort.Location = new Point(12, 60); + comboBoxSort.Name = "comboBoxSort"; + comboBoxSort.Size = new Size(121, 25); + comboBoxSort.TabIndex = 16; + comboBoxSort.SelectedIndexChanged += comboBoxSort_SelectedIndexChanged; + // + // dataGridViewProduct + // + dataGridViewProduct.AllowUserToAddRows = false; + dataGridViewProduct.AllowUserToDeleteRows = false; + dataGridViewProduct.AllowUserToResizeColumns = false; + dataGridViewProduct.AllowUserToResizeRows = false; + dataGridViewProduct.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + dataGridViewProduct.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; + dataGridViewProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewProduct.Location = new Point(12, 89); + dataGridViewProduct.Name = "dataGridViewProduct"; + dataGridViewProduct.Size = new Size(764, 245); + dataGridViewProduct.TabIndex = 15; + dataGridViewProduct.Click += dataGridViewProd_Click; + // + // Orders + // + Orders.BackColor = Color.Red; + Orders.Font = new Font("Comic Sans MS", 10F); + Orders.Location = new Point(701, 440); + Orders.Name = "Orders"; + Orders.Size = new Size(75, 23); + Orders.TabIndex = 25; + Orders.Text = "Заказы"; + Orders.UseVisualStyleBackColor = false; + Orders.Click += Orders_Click; + // + // label10 + // + label10.AutoSize = true; + label10.Font = new Font("Comic Sans MS", 26.25F, FontStyle.Regular, GraphicsUnit.Point, 204); + label10.Location = new Point(143, 8); + label10.Name = "label10"; + label10.Size = new Size(561, 49); + label10.TabIndex = 33; + label10.Text = "ГЛАВНАЯ ФОРМА МЕНЕДЖЕРА"; + // + // button1 + // + button1.BackColor = Color.Red; + button1.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + button1.Location = new Point(701, 469); + button1.Name = "button1"; + button1.Size = new Size(75, 23); + button1.TabIndex = 37; + button1.Text = "Назад"; + button1.UseVisualStyleBackColor = false; + button1.Click += button1_Click_1; + // + // ManagerMainForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(192, 237, 215); + ClientSize = new Size(800, 503); + Controls.Add(button1); + Controls.Add(label10); + Controls.Add(Orders); + Controls.Add(panel1); + Controls.Add(ExitButton); + Controls.Add(labelFIO); + Controls.Add(textBoxSearch); + Controls.Add(comboBoxFilter); + Controls.Add(comboBoxSort); + Controls.Add(dataGridViewProduct); + FormBorderStyle = FormBorderStyle.None; + Name = "ManagerMainForm"; + Text = "ManagerMainForm"; + Load += ManagerMainForm_Load; + panel1.ResumeLayout(false); + panel1.PerformLayout(); + panel2.ResumeLayout(false); + panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + panel3.ResumeLayout(false); + panel3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Panel panel1; + private Panel panel2; + private Label CountLabel; + private Label PriceLabel; + private PictureBox pictureBox1; + private Panel panel3; + private Label Descyption; + private Label SupplierLabel; + private Label ManufacturerLabel; + private Label NameLabel; + private Label CategoryLabel; + private Button ExitButton; + private Label labelFIO; + private TextBox textBoxSearch; + private ComboBox comboBoxFilter; + private ComboBox comboBoxSort; + private DataGridView dataGridViewProduct; + private Button Orders; + private Label label10; + private Button button1; + } +} \ No newline at end of file diff --git a/WinFormsApp1/ManagerMainForm.cs b/WinFormsApp1/ManagerMainForm.cs new file mode 100644 index 0000000..caf80d1 --- /dev/null +++ b/WinFormsApp1/ManagerMainForm.cs @@ -0,0 +1,219 @@ +using MySql.Data.MySqlClient; +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; + +namespace WinFormsApp1 +{ + public partial class ManagerMainForm : Form + { + public ManagerMainForm() + { + InitializeComponent(); + LoadProdData(); + LoadSortOptions(); + LoadFilterOptions(); + } + + private MySqlDataAdapter dataAdapter; + private DataTable prodTable; + private BindingSource bindingSource = new BindingSource(); + private void LoadProdData() + { + try + { + DB db = new DB(); + using (MySqlConnection connection = db.getConnection()) + { + connection.Open(); + string query = "SELECT idProducts, Article AS `Артикул`, ProductName AS `название товара`, CategoryName AS `Категория`, ProductDescryption AS `Описание`, ManufacturerName AS `Производитель`, SupplierName AS `Поставщик`, Price AS `Цена`, Discount AS `Возможная скидка`, QuantityStock AS `Количество на складе`, UnitTypeName AS `Единица измерения` FROM Products LEFT JOIN Category ON Products.Category_id = Category.idCategory JOIN Manufacturer ON Products.Manufacturer_id = Manufacturer.idManufacturer JOIN Supplier ON Products.Supplier_id = Supplier.idSupplier JOIN UnitType ON Products.UnitType_id = UnitType.idUnitType"; + + dataAdapter = new MySqlDataAdapter(query, connection); + prodTable = new DataTable(); + dataAdapter.Fill(prodTable); + dataGridViewProduct.RowTemplate.Height = 60; + bindingSource.DataSource = prodTable; + dataGridViewProduct.DataSource = bindingSource; + + + } + } + catch (MySqlException ex) + { + MessageBox.Show("Ошибка при подключении к базе данных или выполнении запроса: " + ex.Message); + } + catch (Exception ex) + { + MessageBox.Show("Произошла общая ошибка: " + ex.Message); + } + } + private void dataGridViewProd_Click(object sender, EventArgs e) + { + CategoryLabel.Text = dataGridViewProduct.CurrentRow.Cells[3].Value.ToString(); + NameLabel.Text = dataGridViewProduct.CurrentRow.Cells[2].Value.ToString(); + Descyption.Text = dataGridViewProduct.CurrentRow.Cells[4].Value.ToString(); + PriceLabel.Text = dataGridViewProduct.CurrentRow.Cells[7].Value.ToString(); + CountLabel.Text = dataGridViewProduct.CurrentRow.Cells[9].Value.ToString(); + ManufacturerLabel.Text = dataGridViewProduct.CurrentRow.Cells[5].Value.ToString(); + SupplierLabel.Text = dataGridViewProduct.CurrentRow.Cells[6].Value.ToString(); + } + private void LoadSortOptions() + { + comboBoxSort.Items.Add("По умолчанию"); + comboBoxSort.Items.Add("Цена (возрастающая)"); + comboBoxSort.Items.Add("Цена (убывающая)"); + comboBoxSort.SelectedIndex = 0; + } + + private void comboBoxSort_SelectedIndexChanged(object sender, EventArgs e) + { + string sortOption = comboBoxSort.SelectedItem.ToString(); + + switch (sortOption) + { + case "По умолчанию": + bindingSource.Sort = ""; + break; + case "Цена (возрастающая)": + bindingSource.Sort = "Цена ASC"; + break; + case "Цена (убывающая)": + bindingSource.Sort = "Цена DESC"; + break; + } + } + private void LoadFilterOptions() + { + comboBoxFilter.Items.Add("Все производители"); + comboBoxFilter.Items.Add("Adidas"); + comboBoxFilter.Items.Add("Barbell"); + comboBoxFilter.Items.Add("Demix"); + comboBoxFilter.Items.Add("Deuter"); + comboBoxFilter.Items.Add("Everlast"); + comboBoxFilter.Items.Add("Fischer"); + comboBoxFilter.Items.Add("Head"); + comboBoxFilter.Items.Add("Joss"); + comboBoxFilter.Items.Add("Kettler"); + comboBoxFilter.Items.Add("Mikasa"); + comboBoxFilter.Items.Add("Nike"); + comboBoxFilter.Items.Add("Nordway"); + comboBoxFilter.Items.Add("Outventure"); + comboBoxFilter.Items.Add("Puma"); + comboBoxFilter.Items.Add("Reebok"); + comboBoxSort.SelectedIndex = 0; + } + private void comboBoxFilter_SelectedIndexChanged(object sender, EventArgs e) + { + string filterOption = comboBoxFilter.SelectedItem.ToString().Trim(); + switch (filterOption) + { + case "Все производители": + bindingSource.Filter = ""; + break; + + case "Adidas": + bindingSource.Filter = "[Производитель] = 'Adidas'"; + break; + + case "Barbell": + bindingSource.Filter = "[Производитель] = 'Barbell'"; + break; + + case "Demix": + bindingSource.Filter = "[Производитель] = 'Demix'"; + break; + + case "Deuter": + bindingSource.Filter = "[Производитель] = 'Deuter'"; + break; + + case "Everlast": + bindingSource.Filter = "[Производитель] = 'Everlast'"; + break; + + case "Fischer": + bindingSource.Filter = "[Производитель] = 'Fischer'"; + break; + + case "Head": + bindingSource.Filter = "[Производитель] = 'Head'"; + break; + + case "Joss": + bindingSource.Filter = "[Производитель] = 'Joss'"; + break; + + case "Kettler": + bindingSource.Filter = "[Производитель] = 'Kettler'"; + break; + + case "Mikasa": + bindingSource.Filter = "[Производитель] = 'Mikasa'"; + break; + + case "Nike": + bindingSource.Filter = "[Производитель] = 'Nike'"; + break; + + case "Nordway": + bindingSource.Filter = "[Производитель] = 'Nordway'"; + break; + + case "Outventure": + bindingSource.Filter = "[Производитель] = 'Outventure'"; + break; + + case "Puma": + bindingSource.Filter = "[Производитель] = 'Puma'"; + break; + + case "Reebok": + bindingSource.Filter = "[Производитель] = 'Reebok'"; + break; + } + } + private void textBoxSearch_TextChanged(object sender, EventArgs e) + { + var value = textBoxSearch.Text.Trim().Replace("'", "''"); + + bindingSource.Filter = string.IsNullOrWhiteSpace(value) + ? "" + : $"[Артикул] LIKE '%{value}%' OR " + + $"[Производитель] LIKE '%{value}%' OR " + + $"[Поставщик] LIKE '%{value}%' OR " + + $"[Категория] LIKE '%{value}%' OR " + + $"Convert([Цена], 'System.String') LIKE '%{value}%' OR " + + $"Convert([Возможная скидка], 'System.String') LIKE '%{value}%'"; + } + + private void button1_Click(object sender, EventArgs e) + { + Application.Exit(); + } + + private void ManagerMainForm_Load(object sender, EventArgs e) + { + labelFIO.Text = loginForm.FIO; + } + + private void Orders_Click(object sender, EventArgs e) + { + this.Hide(); + ManagerOrder mo = new ManagerOrder(); + mo.Show(); + } + + private void button1_Click_1(object sender, EventArgs e) + { + this.Hide(); + loginForm loginForm = new loginForm(); + loginForm.Show(); + } + } +} diff --git a/WinFormsApp1/ManagerMainForm.resx b/WinFormsApp1/ManagerMainForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/WinFormsApp1/ManagerMainForm.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/WinFormsApp1/ManagerOrder.Designer.cs b/WinFormsApp1/ManagerOrder.Designer.cs new file mode 100644 index 0000000..071d3aa --- /dev/null +++ b/WinFormsApp1/ManagerOrder.Designer.cs @@ -0,0 +1,111 @@ +namespace WinFormsApp1 +{ + partial class ManagerOrder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewProduct = new DataGridView(); + label10 = new Label(); + ExitButton = new Button(); + button1 = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).BeginInit(); + SuspendLayout(); + // + // dataGridViewProduct + // + dataGridViewProduct.AllowUserToAddRows = false; + dataGridViewProduct.AllowUserToDeleteRows = false; + dataGridViewProduct.AllowUserToResizeColumns = false; + dataGridViewProduct.AllowUserToResizeRows = false; + dataGridViewProduct.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + dataGridViewProduct.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; + dataGridViewProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewProduct.Location = new Point(12, 77); + dataGridViewProduct.Name = "dataGridViewProduct"; + dataGridViewProduct.Size = new Size(776, 308); + dataGridViewProduct.TabIndex = 16; + // + // label10 + // + label10.AutoSize = true; + label10.Font = new Font("Comic Sans MS", 26.25F, FontStyle.Regular, GraphicsUnit.Point, 204); + label10.Location = new Point(119, 9); + label10.Name = "label10"; + label10.Size = new Size(561, 49); + label10.TabIndex = 34; + label10.Text = "ГЛАВНАЯ ФОРМА МЕНЕДЖЕРА"; + // + // ExitButton + // + ExitButton.BackColor = Color.Red; + ExitButton.Location = new Point(757, 9); + ExitButton.Name = "ExitButton"; + ExitButton.Size = new Size(31, 26); + ExitButton.TabIndex = 35; + ExitButton.Text = "X"; + ExitButton.UseVisualStyleBackColor = false; + ExitButton.Click += ExitButton_Click; + // + // button1 + // + button1.BackColor = Color.Red; + button1.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + button1.Location = new Point(697, 406); + button1.Name = "button1"; + button1.Size = new Size(75, 23); + button1.TabIndex = 36; + button1.Text = "Назад"; + button1.UseVisualStyleBackColor = false; + button1.Click += button1_Click; + // + // ManagerOrder + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(192, 237, 215); + ClientSize = new Size(800, 450); + Controls.Add(button1); + Controls.Add(ExitButton); + Controls.Add(label10); + Controls.Add(dataGridViewProduct); + FormBorderStyle = FormBorderStyle.None; + Name = "ManagerOrder"; + Text = "ManagerOrder"; + Load += ManagerOrder_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private DataGridView dataGridViewProduct; + private Label label10; + private Button ExitButton; + private Button button1; + } +} \ No newline at end of file diff --git a/WinFormsApp1/ManagerOrder.cs b/WinFormsApp1/ManagerOrder.cs new file mode 100644 index 0000000..9d3366e --- /dev/null +++ b/WinFormsApp1/ManagerOrder.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.Common; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using MySql.Data.MySqlClient; + +namespace WinFormsApp1 +{ + public partial class ManagerOrder : Form + { + public ManagerOrder() + { + InitializeComponent(); + LoadProdData(); + } + + private MySqlDataAdapter dataAdapter; + private DataTable prodTable; + private BindingSource bindingSource = new BindingSource(); + + private void ExitButton_Click(object sender, EventArgs e) + { + Application.Exit(); + } + private void LoadProdData() + { + try + { + DB db = new DB(); + using (MySqlConnection connection = db.getConnection()) + { + connection.Open(); + string query = "SELECT idOrders AS `Идентификатор заказа`, Article AS `Артикул`, FIO AS `Клиент`, StatusName AS `Статус заказа`, PickUpPoint AS `Пункт выдачи`, Order_date AS `Дата заказа`, Delivery_date AS `Дата доставки` FROM Orders LEFT JOIN Clients ON Orders.Clients_id = Clients.idClients JOIN Status ON Orders.Status_id = Status.idStatus JOIN PickUp ON Orders.PickUp_id = PickUp.idPickUp"; + + dataAdapter = new MySqlDataAdapter(query, connection); + prodTable = new DataTable(); + dataAdapter.Fill(prodTable); + dataGridViewProduct.RowTemplate.Height = 60; + bindingSource.DataSource = prodTable; + dataGridViewProduct.DataSource = bindingSource; + + + } + } + catch (MySqlException ex) + { + MessageBox.Show("Ошибка при подключении к базе данных или выполнении запроса: " + ex.Message); + } + catch (Exception ex) + { + MessageBox.Show("Произошла общая ошибка: " + ex.Message); + } + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + ManagerMainForm mf = new ManagerMainForm(); + mf.Show(); + } + + private void ManagerOrder_Load(object sender, EventArgs e) + { + + } + } +} diff --git a/WinFormsApp1/ManagerOrder.resx b/WinFormsApp1/ManagerOrder.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/WinFormsApp1/ManagerOrder.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/WinFormsApp1/Program.cs b/WinFormsApp1/Program.cs new file mode 100644 index 0000000..13ac290 --- /dev/null +++ b/WinFormsApp1/Program.cs @@ -0,0 +1,17 @@ +namespace WinFormsApp1 +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new loginForm()); + } + } +} \ No newline at end of file diff --git a/WinFormsApp1/Properties/Resources.Designer.cs b/WinFormsApp1/Properties/Resources.Designer.cs new file mode 100644 index 0000000..3b0a0c8 --- /dev/null +++ b/WinFormsApp1/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace WinFormsApp1.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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 (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinFormsApp1.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/WinFormsApp1/Properties/Resources.resx b/WinFormsApp1/Properties/Resources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WinFormsApp1/Properties/Resources.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/WinFormsApp1/Reduct2.Designer.cs b/WinFormsApp1/Reduct2.Designer.cs new file mode 100644 index 0000000..64d737f --- /dev/null +++ b/WinFormsApp1/Reduct2.Designer.cs @@ -0,0 +1,386 @@ +namespace WinFormsApp1 +{ + partial class Reduct2 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + button2 = new Button(); + button1 = new Button(); + textBoxStockQuan = new TextBox(); + textBoxSale = new TextBox(); + textBoxPrice = new TextBox(); + comboBoxCategories = new ComboBox(); + comboBoxManufacturer = new ComboBox(); + comboBoxUnitType = new ComboBox(); + textBoxDesc = new TextBox(); + textBoxProdName = new TextBox(); + textBoxArticle = new TextBox(); + comboBoxSupplier = new ComboBox(); + textBoxID = new TextBox(); + label9 = new Label(); + label8 = new Label(); + label7 = new Label(); + label6 = new Label(); + label5 = new Label(); + label4 = new Label(); + label3 = new Label(); + label2 = new Label(); + label1 = new Label(); + label11 = new Label(); + label10 = new Label(); + label12 = new Label(); + button3 = new Button(); + SuspendLayout(); + // + // button2 + // + button2.BackColor = Color.Red; + button2.Font = new Font("Comic Sans MS", 9F); + button2.Location = new Point(448, 12); + button2.Name = "button2"; + button2.Size = new Size(38, 29); + button2.TabIndex = 34; + button2.Text = "X"; + button2.UseVisualStyleBackColor = false; + button2.Click += button2_Click; + // + // button1 + // + button1.BackColor = Color.Red; + button1.Font = new Font("Comic Sans MS", 9F); + button1.Location = new Point(225, 408); + button1.Name = "button1"; + button1.Size = new Size(108, 23); + button1.TabIndex = 33; + button1.Text = "Редактировать"; + button1.UseVisualStyleBackColor = false; + button1.Click += btnSave_Click; + // + // textBoxStockQuan + // + textBoxStockQuan.BackColor = Color.FromArgb(133, 242, 189); + textBoxStockQuan.Font = new Font("Comic Sans MS", 9F); + textBoxStockQuan.Location = new Point(165, 337); + textBoxStockQuan.Name = "textBoxStockQuan"; + textBoxStockQuan.Size = new Size(225, 24); + textBoxStockQuan.TabIndex = 32; + // + // textBoxSale + // + textBoxSale.BackColor = Color.FromArgb(133, 242, 189); + textBoxSale.Font = new Font("Comic Sans MS", 9F); + textBoxSale.Location = new Point(165, 308); + textBoxSale.Name = "textBoxSale"; + textBoxSale.Size = new Size(225, 24); + textBoxSale.TabIndex = 31; + // + // textBoxPrice + // + textBoxPrice.BackColor = Color.FromArgb(133, 242, 189); + textBoxPrice.Font = new Font("Comic Sans MS", 9F); + textBoxPrice.Location = new Point(165, 279); + textBoxPrice.Name = "textBoxPrice"; + textBoxPrice.Size = new Size(225, 24); + textBoxPrice.TabIndex = 30; + // + // comboBoxCategories + // + comboBoxCategories.BackColor = Color.FromArgb(133, 242, 189); + comboBoxCategories.Font = new Font("Comic Sans MS", 9F); + comboBoxCategories.FormattingEnabled = true; + comboBoxCategories.Location = new Point(165, 163); + comboBoxCategories.Name = "comboBoxCategories"; + comboBoxCategories.Size = new Size(225, 25); + comboBoxCategories.TabIndex = 29; + // + // comboBoxManufacturer + // + comboBoxManufacturer.BackColor = Color.FromArgb(133, 242, 189); + comboBoxManufacturer.Font = new Font("Comic Sans MS", 9F); + comboBoxManufacturer.FormattingEnabled = true; + comboBoxManufacturer.Location = new Point(165, 221); + comboBoxManufacturer.Name = "comboBoxManufacturer"; + comboBoxManufacturer.Size = new Size(225, 25); + comboBoxManufacturer.TabIndex = 28; + // + // comboBoxUnitType + // + comboBoxUnitType.BackColor = Color.FromArgb(133, 242, 189); + comboBoxUnitType.Font = new Font("Comic Sans MS", 9F); + comboBoxUnitType.FormattingEnabled = true; + comboBoxUnitType.Location = new Point(165, 366); + comboBoxUnitType.Name = "comboBoxUnitType"; + comboBoxUnitType.Size = new Size(225, 25); + comboBoxUnitType.TabIndex = 27; + // + // textBoxDesc + // + textBoxDesc.BackColor = Color.FromArgb(133, 242, 189); + textBoxDesc.Font = new Font("Comic Sans MS", 9F); + textBoxDesc.Location = new Point(165, 192); + textBoxDesc.Name = "textBoxDesc"; + textBoxDesc.Size = new Size(225, 24); + textBoxDesc.TabIndex = 26; + // + // textBoxProdName + // + textBoxProdName.BackColor = Color.FromArgb(133, 242, 189); + textBoxProdName.Font = new Font("Comic Sans MS", 9F); + textBoxProdName.Location = new Point(165, 134); + textBoxProdName.Name = "textBoxProdName"; + textBoxProdName.Size = new Size(225, 24); + textBoxProdName.TabIndex = 25; + // + // textBoxArticle + // + textBoxArticle.BackColor = Color.FromArgb(133, 242, 189); + textBoxArticle.Font = new Font("Comic Sans MS", 9F); + textBoxArticle.Location = new Point(165, 105); + textBoxArticle.Name = "textBoxArticle"; + textBoxArticle.Size = new Size(225, 24); + textBoxArticle.TabIndex = 24; + // + // comboBoxSupplier + // + comboBoxSupplier.BackColor = Color.FromArgb(133, 242, 189); + comboBoxSupplier.Font = new Font("Comic Sans MS", 9F); + comboBoxSupplier.FormattingEnabled = true; + comboBoxSupplier.Location = new Point(165, 250); + comboBoxSupplier.Name = "comboBoxSupplier"; + comboBoxSupplier.Size = new Size(225, 25); + comboBoxSupplier.TabIndex = 23; + // + // textBoxID + // + textBoxID.BackColor = Color.FromArgb(133, 242, 189); + textBoxID.Location = new Point(165, 76); + textBoxID.Name = "textBoxID"; + textBoxID.ReadOnly = true; + textBoxID.Size = new Size(225, 23); + textBoxID.TabIndex = 35; + // + // label9 + // + label9.AutoSize = true; + label9.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label9.Location = new Point(68, 136); + label9.Name = "label9"; + label9.Size = new Size(61, 17); + label9.TabIndex = 45; + label9.Text = "Название"; + // + // label8 + // + label8.AutoSize = true; + label8.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label8.Location = new Point(68, 194); + label8.Name = "label8"; + label8.Size = new Size(67, 17); + label8.TabIndex = 44; + label8.Text = "Описание"; + // + // label7 + // + label7.AutoSize = true; + label7.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label7.Location = new Point(60, 223); + label7.Name = "label7"; + label7.Size = new Size(99, 17); + label7.TabIndex = 43; + label7.Text = "Производитель"; + // + // label6 + // + label6.AutoSize = true; + label6.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label6.Location = new Point(68, 252); + label6.Name = "label6"; + label6.Size = new Size(74, 17); + label6.TabIndex = 42; + label6.Text = "Поставщик"; + // + // label5 + // + label5.AutoSize = true; + label5.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label5.Location = new Point(68, 281); + label5.Name = "label5"; + label5.Size = new Size(36, 17); + label5.TabIndex = 41; + label5.Text = "Цена"; + // + // label4 + // + label4.AutoSize = true; + label4.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label4.Location = new Point(68, 310); + label4.Name = "label4"; + label4.Size = new Size(48, 17); + label4.TabIndex = 40; + label4.Text = "Скидка"; + // + // label3 + // + label3.AutoSize = true; + label3.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label3.Location = new Point(68, 339); + label3.Name = "label3"; + label3.Size = new Size(76, 17); + label3.TabIndex = 39; + label3.Text = "Количество"; + // + // label2 + // + label2.AutoSize = true; + label2.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label2.Location = new Point(68, 165); + label2.Name = "label2"; + label2.Size = new Size(67, 17); + label2.TabIndex = 38; + label2.Text = "Категория"; + // + // label1 + // + label1.AutoSize = true; + label1.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label1.Location = new Point(68, 107); + label1.Name = "label1"; + label1.Size = new Size(56, 17); + label1.TabIndex = 37; + label1.Text = "Артикул"; + // + // label11 + // + label11.AutoSize = true; + label11.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label11.Location = new Point(68, 369); + label11.Name = "label11"; + label11.Size = new Size(91, 17); + label11.TabIndex = 36; + label11.Text = "Ед. измерения"; + // + // label10 + // + label10.AutoSize = true; + label10.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + label10.Location = new Point(59, 78); + label10.Name = "label10"; + label10.Size = new Size(100, 17); + label10.TabIndex = 46; + label10.Text = "Идентификатор"; + // + // label12 + // + label12.AutoSize = true; + label12.Font = new Font("Comic Sans MS", 26.25F, FontStyle.Regular, GraphicsUnit.Point, 204); + label12.Location = new Point(68, 9); + label12.Name = "label12"; + label12.Size = new Size(356, 49); + label12.TabIndex = 47; + label12.Text = "РЕДАКТИРОВАНИЕ"; + // + // button3 + // + button3.BackColor = Color.Red; + button3.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + button3.Location = new Point(411, 415); + button3.Name = "button3"; + button3.Size = new Size(75, 23); + button3.TabIndex = 48; + button3.Text = "Назад"; + button3.UseVisualStyleBackColor = false; + button3.Click += button3_Click; + // + // Reduct2 + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(192, 237, 215); + ClientSize = new Size(498, 450); + Controls.Add(button3); + Controls.Add(label12); + Controls.Add(label10); + Controls.Add(label9); + Controls.Add(label8); + Controls.Add(label7); + Controls.Add(label6); + Controls.Add(label5); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(label11); + Controls.Add(textBoxID); + Controls.Add(button2); + Controls.Add(button1); + Controls.Add(textBoxStockQuan); + Controls.Add(textBoxSale); + Controls.Add(textBoxPrice); + Controls.Add(comboBoxCategories); + Controls.Add(comboBoxManufacturer); + Controls.Add(comboBoxUnitType); + Controls.Add(textBoxDesc); + Controls.Add(textBoxProdName); + Controls.Add(textBoxArticle); + Controls.Add(comboBoxSupplier); + FormBorderStyle = FormBorderStyle.None; + Name = "Reduct2"; + Text = "Reduct2"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button button2; + private Button button1; + private TextBox textBoxStockQuan; + private TextBox textBoxSale; + private TextBox textBoxPrice; + private ComboBox comboBoxCategories; + private ComboBox comboBoxManufacturer; + private ComboBox comboBoxUnitType; + private TextBox textBoxDesc; + private TextBox textBoxProdName; + private TextBox textBoxArticle; + private ComboBox comboBoxSupplier; + private TextBox textBoxID; + private Label label9; + private Label label8; + private Label label7; + private Label label6; + private Label label5; + private Label label4; + private Label label3; + private Label label2; + private Label label1; + private Label label11; + private Label label10; + private Label label12; + private Button button3; + } +} \ No newline at end of file diff --git a/WinFormsApp1/Reduct2.cs b/WinFormsApp1/Reduct2.cs new file mode 100644 index 0000000..0206b4c --- /dev/null +++ b/WinFormsApp1/Reduct2.cs @@ -0,0 +1,233 @@ +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 MySql.Data.MySqlClient; + +namespace WinFormsApp1 +{ + public partial class Reduct2 : Form + { + public Reduct2(string productId) + { + InitializeComponent(); + LoadProductData(productId); + LoadCategories(); + LoadSuppliers(); + LoadManufacteries(); + LoadUnitType(); + } + private void LoadCategories() + { + DB db = new DB(); + DataTable categories = new DataTable(); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + MySqlCommand command = new MySqlCommand("SELECT idCategory, CategoryName FROM Category", db.getConnection()); + + try + { + db.openConnection(); + adapter.SelectCommand = command; + adapter.Fill(categories); + + comboBoxCategories.DataSource = categories; + comboBoxCategories.DisplayMember = "CategoryName"; + comboBoxCategories.ValueMember = "idCategory"; + } + catch (Exception ex) + { + MessageBox.Show("Ошибка загрузки категорий " + ex.Message); + } + finally + { + db.closeConnection(); + } + } + private void LoadManufacteries() + { + DB db = new DB(); + DataTable manufacturer = new DataTable(); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + MySqlCommand command = new MySqlCommand("SELECT idManufacturer, ManufacturerName FROM Manufacturer", db.getConnection()); + + try + { + db.openConnection(); + adapter.SelectCommand = command; + adapter.Fill(manufacturer); + + comboBoxManufacturer.DataSource = manufacturer; + comboBoxManufacturer.DisplayMember = "ManufacturerName"; + comboBoxManufacturer.ValueMember = "idManufacturer"; + } + catch (Exception ex) + { + MessageBox.Show("Ошибка загрузки категорий " + ex.Message); + } + finally + { + db.closeConnection(); + } + } + private void LoadUnitType() + { + DB db = new DB(); + DataTable UnitType = new DataTable(); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + MySqlCommand command = new MySqlCommand("SELECT idUnitType, UnitTypeName FROM UnitType", db.getConnection()); + + try + { + db.openConnection(); + adapter.SelectCommand = command; + adapter.Fill(UnitType); + + comboBoxUnitType.DataSource = UnitType; + comboBoxUnitType.DisplayMember = "UnitTypeName"; + comboBoxUnitType.ValueMember = "idUnitType"; + } + catch (Exception ex) + { + MessageBox.Show("Ошибка загрузки категорий " + ex.Message); + } + finally + { + db.closeConnection(); + } + } + private void LoadSuppliers() + { + DB db = new DB(); + DataTable suppliers = new DataTable(); + MySqlDataAdapter adapter = new MySqlDataAdapter(); + MySqlCommand command = new MySqlCommand("SELECT idSupplier, SupplierName FROM Supplier", db.getConnection()); + + try + { + db.openConnection(); + adapter.SelectCommand = command; + adapter.Fill(suppliers); + + comboBoxSupplier.DataSource = suppliers; + comboBoxSupplier.DisplayMember = "SupplierName"; + comboBoxSupplier.ValueMember = "idSupplier"; + } + catch (Exception ex) + { + MessageBox.Show("Ошибка загрузки категорий " + ex.Message); + } + finally + { + db.closeConnection(); + } + } + private void LoadProductData(string productId) + { + try + { + DB db = new DB(); + using (MySqlConnection connection = db.getConnection()) + { + connection.Open(); + string query = "SELECT Article, ProductName, Category_id, ProductDescryption, Manufacturer_id, Supplier_id, Price, Discount, QuantityStock, UnitType_id FROM Products WHERE idProducts = @id"; + using (MySqlCommand command = new MySqlCommand(query, connection)) + { + command.Parameters.AddWithValue("@id", productId); + using (MySqlDataReader reader = command.ExecuteReader()) + { + if (reader.Read()) + { + textBoxArticle.Text = reader["Article"].ToString(); + textBoxID.Text = productId; + textBoxProdName.Text = reader["ProductName"].ToString(); + comboBoxCategories.Text = reader["Category_id"].ToString(); + textBoxDesc.Text = reader["ProductDescryption"].ToString(); + comboBoxManufacturer.Text = reader["Manufacturer_id"].ToString(); + comboBoxSupplier.Text = reader["Supplier_id"].ToString(); + textBoxPrice.Text = reader["Price"].ToString(); + textBoxSale.Text = reader["Discount"].ToString(); + textBoxStockQuan.Text = reader["QuantityStock"].ToString(); + comboBoxUnitType.Text = reader["UnitType_id"].ToString(); + } + else + { + MessageBox.Show("Продукт с указанным ID не найден."); + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + } + } + } + } + catch (MySqlException ex) + { + MessageBox.Show("Ошибка при загрузке данных продукта: " + ex.Message); + } + } + private void btnSave_Click(object sender, EventArgs e) + { + try + { + object supplierId = comboBoxSupplier.SelectedValue; + object manufacturerId = comboBoxManufacturer.SelectedValue; + object categoryId = comboBoxCategories.SelectedValue; + object unittypeId = comboBoxUnitType.SelectedValue; + + DB db = new DB(); + using (MySqlConnection connection = db.getConnection()) + { + connection.Open(); + string query = "UPDATE Products SET Article = @art, ProductName = @pr_name, Category_id = @cat, ProductDescryption = @desc, Manufacturer_id = @manu, Supplier_id = @supp, Price = @base, Discount = @sale, QuantityStock = @stock, UnitType_id = @unit WHERE idProducts = @id"; + using (MySqlCommand command = new MySqlCommand(query, connection)) + { + command.Parameters.AddWithValue("@art", textBoxArticle.Text); + command.Parameters.AddWithValue("@pr_name", textBoxProdName.Text); + command.Parameters.AddWithValue("@desc", textBoxDesc.Text); + command.Parameters.AddWithValue("@sale", textBoxSale.Text); + command.Parameters.AddWithValue("@id", textBoxID.Text); + command.Parameters.AddWithValue("@stock", textBoxStockQuan.Text); + command.Parameters.AddWithValue("@base", textBoxPrice.Text); + command.Parameters.AddWithValue("@supp", supplierId); + command.Parameters.AddWithValue("@manu", manufacturerId); + command.Parameters.AddWithValue("@cat", categoryId); + command.Parameters.AddWithValue("@unit", unittypeId); + + int rowsAffected = command.ExecuteNonQuery(); + if (rowsAffected > 0) + { + MessageBox.Show("Данные продукта успешно обновлены."); + this.DialogResult = DialogResult.OK; + this.Hide(); + AdmMainForm main = new AdmMainForm(); + main.Show(); + } + } + } + } + catch (MySqlException ex) + { + MessageBox.Show("Ошибка при сохранении данных продукта: " + ex.Message); + } + } + + private void button2_Click(object sender, EventArgs e) + { + this.Hide(); + AdmMainForm mainForm = new AdmMainForm(); + mainForm.Show(); + } + + private void button3_Click(object sender, EventArgs e) + { + this.Hide(); + AdmMainForm af = new AdmMainForm(); + af.Show(); + } + } +} + diff --git a/WinFormsApp1/Reduct2.resx b/WinFormsApp1/Reduct2.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/WinFormsApp1/Reduct2.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/WinFormsApp1/UserForm.Designer.cs b/WinFormsApp1/UserForm.Designer.cs new file mode 100644 index 0000000..28e8f0c --- /dev/null +++ b/WinFormsApp1/UserForm.Designer.cs @@ -0,0 +1,266 @@ +namespace WinFormsApp1 +{ + partial class UserForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + panel2 = new Panel(); + CountLabel = new Label(); + PriceLabel = new Label(); + pictureBox1 = new PictureBox(); + panel3 = new Panel(); + Descyption = new Label(); + SupplierLabel = new Label(); + ManufacturerLabel = new Label(); + NameLabel = new Label(); + CategoryLabel = new Label(); + dataGridViewUser = new DataGridView(); + ExitButton = new Button(); + labelFIO = new Label(); + label10 = new Label(); + button3 = new Button(); + panel1.SuspendLayout(); + panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + panel3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewUser).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.BackColor = Color.FromArgb(133, 242, 189); + panel1.BorderStyle = BorderStyle.FixedSingle; + panel1.Controls.Add(panel2); + panel1.Controls.Add(pictureBox1); + panel1.Controls.Add(panel3); + panel1.Controls.Add(SupplierLabel); + panel1.Controls.Add(ManufacturerLabel); + panel1.Controls.Add(NameLabel); + panel1.Controls.Add(CategoryLabel); + panel1.Location = new Point(79, 345); + panel1.Name = "panel1"; + panel1.Size = new Size(609, 150); + panel1.TabIndex = 18; + // + // panel2 + // + panel2.BorderStyle = BorderStyle.FixedSingle; + panel2.Controls.Add(CountLabel); + panel2.Controls.Add(PriceLabel); + panel2.Location = new Point(444, -1); + panel2.Name = "panel2"; + panel2.Size = new Size(164, 150); + panel2.TabIndex = 15; + // + // CountLabel + // + CountLabel.AutoSize = true; + CountLabel.Font = new Font("Comic Sans MS", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 204); + CountLabel.Location = new Point(44, 44); + CountLabel.Name = "CountLabel"; + CountLabel.Size = new Size(82, 18); + CountLabel.TabIndex = 1; + CountLabel.Text = "Количество"; + // + // PriceLabel + // + PriceLabel.AutoSize = true; + PriceLabel.Font = new Font("Comic Sans MS", 12F, FontStyle.Regular, GraphicsUnit.Point, 204); + PriceLabel.Location = new Point(35, 10); + PriceLabel.Name = "PriceLabel"; + PriceLabel.Size = new Size(0, 23); + PriceLabel.TabIndex = 0; + // + // pictureBox1 + // + pictureBox1.BorderStyle = BorderStyle.FixedSingle; + pictureBox1.Location = new Point(19, 10); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new Size(137, 127); + pictureBox1.TabIndex = 19; + pictureBox1.TabStop = false; + // + // panel3 + // + panel3.BorderStyle = BorderStyle.FixedSingle; + panel3.Controls.Add(Descyption); + panel3.Location = new Point(162, 55); + panel3.Name = "panel3"; + panel3.Size = new Size(276, 44); + panel3.TabIndex = 18; + // + // Descyption + // + Descyption.AutoSize = true; + Descyption.Font = new Font("Comic Sans MS", 9.5F); + Descyption.Location = new Point(-1, -1); + Descyption.Name = "Descyption"; + Descyption.Size = new Size(70, 18); + Descyption.TabIndex = 15; + Descyption.Text = "Описание"; + // + // SupplierLabel + // + SupplierLabel.AutoSize = true; + SupplierLabel.Font = new Font("Comic Sans MS", 10F); + SupplierLabel.Location = new Point(162, 99); + SupplierLabel.Name = "SupplierLabel"; + SupplierLabel.Size = new Size(119, 19); + SupplierLabel.TabIndex = 17; + SupplierLabel.Text = "Производитель:"; + // + // ManufacturerLabel + // + ManufacturerLabel.AutoSize = true; + ManufacturerLabel.Font = new Font("Comic Sans MS", 10F); + ManufacturerLabel.Location = new Point(162, 118); + ManufacturerLabel.Name = "ManufacturerLabel"; + ManufacturerLabel.Size = new Size(89, 19); + ManufacturerLabel.TabIndex = 16; + ManufacturerLabel.Text = "Поставщик:"; + // + // NameLabel + // + NameLabel.AutoSize = true; + NameLabel.Font = new Font("Comic Sans MS", 15F, FontStyle.Bold); + NameLabel.Location = new Point(162, -1); + NameLabel.Name = "NameLabel"; + NameLabel.Size = new Size(157, 29); + NameLabel.TabIndex = 4; + NameLabel.Text = "Наименование"; + // + // CategoryLabel + // + CategoryLabel.AutoSize = true; + CategoryLabel.Font = new Font("Comic Sans MS", 13F); + CategoryLabel.Location = new Point(162, 28); + CategoryLabel.Name = "CategoryLabel"; + CategoryLabel.Size = new Size(97, 24); + CategoryLabel.TabIndex = 5; + CategoryLabel.Text = "Категория"; + // + // dataGridViewUser + // + dataGridViewUser.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewUser.Location = new Point(61, 103); + dataGridViewUser.Name = "dataGridViewUser"; + dataGridViewUser.Size = new Size(643, 236); + dataGridViewUser.TabIndex = 17; + dataGridViewUser.Click += dataGridViewUser_Click; + // + // ExitButton + // + ExitButton.BackColor = Color.Red; + ExitButton.Location = new Point(758, 12); + ExitButton.Name = "ExitButton"; + ExitButton.Size = new Size(30, 27); + ExitButton.TabIndex = 16; + ExitButton.Text = "X"; + ExitButton.UseVisualStyleBackColor = false; + ExitButton.Click += ExitButton_Click; + // + // labelFIO + // + labelFIO.AutoSize = true; + labelFIO.Font = new Font("Comic Sans MS", 9F); + labelFIO.Location = new Point(591, 74); + labelFIO.Name = "labelFIO"; + labelFIO.Size = new Size(35, 17); + labelFIO.TabIndex = 19; + labelFIO.Text = "ФИО"; + // + // label10 + // + label10.AutoSize = true; + label10.Font = new Font("Comic Sans MS", 26.25F, FontStyle.Regular, GraphicsUnit.Point, 204); + label10.Location = new Point(88, 9); + label10.Name = "label10"; + label10.Size = new Size(635, 49); + label10.TabIndex = 33; + label10.Text = "ГЛАВНАЯ ФОРМА ПОЛЬЗОВАТЕЛЯ"; + // + // button3 + // + button3.BackColor = Color.Red; + button3.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point, 204); + button3.Location = new Point(713, 477); + button3.Name = "button3"; + button3.Size = new Size(75, 23); + button3.TabIndex = 49; + button3.Text = "Назад"; + button3.UseVisualStyleBackColor = false; + button3.Click += button3_Click; + // + // UserForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(192, 237, 215); + ClientSize = new Size(800, 512); + Controls.Add(button3); + Controls.Add(label10); + Controls.Add(labelFIO); + Controls.Add(panel1); + Controls.Add(dataGridViewUser); + Controls.Add(ExitButton); + FormBorderStyle = FormBorderStyle.None; + Name = "UserForm"; + Text = "UserForm"; + Load += UserForm_Load; + panel1.ResumeLayout(false); + panel1.PerformLayout(); + panel2.ResumeLayout(false); + panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + panel3.ResumeLayout(false); + panel3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewUser).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Panel panel1; + private Panel panel2; + private Label CountLabel; + private Label PriceLabel; + private PictureBox pictureBox1; + private Panel panel3; + private Label Descyption; + private Label SupplierLabel; + private Label ManufacturerLabel; + private Label NameLabel; + private Label CategoryLabel; + private DataGridView dataGridViewUser; + private Button ExitButton; + private Label labelFIO; + private Label label10; + private Button button3; + } +} \ No newline at end of file diff --git a/WinFormsApp1/UserForm.cs b/WinFormsApp1/UserForm.cs new file mode 100644 index 0000000..225a4eb --- /dev/null +++ b/WinFormsApp1/UserForm.cs @@ -0,0 +1,84 @@ +using MySql.Data.MySqlClient; +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; + +namespace WinFormsApp1 +{ + public partial class UserForm : Form + { + public UserForm() + { + InitializeComponent(); + LoadUserData(); + } + + private void ExitButton_Click(object sender, EventArgs e) + { + Application.Exit(); + } + + private MySqlDataAdapter dataAdapter; + private DataTable prodTable; + private BindingSource bindingSource = new BindingSource(); + private void LoadUserData() + { + try + { + DB db = new DB(); + using (MySqlConnection connection = db.getConnection()) + { + connection.Open(); + string query = "SELECT idProducts, Article AS `Артикул`, ProductName AS `название товара`, CategoryName AS `Название категории`, ProductDescryption AS `Описание`, ManufacturerName AS `Производитель`, SupplierName AS `Поставщик`, Price AS `Цена`, Discount AS `Процент скидки`, QuantityStock AS `Количество на складе`, UnitTypeName AS `Единица измерения` FROM Products LEFT JOIN Category ON Products.Category_id = Category.idCategory JOIN Manufacturer ON Products.Manufacturer_id = Manufacturer.idManufacturer JOIN Supplier ON Products.Supplier_id = Supplier.idSupplier JOIN UnitType ON Products.UnitType_id = UnitType.idUnitType"; + + dataAdapter = new MySqlDataAdapter(query, connection); + prodTable = new DataTable(); + dataAdapter.Fill(prodTable); + dataGridViewUser.RowTemplate.Height = 60; + bindingSource.DataSource = prodTable; + dataGridViewUser.DataSource = bindingSource; + + } + } + catch (MySqlException ex) + { + MessageBox.Show("Ошибка при подключении к базе данных или выполнении запроса: " + ex.Message); + } + catch (Exception ex) + { + MessageBox.Show("Произошла общая ошибка: " + ex.Message); + } + } + private void dataGridViewUser_Click(object sender, EventArgs e) + { + CategoryLabel.Text = dataGridViewUser.CurrentRow.Cells[3].Value.ToString(); + NameLabel.Text = dataGridViewUser.CurrentRow.Cells[2].Value.ToString(); + Descyption.Text = dataGridViewUser.CurrentRow.Cells[4].Value.ToString(); + PriceLabel.Text = dataGridViewUser.CurrentRow.Cells[7].Value.ToString(); + CountLabel.Text = dataGridViewUser.CurrentRow.Cells[9].Value.ToString(); + ManufacturerLabel.Text = dataGridViewUser.CurrentRow.Cells[5].Value.ToString(); + SupplierLabel.Text = dataGridViewUser.CurrentRow.Cells[6].Value.ToString(); + } + + private void UserForm_Load(object sender, EventArgs e) + { + { + labelFIO.Text = loginForm.FIO; + } + } + + private void button3_Click(object sender, EventArgs e) + { + this.Hide(); + loginForm lf = new loginForm(); + lf.Show(); + } + } +} + diff --git a/WinFormsApp1/UserForm.resx b/WinFormsApp1/UserForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/WinFormsApp1/UserForm.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/WinFormsApp1/WinFormsApp1.csproj b/WinFormsApp1/WinFormsApp1.csproj new file mode 100644 index 0000000..dca6a8f --- /dev/null +++ b/WinFormsApp1/WinFormsApp1.csproj @@ -0,0 +1,30 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/WinFormsApp1/WinFormsApp1.csproj.user b/WinFormsApp1/WinFormsApp1.csproj.user new file mode 100644 index 0000000..88ee7f3 --- /dev/null +++ b/WinFormsApp1/WinFormsApp1.csproj.user @@ -0,0 +1,32 @@ + + + + + Form + + + Form + + + Form + + + Form + + + Form + + + Form + + + Form + + + Form + + + Form + + + \ No newline at end of file