Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- namespace Project2 {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- using namespace MySql::Data::MySqlClient;
- /// <summary>
- /// Summary for MyForm
- /// </summary>
- public ref class MyForm : public System::Windows::Forms::Form
- {
- public:
- MyForm(void)
- {
- InitializeComponent();
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~MyForm()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::TabControl^ shop;
- protected:
- private: System::Windows::Forms::TabPage^ products;
- private: System::Windows::Forms::ComboBox^ cmbBoxCategory;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::TextBox^ txtSearch;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::TabPage^ suppliers;
- private: System::Windows::Forms::TabPage^ employees;
- private: System::Windows::Forms::DataGridView^ dgProducts;
- private: System::Windows::Forms::Button^ btnPSearch;
- private: System::Windows::Forms::GroupBox^ groupBox1;
- private: System::Windows::Forms::TextBox^ txtQuantity;
- private: System::Windows::Forms::TextBox^ txtPrice;
- private: System::Windows::Forms::TextBox^ txtProduct;
- private: System::Windows::Forms::Button^ btnPDelete;
- private: System::Windows::Forms::Button^ btnPEdit;
- private: System::Windows::Forms::Button^ btnPAdd;
- private: System::Windows::Forms::Label^ label7;
- private: System::Windows::Forms::Label^ label6;
- private: System::Windows::Forms::Label^ label5;
- private: System::Windows::Forms::Button^ btnSDelete;
- private: System::Windows::Forms::Button^ btnSEdit;
- private: System::Windows::Forms::Button^ btnSAdd;
- private: System::Windows::Forms::Button^ btnSSearch;
- private: System::Windows::Forms::DataGridView^ dgSuppliers;
- private: System::Windows::Forms::TextBox^ txtSSearch;
- private: System::Windows::Forms::Label^ label10;
- private: System::Windows::Forms::GroupBox^ groupBox2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::Label^ label8;
- private: System::Windows::Forms::Label^ label9;
- private: System::Windows::Forms::TextBox^ txtSWww;
- private: System::Windows::Forms::TextBox^ txtSAdress;
- private: System::Windows::Forms::TextBox^ txtSName;
- private: System::Windows::Forms::Label^ label11;
- private: System::Windows::Forms::Label^ label12;
- private: System::Windows::Forms::Label^ label13;
- private: System::Windows::Forms::TextBox^ txtSNotes;
- private: System::Windows::Forms::TextBox^ txtSMail;
- private: System::Windows::Forms::TextBox^ txtSPhone;
- private: System::Windows::Forms::GroupBox^ groupBox3;
- private: System::Windows::Forms::Label^ label4;
- private: System::Windows::Forms::Label^ label14;
- private: System::Windows::Forms::Label^ label15;
- private: System::Windows::Forms::TextBox^ txtENotes;
- private: System::Windows::Forms::TextBox^ txtEPosition;
- private: System::Windows::Forms::TextBox^ txtESallary;
- private: System::Windows::Forms::Label^ label16;
- private: System::Windows::Forms::Label^ label17;
- private: System::Windows::Forms::Label^ label18;
- private: System::Windows::Forms::TextBox^ txtEPesel;
- private: System::Windows::Forms::TextBox^ txtESurname;
- private: System::Windows::Forms::TextBox^ txtEName;
- private: System::Windows::Forms::Button^ btnEDelete;
- private: System::Windows::Forms::Button^ btnEEdit;
- private: System::Windows::Forms::Button^ btnEAdd;
- private: System::Windows::Forms::Button^ btnESearch;
- private: System::Windows::Forms::DataGridView^ dgEmployees;
- private: System::Windows::Forms::TextBox^ txtESearch;
- private: System::Windows::Forms::Label^ label19;
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- void InitializeComponent(void)
- {
- this->shop = (gcnew System::Windows::Forms::TabControl());
- this->products = (gcnew System::Windows::Forms::TabPage());
- this->btnPDelete = (gcnew System::Windows::Forms::Button());
- this->btnPEdit = (gcnew System::Windows::Forms::Button());
- this->btnPAdd = (gcnew System::Windows::Forms::Button());
- this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
- this->label7 = (gcnew System::Windows::Forms::Label());
- this->label6 = (gcnew System::Windows::Forms::Label());
- this->label5 = (gcnew System::Windows::Forms::Label());
- this->txtQuantity = (gcnew System::Windows::Forms::TextBox());
- this->txtPrice = (gcnew System::Windows::Forms::TextBox());
- this->txtProduct = (gcnew System::Windows::Forms::TextBox());
- this->btnPSearch = (gcnew System::Windows::Forms::Button());
- this->dgProducts = (gcnew System::Windows::Forms::DataGridView());
- this->cmbBoxCategory = (gcnew System::Windows::Forms::ComboBox());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->txtSearch = (gcnew System::Windows::Forms::TextBox());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->suppliers = (gcnew System::Windows::Forms::TabPage());
- this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
- this->label11 = (gcnew System::Windows::Forms::Label());
- this->label12 = (gcnew System::Windows::Forms::Label());
- this->label13 = (gcnew System::Windows::Forms::Label());
- this->txtSNotes = (gcnew System::Windows::Forms::TextBox());
- this->txtSMail = (gcnew System::Windows::Forms::TextBox());
- this->txtSPhone = (gcnew System::Windows::Forms::TextBox());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->label8 = (gcnew System::Windows::Forms::Label());
- this->label9 = (gcnew System::Windows::Forms::Label());
- this->txtSWww = (gcnew System::Windows::Forms::TextBox());
- this->txtSAdress = (gcnew System::Windows::Forms::TextBox());
- this->txtSName = (gcnew System::Windows::Forms::TextBox());
- this->btnSDelete = (gcnew System::Windows::Forms::Button());
- this->btnSEdit = (gcnew System::Windows::Forms::Button());
- this->btnSAdd = (gcnew System::Windows::Forms::Button());
- this->btnSSearch = (gcnew System::Windows::Forms::Button());
- this->dgSuppliers = (gcnew System::Windows::Forms::DataGridView());
- this->txtSSearch = (gcnew System::Windows::Forms::TextBox());
- this->label10 = (gcnew System::Windows::Forms::Label());
- this->employees = (gcnew System::Windows::Forms::TabPage());
- this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->label14 = (gcnew System::Windows::Forms::Label());
- this->label15 = (gcnew System::Windows::Forms::Label());
- this->txtENotes = (gcnew System::Windows::Forms::TextBox());
- this->txtEPosition = (gcnew System::Windows::Forms::TextBox());
- this->txtESallary = (gcnew System::Windows::Forms::TextBox());
- this->label16 = (gcnew System::Windows::Forms::Label());
- this->label17 = (gcnew System::Windows::Forms::Label());
- this->label18 = (gcnew System::Windows::Forms::Label());
- this->txtEPesel = (gcnew System::Windows::Forms::TextBox());
- this->txtESurname = (gcnew System::Windows::Forms::TextBox());
- this->txtEName = (gcnew System::Windows::Forms::TextBox());
- this->btnEDelete = (gcnew System::Windows::Forms::Button());
- this->btnEEdit = (gcnew System::Windows::Forms::Button());
- this->btnEAdd = (gcnew System::Windows::Forms::Button());
- this->btnESearch = (gcnew System::Windows::Forms::Button());
- this->dgEmployees = (gcnew System::Windows::Forms::DataGridView());
- this->txtESearch = (gcnew System::Windows::Forms::TextBox());
- this->label19 = (gcnew System::Windows::Forms::Label());
- this->shop->SuspendLayout();
- this->products->SuspendLayout();
- this->groupBox1->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgProducts))->BeginInit();
- this->suppliers->SuspendLayout();
- this->groupBox2->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgSuppliers))->BeginInit();
- this->employees->SuspendLayout();
- this->groupBox3->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgEmployees))->BeginInit();
- this->SuspendLayout();
- //
- // shop
- //
- this->shop->Controls->Add(this->products);
- this->shop->Controls->Add(this->suppliers);
- this->shop->Controls->Add(this->employees);
- this->shop->Location = System::Drawing::Point(0, 0);
- this->shop->Name = L"shop";
- this->shop->SelectedIndex = 0;
- this->shop->Size = System::Drawing::Size(543, 471);
- this->shop->TabIndex = 0;
- //
- // products
- //
- this->products->Controls->Add(this->btnPDelete);
- this->products->Controls->Add(this->btnPEdit);
- this->products->Controls->Add(this->btnPAdd);
- this->products->Controls->Add(this->groupBox1);
- this->products->Controls->Add(this->btnPSearch);
- this->products->Controls->Add(this->dgProducts);
- this->products->Controls->Add(this->cmbBoxCategory);
- this->products->Controls->Add(this->label2);
- this->products->Controls->Add(this->txtSearch);
- this->products->Controls->Add(this->label1);
- this->products->Location = System::Drawing::Point(4, 22);
- this->products->Name = L"products";
- this->products->Padding = System::Windows::Forms::Padding(3);
- this->products->Size = System::Drawing::Size(535, 445);
- this->products->TabIndex = 1;
- this->products->Text = L"Stan magazynowy";
- this->products->UseVisualStyleBackColor = true;
- //
- // btnPDelete
- //
- this->btnPDelete->Location = System::Drawing::Point(57, 385);
- this->btnPDelete->Name = L"btnPDelete";
- this->btnPDelete->Size = System::Drawing::Size(75, 23);
- this->btnPDelete->TabIndex = 13;
- this->btnPDelete->Text = L"Usuń";
- this->btnPDelete->UseVisualStyleBackColor = true;
- this->btnPDelete->Click += gcnew System::EventHandler(this, &MyForm::btnPDelete_Click);
- //
- // btnPEdit
- //
- this->btnPEdit->Location = System::Drawing::Point(57, 345);
- this->btnPEdit->Name = L"btnPEdit";
- this->btnPEdit->Size = System::Drawing::Size(75, 23);
- this->btnPEdit->TabIndex = 12;
- this->btnPEdit->Text = L"Edytuj";
- this->btnPEdit->UseVisualStyleBackColor = true;
- this->btnPEdit->Click += gcnew System::EventHandler(this, &MyForm::btnPEdit_Click);
- //
- // btnPAdd
- //
- this->btnPAdd->Location = System::Drawing::Point(57, 304);
- this->btnPAdd->Name = L"btnPAdd";
- this->btnPAdd->Size = System::Drawing::Size(75, 23);
- this->btnPAdd->TabIndex = 11;
- this->btnPAdd->Text = L"Dodaj";
- this->btnPAdd->UseVisualStyleBackColor = true;
- this->btnPAdd->Click += gcnew System::EventHandler(this, &MyForm::btnPAdd_Click);
- //
- // groupBox1
- //
- this->groupBox1->Controls->Add(this->label7);
- this->groupBox1->Controls->Add(this->label6);
- this->groupBox1->Controls->Add(this->label5);
- this->groupBox1->Controls->Add(this->txtQuantity);
- this->groupBox1->Controls->Add(this->txtPrice);
- this->groupBox1->Controls->Add(this->txtProduct);
- this->groupBox1->Location = System::Drawing::Point(18, 104);
- this->groupBox1->Name = L"groupBox1";
- this->groupBox1->Size = System::Drawing::Size(159, 176);
- this->groupBox1->TabIndex = 10;
- this->groupBox1->TabStop = false;
- this->groupBox1->Text = L"Edycja";
- //
- // label7
- //
- this->label7->AutoSize = true;
- this->label7->Location = System::Drawing::Point(26, 110);
- this->label7->Name = L"label7";
- this->label7->Size = System::Drawing::Size(29, 13);
- this->label7->TabIndex = 12;
- this->label7->Text = L"Ilość";
- //
- // label6
- //
- this->label6->AutoSize = true;
- this->label6->Location = System::Drawing::Point(26, 71);
- this->label6->Name = L"label6";
- this->label6->Size = System::Drawing::Size(32, 13);
- this->label6->TabIndex = 11;
- this->label6->Text = L"Cena";
- //
- // label5
- //
- this->label5->AutoSize = true;
- this->label5->Location = System::Drawing::Point(26, 29);
- this->label5->Name = L"label5";
- this->label5->Size = System::Drawing::Size(44, 13);
- this->label5->TabIndex = 10;
- this->label5->Text = L"Produkt";
- //
- // txtQuantity
- //
- this->txtQuantity->Location = System::Drawing::Point(26, 126);
- this->txtQuantity->Name = L"txtQuantity";
- this->txtQuantity->Size = System::Drawing::Size(100, 20);
- this->txtQuantity->TabIndex = 9;
- //
- // txtPrice
- //
- this->txtPrice->Location = System::Drawing::Point(26, 87);
- this->txtPrice->Name = L"txtPrice";
- this->txtPrice->Size = System::Drawing::Size(100, 20);
- this->txtPrice->TabIndex = 8;
- this->txtPrice->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::txtPrice_KeyPress);
- //
- // txtProduct
- //
- this->txtProduct->Location = System::Drawing::Point(26, 48);
- this->txtProduct->Name = L"txtProduct";
- this->txtProduct->Size = System::Drawing::Size(100, 20);
- this->txtProduct->TabIndex = 7;
- //
- // btnPSearch
- //
- this->btnPSearch->Location = System::Drawing::Point(340, 55);
- this->btnPSearch->Name = L"btnPSearch";
- this->btnPSearch->Size = System::Drawing::Size(104, 23);
- this->btnPSearch->TabIndex = 6;
- this->btnPSearch->Text = L"Szukaj";
- this->btnPSearch->UseVisualStyleBackColor = true;
- this->btnPSearch->Click += gcnew System::EventHandler(this, &MyForm::btnPSearch_Click);
- //
- // dgProducts
- //
- this->dgProducts->AllowUserToAddRows = false;
- this->dgProducts->AllowUserToDeleteRows = false;
- this->dgProducts->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::AllCells;
- this->dgProducts->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
- this->dgProducts->Location = System::Drawing::Point(211, 109);
- this->dgProducts->Name = L"dgProducts";
- this->dgProducts->ReadOnly = true;
- this->dgProducts->Size = System::Drawing::Size(300, 314);
- this->dgProducts->TabIndex = 5;
- this->dgProducts->CellClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm::dgProducts_CellClick);
- //
- // cmbBoxCategory
- //
- this->cmbBoxCategory->FormattingEnabled = true;
- this->cmbBoxCategory->Location = System::Drawing::Point(113, 15);
- this->cmbBoxCategory->Name = L"cmbBoxCategory";
- this->cmbBoxCategory->Size = System::Drawing::Size(367, 21);
- this->cmbBoxCategory->TabIndex = 4;
- this->cmbBoxCategory->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::cmbBoxCategory_SelectedIndexChanged);
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(18, 18);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(55, 13);
- this->label2->TabIndex = 3;
- this->label2->Text = L"Kategoria:";
- //
- // txtSearch
- //
- this->txtSearch->Location = System::Drawing::Point(113, 57);
- this->txtSearch->Name = L"txtSearch";
- this->txtSearch->Size = System::Drawing::Size(221, 20);
- this->txtSearch->TabIndex = 2;
- this->txtSearch->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::txtSearch_KeyPress);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(18, 60);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(47, 13);
- this->label1->TabIndex = 1;
- this->label1->Text = L"Produkt:";
- //
- // suppliers
- //
- this->suppliers->Controls->Add(this->groupBox2);
- this->suppliers->Controls->Add(this->btnSDelete);
- this->suppliers->Controls->Add(this->btnSEdit);
- this->suppliers->Controls->Add(this->btnSAdd);
- this->suppliers->Controls->Add(this->btnSSearch);
- this->suppliers->Controls->Add(this->dgSuppliers);
- this->suppliers->Controls->Add(this->txtSSearch);
- this->suppliers->Controls->Add(this->label10);
- this->suppliers->Location = System::Drawing::Point(4, 22);
- this->suppliers->Name = L"suppliers";
- this->suppliers->Padding = System::Windows::Forms::Padding(3);
- this->suppliers->Size = System::Drawing::Size(535, 445);
- this->suppliers->TabIndex = 2;
- this->suppliers->Text = L"Dostawcy";
- this->suppliers->UseVisualStyleBackColor = true;
- //
- // groupBox2
- //
- this->groupBox2->Controls->Add(this->label11);
- this->groupBox2->Controls->Add(this->label12);
- this->groupBox2->Controls->Add(this->label13);
- this->groupBox2->Controls->Add(this->txtSNotes);
- this->groupBox2->Controls->Add(this->txtSMail);
- this->groupBox2->Controls->Add(this->txtSPhone);
- this->groupBox2->Controls->Add(this->label3);
- this->groupBox2->Controls->Add(this->label8);
- this->groupBox2->Controls->Add(this->label9);
- this->groupBox2->Controls->Add(this->txtSWww);
- this->groupBox2->Controls->Add(this->txtSAdress);
- this->groupBox2->Controls->Add(this->txtSName);
- this->groupBox2->Location = System::Drawing::Point(25, 41);
- this->groupBox2->Name = L"groupBox2";
- this->groupBox2->Size = System::Drawing::Size(399, 157);
- this->groupBox2->TabIndex = 22;
- this->groupBox2->TabStop = false;
- this->groupBox2->Text = L"Edycja";
- //
- // label11
- //
- this->label11->AutoSize = true;
- this->label11->Location = System::Drawing::Point(208, 107);
- this->label11->Name = L"label11";
- this->label11->Size = System::Drawing::Size(37, 13);
- this->label11->TabIndex = 18;
- this->label11->Text = L"Uwagi";
- //
- // label12
- //
- this->label12->AutoSize = true;
- this->label12->Location = System::Drawing::Point(208, 68);
- this->label12->Name = L"label12";
- this->label12->Size = System::Drawing::Size(64, 13);
- this->label12->TabIndex = 17;
- this->label12->Text = L"Adres e-mail";
- //
- // label13
- //
- this->label13->AutoSize = true;
- this->label13->Location = System::Drawing::Point(208, 26);
- this->label13->Name = L"label13";
- this->label13->Size = System::Drawing::Size(79, 13);
- this->label13->TabIndex = 16;
- this->label13->Text = L"Numer telefonu";
- //
- // txtSNotes
- //
- this->txtSNotes->Location = System::Drawing::Point(208, 123);
- this->txtSNotes->Name = L"txtSNotes";
- this->txtSNotes->Size = System::Drawing::Size(185, 20);
- this->txtSNotes->TabIndex = 15;
- //
- // txtSMail
- //
- this->txtSMail->Location = System::Drawing::Point(208, 84);
- this->txtSMail->Name = L"txtSMail";
- this->txtSMail->Size = System::Drawing::Size(185, 20);
- this->txtSMail->TabIndex = 14;
- //
- // txtSPhone
- //
- this->txtSPhone->Location = System::Drawing::Point(208, 45);
- this->txtSPhone->Name = L"txtSPhone";
- this->txtSPhone->Size = System::Drawing::Size(185, 20);
- this->txtSPhone->TabIndex = 13;
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(6, 107);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(96, 13);
- this->label3->TabIndex = 12;
- this->label3->Text = L"Strona internetowa";
- //
- // label8
- //
- this->label8->AutoSize = true;
- this->label8->Location = System::Drawing::Point(6, 68);
- this->label8->Name = L"label8";
- this->label8->Size = System::Drawing::Size(34, 13);
- this->label8->TabIndex = 11;
- this->label8->Text = L"Adres";
- //
- // label9
- //
- this->label9->AutoSize = true;
- this->label9->Location = System::Drawing::Point(6, 26);
- this->label9->Name = L"label9";
- this->label9->Size = System::Drawing::Size(40, 13);
- this->label9->TabIndex = 10;
- this->label9->Text = L"Nazwa";
- //
- // txtSWww
- //
- this->txtSWww->Location = System::Drawing::Point(6, 123);
- this->txtSWww->Name = L"txtSWww";
- this->txtSWww->Size = System::Drawing::Size(176, 20);
- this->txtSWww->TabIndex = 9;
- //
- // txtSAdress
- //
- this->txtSAdress->Location = System::Drawing::Point(6, 84);
- this->txtSAdress->Name = L"txtSAdress";
- this->txtSAdress->Size = System::Drawing::Size(176, 20);
- this->txtSAdress->TabIndex = 8;
- //
- // txtSName
- //
- this->txtSName->Location = System::Drawing::Point(6, 45);
- this->txtSName->Name = L"txtSName";
- this->txtSName->Size = System::Drawing::Size(176, 20);
- this->txtSName->TabIndex = 7;
- //
- // btnSDelete
- //
- this->btnSDelete->Location = System::Drawing::Point(440, 164);
- this->btnSDelete->Name = L"btnSDelete";
- this->btnSDelete->Size = System::Drawing::Size(75, 23);
- this->btnSDelete->TabIndex = 21;
- this->btnSDelete->Text = L"Usuń";
- this->btnSDelete->UseVisualStyleBackColor = true;
- this->btnSDelete->Click += gcnew System::EventHandler(this, &MyForm::btnSDelete_Click);
- //
- // btnSEdit
- //
- this->btnSEdit->Location = System::Drawing::Point(440, 125);
- this->btnSEdit->Name = L"btnSEdit";
- this->btnSEdit->Size = System::Drawing::Size(75, 23);
- this->btnSEdit->TabIndex = 20;
- this->btnSEdit->Text = L"Edytuj";
- this->btnSEdit->UseVisualStyleBackColor = true;
- this->btnSEdit->Click += gcnew System::EventHandler(this, &MyForm::btnSEdit_Click);
- //
- // btnSAdd
- //
- this->btnSAdd->Location = System::Drawing::Point(440, 86);
- this->btnSAdd->Name = L"btnSAdd";
- this->btnSAdd->Size = System::Drawing::Size(75, 23);
- this->btnSAdd->TabIndex = 19;
- this->btnSAdd->Text = L"Dodaj";
- this->btnSAdd->UseVisualStyleBackColor = true;
- this->btnSAdd->Click += gcnew System::EventHandler(this, &MyForm::btnSAdd_Click);
- //
- // btnSSearch
- //
- this->btnSSearch->Location = System::Drawing::Point(314, 12);
- this->btnSSearch->Name = L"btnSSearch";
- this->btnSSearch->Size = System::Drawing::Size(104, 23);
- this->btnSSearch->TabIndex = 17;
- this->btnSSearch->Text = L"Szukaj";
- this->btnSSearch->UseVisualStyleBackColor = true;
- this->btnSSearch->Click += gcnew System::EventHandler(this, &MyForm::btnSSearch_Click);
- //
- // dgSuppliers
- //
- this->dgSuppliers->AllowUserToAddRows = false;
- this->dgSuppliers->AllowUserToDeleteRows = false;
- this->dgSuppliers->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::AllCells;
- this->dgSuppliers->AutoSizeRowsMode = System::Windows::Forms::DataGridViewAutoSizeRowsMode::AllCells;
- this->dgSuppliers->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
- this->dgSuppliers->Location = System::Drawing::Point(25, 204);
- this->dgSuppliers->Name = L"dgSuppliers";
- this->dgSuppliers->ReadOnly = true;
- this->dgSuppliers->Size = System::Drawing::Size(490, 232);
- this->dgSuppliers->TabIndex = 16;
- this->dgSuppliers->CellClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm::dgSuppliers_CellClick);
- //
- // txtSSearch
- //
- this->txtSSearch->Location = System::Drawing::Point(63, 15);
- this->txtSSearch->Name = L"txtSSearch";
- this->txtSSearch->Size = System::Drawing::Size(221, 20);
- this->txtSSearch->TabIndex = 15;
- //
- // label10
- //
- this->label10->AutoSize = true;
- this->label10->Location = System::Drawing::Point(22, 17);
- this->label10->Name = L"label10";
- this->label10->Size = System::Drawing::Size(35, 13);
- this->label10->TabIndex = 14;
- this->label10->Text = L"Firma:";
- //
- // employees
- //
- this->employees->Controls->Add(this->groupBox3);
- this->employees->Controls->Add(this->btnEDelete);
- this->employees->Controls->Add(this->btnEEdit);
- this->employees->Controls->Add(this->btnEAdd);
- this->employees->Controls->Add(this->btnESearch);
- this->employees->Controls->Add(this->dgEmployees);
- this->employees->Controls->Add(this->txtESearch);
- this->employees->Controls->Add(this->label19);
- this->employees->Location = System::Drawing::Point(4, 22);
- this->employees->Name = L"employees";
- this->employees->Padding = System::Windows::Forms::Padding(3);
- this->employees->Size = System::Drawing::Size(535, 445);
- this->employees->TabIndex = 3;
- this->employees->Text = L"Zatrudnieni";
- this->employees->UseVisualStyleBackColor = true;
- //
- // groupBox3
- //
- this->groupBox3->Controls->Add(this->label4);
- this->groupBox3->Controls->Add(this->label14);
- this->groupBox3->Controls->Add(this->label15);
- this->groupBox3->Controls->Add(this->txtENotes);
- this->groupBox3->Controls->Add(this->txtEPosition);
- this->groupBox3->Controls->Add(this->txtESallary);
- this->groupBox3->Controls->Add(this->label16);
- this->groupBox3->Controls->Add(this->label17);
- this->groupBox3->Controls->Add(this->label18);
- this->groupBox3->Controls->Add(this->txtEPesel);
- this->groupBox3->Controls->Add(this->txtESurname);
- this->groupBox3->Controls->Add(this->txtEName);
- this->groupBox3->Location = System::Drawing::Point(25, 41);
- this->groupBox3->Name = L"groupBox3";
- this->groupBox3->Size = System::Drawing::Size(399, 157);
- this->groupBox3->TabIndex = 30;
- this->groupBox3->TabStop = false;
- this->groupBox3->Text = L"Edycja";
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Location = System::Drawing::Point(208, 107);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(37, 13);
- this->label4->TabIndex = 18;
- this->label4->Text = L"Uwagi";
- //
- // label14
- //
- this->label14->AutoSize = true;
- this->label14->Location = System::Drawing::Point(208, 68);
- this->label14->Name = L"label14";
- this->label14->Size = System::Drawing::Size(62, 13);
- this->label14->TabIndex = 17;
- this->label14->Text = L"Stanowisko";
- //
- // label15
- //
- this->label15->AutoSize = true;
- this->label15->Location = System::Drawing::Point(208, 26);
- this->label15->Name = L"label15";
- this->label15->Size = System::Drawing::Size(39, 13);
- this->label15->TabIndex = 16;
- this->label15->Text = L"Pensja";
- //
- // txtENotes
- //
- this->txtENotes->Location = System::Drawing::Point(208, 123);
- this->txtENotes->Name = L"txtENotes";
- this->txtENotes->Size = System::Drawing::Size(185, 20);
- this->txtENotes->TabIndex = 15;
- //
- // txtEPosition
- //
- this->txtEPosition->Location = System::Drawing::Point(208, 84);
- this->txtEPosition->Name = L"txtEPosition";
- this->txtEPosition->Size = System::Drawing::Size(185, 20);
- this->txtEPosition->TabIndex = 14;
- //
- // txtESallary
- //
- this->txtESallary->Location = System::Drawing::Point(208, 45);
- this->txtESallary->Name = L"txtESallary";
- this->txtESallary->Size = System::Drawing::Size(185, 20);
- this->txtESallary->TabIndex = 13;
- //
- // label16
- //
- this->label16->AutoSize = true;
- this->label16->Location = System::Drawing::Point(6, 107);
- this->label16->Name = L"label16";
- this->label16->Size = System::Drawing::Size(33, 13);
- this->label16->TabIndex = 12;
- this->label16->Text = L"Pesel";
- //
- // label17
- //
- this->label17->AutoSize = true;
- this->label17->Location = System::Drawing::Point(6, 68);
- this->label17->Name = L"label17";
- this->label17->Size = System::Drawing::Size(53, 13);
- this->label17->TabIndex = 11;
- this->label17->Text = L"Nazwisko";
- //
- // label18
- //
- this->label18->AutoSize = true;
- this->label18->Location = System::Drawing::Point(6, 26);
- this->label18->Name = L"label18";
- this->label18->Size = System::Drawing::Size(26, 13);
- this->label18->TabIndex = 10;
- this->label18->Text = L"Imię";
- //
- // txtEPesel
- //
- this->txtEPesel->Location = System::Drawing::Point(6, 123);
- this->txtEPesel->Name = L"txtEPesel";
- this->txtEPesel->Size = System::Drawing::Size(176, 20);
- this->txtEPesel->TabIndex = 9;
- //
- // txtESurname
- //
- this->txtESurname->Location = System::Drawing::Point(6, 84);
- this->txtESurname->Name = L"txtESurname";
- this->txtESurname->Size = System::Drawing::Size(176, 20);
- this->txtESurname->TabIndex = 8;
- //
- // txtEName
- //
- this->txtEName->Location = System::Drawing::Point(6, 45);
- this->txtEName->Name = L"txtEName";
- this->txtEName->Size = System::Drawing::Size(176, 20);
- this->txtEName->TabIndex = 7;
- //
- // btnEDelete
- //
- this->btnEDelete->Location = System::Drawing::Point(440, 164);
- this->btnEDelete->Name = L"btnEDelete";
- this->btnEDelete->Size = System::Drawing::Size(75, 23);
- this->btnEDelete->TabIndex = 29;
- this->btnEDelete->Text = L"Usuń";
- this->btnEDelete->UseVisualStyleBackColor = true;
- this->btnEDelete->Click += gcnew System::EventHandler(this, &MyForm::btnEDelete_Click);
- //
- // btnEEdit
- //
- this->btnEEdit->Location = System::Drawing::Point(440, 125);
- this->btnEEdit->Name = L"btnEEdit";
- this->btnEEdit->Size = System::Drawing::Size(75, 23);
- this->btnEEdit->TabIndex = 28;
- this->btnEEdit->Text = L"Edytuj";
- this->btnEEdit->UseVisualStyleBackColor = true;
- this->btnEEdit->Click += gcnew System::EventHandler(this, &MyForm::btnEEdit_Click);
- //
- // btnEAdd
- //
- this->btnEAdd->Location = System::Drawing::Point(440, 86);
- this->btnEAdd->Name = L"btnEAdd";
- this->btnEAdd->Size = System::Drawing::Size(75, 23);
- this->btnEAdd->TabIndex = 27;
- this->btnEAdd->Text = L"Dodaj";
- this->btnEAdd->UseVisualStyleBackColor = true;
- this->btnEAdd->Click += gcnew System::EventHandler(this, &MyForm::btnEAdd_Click);
- //
- // btnESearch
- //
- this->btnESearch->Location = System::Drawing::Point(314, 12);
- this->btnESearch->Name = L"btnESearch";
- this->btnESearch->Size = System::Drawing::Size(104, 23);
- this->btnESearch->TabIndex = 26;
- this->btnESearch->Text = L"Szukaj";
- this->btnESearch->UseVisualStyleBackColor = true;
- this->btnESearch->Click += gcnew System::EventHandler(this, &MyForm::btnESearch_Click);
- //
- // dgEmployees
- //
- this->dgEmployees->AllowUserToAddRows = false;
- this->dgEmployees->AllowUserToDeleteRows = false;
- this->dgEmployees->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::AllCells;
- this->dgEmployees->AutoSizeRowsMode = System::Windows::Forms::DataGridViewAutoSizeRowsMode::AllCells;
- this->dgEmployees->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
- this->dgEmployees->Location = System::Drawing::Point(25, 204);
- this->dgEmployees->Name = L"dgEmployees";
- this->dgEmployees->ReadOnly = true;
- this->dgEmployees->Size = System::Drawing::Size(490, 232);
- this->dgEmployees->TabIndex = 25;
- this->dgEmployees->CellClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm::dgEmployees_CellClick);
- //
- // txtESearch
- //
- this->txtESearch->Location = System::Drawing::Point(88, 15);
- this->txtESearch->Name = L"txtESearch";
- this->txtESearch->Size = System::Drawing::Size(196, 20);
- this->txtESearch->TabIndex = 24;
- //
- // label19
- //
- this->label19->AutoSize = true;
- this->label19->Location = System::Drawing::Point(22, 17);
- this->label19->Name = L"label19";
- this->label19->Size = System::Drawing::Size(60, 13);
- this->label19->TabIndex = 23;
- this->label19->Text = L"Pracownik:";
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(541, 470);
- this->Controls->Add(this->shop);
- this->Name = L"MyForm";
- this->Text = L"MAXIMUS 1.0";
- this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &MyForm::MyForm_FormClosed);
- this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
- this->shop->ResumeLayout(false);
- this->products->ResumeLayout(false);
- this->products->PerformLayout();
- this->groupBox1->ResumeLayout(false);
- this->groupBox1->PerformLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgProducts))->EndInit();
- this->suppliers->ResumeLayout(false);
- this->suppliers->PerformLayout();
- this->groupBox2->ResumeLayout(false);
- this->groupBox2->PerformLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgSuppliers))->EndInit();
- this->employees->ResumeLayout(false);
- this->employees->PerformLayout();
- this->groupBox3->ResumeLayout(false);
- this->groupBox3->PerformLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dgEmployees))->EndInit();
- this->ResumeLayout(false);
- }
- #pragma endregion
- int record_id;
- String^ konfiguracja = L"datasource=warna.vot.pl;port=3306;username=warna_maximus;password=maximus12345;database=warna_maximus";
- MySqlConnection^ laczBaze = gcnew MySqlConnection(konfiguracja);
- private: System::Void btnPSearch_Click(System::Object^ sender, System::EventArgs^ e) {
- 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);
- try {
- MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
- moja->SelectCommand = zapytanie;
- DataTable^ tabela = gcnew DataTable();
- moja->Fill(tabela);
- dgProducts->DataSource = tabela;
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- dgProducts->Columns[0]->Visible = false;
- }
- private: System::Void cmbBoxCategory_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
- MySqlCommand^ zapytanie = gcnew MySqlCommand("SELECT id, name AS Nazwa, price AS Cena, quantity AS Ilosc FROM products WHERE category_id = '" + cmbBoxCategory->SelectedValue + "';", laczBaze);
- try {
- MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
- moja->SelectCommand = zapytanie;
- DataTable^ tabela = gcnew DataTable();
- moja->Fill(tabela);
- dgProducts->DataSource = tabela;
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- dgProducts->Columns[0]->Visible = false;
- }
- private: System::Void dgProducts_CellClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
- if (e->RowIndex >= 0) {
- record_id = (int)dgProducts->Rows[e->RowIndex]->Cells["id"]->Value;
- txtProduct->Text = dgProducts->Rows[e->RowIndex]->Cells["Nazwa"]->Value->ToString();
- txtPrice->Text = dgProducts->Rows[e->RowIndex]->Cells["Cena"]->Value->ToString();
- txtQuantity->Text = dgProducts->Rows[e->RowIndex]->Cells["Ilosc"]->Value->ToString();
- }
- }
- private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
- laczBaze->Open();
- MySqlCommand^ zapytanie = gcnew MySqlCommand("SELECT id, name FROM categories", laczBaze);
- try {
- MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
- moja->SelectCommand = zapytanie;
- moja->SelectCommand = zapytanie;
- moja->SelectCommand = zapytanie;
- DataTable^ tabela = gcnew DataTable();
- moja->Fill(tabela);
- cmbBoxCategory->DataSource = tabela;
- cmbBoxCategory->DisplayMember = "name";
- cmbBoxCategory->ValueMember = "id";
- cmbBoxCategory_SelectedIndexChanged(sender, e);
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- Loaddata_suppliers();
- Loaddata_employees();
- }
- private: System::Void MyForm_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e) {
- laczBaze->Close();
- }
- private: System::Void btnPAdd_Click(System::Object^ sender, System::EventArgs^ e) {
- if (txtProduct->Text->Length < 2 || txtPrice->Text->Length < 1 || txtQuantity->Text->Length <= 1) {
- MessageBox::Show("Uzupełnij dane!");
- }
- else {
- MessageBox::Show("Dodano produkt.");
- MySqlCommand^ polecenie = laczBaze->CreateCommand();
- polecenie->Connection = laczBaze;
- try {
- polecenie->CommandText = "INSERT INTO products SET name ='" + txtProduct->Text + "', price ='" + txtPrice->Text + "', quantity = '" + txtQuantity->Text + "', category_id = '" + cmbBoxCategory->SelectedValue + "'; ";
- polecenie->ExecuteNonQuery();
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- cmbBoxCategory_SelectedIndexChanged(sender, e);
- }
- }
- private: System::Void txtPrice_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
- if (e->KeyChar == '.') {
- if (this->txtPrice->Text->Contains(".") && !this->txtPrice->SelectedText->Contains("."))
- e->Handled = true;
- }
- else if (!Char::IsDigit(e->KeyChar) && e->KeyChar != 8) {
- e->Handled = true;
- }
- }
- private: System::Void txtQuantity_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
- if (!Char::IsDigit(e->KeyChar) && e->KeyChar != 8) {
- e->Handled = true;
- }
- }
- private: System::Void btnPEdit_Click(System::Object^ sender, System::EventArgs^ e) {
- if (txtProduct->Text->Length < 2 || txtPrice->Text->Length < 1 || txtQuantity->Text->Length <= 1) {
- MessageBox::Show("Uzupełnij dane!");
- }
- else {
- MessageBox::Show("Zmodyfikowano wpis.");
- MySqlCommand^ polecenie = laczBaze->CreateCommand();
- polecenie->Connection = laczBaze;
- try {
- polecenie->CommandText = "UPDATE products SET name ='" + txtProduct->Text + "', price ='" + txtPrice->Text + "', quantity = '" + txtQuantity->Text + "', category_id = '" + cmbBoxCategory->SelectedValue + "' WHERE id ='" + record_id + "'; ";
- polecenie->ExecuteNonQuery();
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- cmbBoxCategory_SelectedIndexChanged(sender, e);
- }
- }
- private: System::Void btnPDelete_Click(System::Object^ sender, System::EventArgs^ e) {
- MySqlCommand^ polecenie = laczBaze->CreateCommand();
- polecenie->Connection = laczBaze;
- try {
- if (MessageBox::Show("Czy usunąć wybrany Produkt?", "Uwaga!!!", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes) {
- polecenie->CommandText = "DELETE FROM products WHERE id = " + record_id + "; ";
- polecenie->ExecuteNonQuery();
- MessageBox::Show("Produkt został usunięty");
- }
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- txtProduct->Text = "";
- txtPrice->Text = "";
- txtQuantity->Text = "";
- cmbBoxCategory_SelectedIndexChanged(sender, e);
- }
- private: System::Void txtSearch_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
- if (e->KeyChar == 13) {
- btnPSearch_Click(sender, e);
- }
- }
- private: System::Void btnSSearch_Click(System::Object^ sender, System::EventArgs^ e) {
- 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);
- try {
- MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
- moja->SelectCommand = zapytanie;
- DataTable^ tabela = gcnew DataTable();
- moja->Fill(tabela);
- dgSuppliers->DataSource = tabela;
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- dgSuppliers->Columns[0]->Visible = false;
- }
- private: System::Void dgSuppliers_CellClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
- if (e->RowIndex >= 0) {
- record_id = (int)dgSuppliers->Rows[e->RowIndex]->Cells["id"]->Value;
- txtSName->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Nazwa"]->Value->ToString();
- txtSAdress->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Adres"]->Value->ToString();
- txtSMail->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Adres e-mail"]->Value->ToString();
- txtSNotes->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Uwagi"]->Value->ToString();
- txtSPhone->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Numer telefonu"]->Value->ToString();
- txtSWww->Text = dgSuppliers->Rows[e->RowIndex]->Cells["Strona internetowa"]->Value->ToString();
- }
- }
- private: System::Void btnSAdd_Click(System::Object^ sender, System::EventArgs^ e) {
- if (txtSAdress->Text->Length < 4 || txtSMail->Text->Length < 4 || txtSName->Text->Length <= 1 || txtSPhone->Text->Length <= 4 ||txtSWww->Text->Length <= 4) {
- MessageBox::Show("Uzupełnij dane!");
- }
- else {
- MessageBox::Show("Dodano produkt.");
- MySqlCommand^ polecenie = laczBaze->CreateCommand();
- polecenie->Connection = laczBaze;
- try {
- polecenie->CommandText = "INSERT INTO suppliers SET name ='" + txtSName->Text + "', mail ='" + txtSMail->Text + "', adress = '" + txtSAdress->Text + "', phone = '" + txtSPhone->Text + "', www = '" + txtSWww->Text + "', notes = '" + txtSNotes->Text + "'; ";
- polecenie->ExecuteNonQuery();
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- Loaddata_suppliers();
- }
- }
- private: System::Void Loaddata_suppliers(){
- 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);
- try {
- MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
- moja->SelectCommand = zapytanie;
- DataTable^ tabela = gcnew DataTable();
- moja->Fill(tabela);
- dgSuppliers->DataSource = tabela;
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- dgSuppliers->Columns[0]->Visible = false;
- }
- private: System::Void btnSEdit_Click(System::Object^ sender, System::EventArgs^ e) {
- if (txtSAdress->Text->Length < 4 || txtSMail->Text->Length < 4 || txtSName->Text->Length <= 1 || txtSPhone->Text->Length <= 4 || txtSWww->Text->Length <= 4) {
- MessageBox::Show("Uzupełnij dane!");
- }
- else {
- MessageBox::Show("Zmodyfikowano wpis.");
- MySqlCommand^ polecenie = laczBaze->CreateCommand();
- polecenie->Connection = laczBaze;
- try {
- 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 + "'; ";
- polecenie->ExecuteNonQuery();
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- cmbBoxCategory_SelectedIndexChanged(sender, e);
- }
- Loaddata_suppliers();
- }
- private: System::Void btnSDelete_Click(System::Object^ sender, System::EventArgs^ e) {
- MySqlCommand^ polecenie = laczBaze->CreateCommand();
- polecenie->Connection = laczBaze;
- try {
- if (MessageBox::Show("Czy usunąć wybrany wpis?", "Uwaga!!!", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes) {
- polecenie->CommandText = "DELETE FROM suppliers WHERE id = " + record_id + "; ";
- polecenie->ExecuteNonQuery();
- MessageBox::Show("Produkt został usunięty");
- }
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- txtSAdress->Text = "";
- txtSMail->Text = "";
- txtSName->Text = "";
- txtSNotes->Text = "";
- txtSPhone->Text = "";
- txtSWww->Text = "";
- Loaddata_suppliers();
- }
- private: System::Void Loaddata_employees() {
- 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);
- try {
- MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
- moja->SelectCommand = zapytanie;
- DataTable^ tabela = gcnew DataTable();
- moja->Fill(tabela);
- dgEmployees->DataSource = tabela;
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- dgEmployees->Columns[0]->Visible = false;
- }
- private: System::Void btnESearch_Click(System::Object^ sender, System::EventArgs^ e) {
- 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);
- try {
- MySqlDataAdapter^ moja = gcnew MySqlDataAdapter();
- moja->SelectCommand = zapytanie;
- DataTable^ tabela = gcnew DataTable();
- moja->Fill(tabela);
- dgEmployees->DataSource = tabela;
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- dgEmployees->Columns[0]->Visible = false;
- }
- private: System::Void btnEAdd_Click(System::Object^ sender, System::EventArgs^ e) {
- if (txtEName->Text->Length < 2 || txtEPesel->Text->Length < 2 || txtEPosition->Text->Length < 1 || txtESallary->Text->Length < 2 || txtESurname->Text->Length < 3) {
- MessageBox::Show("Uzupełnij dane!");
- }
- else {
- MessageBox::Show("Dodano produkt.");
- MySqlCommand^ polecenie = laczBaze->CreateCommand();
- polecenie->Connection = laczBaze;
- try {
- polecenie->CommandText = "INSERT INTO employees SET name ='" + txtEName->Text + "', surname ='" + txtESurname->Text + "', pesel = '" + txtEPesel->Text + "', sallary = '" + txtESallary->Text + "', position = '" + txtEPosition->Text + "', notes = '" + txtENotes->Text + "'; ";
- polecenie->ExecuteNonQuery();
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- Loaddata_employees();
- }
- }
- private: System::Void btnEEdit_Click(System::Object^ sender, System::EventArgs^ e) {
- if (txtEName->Text->Length < 2 || txtEPesel->Text->Length < 2 || txtEPosition->Text->Length < 1 || txtESallary->Text->Length < 2 || txtESurname->Text->Length < 3) {
- MessageBox::Show("Uzupełnij dane!");
- }
- else {
- MessageBox::Show("Zmodyfikowano wpis.");
- MySqlCommand^ polecenie = laczBaze->CreateCommand();
- polecenie->Connection = laczBaze;
- try {
- 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 + "'; ";
- polecenie->ExecuteNonQuery();
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- Loaddata_employees();
- }
- }
- private: System::Void dgEmployees_CellClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
- if (e->RowIndex >= 0) {
- record_id = (int)dgEmployees->Rows[e->RowIndex]->Cells["id"]->Value;
- txtEName->Text = dgEmployees->Rows[e->RowIndex]->Cells["Imie"]->Value->ToString();
- txtENotes->Text = dgEmployees->Rows[e->RowIndex]->Cells["Uwagi"]->Value->ToString();
- txtEPesel->Text = dgEmployees->Rows[e->RowIndex]->Cells["Pesel"]->Value->ToString();
- txtEPosition->Text = dgEmployees->Rows[e->RowIndex]->Cells["Stanowisko"]->Value->ToString();
- txtESallary->Text = dgEmployees->Rows[e->RowIndex]->Cells["Pensja"]->Value->ToString();
- txtESurname->Text = dgEmployees->Rows[e->RowIndex]->Cells["Nazwisko"]->Value->ToString();
- }
- }
- private: System::Void btnEDelete_Click(System::Object^ sender, System::EventArgs^ e) {
- MySqlCommand^ polecenie = laczBaze->CreateCommand();
- polecenie->Connection = laczBaze;
- try {
- if (MessageBox::Show("Czy usunąć wybrany wpis?", "Uwaga!!!", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes) {
- polecenie->CommandText = "DELETE FROM employees WHERE id = " + record_id + "; ";
- polecenie->ExecuteNonQuery();
- MessageBox::Show("Produkt został usunięty");
- }
- }
- catch (Exception^ komunikat) {
- MessageBox::Show(komunikat->Message);
- }
- txtEName->Text = "";
- txtENotes->Text = "";
- txtEPesel->Text = "";
- txtEPosition->Text = "";
- txtESallary->Text = "";
- txtESurname->Text = "";
- Loaddata_employees();
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement