text: #pragma once
  
  namespace Bloodbanksystem {
  
  	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 Bloodbank
  	/// </summary>
  	public ref class Bloodbank : public System::Windows::Forms::Form
  	{
  	public:
  		Bloodbank(void)
  		{
  			InitializeComponent();
  			//
  			//TODO: Add the constructor code here
  			//
  		}
  
  	protected:
  		/// <summary>
  		/// Clean up any resources being used.
  		/// </summary>
  		~Bloodbank()
  		{
  			if (components)
  			{
  				delete components;
  			}
  		}
  	private: System::Windows::Forms::Label^  label1;
  	protected:
  	private: System::Windows::Forms::Label^  label2;
  	private: System::Windows::Forms::Label^  label3;
  	private: System::Windows::Forms::TextBox^  textBox1;
  	private: System::Windows::Forms::TextBox^  textBox2;
  	private: System::Windows::Forms::TextBox^  textBox3;
  	private: System::Windows::Forms::Button^  button1;
  	private: System::Windows::Forms::Button^  button2;
  	private: System::Windows::Forms::Button^  button3;
  	private: System::Windows::Forms::Button^  button4;
  	private: System::Windows::Forms::Button^  button5;
  	private: System::Windows::Forms::DataGridView^  dataGridView1;
  	private: System::Windows::Forms::BindingSource^  bindingSource1;
  	private: System::Windows::Forms::Button^  button6;
  	private: System::ComponentModel::IContainer^  components;
  
  	private:
  		/// <summary>
  		/// Required designer variable.
  		/// </summary>
  
  
  #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->components = (gcnew System::ComponentModel::Container());
  			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Bloodbank::typeid));
  			this->label1 = (gcnew System::Windows::Forms::Label());
  			this->label2 = (gcnew System::Windows::Forms::Label());
  			this->label3 = (gcnew System::Windows::Forms::Label());
  			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  			this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  			this->textBox3 = (gcnew System::Windows::Forms::TextBox());
  			this->button1 = (gcnew System::Windows::Forms::Button());
  			this->button2 = (gcnew System::Windows::Forms::Button());
  			this->button3 = (gcnew System::Windows::Forms::Button());
  			this->button4 = (gcnew System::Windows::Forms::Button());
  			this->button5 = (gcnew System::Windows::Forms::Button());
  			this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
  			this->bindingSource1 = (gcnew System::Windows::Forms::BindingSource(this->components));
  			this->button6 = (gcnew System::Windows::Forms::Button());
  			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->BeginInit();
  			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->bindingSource1))->BeginInit();
  			this->SuspendLayout();
  			// 
  			// label1
  			// 
  			this->label1->AutoSize = true;
  			this->label1->BackColor = System::Drawing::SystemColors::Info;
  			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  				static_cast<System::Byte>(0)));
  			this->label1->ForeColor = System::Drawing::SystemColors::ButtonHighlight;
  			this->label1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"label1.Image")));
  			this->label1->Location = System::Drawing::Point(54, 70);
  			this->label1->Margin = System::Windows::Forms::Padding(5, 0, 5, 0);
  			this->label1->Name = L"label1";
  			this->label1->Size = System::Drawing::Size(73, 18);
  			this->label1->TabIndex = 1;
  			this->label1->Text = L"Bank No";
  			// 
  			// label2
  			// 
  			this->label2->AutoSize = true;
  			this->label2->BackColor = System::Drawing::SystemColors::Info;
  			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  				static_cast<System::Byte>(0)));
  			this->label2->ForeColor = System::Drawing::SystemColors::ButtonHighlight;
  			this->label2->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"label2.Image")));
  			this->label2->Location = System::Drawing::Point(54, 138);
  			this->label2->Margin = System::Windows::Forms::Padding(5, 0, 5, 0);
  			this->label2->Name = L"label2";
  			this->label2->Size = System::Drawing::Size(94, 18);
  			this->label2->TabIndex = 2;
  			this->label2->Text = L"Description";
  			// 
  			// label3
  			// 
  			this->label3->AutoSize = true;
  			this->label3->BackColor = System::Drawing::SystemColors::Info;
  			this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  				static_cast<System::Byte>(0)));
  			this->label3->ForeColor = System::Drawing::SystemColors::ButtonHighlight;
  			this->label3->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"label3.Image")));
  			this->label3->Location = System::Drawing::Point(54, 215);
  			this->label3->Margin = System::Windows::Forms::Padding(5, 0, 5, 0);
  			this->label3->Name = L"label3";
  			this->label3->Size = System::Drawing::Size(48, 18);
  			this->label3->TabIndex = 3;
  			this->label3->Text = L"Code";
  			// 
  			// textBox1
  			// 
  			this->textBox1->Location = System::Drawing::Point(199, 71);
  			this->textBox1->Name = L"textBox1";
  			this->textBox1->Size = System::Drawing::Size(220, 20);
  			this->textBox1->TabIndex = 5;
  			// 
  			// textBox2
  			// 
  			this->textBox2->Location = System::Drawing::Point(199, 136);
  			this->textBox2->Name = L"textBox2";
  			this->textBox2->Size = System::Drawing::Size(220, 20);
  			this->textBox2->TabIndex = 6;
  			// 
  			// textBox3
  			// 
  			this->textBox3->Location = System::Drawing::Point(199, 216);
  			this->textBox3->Name = L"textBox3";
  			this->textBox3->Size = System::Drawing::Size(220, 20);
  			this->textBox3->TabIndex = 7;
  			// 
  			// button1
  			// 
  			this->button1->BackColor = System::Drawing::SystemColors::Info;
  			this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  				static_cast<System::Byte>(0)));
  			this->button1->ForeColor = System::Drawing::SystemColors::ButtonHighlight;
  			this->button1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button1.Image")));
  			this->button1->Location = System::Drawing::Point(57, 314);
  			this->button1->Margin = System::Windows::Forms::Padding(4);
  			this->button1->Name = L"button1";
  			this->button1->Size = System::Drawing::Size(112, 30);
  			this->button1->TabIndex = 11;
  			this->button1->Text = L"Update";
  			this->button1->UseVisualStyleBackColor = false;
  			this->button1->Click += gcnew System::EventHandler(this, &Bloodbank::button1_Click);
  			// 
  			// button2
  			// 
  			this->button2->BackColor = System::Drawing::SystemColors::Info;
  			this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  				static_cast<System::Byte>(0)));
  			this->button2->ForeColor = System::Drawing::SystemColors::ButtonHighlight;
  			this->button2->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button2.Image")));
  			this->button2->Location = System::Drawing::Point(199, 314);
  			this->button2->Margin = System::Windows::Forms::Padding(4);
  			this->button2->Name = L"button2";
  			this->button2->Size = System::Drawing::Size(112, 30);
  			this->button2->TabIndex = 12;
  			this->button2->Text = L"Insert";
  			this->button2->UseVisualStyleBackColor = false;
  			this->button2->Click += gcnew System::EventHandler(this, &Bloodbank::button2_Click);
  			// 
  			// button3
  			// 
  			this->button3->BackColor = System::Drawing::SystemColors::Info;
  			this->button3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  				static_cast<System::Byte>(0)));
  			this->button3->ForeColor = System::Drawing::SystemColors::ButtonHighlight;
  			this->button3->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button3.Image")));
  			this->button3->Location = System::Drawing::Point(340, 314);
  			this->button3->Margin = System::Windows::Forms::Padding(4);
  			this->button3->Name = L"button3";
  			this->button3->Size = System::Drawing::Size(112, 30);
  			this->button3->TabIndex = 13;
  			this->button3->Text = L"Delete";
  			this->button3->UseVisualStyleBackColor = false;
  			this->button3->Click += gcnew System::EventHandler(this, &Bloodbank::button3_Click);
  			// 
  			// button4
  			// 
  			this->button4->BackColor = System::Drawing::SystemColors::Info;
  			this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  				static_cast<System::Byte>(0)));
  			this->button4->ForeColor = System::Drawing::SystemColors::ButtonHighlight;
  			this->button4->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button4.Image")));
  			this->button4->Location = System::Drawing::Point(468, 61);
  			this->button4->Margin = System::Windows::Forms::Padding(4);
  			this->button4->Name = L"button4";
  			this->button4->Size = System::Drawing::Size(112, 30);
  			this->button4->TabIndex = 14;
  			this->button4->Text = L"GO";
  			this->button4->UseVisualStyleBackColor = false;
  			this->button4->Click += gcnew System::EventHandler(this, &Bloodbank::button4_Click);
  			// 
  			// button5
  			// 
  			this->button5->BackColor = System::Drawing::SystemColors::Info;
  			this->button5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  				static_cast<System::Byte>(0)));
  			this->button5->ForeColor = System::Drawing::SystemColors::ButtonHighlight;
  			this->button5->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button5.Image")));
  			this->button5->Location = System::Drawing::Point(603, 61);
  			this->button5->Margin = System::Windows::Forms::Padding(4);
  			this->button5->Name = L"button5";
  			this->button5->Size = System::Drawing::Size(112, 30);
  			this->button5->TabIndex = 15;
  			this->button5->Text = L"Select ALL";
  			this->button5->UseVisualStyleBackColor = false;
  			this->button5->Click += gcnew System::EventHandler(this, &Bloodbank::button5_Click);
  			// 
  			// dataGridView1
  			// 
  			this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  			this->dataGridView1->Location = System::Drawing::Point(499, 136);
  			this->dataGridView1->Margin = System::Windows::Forms::Padding(4);
  			this->dataGridView1->Name = L"dataGridView1";
  			this->dataGridView1->Size = System::Drawing::Size(388, 279);
  			this->dataGridView1->TabIndex = 16;
  			// 
  			// button6
  			// 
  			this->button6->BackColor = System::Drawing::Color::LavenderBlush;
  			this->button6->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button6.BackgroundImage")));
  			this->button6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  				static_cast<System::Byte>(0)));
  			this->button6->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(64)), static_cast<System::Int32>(static_cast<System::Byte>(0)),
  				static_cast<System::Int32>(static_cast<System::Byte>(64)));
  			this->button6->Location = System::Drawing::Point(812, 48);
  			this->button6->Name = L"button6";
  			this->button6->Size = System::Drawing::Size(75, 43);
  			this->button6->TabIndex = 17;
  			this->button6->Text = L"<-Back ";
  			this->button6->UseVisualStyleBackColor = false;
  			this->button6->Click += gcnew System::EventHandler(this, &Bloodbank::button6_Click);
  			// 
  			// Bloodbank
  			// 
  			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  			this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"$this.BackgroundImage")));
  			this->ClientSize = System::Drawing::Size(958, 441);
  			this->Controls->Add(this->button6);
  			this->Controls->Add(this->dataGridView1);
  			this->Controls->Add(this->button5);
  			this->Controls->Add(this->button4);
  			this->Controls->Add(this->button3);
  			this->Controls->Add(this->button2);
  			this->Controls->Add(this->button1);
  			this->Controls->Add(this->textBox3);
  			this->Controls->Add(this->textBox2);
  			this->Controls->Add(this->textBox1);
  			this->Controls->Add(this->label3);
  			this->Controls->Add(this->label2);
  			this->Controls->Add(this->label1);
  			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
  			this->Name = L"Bloodbank";
  			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->EndInit();
  			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->bindingSource1))->EndInit();
  			this->ResumeLayout(false);
  			this->PerformLayout();
  
  		}
  #pragma endregion
  	private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
  				 this->Close();
  	}
  			 //Insert button event
  private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
  			 //Insert Onclick Handler 
  			 //MessageBox::Show("Insert clicked!!!");
  			 try{
  				 String^ info = "Server=127.0.0.1;Uid=root;Pwd=;Database=blood bank management system";
  				 MySqlConnection^ con = gcnew MySqlConnection(info);
  
  				 int bankno = Int32::Parse(textBox1->Text);
  				 String^ Description = textBox2->Text;
  				 int Code = Int32::Parse(textBox3->Text);
  
  				 MySqlCommand^ cmd = gcnew  MySqlCommand("insert into bloodbank values(" + Code + ",'" + Description + "'," + bankno + ")", con);
  				 con->Open();
  				 MySqlDataReader^ dr;
  				 dr = cmd->ExecuteReader();
  				 MessageBox::Show("User info saved!!!!");
  				 con->Close();
  			 }
  			 catch (Exception^ ex){
  				 MessageBox::Show(ex->Message);
  			 }
  }
  		 //Update table
  private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  			 try{
  				 String^ info = "Server=127.0.0.1;Uid=root;Pwd=;Database=blood bank management system";
  				 MySqlConnection^ con = gcnew MySqlConnection(info);
  
  				 int bankno = Int32::Parse(textBox1->Text);
  				 String^ Description = textBox2->Text;
  				 int Code = Int32::Parse(textBox3->Text);
  
  				 MySqlCommand^ cmd = gcnew  MySqlCommand("update bloodbank set Description='" + Description + "',Code='" + Code + "'where Bankno=" + bankno + "", con);
  				 con->Open();
  				 MySqlDataReader^ dr;
  				 dr = cmd->ExecuteReader();
  				 MessageBox::Show("User info updated!!!!");
  				 con->Close();
  			 }
  			 catch (Exception^ ex){
  				 MessageBox::Show(ex->Message);
  			 }
  }
  		 //delete data
  private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
  			 try{
  				 String^ info = "Server=127.0.0.1;Uid=root;Pwd=;Database=blood bank management system";
  				 MySqlConnection^ con = gcnew MySqlConnection(info);
  
  				 int Code = Int32::Parse(textBox1->Text);
  				 MySqlCommand^ cmd = gcnew  MySqlCommand("delete from bloodbank where Code=" + Code + "", con);
  				 con->Open();
  				 MySqlDataReader^ dr;
  				 dr = cmd->ExecuteReader();
  				 MessageBox::Show("User info deleted!!!!");
  				 con->Close();
  			 }
  			 catch (Exception^ ex){
  				 MessageBox::Show(ex->Message);
  			 }
  }
  		 //Go button
  private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
  			 try{
  				 int bankno = Int32::Parse(textBox1->Text);
  				 String^ info = "Server=127.0.0.1;Uid=root;Pwd=;Database=blood bank management system";
  				 MySqlConnection^ con = gcnew MySqlConnection(info);
  
  				 MySqlCommand^ cmd = gcnew  MySqlCommand("Select * from bloodbank where Bankno=" + bankno + "", con);
  				 con->Open();
  				 MySqlDataReader^ dr;
  				 dr = cmd->ExecuteReader();
  				 while (dr->Read()){
  
  					 textBox2->Text = dr->GetString(1);
  					 textBox3->Text = dr->GetString(2);
  
  				 }
  				 con->Close();
  			 }
  			 catch (Exception^ ex){
  				 MessageBox::Show(ex->Message);
  			 }
  }
  		 //fetch all data
  private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
  			 try{
  				 String^ info = "Server=127.0.0.1;Uid=root;Pwd=;Database=blood bank management system";
  				 MySqlConnection^ con = gcnew MySqlConnection(info);
  				 MySqlDataAdapter^ sda = gcnew MySqlDataAdapter("select * from bloodbank", con);
  				 DataTable^ dt = gcnew DataTable();
  				 sda->Fill(dt);
  				 bindingSource1->DataSource = dt;
  				 dataGridView1->DataSource = bindingSource1;
  			 }
  			 catch (Exception^ ex){
  				 MessageBox::Show(ex->Message);
  			 }
  }
  };
  }
  