Advertisement
Guest User

Untitled

a guest
Jan 9th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.69 KB | None | 0 0
  1. #pragma once
  2.  
  3. namespace Project2 {
  4.  
  5. using namespace System;
  6. using namespace System::ComponentModel;
  7. using namespace System::Collections;
  8. using namespace System::Windows::Forms;
  9. using namespace System::Data;
  10. using namespace System::Drawing;
  11. using namespace MySql::Data::MySqlClient;
  12.  
  13. /// <summary>
  14. /// Summary for MyForm
  15. /// </summary>
  16. public ref class MyForm : public System::Windows::Forms::Form
  17. {
  18. public:
  19. MyForm(void)
  20. {
  21. InitializeComponent();
  22.  
  23. }
  24.  
  25. protected:
  26. /// <summary>
  27. /// Clean up any resources being used.
  28. /// </summary>
  29. ~MyForm()
  30. {
  31. if (components)
  32. {
  33. delete components;
  34. }
  35. }
  36. private: System::Windows::Forms::TabControl^ shop;
  37. protected:
  38. private: System::Windows::Forms::TabPage^ products;
  39. private: System::Windows::Forms::ComboBox^ cmbBoxCategory;
  40.  
  41. private: System::Windows::Forms::Label^ label2;
  42. private: System::Windows::Forms::TextBox^ txtSearch;
  43.  
  44. private: System::Windows::Forms::Label^ label1;
  45.  
  46. private: System::Windows::Forms::TabPage^ suppliers;
  47. private: System::Windows::Forms::TabPage^ employees;
  48. private: System::Windows::Forms::DataGridView^ dgProducts;
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. private: System::Windows::Forms::Button^ btnPSearch;
  57.  
  58.  
  59. private: System::Windows::Forms::GroupBox^ groupBox1;
  60. private: System::Windows::Forms::TextBox^ txtQuantity;
  61.  
  62. private: System::Windows::Forms::TextBox^ txtPrice;
  63.  
  64. private: System::Windows::Forms::TextBox^ txtProduct;
  65. private: System::Windows::Forms::Button^ btnPDelete;
  66.  
  67.  
  68. private: System::Windows::Forms::Button^ btnPEdit;
  69.  
  70. private: System::Windows::Forms::Button^ btnPAdd;
  71.  
  72.  
  73. private: System::Windows::Forms::Label^ label7;
  74. private: System::Windows::Forms::Label^ label6;
  75. private: System::Windows::Forms::Label^ label5;
  76. private: System::Windows::Forms::Button^ btnSDelete;
  77.  
  78. private: System::Windows::Forms::Button^ btnSEdit;
  79.  
  80. private: System::Windows::Forms::Button^ btnSAdd;
  81. private: System::Windows::Forms::Button^ btnSSearch;
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. private: System::Windows::Forms::DataGridView^ dgSuppliers;
  92. private: System::Windows::Forms::TextBox^ txtSSearch;
  93.  
  94.  
  95. private: System::Windows::Forms::Label^ label10;
  96. private: System::Windows::Forms::GroupBox^ groupBox2;
  97. private: System::Windows::Forms::Label^ label3;
  98. private: System::Windows::Forms::Label^ label8;
  99. private: System::Windows::Forms::Label^ label9;
  100. private: System::Windows::Forms::TextBox^ txtSWww;
  101.  
  102. private: System::Windows::Forms::TextBox^ txtSAdress;
  103.  
  104. private: System::Windows::Forms::TextBox^ txtSName;
  105. private: System::Windows::Forms::Label^ label11;
  106. private: System::Windows::Forms::Label^ label12;
  107. private: System::Windows::Forms::Label^ label13;
  108. private: System::Windows::Forms::TextBox^ txtSNotes;
  109.  
  110. private: System::Windows::Forms::TextBox^ txtSMail;
  111.  
  112. private: System::Windows::Forms::TextBox^ txtSPhone;
  113. private: System::Windows::Forms::GroupBox^ groupBox3;
  114. private: System::Windows::Forms::Label^ label4;
  115. private: System::Windows::Forms::Label^ label14;
  116. private: System::Windows::Forms::Label^ label15;
  117. private: System::Windows::Forms::TextBox^ txtENotes;
  118. private: System::Windows::Forms::TextBox^ txtEPosition;
  119. private: System::Windows::Forms::TextBox^ txtESallary;
  120. private: System::Windows::Forms::Label^ label16;
  121. private: System::Windows::Forms::Label^ label17;
  122. private: System::Windows::Forms::Label^ label18;
  123. private: System::Windows::Forms::TextBox^ txtEPesel;
  124. private: System::Windows::Forms::TextBox^ txtESurname;
  125. private: System::Windows::Forms::TextBox^ txtEName;
  126. private: System::Windows::Forms::Button^ btnEDelete;
  127. private: System::Windows::Forms::Button^ btnEEdit;
  128. private: System::Windows::Forms::Button^ btnEAdd;
  129. private: System::Windows::Forms::Button^ btnESearch;
  130.  
  131. private: System::Windows::Forms::DataGridView^ dgEmployees;
  132. private: System::Windows::Forms::TextBox^ txtESearch;
  133. private: System::Windows::Forms::Label^ label19;
  134.  
  135.  
  136.  
  137. private:
  138. /// <summary>
  139. /// Required designer variable.
  140. /// </summary>
  141. System::ComponentModel::Container ^components;
  142.  
  143. #pragma region Windows Form Designer generated code
  144. /// <summary>
  145. /// Required method for Designer support - do not modify
  146. /// the contents of this method with the code editor.
  147. /// </summary>
  148. void InitializeComponent(void)
  149. {
  150. this->shop = (gcnew System::Windows::Forms::TabControl());
  151. this->products = (gcnew System::Windows::Forms::TabPage());
  152. this->btnPDelete = (gcnew System::Windows::Forms::Button());
  153. this->btnPEdit = (gcnew System::Windows::Forms::Button());
  154. this->btnPAdd = (gcnew System::Windows::Forms::Button());
  155. this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
  156. this->label7 = (gcnew System::Windows::Forms::Label());
  157. this->label6 = (gcnew System::Windows::Forms::Label());
  158. this->label5 = (gcnew System::Windows::Forms::Label());
  159. this->txtQuantity = (gcnew System::Windows::Forms::TextBox());
  160. this->txtPrice = (gcnew System::Windows::Forms::TextBox());
  161. this->txtProduct = (gcnew System::Windows::Forms::TextBox());
  162. this->btnPSearch = (gcnew System::Windows::Forms::Button());
  163. this->dgProducts = (gcnew System::Windows::Forms::DataGridView());
  164. this->cmbBoxCategory = (gcnew System::Windows::Forms::ComboBox());
  165. this->label2 = (gcnew System::Windows::Forms::Label());
  166. this->txtSearch = (gcnew System::Windows::Forms::TextBox());
  167. this->label1 = (gcnew System::Windows::Forms::Label());
  168. this->suppliers = (gcnew System::Windows::Forms::TabPage());
  169. this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
  170. this->label11 = (gcnew System::Windows::Forms::Label());
  171. this->label12 = (gcnew System::Windows::Forms::Label());
  172. this->label13 = (gcnew System::Windows::Forms::Label());
  173. this->txtSNotes = (gcnew System::Windows::Forms::TextBox());
  174. this->txtSMail = (gcnew System::Windows::Forms::TextBox());
  175. this->txtSPhone = (gcnew System::Windows::Forms::TextBox());
  176. this->label3 = (gcnew System::Windows::Forms::Label());
  177. this->label8 = (gcnew System::Windows::Forms::Label());
  178. this->label9 = (gcnew System::Windows::Forms::Label());
  179. this->txtSWww = (gcnew System::Windows::Forms::TextBox());
  180. this->txtSAdress = (gcnew System::Windows::Forms::TextBox());
  181. this->txtSName = (gcnew System::Windows::Forms::TextBox());
  182. this->btnSDelete = (gcnew System::Windows::Forms::Button());
  183. this->btnSEdit = (gcnew System::Windows::Forms::Button());
  184. this->btnSAdd = (gcnew System::Windows::Forms::Button());
  185. this->btnSSearch = (gcnew System::Windows::Forms::Button());
  186. this->dgSuppliers = (gcnew System::Windows::Forms::DataGridView());
  187. this->txtSSearch = (gcnew System::Windows::Forms::TextBox());
  188. this->label10 = (gcnew System::Windows::Forms::Label());
  189. this->employees = (gcnew System::Windows::Forms::TabPage());
  190. this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
  191. this->label4 = (gcnew System::Windows::Forms::Label());
  192. this->label14 = (gcnew System::Windows::Forms::Label());
  193. this->label15 = (gcnew System::Windows::Forms::Label());
  194. this->txtENotes = (gcnew System::Windows::Forms::TextBox());
  195. this->txtEPosition = (gcnew System::Windows::Forms::TextBox());
  196. this->txtESallary = (gcnew System::Windows::Forms::TextBox());
  197. this->label16 = (gcnew System::Windows::Forms::Label());
  198. this->label17 = (gcnew System::Windows::Forms::Label());
  199. this->label18 = (gcnew System::Windows::Forms::Label());
  200. this->txtEPesel = (gcnew System::Windows::Forms::TextBox());
  201. this->txtESurname = (gcnew System::Windows::Forms::TextBox());
  202. this->txtEName = (gcnew System::Windows::Forms::TextBox());
  203. this->btnEDelete = (gcnew System::Windows::Forms::Button());
  204. this->btnEEdit = (gcnew System::Windows::Forms::Button());
  205. this->btnEAdd = (gcnew System::Windows::Forms::Button());
  206. this->btnESearch = (gcnew System::Windows::Forms::Button());
  207. this->dgEmployees = (gcnew System::Windows::Forms::DataGridView());
  208. this->txtESearch = (gcnew System::Windows::Forms::TextBox());
  209. this->label19 = (gcnew System::Windows::Forms::Label());
  210. this->shop->SuspendLayout();
  211. this->products->SuspendLayout();
  212. this->groupBox1->SuspendLayout();
  213. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgProducts))->BeginInit();
  214. this->suppliers->SuspendLayout();
  215. this->groupBox2->SuspendLayout();
  216. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgSuppliers))->BeginInit();
  217. this->employees->SuspendLayout();
  218. this->groupBox3->SuspendLayout();
  219. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgEmployees))->BeginInit();
  220. this->SuspendLayout();
  221. //
  222. // shop
  223. //
  224. this->shop->Controls->Add(this->products);
  225. this->shop->Controls->Add(this->suppliers);
  226. this->shop->Controls->Add(this->employees);
  227. this->shop->Location = System::Drawing::Point(0, 0);
  228. this->shop->Name = L"shop";
  229. this->shop->SelectedIndex = 0;
  230. this->shop->Size = System::Drawing::Size(543, 471);
  231. this->shop->TabIndex = 0;
  232. //
  233. // products
  234. //
  235. this->products->Controls->Add(this->btnPDelete);
  236. this->products->Controls->Add(this->btnPEdit);
  237. this->products->Controls->Add(this->btnPAdd);
  238. this->products->Controls->Add(this->groupBox1);
  239. this->products->Controls->Add(this->btnPSearch);
  240. this->products->Controls->Add(this->dgProducts);
  241. this->products->Controls->Add(this->cmbBoxCategory);
  242. this->products->Controls->Add(this->label2);
  243. this->products->Controls->Add(this->txtSearch);
  244. this->products->Controls->Add(this->label1);
  245. this->products->Location = System::Drawing::Point(4, 22);
  246. this->products->Name = L"products";
  247. this->products->Padding = System::Windows::Forms::Padding(3);
  248. this->products->Size = System::Drawing::Size(535, 445);
  249. this->products->TabIndex = 1;
  250. this->products->Text = L"Stan magazynowy";
  251. this->products->UseVisualStyleBackColor = true;
  252. //
  253. // btnPDelete
  254. //
  255. this->btnPDelete->Location = System::Drawing::Point(57, 385);
  256. this->btnPDelete->Name = L"btnPDelete";
  257. this->btnPDelete->Size = System::Drawing::Size(75, 23);
  258. this->btnPDelete->TabIndex = 13;
  259. this->btnPDelete->Text = L"Usuń";
  260. this->btnPDelete->UseVisualStyleBackColor = true;
  261. this->btnPDelete->Click += gcnew System::EventHandler(this, &MyForm::btnPDelete_Click);
  262. //
  263. // btnPEdit
  264. //
  265. this->btnPEdit->Location = System::Drawing::Point(57, 345);
  266. this->btnPEdit->Name = L"btnPEdit";
  267. this->btnPEdit->Size = System::Drawing::Size(75, 23);
  268. this->btnPEdit->TabIndex = 12;
  269. this->btnPEdit->Text = L"Edytuj";
  270. this->btnPEdit->UseVisualStyleBackColor = true;
  271. this->btnPEdit->Click += gcnew System::EventHandler(this, &MyForm::btnPEdit_Click);
  272. //
  273. // btnPAdd
  274. //
  275. this->btnPAdd->Location = System::Drawing::Point(57, 304);
  276. this->btnPAdd->Name = L"btnPAdd";
  277. this->btnPAdd->Size = System::Drawing::Size(75, 23);
  278. this->btnPAdd->TabIndex = 11;
  279. this->btnPAdd->Text = L"Dodaj";
  280. this->btnPAdd->UseVisualStyleBackColor = true;
  281. this->btnPAdd->Click += gcnew System::EventHandler(this, &MyForm::btnPAdd_Click);
  282. //
  283. // groupBox1
  284. //
  285. this->groupBox1->Controls->Add(this->label7);
  286. this->groupBox1->Controls->Add(this->label6);
  287. this->groupBox1->Controls->Add(this->label5);
  288. this->groupBox1->Controls->Add(this->txtQuantity);
  289. this->groupBox1->Controls->Add(this->txtPrice);
  290. this->groupBox1->Controls->Add(this->txtProduct);
  291. this->groupBox1->Location = System::Drawing::Point(18, 104);
  292. this->groupBox1->Name = L"groupBox1";
  293. this->groupBox1->Size = System::Drawing::Size(159, 176);
  294. this->groupBox1->TabIndex = 10;
  295. this->groupBox1->TabStop = false;
  296. this->groupBox1->Text = L"Edycja";
  297. //
  298. // label7
  299. //
  300. this->label7->AutoSize = true;
  301. this->label7->Location = System::Drawing::Point(26, 110);
  302. this->label7->Name = L"label7";
  303. this->label7->Size = System::Drawing::Size(29, 13);
  304. this->label7->TabIndex = 12;
  305. this->label7->Text = L"Ilość";
  306. //
  307. // label6
  308. //
  309. this->label6->AutoSize = true;
  310. this->label6->Location = System::Drawing::Point(26, 71);
  311. this->label6->Name = L"label6";
  312. this->label6->Size = System::Drawing::Size(32, 13);
  313. this->label6->TabIndex = 11;
  314. this->label6->Text = L"Cena";
  315. //
  316. // label5
  317. //
  318. this->label5->AutoSize = true;
  319. this->label5->Location = System::Drawing::Point(26, 29);
  320. this->label5->Name = L"label5";
  321. this->label5->Size = System::Drawing::Size(44, 13);
  322. this->label5->TabIndex = 10;
  323. this->label5->Text = L"Produkt";
  324. //
  325. // txtQuantity
  326. //
  327. this->txtQuantity->Location = System::Drawing::Point(26, 126);
  328. this->txtQuantity->Name = L"txtQuantity";
  329. this->txtQuantity->Size = System::Drawing::Size(100, 20);
  330. this->txtQuantity->TabIndex = 9;
  331. //
  332. // txtPrice
  333. //
  334. this->txtPrice->Location = System::Drawing::Point(26, 87);
  335. this->txtPrice->Name = L"txtPrice";
  336. this->txtPrice->Size = System::Drawing::Size(100, 20);
  337. this->txtPrice->TabIndex = 8;
  338. this->txtPrice->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::txtPrice_KeyPress);
  339. //
  340. // txtProduct
  341. //
  342. this->txtProduct->Location = System::Drawing::Point(26, 48);
  343. this->txtProduct->Name = L"txtProduct";
  344. this->txtProduct->Size = System::Drawing::Size(100, 20);
  345. this->txtProduct->TabIndex = 7;
  346. //
  347. // btnPSearch
  348. //
  349. this->btnPSearch->Location = System::Drawing::Point(340, 55);
  350. this->btnPSearch->Name = L"btnPSearch";
  351. this->btnPSearch->Size = System::Drawing::Size(104, 23);
  352. this->btnPSearch->TabIndex = 6;
  353. this->btnPSearch->Text = L"Szukaj";
  354. this->btnPSearch->UseVisualStyleBackColor = true;
  355. this->btnPSearch->Click += gcnew System::EventHandler(this, &MyForm::btnPSearch_Click);
  356. //
  357. // dgProducts
  358. //
  359. this->dgProducts->AllowUserToAddRows = false;
  360. this->dgProducts->AllowUserToDeleteRows = false;
  361. this->dgProducts->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::AllCells;
  362. this->dgProducts->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  363. this->dgProducts->Location = System::Drawing::Point(211, 109);
  364. this->dgProducts->Name = L"dgProducts";
  365. this->dgProducts->ReadOnly = true;
  366. this->dgProducts->Size = System::Drawing::Size(300, 314);
  367. this->dgProducts->TabIndex = 5;
  368. this->dgProducts->CellClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm::dgProducts_CellClick);
  369. //
  370. // cmbBoxCategory
  371. //
  372. this->cmbBoxCategory->FormattingEnabled = true;
  373. this->cmbBoxCategory->Location = System::Drawing::Point(113, 15);
  374. this->cmbBoxCategory->Name = L"cmbBoxCategory";
  375. this->cmbBoxCategory->Size = System::Drawing::Size(367, 21);
  376. this->cmbBoxCategory->TabIndex = 4;
  377. this->cmbBoxCategory->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::cmbBoxCategory_SelectedIndexChanged);
  378. //
  379. // label2
  380. //
  381. this->label2->AutoSize = true;
  382. this->label2->Location = System::Drawing::Point(18, 18);
  383. this->label2->Name = L"label2";
  384. this->label2->Size = System::Drawing::Size(55, 13);
  385. this->label2->TabIndex = 3;
  386. this->label2->Text = L"Kategoria:";
  387. //
  388. // txtSearch
  389. //
  390. this->txtSearch->Location = System::Drawing::Point(113, 57);
  391. this->txtSearch->Name = L"txtSearch";
  392. this->txtSearch->Size = System::Drawing::Size(221, 20);
  393. this->txtSearch->TabIndex = 2;
  394. this->txtSearch->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::txtSearch_KeyPress);
  395. //
  396. // label1
  397. //
  398. this->label1->AutoSize = true;
  399. this->label1->Location = System::Drawing::Point(18, 60);
  400. this->label1->Name = L"label1";
  401. this->label1->Size = System::Drawing::Size(47, 13);
  402. this->label1->TabIndex = 1;
  403. this->label1->Text = L"Produkt:";
  404. //
  405. // suppliers
  406. //
  407. this->suppliers->Controls->Add(this->groupBox2);
  408. this->suppliers->Controls->Add(this->btnSDelete);
  409. this->suppliers->Controls->Add(this->btnSEdit);
  410. this->suppliers->Controls->Add(this->btnSAdd);
  411. this->suppliers->Controls->Add(this->btnSSearch);
  412. this->suppliers->Controls->Add(this->dgSuppliers);
  413. this->suppliers->Controls->Add(this->txtSSearch);
  414. this->suppliers->Controls->Add(this->label10);
  415. this->suppliers->Location = System::Drawing::Point(4, 22);
  416. this->suppliers->Name = L"suppliers";
  417. this->suppliers->Padding = System::Windows::Forms::Padding(3);
  418. this->suppliers->Size = System::Drawing::Size(535, 445);
  419. this->suppliers->TabIndex = 2;
  420. this->suppliers->Text = L"Dostawcy";
  421. this->suppliers->UseVisualStyleBackColor = true;
  422. //
  423. // groupBox2
  424. //
  425. this->groupBox2->Controls->Add(this->label11);
  426. this->groupBox2->Controls->Add(this->label12);
  427. this->groupBox2->Controls->Add(this->label13);
  428. this->groupBox2->Controls->Add(this->txtSNotes);
  429. this->groupBox2->Controls->Add(this->txtSMail);
  430. this->groupBox2->Controls->Add(this->txtSPhone);
  431. this->groupBox2->Controls->Add(this->label3);
  432. this->groupBox2->Controls->Add(this->label8);
  433. this->groupBox2->Controls->Add(this->label9);
  434. this->groupBox2->Controls->Add(this->txtSWww);
  435. this->groupBox2->Controls->Add(this->txtSAdress);
  436. this->groupBox2->Controls->Add(this->txtSName);
  437. this->groupBox2->Location = System::Drawing::Point(25, 41);
  438. this->groupBox2->Name = L"groupBox2";
  439. this->groupBox2->Size = System::Drawing::Size(399, 157);
  440. this->groupBox2->TabIndex = 22;
  441. this->groupBox2->TabStop = false;
  442. this->groupBox2->Text = L"Edycja";
  443. //
  444. // label11
  445. //
  446. this->label11->AutoSize = true;
  447. this->label11->Location = System::Drawing::Point(208, 107);
  448. this->label11->Name = L"label11";
  449. this->label11->Size = System::Drawing::Size(37, 13);
  450. this->label11->TabIndex = 18;
  451. this->label11->Text = L"Uwagi";
  452. //
  453. // label12
  454. //
  455. this->label12->AutoSize = true;
  456. this->label12->Location = System::Drawing::Point(208, 68);
  457. this->label12->Name = L"label12";
  458. this->label12->Size = System::Drawing::Size(64, 13);
  459. this->label12->TabIndex = 17;
  460. this->label12->Text = L"Adres e-mail";
  461. //
  462. // label13
  463. //
  464. this->label13->AutoSize = true;
  465. this->label13->Location = System::Drawing::Point(208, 26);
  466. this->label13->Name = L"label13";
  467. this->label13->Size = System::Drawing::Size(79, 13);
  468. this->label13->TabIndex = 16;
  469. this->label13->Text = L"Numer telefonu";
  470. //
  471. // txtSNotes
  472. //
  473. this->txtSNotes->Location = System::Drawing::Point(208, 123);
  474. this->txtSNotes->Name = L"txtSNotes";
  475. this->txtSNotes->Size = System::Drawing::Size(185, 20);
  476. this->txtSNotes->TabIndex = 15;
  477. //
  478. // txtSMail
  479. //
  480. this->txtSMail->Location = System::Drawing::Point(208, 84);
  481. this->txtSMail->Name = L"txtSMail";
  482. this->txtSMail->Size = System::Drawing::Size(185, 20);
  483. this->txtSMail->TabIndex = 14;
  484. //
  485. // txtSPhone
  486. //
  487. this->txtSPhone->Location = System::Drawing::Point(208, 45);
  488. this->txtSPhone->Name = L"txtSPhone";
  489. this->txtSPhone->Size = System::Drawing::Size(185, 20);
  490. this->txtSPhone->TabIndex = 13;
  491. //
  492. // label3
  493. //
  494. this->label3->AutoSize = true;
  495. this->label3->Location = System::Drawing::Point(6, 107);
  496. this->label3->Name = L"label3";
  497. this->label3->Size = System::Drawing::Size(96, 13);
  498. this->label3->TabIndex = 12;
  499. this->label3->Text = L"Strona internetowa";
  500. //
  501. // label8
  502. //
  503. this->label8->AutoSize = true;
  504. this->label8->Location = System::Drawing::Point(6, 68);
  505. this->label8->Name = L"label8";
  506. this->label8->Size = System::Drawing::Size(34, 13);
  507. this->label8->TabIndex = 11;
  508. this->label8->Text = L"Adres";
  509. //
  510. // label9
  511. //
  512. this->label9->AutoSize = true;
  513. this->label9->Location = System::Drawing::Point(6, 26);
  514. this->label9->Name = L"label9";
  515. this->label9->Size = System::Drawing::Size(40, 13);
  516. this->label9->TabIndex = 10;
  517. this->label9->Text = L"Nazwa";
  518. //
  519. // txtSWww
  520. //
  521. this->txtSWww->Location = System::Drawing::Point(6, 123);
  522. this->txtSWww->Name = L"txtSWww";
  523. this->txtSWww->Size = System::Drawing::Size(176, 20);
  524. this->txtSWww->TabIndex = 9;
  525. //
  526. // txtSAdress
  527. //
  528. this->txtSAdress->Location = System::Drawing::Point(6, 84);
  529. this->txtSAdress->Name = L"txtSAdress";
  530. this->txtSAdress->Size = System::Drawing::Size(176, 20);
  531. this->txtSAdress->TabIndex = 8;
  532. //
  533. // txtSName
  534. //
  535. this->txtSName->Location = System::Drawing::Point(6, 45);
  536. this->txtSName->Name = L"txtSName";
  537. this->txtSName->Size = System::Drawing::Size(176, 20);
  538. this->txtSName->TabIndex = 7;
  539. //
  540. // btnSDelete
  541. //
  542. this->btnSDelete->Location = System::Drawing::Point(440, 164);
  543. this->btnSDelete->Name = L"btnSDelete";
  544. this->btnSDelete->Size = System::Drawing::Size(75, 23);
  545. this->btnSDelete->TabIndex = 21;
  546. this->btnSDelete->Text = L"Usuń";
  547. this->btnSDelete->UseVisualStyleBackColor = true;
  548. this->btnSDelete->Click += gcnew System::EventHandler(this, &MyForm::btnSDelete_Click);
  549. //
  550. // btnSEdit
  551. //
  552. this->btnSEdit->Location = System::Drawing::Point(440, 125);
  553. this->btnSEdit->Name = L"btnSEdit";
  554. this->btnSEdit->Size = System::Drawing::Size(75, 23);
  555. this->btnSEdit->TabIndex = 20;
  556. this->btnSEdit->Text = L"Edytuj";
  557. this->btnSEdit->UseVisualStyleBackColor = true;
  558. this->btnSEdit->Click += gcnew System::EventHandler(this, &MyForm::btnSEdit_Click);
  559. //
  560. // btnSAdd
  561. //
  562. this->btnSAdd->Location = System::Drawing::Point(440, 86);
  563. this->btnSAdd->Name = L"btnSAdd";
  564. this->btnSAdd->Size = System::Drawing::Size(75, 23);
  565. this->btnSAdd->TabIndex = 19;
  566. this->btnSAdd->Text = L"Dodaj";
  567. this->btnSAdd->UseVisualStyleBackColor = true;
  568. this->btnSAdd->Click += gcnew System::EventHandler(this, &MyForm::btnSAdd_Click);
  569. //
  570. // btnSSearch
  571. //
  572. this->btnSSearch->Location = System::Drawing::Point(314, 12);
  573. this->btnSSearch->Name = L"btnSSearch";
  574. this->btnSSearch->Size = System::Drawing::Size(104, 23);
  575. this->btnSSearch->TabIndex = 17;
  576. this->btnSSearch->Text = L"Szukaj";
  577. this->btnSSearch->UseVisualStyleBackColor = true;
  578. this->btnSSearch->Click += gcnew System::EventHandler(this, &MyForm::btnSSearch_Click);
  579. //
  580. // dgSuppliers
  581. //
  582. this->dgSuppliers->AllowUserToAddRows = false;
  583. this->dgSuppliers->AllowUserToDeleteRows = false;
  584. this->dgSuppliers->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::AllCells;
  585. this->dgSuppliers->AutoSizeRowsMode = System::Windows::Forms::DataGridViewAutoSizeRowsMode::AllCells;
  586. this->dgSuppliers->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  587. this->dgSuppliers->Location = System::Drawing::Point(25, 204);
  588. this->dgSuppliers->Name = L"dgSuppliers";
  589. this->dgSuppliers->ReadOnly = true;
  590. this->dgSuppliers->Size = System::Drawing::Size(490, 232);
  591. this->dgSuppliers->TabIndex = 16;
  592. this->dgSuppliers->CellClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm::dgSuppliers_CellClick);
  593. //
  594. // txtSSearch
  595. //
  596. this->txtSSearch->Location = System::Drawing::Point(63, 15);
  597. this->txtSSearch->Name = L"txtSSearch";
  598. this->txtSSearch->Size = System::Drawing::Size(221, 20);
  599. this->txtSSearch->TabIndex = 15;
  600. //
  601. // label10
  602. //
  603. this->label10->AutoSize = true;
  604. this->label10->Location = System::Drawing::Point(22, 17);
  605. this->label10->Name = L"label10";
  606. this->label10->Size = System::Drawing::Size(35, 13);
  607. this->label10->TabIndex = 14;
  608. this->label10->Text = L"Firma:";
  609. //
  610. // employees
  611. //
  612. this->employees->Controls->Add(this->groupBox3);
  613. this->employees->Controls->Add(this->btnEDelete);
  614. this->employees->Controls->Add(this->btnEEdit);
  615. this->employees->Controls->Add(this->btnEAdd);
  616. this->employees->Controls->Add(this->btnESearch);
  617. this->employees->Controls->Add(this->dgEmployees);
  618. this->employees->Controls->Add(this->txtESearch);
  619. this->employees->Controls->Add(this->label19);
  620. this->employees->Location = System::Drawing::Point(4, 22);
  621. this->employees->Name = L"employees";
  622. this->employees->Padding = System::Windows::Forms::Padding(3);
  623. this->employees->Size = System::Drawing::Size(535, 445);
  624. this->employees->TabIndex = 3;
  625. this->employees->Text = L"Zatrudnieni";
  626. this->employees->UseVisualStyleBackColor = true;
  627. //
  628. // groupBox3
  629. //
  630. this->groupBox3->Controls->Add(this->label4);
  631. this->groupBox3->Controls->Add(this->label14);
  632. this->groupBox3->Controls->Add(this->label15);
  633. this->groupBox3->Controls->Add(this->txtENotes);
  634. this->groupBox3->Controls->Add(this->txtEPosition);
  635. this->groupBox3->Controls->Add(this->txtESallary);
  636. this->groupBox3->Controls->Add(this->label16);
  637. this->groupBox3->Controls->Add(this->label17);
  638. this->groupBox3->Controls->Add(this->label18);
  639. this->groupBox3->Controls->Add(this->txtEPesel);
  640. this->groupBox3->Controls->Add(this->txtESurname);
  641. this->groupBox3->Controls->Add(this->txtEName);
  642. this->groupBox3->Location = System::Drawing::Point(25, 41);
  643. this->groupBox3->Name = L"groupBox3";
  644. this->groupBox3->Size = System::Drawing::Size(399, 157);
  645. this->groupBox3->TabIndex = 30;
  646. this->groupBox3->TabStop = false;
  647. this->groupBox3->Text = L"Edycja";
  648. //
  649. // label4
  650. //
  651. this->label4->AutoSize = true;
  652. this->label4->Location = System::Drawing::Point(208, 107);
  653. this->label4->Name = L"label4";
  654. this->label4->Size = System::Drawing::Size(37, 13);
  655. this->label4->TabIndex = 18;
  656. this->label4->Text = L"Uwagi";
  657. //
  658. // label14
  659. //
  660. this->label14->AutoSize = true;
  661. this->label14->Location = System::Drawing::Point(208, 68);
  662. this->label14->Name = L"label14";
  663. this->label14->Size = System::Drawing::Size(62, 13);
  664. this->label14->TabIndex = 17;
  665. this->label14->Text = L"Stanowisko";
  666. //
  667. // label15
  668. //
  669. this->label15->AutoSize = true;
  670. this->label15->Location = System::Drawing::Point(208, 26);
  671. this->label15->Name = L"label15";
  672. this->label15->Size = System::Drawing::Size(39, 13);
  673. this->label15->TabIndex = 16;
  674. this->label15->Text = L"Pensja";
  675. //
  676. // txtENotes
  677. //
  678. this->txtENotes->Location = System::Drawing::Point(208, 123);
  679. this->txtENotes->Name = L"txtENotes";
  680. this->txtENotes->Size = System::Drawing::Size(185, 20);
  681. this->txtENotes->TabIndex = 15;
  682. //
  683. // txtEPosition
  684. //
  685. this->txtEPosition->Location = System::Drawing::Point(208, 84);
  686. this->txtEPosition->Name = L"txtEPosition";
  687. this->txtEPosition->Size = System::Drawing::Size(185, 20);
  688. this->txtEPosition->TabIndex = 14;
  689. //
  690. // txtESallary
  691. //
  692. this->txtESallary->Location = System::Drawing::Point(208, 45);
  693. this->txtESallary->Name = L"txtESallary";
  694. this->txtESallary->Size = System::Drawing::Size(185, 20);
  695. this->txtESallary->TabIndex = 13;
  696. //
  697. // label16
  698. //
  699. this->label16->AutoSize = true;
  700. this->label16->Location = System::Drawing::Point(6, 107);
  701. this->label16->Name = L"label16";
  702. this->label16->Size = System::Drawing::Size(33, 13);
  703. this->label16->TabIndex = 12;
  704. this->label16->Text = L"Pesel";
  705. //
  706. // label17
  707. //
  708. this->label17->AutoSize = true;
  709. this->label17->Location = System::Drawing::Point(6, 68);
  710. this->label17->Name = L"label17";
  711. this->label17->Size = System::Drawing::Size(53, 13);
  712. this->label17->TabIndex = 11;
  713. this->label17->Text = L"Nazwisko";
  714. //
  715. // label18
  716. //
  717. this->label18->AutoSize = true;
  718. this->label18->Location = System::Drawing::Point(6, 26);
  719. this->label18->Name = L"label18";
  720. this->label18->Size = System::Drawing::Size(26, 13);
  721. this->label18->TabIndex = 10;
  722. this->label18->Text = L"Imię";
  723. //
  724. // txtEPesel
  725. //
  726. this->txtEPesel->Location = System::Drawing::Point(6, 123);
  727. this->txtEPesel->Name = L"txtEPesel";
  728. this->txtEPesel->Size = System::Drawing::Size(176, 20);
  729. this->txtEPesel->TabIndex = 9;
  730. //
  731. // txtESurname
  732. //
  733. this->txtESurname->Location = System::Drawing::Point(6, 84);
  734. this->txtESurname->Name = L"txtESurname";
  735. this->txtESurname->Size = System::Drawing::Size(176, 20);
  736. this->txtESurname->TabIndex = 8;
  737. //
  738. // txtEName
  739. //
  740. this->txtEName->Location = System::Drawing::Point(6, 45);
  741. this->txtEName->Name = L"txtEName";
  742. this->txtEName->Size = System::Drawing::Size(176, 20);
  743. this->txtEName->TabIndex = 7;
  744. //
  745. // btnEDelete
  746. //
  747. this->btnEDelete->Location = System::Drawing::Point(440, 164);
  748. this->btnEDelete->Name = L"btnEDelete";
  749. this->btnEDelete->Size = System::Drawing::Size(75, 23);
  750. this->btnEDelete->TabIndex = 29;
  751. this->btnEDelete->Text = L"Usuń";
  752. this->btnEDelete->UseVisualStyleBackColor = true;
  753. this->btnEDelete->Click += gcnew System::EventHandler(this, &MyForm::btnEDelete_Click);
  754. //
  755. // btnEEdit
  756. //
  757. this->btnEEdit->Location = System::Drawing::Point(440, 125);
  758. this->btnEEdit->Name = L"btnEEdit";
  759. this->btnEEdit->Size = System::Drawing::Size(75, 23);
  760. this->btnEEdit->TabIndex = 28;
  761. this->btnEEdit->Text = L"Edytuj";
  762. this->btnEEdit->UseVisualStyleBackColor = true;
  763. this->btnEEdit->Click += gcnew System::EventHandler(this, &MyForm::btnEEdit_Click);
  764. //
  765. // btnEAdd
  766. //
  767. this->btnEAdd->Location = System::Drawing::Point(440, 86);
  768. this->btnEAdd->Name = L"btnEAdd";
  769. this->btnEAdd->Size = System::Drawing::Size(75, 23);
  770. this->btnEAdd->TabIndex = 27;
  771. this->btnEAdd->Text = L"Dodaj";
  772. this->btnEAdd->UseVisualStyleBackColor = true;
  773. this->btnEAdd->Click += gcnew System::EventHandler(this, &MyForm::btnEAdd_Click);
  774. //
  775. // btnESearch
  776. //
  777. this->btnESearch->Location = System::Drawing::Point(314, 12);
  778. this->btnESearch->Name = L"btnESearch";
  779. this->btnESearch->Size = System::Drawing::Size(104, 23);
  780. this->btnESearch->TabIndex = 26;
  781. this->btnESearch->Text = L"Szukaj";
  782. this->btnESearch->UseVisualStyleBackColor = true;
  783. this->btnESearch->Click += gcnew System::EventHandler(this, &MyForm::btnESearch_Click);
  784. //
  785. // dgEmployees
  786. //
  787. this->dgEmployees->AllowUserToAddRows = false;
  788. this->dgEmployees->AllowUserToDeleteRows = false;
  789. this->dgEmployees->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::AllCells;
  790. this->dgEmployees->AutoSizeRowsMode = System::Windows::Forms::DataGridViewAutoSizeRowsMode::AllCells;
  791. this->dgEmployees->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  792. this->dgEmployees->Location = System::Drawing::Point(25, 204);
  793. this->dgEmployees->Name = L"dgEmployees";
  794. this->dgEmployees->ReadOnly = true;
  795. this->dgEmployees->Size = System::Drawing::Size(490, 232);
  796. this->dgEmployees->TabIndex = 25;
  797. this->dgEmployees->CellClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm::dgEmployees_CellClick);
  798. //
  799. // txtESearch
  800. //
  801. this->txtESearch->Location = System::Drawing::Point(88, 15);
  802. this->txtESearch->Name = L"txtESearch";
  803. this->txtESearch->Size = System::Drawing::Size(196, 20);
  804. this->txtESearch->TabIndex = 24;
  805. //
  806. // label19
  807. //
  808. this->label19->AutoSize = true;
  809. this->label19->Location = System::Drawing::Point(22, 17);
  810. this->label19->Name = L"label19";
  811. this->label19->Size = System::Drawing::Size(60, 13);
  812. this->label19->TabIndex = 23;
  813. this->label19->Text = L"Pracownik:";
  814. //
  815. // MyForm
  816. //
  817. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  818. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  819. this->ClientSize = System::Drawing::Size(541, 470);
  820. this->Controls->Add(this->shop);
  821. this->Name = L"MyForm";
  822. this->Text = L"MAXIMUS 1.0";
  823. this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &MyForm::MyForm_FormClosed);
  824. this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
  825. this->shop->ResumeLayout(false);
  826. this->products->ResumeLayout(false);
  827. this->products->PerformLayout();
  828. this->groupBox1->ResumeLayout(false);
  829. this->groupBox1->PerformLayout();
  830. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgProducts))->EndInit();
  831. this->suppliers->ResumeLayout(false);
  832. this->suppliers->PerformLayout();
  833. this->groupBox2->ResumeLayout(false);
  834. this->groupBox2->PerformLayout();
  835. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgSuppliers))->EndInit();
  836. this->employees->ResumeLayout(false);
  837. this->employees->PerformLayout();
  838. this->groupBox3->ResumeLayout(false);
  839. this->groupBox3->PerformLayout();
  840. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgEmployees))->EndInit();
  841. this->ResumeLayout(false);
  842.  
  843. }
  844. #pragma endregion
  845. int record_id;
  846. String^ konfiguracja = L"datasource=warna.vot.pl;port=3306;username=warna_maximus;password=maximus12345;database=warna_maximus";
  847. MySqlConnection^ laczBaze = gcnew MySqlConnection(konfiguracja);
  848.  
  849. private: System::Void btnPSearch_Click(System::Object^ sender, System::EventArgs^ e) {
  850. MySqlCommand^ zapytanie = gcnew MySqlCommand("SELECT id, name AS Nazwa, price AS Cena, quantity AS Ilosc FROM products WHERE name LIKE '%" + txtSearch->Text + "%' && category_id = '" + cmbBoxCategory->SelectedValue + "';", laczBaze);
  851. try {
  852. MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
  853. moja->SelectCommand = zapytanie;
  854. DataTable^ tabela = gcnew DataTable();
  855. moja->Fill(tabela);
  856. dgProducts->DataSource = tabela;
  857. }
  858. catch (Exception^ komunikat) {
  859. MessageBox::Show(komunikat->Message);
  860. }
  861. dgProducts->Columns[0]->Visible = false;
  862. }
  863. private: System::Void cmbBoxCategory_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
  864.  
  865. MySqlCommand^ zapytanie = gcnew MySqlCommand("SELECT id, name AS Nazwa, price AS Cena, quantity AS Ilosc FROM products WHERE category_id = '" + cmbBoxCategory->SelectedValue + "';", laczBaze);
  866.  
  867. try {
  868. MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
  869. moja->SelectCommand = zapytanie;
  870. DataTable^ tabela = gcnew DataTable();
  871. moja->Fill(tabela);
  872. dgProducts->DataSource = tabela;
  873. }
  874. catch (Exception^ komunikat) {
  875. MessageBox::Show(komunikat->Message);
  876. }
  877. dgProducts->Columns[0]->Visible = false;
  878. }
  879. private: System::Void dgProducts_CellClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
  880. if (e->RowIndex >= 0) {
  881. record_id = (int)dgProducts->Rows[e->RowIndex]->Cells["id"]->Value;
  882. txtProduct->Text = dgProducts->Rows[e->RowIndex]->Cells["Nazwa"]->Value->ToString();
  883. txtPrice->Text = dgProducts->Rows[e->RowIndex]->Cells["Cena"]->Value->ToString();
  884. txtQuantity->Text = dgProducts->Rows[e->RowIndex]->Cells["Ilosc"]->Value->ToString();
  885. }
  886. }
  887. private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
  888. laczBaze->Open();
  889. MySqlCommand^ zapytanie = gcnew MySqlCommand("SELECT id, name FROM categories", laczBaze);
  890. try {
  891. MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
  892. moja->SelectCommand = zapytanie;
  893. moja->SelectCommand = zapytanie;
  894. moja->SelectCommand = zapytanie;
  895. DataTable^ tabela = gcnew DataTable();
  896. moja->Fill(tabela);
  897. cmbBoxCategory->DataSource = tabela;
  898. cmbBoxCategory->DisplayMember = "name";
  899. cmbBoxCategory->ValueMember = "id";
  900. cmbBoxCategory_SelectedIndexChanged(sender, e);
  901. }
  902. catch (Exception^ komunikat) {
  903. MessageBox::Show(komunikat->Message);
  904. }
  905. Loaddata_suppliers();
  906. Loaddata_employees();
  907. }
  908. private: System::Void MyForm_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e) {
  909. laczBaze->Close();
  910. }
  911. private: System::Void btnPAdd_Click(System::Object^ sender, System::EventArgs^ e) {
  912. if (txtProduct->Text->Length < 2 || txtPrice->Text->Length < 1 || txtQuantity->Text->Length <= 1) {
  913. MessageBox::Show("Uzupełnij dane!");
  914. }
  915. else {
  916. MessageBox::Show("Dodano produkt.");
  917. MySqlCommand^ polecenie = laczBaze->CreateCommand();
  918. polecenie->Connection = laczBaze;
  919. try {
  920. polecenie->CommandText = "INSERT INTO products SET name ='" + txtProduct->Text + "', price ='" + txtPrice->Text + "', quantity = '" + txtQuantity->Text + "', category_id = '" + cmbBoxCategory->SelectedValue + "'; ";
  921.  
  922. polecenie->ExecuteNonQuery();
  923. }
  924. catch (Exception^ komunikat) {
  925. MessageBox::Show(komunikat->Message);
  926. }
  927. cmbBoxCategory_SelectedIndexChanged(sender, e);
  928. }
  929. }
  930. private: System::Void txtPrice_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  931. if (e->KeyChar == '.') {
  932. if (this->txtPrice->Text->Contains(".") && !this->txtPrice->SelectedText->Contains("."))
  933. e->Handled = true;
  934. }
  935. else if (!Char::IsDigit(e->KeyChar) && e->KeyChar != 8) {
  936. e->Handled = true;
  937. }
  938. }
  939. private: System::Void txtQuantity_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  940. if (!Char::IsDigit(e->KeyChar) && e->KeyChar != 8) {
  941. e->Handled = true;
  942. }
  943. }
  944.  
  945. private: System::Void btnPEdit_Click(System::Object^ sender, System::EventArgs^ e) {
  946. if (txtProduct->Text->Length < 2 || txtPrice->Text->Length < 1 || txtQuantity->Text->Length <= 1) {
  947. MessageBox::Show("Uzupełnij dane!");
  948. }
  949. else {
  950. MessageBox::Show("Zmodyfikowano wpis.");
  951. MySqlCommand^ polecenie = laczBaze->CreateCommand();
  952. polecenie->Connection = laczBaze;
  953. try {
  954. polecenie->CommandText = "UPDATE products SET name ='" + txtProduct->Text + "', price ='" + txtPrice->Text + "', quantity = '" + txtQuantity->Text + "', category_id = '" + cmbBoxCategory->SelectedValue + "' WHERE id ='" + record_id + "'; ";
  955. polecenie->ExecuteNonQuery();
  956. }
  957. catch (Exception^ komunikat) {
  958. MessageBox::Show(komunikat->Message);
  959. }
  960. cmbBoxCategory_SelectedIndexChanged(sender, e);
  961. }
  962. }
  963. private: System::Void btnPDelete_Click(System::Object^ sender, System::EventArgs^ e) {
  964. MySqlCommand^ polecenie = laczBaze->CreateCommand();
  965. polecenie->Connection = laczBaze;
  966. try {
  967. if (MessageBox::Show("Czy usunąć wybrany Produkt?", "Uwaga!!!", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes) {
  968. polecenie->CommandText = "DELETE FROM products WHERE id = " + record_id + "; ";
  969. polecenie->ExecuteNonQuery();
  970. MessageBox::Show("Produkt został usunięty");
  971. }
  972. }
  973. catch (Exception^ komunikat) {
  974. MessageBox::Show(komunikat->Message);
  975. }
  976. txtProduct->Text = "";
  977. txtPrice->Text = "";
  978. txtQuantity->Text = "";
  979. cmbBoxCategory_SelectedIndexChanged(sender, e);
  980. }
  981. private: System::Void txtSearch_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
  982. if (e->KeyChar == 13) {
  983. btnPSearch_Click(sender, e);
  984. }
  985. }
  986. private: System::Void btnSSearch_Click(System::Object^ sender, System::EventArgs^ e) {
  987. MySqlCommand^ zapytanie = gcnew MySqlCommand("SELECT id, name AS Nazwa, phone AS 'Numer telefonu', adress AS Adres, mail AS 'Adres e-mail', www AS 'Strona internetowa', notes AS Uwagi FROM suppliers WHERE name LIKE '%" + txtSSearch->Text + "%';", laczBaze);
  988. try {
  989. MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
  990. moja->SelectCommand = zapytanie;
  991. DataTable^ tabela = gcnew DataTable();
  992. moja->Fill(tabela);
  993. dgSuppliers->DataSource = tabela;
  994. }
  995. catch (Exception^ komunikat) {
  996. MessageBox::Show(komunikat->Message);
  997. }
  998. dgSuppliers->Columns[0]->Visible = false;
  999. }
  1000. private: System::Void dgSuppliers_CellClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
  1001. if (e->RowIndex >= 0) {
  1002. record_id = (int)dgSuppliers->Rows[e->RowIndex]->Cells["id"]->Value;
  1003. txtSName->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Nazwa"]->Value->ToString();
  1004. txtSAdress->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Adres"]->Value->ToString();
  1005. txtSMail->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Adres e-mail"]->Value->ToString();
  1006. txtSNotes->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Uwagi"]->Value->ToString();
  1007. txtSPhone->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Numer telefonu"]->Value->ToString();
  1008. txtSWww->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Strona internetowa"]->Value->ToString();
  1009. }
  1010. }
  1011. private: System::Void btnSAdd_Click(System::Object^ sender, System::EventArgs^ e) {
  1012. if (txtSAdress->Text->Length < 4 || txtSMail->Text->Length < 4 || txtSName->Text->Length <= 1 || txtSPhone->Text->Length <= 4 ||txtSWww->Text->Length <= 4) {
  1013. MessageBox::Show("Uzupełnij dane!");
  1014. }
  1015. else {
  1016. MessageBox::Show("Dodano produkt.");
  1017. MySqlCommand^ polecenie = laczBaze->CreateCommand();
  1018. polecenie->Connection = laczBaze;
  1019. try {
  1020. polecenie->CommandText = "INSERT INTO suppliers SET name ='" + txtSName->Text + "', mail ='" + txtSMail->Text + "', adress = '" + txtSAdress->Text + "', phone = '" + txtSPhone->Text + "', www = '" + txtSWww->Text + "', notes = '" + txtSNotes->Text + "'; ";
  1021.  
  1022. polecenie->ExecuteNonQuery();
  1023. }
  1024. catch (Exception^ komunikat) {
  1025. MessageBox::Show(komunikat->Message);
  1026. }
  1027. Loaddata_suppliers();
  1028. }
  1029. }
  1030. private: System::Void Loaddata_suppliers(){
  1031. MySqlCommand^ zapytanie = gcnew MySqlCommand("SELECT id, name AS Nazwa, phone AS 'Numer telefonu', adress AS Adres, mail AS 'Adres e-mail', www AS 'Strona internetowa', notes AS Uwagi FROM suppliers;", laczBaze);
  1032. try {
  1033. MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
  1034. moja->SelectCommand = zapytanie;
  1035. DataTable^ tabela = gcnew DataTable();
  1036. moja->Fill(tabela);
  1037. dgSuppliers->DataSource = tabela;
  1038. }
  1039. catch (Exception^ komunikat) {
  1040. MessageBox::Show(komunikat->Message);
  1041. }
  1042. dgSuppliers->Columns[0]->Visible = false;
  1043. }
  1044. private: System::Void btnSEdit_Click(System::Object^ sender, System::EventArgs^ e) {
  1045. if (txtSAdress->Text->Length < 4 || txtSMail->Text->Length < 4 || txtSName->Text->Length <= 1 || txtSPhone->Text->Length <= 4 || txtSWww->Text->Length <= 4) {
  1046. MessageBox::Show("Uzupełnij dane!");
  1047. }
  1048. else {
  1049. MessageBox::Show("Zmodyfikowano wpis.");
  1050. MySqlCommand^ polecenie = laczBaze->CreateCommand();
  1051. polecenie->Connection = laczBaze;
  1052. try {
  1053. polecenie->CommandText = "UPDATE suppliers SET name ='" + txtSName->Text + "', mail ='" + txtSMail->Text + "', adress = '" + txtSAdress->Text + "', phone = '" + txtSPhone->Text + "', www = '" + txtSWww->Text + "', notes = '" + txtSNotes->Text + "' WHERE id ='" + record_id + "'; ";
  1054. polecenie->ExecuteNonQuery();
  1055. }
  1056. catch (Exception^ komunikat) {
  1057. MessageBox::Show(komunikat->Message);
  1058. }
  1059. cmbBoxCategory_SelectedIndexChanged(sender, e);
  1060. }
  1061. Loaddata_suppliers();
  1062. }
  1063. private: System::Void btnSDelete_Click(System::Object^ sender, System::EventArgs^ e) {
  1064. MySqlCommand^ polecenie = laczBaze->CreateCommand();
  1065. polecenie->Connection = laczBaze;
  1066. try {
  1067. if (MessageBox::Show("Czy usunąć wybrany wpis?", "Uwaga!!!", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes) {
  1068. polecenie->CommandText = "DELETE FROM suppliers WHERE id = " + record_id + "; ";
  1069. polecenie->ExecuteNonQuery();
  1070. MessageBox::Show("Produkt został usunięty");
  1071. }
  1072. }
  1073. catch (Exception^ komunikat) {
  1074. MessageBox::Show(komunikat->Message);
  1075. }
  1076. txtSAdress->Text = "";
  1077. txtSMail->Text = "";
  1078. txtSName->Text = "";
  1079. txtSNotes->Text = "";
  1080. txtSPhone->Text = "";
  1081. txtSWww->Text = "";
  1082. Loaddata_suppliers();
  1083. }
  1084. private: System::Void Loaddata_employees() {
  1085. MySqlCommand^ zapytanie = gcnew MySqlCommand("SELECT id, name AS Imie, surname AS Nazwisko, pesel AS Pesel, sallary AS Pensja, position AS Stanowisko, notes AS Uwagi FROM employees;", laczBaze);
  1086. try {
  1087. MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
  1088. moja->SelectCommand = zapytanie;
  1089. DataTable^ tabela = gcnew DataTable();
  1090. moja->Fill(tabela);
  1091. dgEmployees->DataSource = tabela;
  1092. }
  1093. catch (Exception^ komunikat) {
  1094. MessageBox::Show(komunikat->Message);
  1095. }
  1096. dgEmployees->Columns[0]->Visible = false;
  1097. }
  1098. private: System::Void btnESearch_Click(System::Object^ sender, System::EventArgs^ e) {
  1099. MySqlCommand^ zapytanie = gcnew MySqlCommand("SELECT id, name AS Imie, surname AS Nazwisko, pesel AS Pesel, sallary AS Pensja, position AS Stanowisko, notes AS Uwagi FROM employees WHERE name LIKE '%" + txtESearch->Text + "%';", laczBaze);
  1100. try {
  1101. MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
  1102. moja->SelectCommand = zapytanie;
  1103. DataTable^ tabela = gcnew DataTable();
  1104. moja->Fill(tabela);
  1105. dgEmployees->DataSource = tabela;
  1106. }
  1107. catch (Exception^ komunikat) {
  1108. MessageBox::Show(komunikat->Message);
  1109. }
  1110. dgEmployees->Columns[0]->Visible = false;
  1111. }
  1112. private: System::Void btnEAdd_Click(System::Object^ sender, System::EventArgs^ e) {
  1113. if (txtEName->Text->Length < 2 || txtEPesel->Text->Length < 2 || txtEPosition->Text->Length < 1 || txtESallary->Text->Length < 2 || txtESurname->Text->Length < 3) {
  1114. MessageBox::Show("Uzupełnij dane!");
  1115. }
  1116. else {
  1117. MessageBox::Show("Dodano produkt.");
  1118. MySqlCommand^ polecenie = laczBaze->CreateCommand();
  1119. polecenie->Connection = laczBaze;
  1120. try {
  1121. polecenie->CommandText = "INSERT INTO employees SET name ='" + txtEName->Text + "', surname ='" + txtESurname->Text + "', pesel = '" + txtEPesel->Text + "', sallary = '" + txtESallary->Text + "', position = '" + txtEPosition->Text + "', notes = '" + txtENotes->Text + "'; ";
  1122. polecenie->ExecuteNonQuery();
  1123. }
  1124. catch (Exception^ komunikat) {
  1125. MessageBox::Show(komunikat->Message);
  1126. }
  1127. Loaddata_employees();
  1128. }
  1129. }
  1130. private: System::Void btnEEdit_Click(System::Object^ sender, System::EventArgs^ e) {
  1131. if (txtEName->Text->Length < 2 || txtEPesel->Text->Length < 2 || txtEPosition->Text->Length < 1 || txtESallary->Text->Length < 2 || txtESurname->Text->Length < 3) {
  1132. MessageBox::Show("Uzupełnij dane!");
  1133. }
  1134. else {
  1135. MessageBox::Show("Zmodyfikowano wpis.");
  1136. MySqlCommand^ polecenie = laczBaze->CreateCommand();
  1137. polecenie->Connection = laczBaze;
  1138. try {
  1139. polecenie->CommandText = "UPDATE employees SET name ='" + txtEName->Text + "', surname ='" + txtESurname->Text + "', pesel = '" + txtEPesel->Text + "', sallary = '" + txtESallary->Text + "', position = '" + txtEPosition->Text + "', notes = '" + txtENotes->Text + "' WHERE id ='" + record_id + "'; ";
  1140. polecenie->ExecuteNonQuery();
  1141. }
  1142. catch (Exception^ komunikat) {
  1143. MessageBox::Show(komunikat->Message);
  1144. }
  1145. Loaddata_employees();
  1146. }
  1147. }
  1148. private: System::Void dgEmployees_CellClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
  1149. if (e->RowIndex >= 0) {
  1150. record_id = (int)dgEmployees->Rows[e->RowIndex]->Cells["id"]->Value;
  1151. txtEName->Text = dgEmployees->Rows[e->RowIndex]->Cells["Imie"]->Value->ToString();
  1152. txtENotes->Text = dgEmployees->Rows[e->RowIndex]->Cells["Uwagi"]->Value->ToString();
  1153. txtEPesel->Text = dgEmployees->Rows[e->RowIndex]->Cells["Pesel"]->Value->ToString();
  1154. txtEPosition->Text = dgEmployees->Rows[e->RowIndex]->Cells["Stanowisko"]->Value->ToString();
  1155. txtESallary->Text = dgEmployees->Rows[e->RowIndex]->Cells["Pensja"]->Value->ToString();
  1156. txtESurname->Text = dgEmployees->Rows[e->RowIndex]->Cells["Nazwisko"]->Value->ToString();
  1157. }
  1158. }
  1159. private: System::Void btnEDelete_Click(System::Object^ sender, System::EventArgs^ e) {
  1160. MySqlCommand^ polecenie = laczBaze->CreateCommand();
  1161. polecenie->Connection = laczBaze;
  1162. try {
  1163. if (MessageBox::Show("Czy usunąć wybrany wpis?", "Uwaga!!!", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes) {
  1164. polecenie->CommandText = "DELETE FROM employees WHERE id = " + record_id + "; ";
  1165. polecenie->ExecuteNonQuery();
  1166. MessageBox::Show("Produkt został usunięty");
  1167. }
  1168. }
  1169. catch (Exception^ komunikat) {
  1170. MessageBox::Show(komunikat->Message);
  1171. }
  1172. txtEName->Text = "";
  1173. txtENotes->Text = "";
  1174. txtEPesel->Text = "";
  1175. txtEPosition->Text = "";
  1176. txtESallary->Text = "";
  1177. txtESurname->Text = "";
  1178. Loaddata_employees();
  1179. }
  1180. };
  1181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement