Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.77 KB | None | 0 0
  1. #include <string>
  2. #include "class_body.h"
  3. #include "Erorr.h"
  4.  
  5. #pragma once
  6.  
  7.  
  8. namespace BaigiamasisDarbas {
  9.  
  10. using namespace System;
  11. using namespace System::ComponentModel;
  12. using namespace System::Collections;
  13. using namespace System::Windows::Forms;
  14. using namespace System::Data;
  15. using namespace System::Drawing;
  16.  
  17.  
  18. namespace
  19. {
  20. bylos C;
  21. }
  22. /// <summary>
  23. /// Summary for Bylos
  24. /// </summary>
  25. public ref class Bylos : public System::Windows::Forms::Form
  26. {
  27. public:
  28. Bylos(void)
  29. {
  30. InitializeComponent();
  31. bylos();
  32. bylusar();
  33. //
  34. //TODO: Add the constructor code here
  35. //
  36. }
  37.  
  38. protected:
  39. /// <summary>
  40. /// Clean up any resources being used.
  41. /// </summary>
  42. ~Bylos()
  43. {
  44. if (components)
  45. {
  46. delete components;
  47. }
  48. }
  49. private: System::Windows::Forms::Label^ label1;
  50. protected:
  51. private: System::Windows::Forms::Button^ button1;
  52. private: System::Windows::Forms::DataGridView^ dataGridView1;
  53. private: System::Windows::Forms::DataGridViewTextBoxColumn^ ID;
  54. private: System::Windows::Forms::DataGridViewTextBoxColumn^ Pavadinimas;
  55. private: System::Windows::Forms::DataGridViewTextBoxColumn^ Tipas;
  56. private: System::Windows::Forms::DataGridViewTextBoxColumn^ Sale;
  57. private: System::Windows::Forms::DataGridViewTextBoxColumn^ Data;
  58. private: System::Windows::Forms::Label^ label2;
  59. private: System::Windows::Forms::Label^ label3;
  60. private: System::Windows::Forms::Label^ label4;
  61. private: System::Windows::Forms::Label^ label5;
  62. private: System::Windows::Forms::Label^ label6;
  63. private: System::Windows::Forms::TextBox^ textBox1;
  64. private: System::Windows::Forms::TextBox^ textBox2;
  65.  
  66. private: System::Windows::Forms::TextBox^ textBox4;
  67.  
  68. private: System::Windows::Forms::Button^ button2;
  69. private: System::Windows::Forms::ComboBox^ comboBox1;
  70. private: System::Windows::Forms::DateTimePicker^ dateTimePicker1;
  71.  
  72. private:
  73. /// <summary>
  74. /// Required designer variable.
  75. /// </summary>
  76. System::ComponentModel::Container ^components;
  77.  
  78. #pragma region Windows Form Designer generated code
  79. /// <summary>
  80. /// Required method for Designer support - do not modify
  81. /// the contents of this method with the code editor.
  82. /// </summary>
  83. void InitializeComponent(void)
  84. {
  85. System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Bylos::typeid));
  86. this->label1 = (gcnew System::Windows::Forms::Label());
  87. this->button1 = (gcnew System::Windows::Forms::Button());
  88. this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
  89. this->ID = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  90. this->Pavadinimas = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  91. this->Tipas = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  92. this->Sale = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  93. this->Data = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  94. this->label2 = (gcnew System::Windows::Forms::Label());
  95. this->label3 = (gcnew System::Windows::Forms::Label());
  96. this->label4 = (gcnew System::Windows::Forms::Label());
  97. this->label5 = (gcnew System::Windows::Forms::Label());
  98. this->label6 = (gcnew System::Windows::Forms::Label());
  99. this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  100. this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  101. this->textBox4 = (gcnew System::Windows::Forms::TextBox());
  102. this->button2 = (gcnew System::Windows::Forms::Button());
  103. this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
  104. this->dateTimePicker1 = (gcnew System::Windows::Forms::DateTimePicker());
  105. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->BeginInit();
  106. this->SuspendLayout();
  107. //
  108. // label1
  109. //
  110. this->label1->AutoSize = true;
  111. this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 36, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  112. static_cast<System::Byte>(0)));
  113. this->label1->Location = System::Drawing::Point(364, 9);
  114. this->label1->Name = L"label1";
  115. this->label1->Size = System::Drawing::Size(141, 55);
  116. this->label1->TabIndex = 0;
  117. this->label1->Text = L"Bylos";
  118. //
  119. // button1
  120. //
  121. this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 36, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  122. static_cast<System::Byte>(0)));
  123. this->button1->Location = System::Drawing::Point(583, 535);
  124. this->button1->Name = L"button1";
  125. this->button1->Size = System::Drawing::Size(185, 66);
  126. this->button1->TabIndex = 1;
  127. this->button1->Text = L"Grizti";
  128. this->button1->UseVisualStyleBackColor = true;
  129. this->button1->Click += gcnew System::EventHandler(this, &Bylos::button1_Click);
  130. //
  131. // dataGridView1
  132. //
  133. this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  134. this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(5) {
  135. this->ID, this->Pavadinimas,
  136. this->Tipas, this->Sale, this->Data
  137. });
  138. this->dataGridView1->Location = System::Drawing::Point(128, 82);
  139. this->dataGridView1->Name = L"dataGridView1";
  140. this->dataGridView1->Size = System::Drawing::Size(640, 242);
  141. this->dataGridView1->TabIndex = 2;
  142. this->dataGridView1->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &Bylos::dataGridView1_CellContentClick);
  143. //
  144. // ID
  145. //
  146. this->ID->HeaderText = L"ID";
  147. this->ID->Name = L"ID";
  148. //
  149. // Pavadinimas
  150. //
  151. this->Pavadinimas->HeaderText = L"Pavadinimas";
  152. this->Pavadinimas->Name = L"Pavadinimas";
  153. this->Pavadinimas->Width = 200;
  154. //
  155. // Tipas
  156. //
  157. this->Tipas->HeaderText = L"Tipas";
  158. this->Tipas->Name = L"Tipas";
  159. //
  160. // Sale
  161. //
  162. this->Sale->HeaderText = L"Sale";
  163. this->Sale->Name = L"Sale";
  164. //
  165. // Data
  166. //
  167. this->Data->HeaderText = L"Data";
  168. this->Data->Name = L"Data";
  169. //
  170. // label2
  171. //
  172. this->label2->AutoSize = true;
  173. this->label2->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  174. this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  175. static_cast<System::Byte>(186)));
  176. this->label2->Location = System::Drawing::Point(128, 370);
  177. this->label2->Name = L"label2";
  178. this->label2->Size = System::Drawing::Size(24, 20);
  179. this->label2->TabIndex = 3;
  180. this->label2->Text = L"ID";
  181. this->label2->Click += gcnew System::EventHandler(this, &Bylos::label2_Click);
  182. //
  183. // label3
  184. //
  185. this->label3->AutoSize = true;
  186. this->label3->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  187. this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  188. static_cast<System::Byte>(186)));
  189. this->label3->Location = System::Drawing::Point(58, 402);
  190. this->label3->Name = L"label3";
  191. this->label3->Size = System::Drawing::Size(94, 20);
  192. this->label3->TabIndex = 4;
  193. this->label3->Text = L"Pavadinimas";
  194. //
  195. // label4
  196. //
  197. this->label4->AutoSize = true;
  198. this->label4->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  199. this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  200. static_cast<System::Byte>(186)));
  201. this->label4->Location = System::Drawing::Point(106, 433);
  202. this->label4->Name = L"label4";
  203. this->label4->Size = System::Drawing::Size(46, 20);
  204. this->label4->TabIndex = 5;
  205. this->label4->Text = L"Tipas";
  206. //
  207. // label5
  208. //
  209. this->label5->AutoSize = true;
  210. this->label5->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  211. this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  212. static_cast<System::Byte>(186)));
  213. this->label5->Location = System::Drawing::Point(496, 369);
  214. this->label5->Name = L"label5";
  215. this->label5->Size = System::Drawing::Size(39, 20);
  216. this->label5->TabIndex = 6;
  217. this->label5->Text = L"Sale";
  218. //
  219. // label6
  220. //
  221. this->label6->AutoSize = true;
  222. this->label6->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  223. this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  224. static_cast<System::Byte>(186)));
  225. this->label6->Location = System::Drawing::Point(496, 402);
  226. this->label6->Name = L"label6";
  227. this->label6->Size = System::Drawing::Size(41, 20);
  228. this->label6->TabIndex = 7;
  229. this->label6->Text = L"Data";
  230. this->label6->Click += gcnew System::EventHandler(this, &Bylos::label6_Click);
  231. //
  232. // textBox1
  233. //
  234. this->textBox1->Location = System::Drawing::Point(158, 370);
  235. this->textBox1->Name = L"textBox1";
  236. this->textBox1->Size = System::Drawing::Size(227, 20);
  237. this->textBox1->TabIndex = 8;
  238. this->textBox1->TextChanged += gcnew System::EventHandler(this, &Bylos::textBox1_TextChanged);
  239. //
  240. // textBox2
  241. //
  242. this->textBox2->Location = System::Drawing::Point(158, 402);
  243. this->textBox2->Name = L"textBox2";
  244. this->textBox2->Size = System::Drawing::Size(227, 20);
  245. this->textBox2->TabIndex = 9;
  246. //
  247. // textBox4
  248. //
  249. this->textBox4->Location = System::Drawing::Point(541, 370);
  250. this->textBox4->Name = L"textBox4";
  251. this->textBox4->Size = System::Drawing::Size(227, 20);
  252. this->textBox4->TabIndex = 11;
  253. //
  254. // button2
  255. //
  256. this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 36, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  257. static_cast<System::Byte>(186)));
  258. this->button2->Location = System::Drawing::Point(128, 535);
  259. this->button2->Name = L"button2";
  260. this->button2->Size = System::Drawing::Size(185, 66);
  261. this->button2->TabIndex = 13;
  262. this->button2->Text = L"Ivesti";
  263. this->button2->UseVisualStyleBackColor = true;
  264. this->button2->Click += gcnew System::EventHandler(this, &Bylos::button2_Click);
  265. //
  266. // comboBox1
  267. //
  268. this->comboBox1->FormattingEnabled = true;
  269. this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^ >(2) { L"Viesas", L"Uzdaras" });
  270. this->comboBox1->Location = System::Drawing::Point(158, 434);
  271. this->comboBox1->Name = L"comboBox1";
  272. this->comboBox1->Size = System::Drawing::Size(227, 21);
  273. this->comboBox1->TabIndex = 14;
  274. this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Bylos::comboBox1_SelectedIndexChanged);
  275. //
  276. // dateTimePicker1
  277. //
  278. this->dateTimePicker1->Format = System::Windows::Forms::DateTimePickerFormat::Short;
  279. this->dateTimePicker1->Location = System::Drawing::Point(541, 402);
  280. this->dateTimePicker1->Name = L"dateTimePicker1";
  281. this->dateTimePicker1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
  282. this->dateTimePicker1->Size = System::Drawing::Size(227, 20);
  283. this->dateTimePicker1->TabIndex = 15;
  284. //
  285. // Bylos
  286. //
  287. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  288. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  289. this->ClientSize = System::Drawing::Size(944, 921);
  290. this->Controls->Add(this->dateTimePicker1);
  291. this->Controls->Add(this->comboBox1);
  292. this->Controls->Add(this->button2);
  293. this->Controls->Add(this->textBox4);
  294. this->Controls->Add(this->textBox2);
  295. this->Controls->Add(this->textBox1);
  296. this->Controls->Add(this->label6);
  297. this->Controls->Add(this->label5);
  298. this->Controls->Add(this->label4);
  299. this->Controls->Add(this->label3);
  300. this->Controls->Add(this->label2);
  301. this->Controls->Add(this->dataGridView1);
  302. this->Controls->Add(this->button1);
  303. this->Controls->Add(this->label1);
  304. this->Icon = (cli::safe_cast<System::Drawing::Icon^>(resources->GetObject(L"$this.Icon")));
  305. this->Name = L"Bylos";
  306. this->Text = L"Bylos";
  307. this->Load += gcnew System::EventHandler(this, &Bylos::Bylos_Load);
  308. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->EndInit();
  309. this->ResumeLayout(false);
  310. this->PerformLayout();
  311.  
  312. }
  313.  
  314.  
  315. #pragma endregion
  316.  
  317. void bylusar()
  318. {
  319. //spausdinimas i grida
  320. String^ spausd;
  321.  
  322. for (int i = 0; i <= C.b; i++)
  323. {
  324. dataGridView1->Rows->Add();
  325. spausd = gcnew String(C.Byla[i].byla_ID.c_str());
  326. dataGridView1[0, i]->Value = spausd;
  327. spausd = gcnew String(C.Byla[i].byla_pavadinimas.c_str());
  328. dataGridView1[1, i]->Value = spausd;
  329. spausd = gcnew String(C.Byla[i].byla_tipas.c_str());
  330. dataGridView1[2, i]->Value = spausd;
  331. spausd = gcnew String(C.Byla[i].byla_vieta.c_str());
  332. dataGridView1[3, i]->Value = spausd;
  333. spausd = gcnew String(C.Byla[i].byla_data.c_str());
  334. dataGridView1[4, i]->Value = spausd;
  335.  
  336.  
  337.  
  338. }
  339. }
  340. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  341. Close();
  342.  
  343. }
  344. private: System::Void Bylos_Load(System::Object^ sender, System::EventArgs^ e) {
  345. }
  346. private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
  347. }
  348. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
  349. String ^ ID, ^ pavadinimas, ^tipas, ^vieta, ^data; //apsauga butinai padaryt
  350. std::string id, pav, tip, vie, dat;
  351.  
  352.  
  353. if (textBox1->Text == "" || textBox2->Text == "" || textBox4->Text == "")
  354. {
  355. Erorr ^err = gcnew Erorr();
  356. err->Show();
  357. }
  358. else {
  359. //Cia ivedimas
  360.  
  361. ID = textBox1->Text;
  362. pavadinimas = textBox2->Text;
  363. tipas = comboBox1->SelectedItem->ToString();
  364. vieta = textBox4->Text;
  365. data = dateTimePicker1->Value.ToString("yyyy-MM-dd");
  366.  
  367. id = C.convert(ID);
  368. pav = C.convert(pavadinimas);
  369. tip = C.convert(tipas);
  370. vie = C.convert(vieta);
  371. dat = C.convert(data);
  372.  
  373.  
  374. C.naujabyla(id, pav, tip, vie, dat);
  375.  
  376. textBox1->Text = "";
  377. textBox2->Text = "";
  378. textBox4->Text = "";
  379.  
  380. dataGridView1->Rows->Clear();
  381.  
  382. bylusar();
  383. C.duomfb();
  384. }
  385. }
  386. private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  387. }
  388. private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
  389.  
  390. }
  391.  
  392. private: System::Void label6_Click(System::Object^ sender, System::EventArgs^ e) {
  393. }
  394. private: System::Void dataGridView1_CellContentClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
  395.  
  396. }
  397. };
  398. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement