You are on page 1of 157

LAPORAN PRAKTIKUM

PEMROGRAMAN KOMPUTER 2

Disusun Oleh:
1. Ainun Dwi Herwani (16/12237)
2. Yovi Setiawan (16/12361)
Kelas : FM3 No. Komputer :16
Tahun : Sem IV/2018 Tgl. Praktikum : 7 – 11 Mei 2018

DEPARTEMEN TEKNIK MESIN


SEKOLAH VOKASI
UNIVERSITAS GADJAH MADA
YOGYAKARTA
2018
TUGAS 1
DATABASE
Cek Koneksi
Load Data Makanan

Load Data Minuman


Hitung

Reset
Program
#pragma once

namespace tugas1 {
int kode;

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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
protected:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::GroupBox^ groupBox1;
private: System::Windows::Forms::GroupBox^ groupBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::TextBox^ textBox4;
private: System::Windows::Forms::ComboBox^ comboBox2;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::Label^ label10;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button6;

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->label1 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->label8 = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->label10 = (gcnew System::Windows::Forms::Label());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->groupBox1->SuspendLayout();
this->groupBox2->SuspendLayout();
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"News701 BT", 20.25F,
static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)),
System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(221, 28);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(241, 32);
this->label1->TabIndex = 0;
this->label1->Text = L"TIG TUG CAFE";
//
// button1
//
this->button1->Location = System::Drawing::Point(55, 35);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(111, 28);
this->button1->TabIndex = 1;
this->button1->Text = L"CEK!!!";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(55, 108);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(111, 28);
this->button2->TabIndex = 3;
this->button2->Text = L"Load Data";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(6, 37);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(83, 13);
this->label2->TabIndex = 0;
this->label2->Text = L"Nama Makanan";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(10, 74);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(36, 13);
this->label3->TabIndex = 1;
this->label3->Text = L"Harga";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(11, 113);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(40, 13);
this->label4->TabIndex = 2;
this->label4->Text = L"Jumlah";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(95, 34);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 3;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(95, 71);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(121, 20);
this->textBox1->TabIndex = 4;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(95, 106);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(121, 20);
this->textBox2->TabIndex = 5;
//
// groupBox1
//
this->groupBox1->Controls->Add(this->textBox2);
this->groupBox1->Controls->Add(this->textBox1);
this->groupBox1->Controls->Add(this->comboBox1);
this->groupBox1->Controls->Add(this->label4);
this->groupBox1->Controls->Add(this->label3);
this->groupBox1->Controls->Add(this->label2);
this->groupBox1->Location = System::Drawing::Point(55, 152);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Size = System::Drawing::Size(244, 148);
this->groupBox1->TabIndex = 2;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"Daftar Makanan";
//
// groupBox2
//
this->groupBox2->Controls->Add(this->textBox3);
this->groupBox2->Controls->Add(this->textBox4);
this->groupBox2->Controls->Add(this->comboBox2);
this->groupBox2->Controls->Add(this->label5);
this->groupBox2->Controls->Add(this->label6);
this->groupBox2->Controls->Add(this->label7);
this->groupBox2->Location = System::Drawing::Point(342, 152);
this->groupBox2->Name = L"groupBox2";
this->groupBox2->Size = System::Drawing::Size(244, 148);
this->groupBox2->TabIndex = 6;
this->groupBox2->TabStop = false;
this->groupBox2->Text = L"Daftar Minuman";
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(95, 106);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(121, 20);
this->textBox3->TabIndex = 5;
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(95, 71);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(121, 20);
this->textBox4->TabIndex = 4;
//
// comboBox2
//
this->comboBox2->FormattingEnabled = true;
this->comboBox2->Location = System::Drawing::Point(95, 34);
this->comboBox2->Name = L"comboBox2";
this->comboBox2->Size = System::Drawing::Size(121, 21);
this->comboBox2->TabIndex = 3;
this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox2_SelectedIndexChanged);
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(11, 113);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(40, 13);
this->label5->TabIndex = 2;
this->label5->Text = L"Jumlah";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(10, 74);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(36, 13);
this->label6->TabIndex = 1;
this->label6->Text = L"Harga";
//
// label7
//
this->label7->AutoSize = true;
this->label7->Location = System::Drawing::Point(6, 37);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(81, 13);
this->label7->TabIndex = 0;
this->label7->Text = L"Nama Minuman";
//
// button3
//
this->button3->Location = System::Drawing::Point(342, 108);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(111, 28);
this->button3->TabIndex = 7;
this->button3->Text = L"Load Data";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// button4
//
this->button4->Location = System::Drawing::Point(55, 352);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(89, 56);
this->button4->TabIndex = 8;
this->button4->Text = L"HITUNG";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
//
// label8
//
this->label8->AutoSize = true;
this->label8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label8->Location = System::Drawing::Point(65, 329);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(58, 20);
this->label8->TabIndex = 6;
this->label8->Text = L"KASIR";
//
// label9
//
this->label9->AutoSize = true;
this->label9->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label9->Location = System::Drawing::Point(205, 366);
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(94, 24);
this->label9->TabIndex = 6;
this->label9->Text = L"XXXXXX";
//
// label10
//
this->label10->AutoSize = true;
this->label10->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label10->Location = System::Drawing::Point(150, 366);
this->label10->Name = L"label10";
this->label10->Size = System::Drawing::Size(55, 24);
this->label10->TabIndex = 9;
this->label10->Text = L"= Rp.";
//
// button5
//
this->button5->Location = System::Drawing::Point(402, 352);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(89, 38);
this->button5->TabIndex = 10;
this->button5->Text = L"Reset";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
//
// button6
//
this->button6->Location = System::Drawing::Point(497, 352);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(89, 38);
this->button6->TabIndex = 11;
this->button6->Text = L"Quit";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)),
static_cast<System::Int32>(static_cast<System::Byte>(255)),
static_cast<System::Int32>(static_cast<System::Byte>(192)));
this->ClientSize = System::Drawing::Size(628, 451);
this->Controls->Add(this->button6);
this->Controls->Add(this->button5);
this->Controls->Add(this->label10);
this->Controls->Add(this->label9);
this->Controls->Add(this->label8);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->button2);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->button1);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
this->groupBox1->ResumeLayout(false);
this->groupBox1->PerformLayout();
this->groupBox2->ResumeLayout(false);
this->groupBox2->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from food", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";
MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from food", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data Makanan ");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("makan"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";
MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from drink", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data Minuman");
while (myReader->Read())
{
comboBox2->Items->Add(myReader->GetString("minum"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from food where makan = '" + comboBox1-
>Text + "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox1->Text = (myReader->GetInt32("harga").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void comboBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from drink where minum = '" + comboBox2-
>Text + "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox4->Text = (myReader->GetInt32("rego").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {

float f, z1, d,z2,t;

z1 = Convert::ToDouble(textBox2->Text);
z2 = Convert::ToDouble(textBox3->Text);

f = Convert::ToDouble(textBox1->Text);
d= Convert::ToDouble(textBox4->Text);

t = (f*z1)+(d*z2);

label9->Text = Convert::ToString(t);

}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
textBox2->Text = "";
comboBox2->Items->Clear();
comboBox2->Text = "";
textBox3->Text = "";
textBox4->Text = "";
label9->Text = "";
}
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {

Close();
}
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
}
};
}
Tugas 2

Load Data
Hitung

Reset
Program
#pragma once

namespace tugas2 {
int kode;

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();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button6;
protected:
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Label^ label10;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::GroupBox^ groupBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::TextBox^ textBox4;
private: System::Windows::Forms::ComboBox^ comboBox2;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::GroupBox^ groupBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label1;

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->button6 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->label10 = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->button4 = (gcnew System::Windows::Forms::Button());
this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button1 = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->groupBox2->SuspendLayout();
this->groupBox1->SuspendLayout();
this->SuspendLayout();
//
// button6
//
this->button6->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)),
static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button6->Location = System::Drawing::Point(522, 366);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(89, 38);
this->button6->TabIndex = 23;
this->button6->Text = L"Quit";
this->button6->UseVisualStyleBackColor = false;
this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
//
// button5
//
this->button5->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)),
static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button5->Location = System::Drawing::Point(427, 366);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(89, 38);
this->button5->TabIndex = 22;
this->button5->Text = L"Reset";
this->button5->UseVisualStyleBackColor = false;
this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
//
// label10
//
this->label10->AutoSize = true;
this->label10->BackColor = System::Drawing::Color::Yellow;
this->label10->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label10->Location = System::Drawing::Point(175, 380);
this->label10->Name = L"label10";
this->label10->Size = System::Drawing::Size(55, 24);
this->label10->TabIndex = 21;
this->label10->Text = L"= Rp.";
//
// label9
//
this->label9->AutoSize = true;
this->label9->BackColor = System::Drawing::Color::Yellow;
this->label9->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label9->Location = System::Drawing::Point(230, 380);
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(94, 24);
this->label9->TabIndex = 16;
this->label9->Text = L"XXXXXX";
//
// label8
//
this->label8->AutoSize = true;
this->label8->BackColor = System::Drawing::Color::Yellow;
this->label8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label8->Location = System::Drawing::Point(90, 343);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(58, 20);
this->label8->TabIndex = 17;
this->label8->Text = L"KASIR";
//
// button4
//
this->button4->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)),
static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button4->Location = System::Drawing::Point(80, 366);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(89, 56);
this->button4->TabIndex = 20;
this->button4->Text = L"HITUNG";
this->button4->UseVisualStyleBackColor = false;
this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
//
// groupBox2
//
this->groupBox2->BackColor = System::Drawing::Color::Yellow;
this->groupBox2->Controls->Add(this->textBox3);
this->groupBox2->Controls->Add(this->textBox4);
this->groupBox2->Controls->Add(this->comboBox2);
this->groupBox2->Controls->Add(this->label5);
this->groupBox2->Controls->Add(this->label6);
this->groupBox2->Controls->Add(this->label7);
this->groupBox2->Location = System::Drawing::Point(367, 166);
this->groupBox2->Name = L"groupBox2";
this->groupBox2->Size = System::Drawing::Size(244, 148);
this->groupBox2->TabIndex = 18;
this->groupBox2->TabStop = false;
this->groupBox2->Text = L"Daftar Minuman";
//
// textBox3
//
this->textBox3->BackColor = System::Drawing::Color::Yellow;
this->textBox3->Location = System::Drawing::Point(95, 106);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(121, 20);
this->textBox3->TabIndex = 5;
//
// textBox4
//
this->textBox4->BackColor = System::Drawing::Color::Yellow;
this->textBox4->Location = System::Drawing::Point(95, 71);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(121, 20);
this->textBox4->TabIndex = 4;
//
// comboBox2
//
this->comboBox2->BackColor = System::Drawing::Color::Yellow;
this->comboBox2->FormattingEnabled = true;
this->comboBox2->Location = System::Drawing::Point(95, 34);
this->comboBox2->Name = L"comboBox2";
this->comboBox2->Size = System::Drawing::Size(121, 21);
this->comboBox2->TabIndex = 3;
this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox2_SelectedIndexChanged);
//
// label5
//
this->label5->AutoSize = true;
this->label5->BackColor = System::Drawing::Color::Yellow;
this->label5->Location = System::Drawing::Point(11, 113);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(40, 13);
this->label5->TabIndex = 2;
this->label5->Text = L"Jumlah";
//
// label6
//
this->label6->AutoSize = true;
this->label6->BackColor = System::Drawing::Color::Yellow;
this->label6->Location = System::Drawing::Point(10, 74);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(36, 13);
this->label6->TabIndex = 1;
this->label6->Text = L"Harga";
//
// label7
//
this->label7->AutoSize = true;
this->label7->BackColor = System::Drawing::Color::Yellow;
this->label7->Location = System::Drawing::Point(6, 37);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(81, 13);
this->label7->TabIndex = 0;
this->label7->Text = L"Nama Minuman";
//
// groupBox1
//
this->groupBox1->BackColor = System::Drawing::Color::Yellow;
this->groupBox1->Controls->Add(this->textBox2);
this->groupBox1->Controls->Add(this->textBox1);
this->groupBox1->Controls->Add(this->comboBox1);
this->groupBox1->Controls->Add(this->label4);
this->groupBox1->Controls->Add(this->label3);
this->groupBox1->Controls->Add(this->label2);
this->groupBox1->Location = System::Drawing::Point(80, 166);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Size = System::Drawing::Size(244, 148);
this->groupBox1->TabIndex = 14;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"Daftar Makanan";
//
// textBox2
//
this->textBox2->BackColor = System::Drawing::Color::Yellow;
this->textBox2->Location = System::Drawing::Point(95, 106);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(121, 20);
this->textBox2->TabIndex = 5;
//
// textBox1
//
this->textBox1->BackColor = System::Drawing::Color::Yellow;
this->textBox1->Location = System::Drawing::Point(95, 71);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(121, 20);
this->textBox1->TabIndex = 4;
//
// comboBox1
//
this->comboBox1->BackColor = System::Drawing::Color::Yellow;
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(95, 34);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 3;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// label4
//
this->label4->AutoSize = true;
this->label4->BackColor = System::Drawing::Color::Yellow;
this->label4->Location = System::Drawing::Point(11, 113);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(40, 13);
this->label4->TabIndex = 2;
this->label4->Text = L"Jumlah";
//
// label3
//
this->label3->AutoSize = true;
this->label3->BackColor = System::Drawing::Color::Yellow;
this->label3->Location = System::Drawing::Point(10, 74);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(36, 13);
this->label3->TabIndex = 1;
this->label3->Text = L"Harga";
//
// label2
//
this->label2->AutoSize = true;
this->label2->BackColor = System::Drawing::Color::Yellow;
this->label2->Location = System::Drawing::Point(6, 37);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(83, 13);
this->label2->TabIndex = 0;
this->label2->Text = L"Nama Makanan";
//
// button2
//
this->button2->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)),
static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button2->Location = System::Drawing::Point(80, 110);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(111, 50);
this->button2->TabIndex = 15;
this->button2->Text = L"Load Data";
this->button2->UseVisualStyleBackColor = false;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// button1
//
this->button1->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)),
static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button1->Location = System::Drawing::Point(80, 49);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(111, 28);
this->button1->TabIndex = 13;
this->button1->Text = L"CEK!!!";
this->button1->UseVisualStyleBackColor = false;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->BackColor = System::Drawing::Color::Yellow;
this->label1->Font = (gcnew System::Drawing::Font(L"News701 BT", 20.25F,
static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)),
System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(246, 42);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(241, 32);
this->label1->TabIndex = 12;
this->label1->Text = L"TIG TUG CAFE";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::AntiqueWhite;
this->ClientSize = System::Drawing::Size(690, 465);
this->Controls->Add(this->button6);
this->Controls->Add(this->button5);
this->Controls->Add(this->label10);
this->Controls->Add(this->label9);
this->Controls->Add(this->label8);
this->Controls->Add(this->button4);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->groupBox2->ResumeLayout(false);
this->groupBox2->PerformLayout();
this->groupBox1->ResumeLayout(false);
this->groupBox1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";
MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from food", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlConnection^ zzz = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from food", yyy);
MySqlCommand^ mmm = gcnew MySqlCommand("select * from drink", zzz);

MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data Makanan");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("makan"));
}
yyy->Close();

zzz->Open();
myReader = mmm->ExecuteReader();
MessageBox::Show("Load Data Minuman");
while (myReader->Read())
{
comboBox2->Items->Add(myReader->GetString("minum"));
}
yyy->Close();

}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);

}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from food where makan = '" + comboBox1-
>Text + "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox1->Text = (myReader->GetInt32("harga").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void comboBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from drink where minum = '" + comboBox2-
>Text + "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox4->Text = (myReader->GetInt32("rego").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {

float f, z1, d, z2, t;

z1 = Convert::ToDouble(textBox2->Text);
z2 = Convert::ToDouble(textBox3->Text);

f = Convert::ToDouble(textBox1->Text);
d = Convert::ToDouble(textBox4->Text);

t = (f*z1) + (d*z2);

label9->Text = Convert::ToString(t);
}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
textBox2->Text = "";
comboBox2->Items->Clear();
comboBox2->Text = "";
textBox3->Text = "";
textBox4->Text = "";
label9->Text = "";
}
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {

Close();
}
};
}

Tugas 3

Cek Koneksi
Load Data
Hitung
Reset
Search
Insert
Update
Delete
Program
#pragma once

namespace tugas3 {
int kode;

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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::GroupBox^ groupBox1;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::GroupBox^ groupBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::ComboBox^ comboBox2;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::TextBox^ textBox4;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::Label^ label10;
private: System::Windows::Forms::TextBox^ textBox5;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button6;
private: System::Windows::Forms::Button^ button7;
private: System::Windows::Forms::Button^ button8;
private: System::Windows::Forms::Button^ button9;

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->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->label5 = (gcnew System::Windows::Forms::Label());
this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
this->button3 = (gcnew System::Windows::Forms::Button());
this->label8 = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->label10 = (gcnew System::Windows::Forms::Label());
this->textBox5 = (gcnew System::Windows::Forms::TextBox());
this->button4 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->button7 = (gcnew System::Windows::Forms::Button());
this->button8 = (gcnew System::Windows::Forms::Button());
this->button9 = (gcnew System::Windows::Forms::Button());
this->groupBox1->SuspendLayout();
this->groupBox2->SuspendLayout();
this->SuspendLayout();
//
// button1
//
this->button1->BackColor = System::Drawing::Color::White;
this->button1->Location = System::Drawing::Point(22, 39);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"CEKK";
this->button1->UseVisualStyleBackColor = false;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// button2
//
this->button2->BackColor = System::Drawing::Color::Lime;
this->button2->Location = System::Drawing::Point(22, 79);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 40);
this->button2->TabIndex = 1;
this->button2->Text = L"Load Data";
this->button2->UseVisualStyleBackColor = false;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(6, 37);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(83, 13);
this->label1->TabIndex = 2;
this->label1->Text = L"Nama Makanan";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(111, 34);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 3;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(6, 77);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(36, 13);
this->label2->TabIndex = 4;
this->label2->Text = L"Harga";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(111, 74);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(121, 20);
this->textBox1->TabIndex = 5;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"News706 BT", 20.25F,
static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)),
System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
this->label3->Location = System::Drawing::Point(210, 29);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(223, 32);
this->label3->TabIndex = 6;
this->label3->Text = L"TIG TUG CAFE";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(6, 118);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(40, 13);
this->label4->TabIndex = 7;
this->label4->Text = L"Jumlah";
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(111, 111);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(121, 20);
this->textBox2->TabIndex = 8;
//
// groupBox1
//
this->groupBox1->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)),
static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->groupBox1->Controls->Add(this->label1);
this->groupBox1->Controls->Add(this->textBox2);
this->groupBox1->Controls->Add(this->comboBox1);
this->groupBox1->Controls->Add(this->label4);
this->groupBox1->Controls->Add(this->label2);
this->groupBox1->Controls->Add(this->textBox1);
this->groupBox1->Location = System::Drawing::Point(22, 125);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Size = System::Drawing::Size(252, 153);
this->groupBox1->TabIndex = 9;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"Daftar Makanan";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(6, 37);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(81, 13);
this->label5->TabIndex = 2;
this->label5->Text = L"Nama Minuman";
//
// groupBox2
//
this->groupBox2->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)),
static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->groupBox2->Controls->Add(this->label5);
this->groupBox2->Controls->Add(this->textBox3);
this->groupBox2->Controls->Add(this->comboBox2);
this->groupBox2->Controls->Add(this->label6);
this->groupBox2->Controls->Add(this->label7);
this->groupBox2->Controls->Add(this->textBox4);
this->groupBox2->Location = System::Drawing::Point(337, 125);
this->groupBox2->Name = L"groupBox2";
this->groupBox2->Size = System::Drawing::Size(252, 153);
this->groupBox2->TabIndex = 10;
this->groupBox2->TabStop = false;
this->groupBox2->Text = L"Daftar Minuman";
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(111, 111);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(121, 20);
this->textBox3->TabIndex = 8;
//
// comboBox2
//
this->comboBox2->FormattingEnabled = true;
this->comboBox2->Location = System::Drawing::Point(111, 34);
this->comboBox2->Name = L"comboBox2";
this->comboBox2->Size = System::Drawing::Size(121, 21);
this->comboBox2->TabIndex = 3;
this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox2_SelectedIndexChanged);
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(6, 118);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(40, 13);
this->label6->TabIndex = 7;
this->label6->Text = L"Jumlah";
//
// label7
//
this->label7->AutoSize = true;
this->label7->Location = System::Drawing::Point(6, 77);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(36, 13);
this->label7->TabIndex = 4;
this->label7->Text = L"Harga";
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(111, 74);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(121, 20);
this->textBox4->TabIndex = 5;
//
// button3
//
this->button3->BackColor = System::Drawing::Color::Aqua;
this->button3->Location = System::Drawing::Point(22, 322);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(75, 51);
this->button3->TabIndex = 11;
this->button3->Text = L"HITUNG";
this->button3->UseVisualStyleBackColor = false;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// label8
//
this->label8->AutoSize = true;
this->label8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label8->Location = System::Drawing::Point(18, 294);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(51, 24);
this->label8->TabIndex = 9;
this->label8->Text = L"Kasir";
//
// label9
//
this->label9->AutoSize = true;
this->label9->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label9->Location = System::Drawing::Point(103, 333);
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(55, 24);
this->label9->TabIndex = 12;
this->label9->Text = L"= Rp.";
//
// label10
//
this->label10->AutoSize = true;
this->label10->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label10->Location = System::Drawing::Point(164, 333);
this->label10->Name = L"label10";
this->label10->Size = System::Drawing::Size(66, 24);
this->label10->TabIndex = 13;
this->label10->Text = L"XXXX";
//
// textBox5
//
this->textBox5->Location = System::Drawing::Point(386, 299);
this->textBox5->Name = L"textBox5";
this->textBox5->Size = System::Drawing::Size(137, 20);
this->textBox5->TabIndex = 9;
//
// button4
//
this->button4->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F));
this->button4->Location = System::Drawing::Point(415, 322);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(75, 32);
this->button4->TabIndex = 14;
this->button4->Text = L"Cari";
this->button4->UseVisualStyleBackColor = false;
this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
//
// button5
//
this->button5->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)),
static_cast<System::Int32>(static_cast<System::Byte>(224)),
static_cast<System::Int32>(static_cast<System::Byte>(192)));
this->button5->Location = System::Drawing::Point(83, 388);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(75, 48);
this->button5->TabIndex = 15;
this->button5->Text = L"Reset";
this->button5->UseVisualStyleBackColor = false;
this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
//
// button6
//
this->button6->BackColor = System::Drawing::Color::MintCream;
this->button6->Location = System::Drawing::Point(179, 388);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(75, 48);
this->button6->TabIndex = 16;
this->button6->Text = L"Insert";
this->button6->UseVisualStyleBackColor = false;
this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
//
// button7
//
this->button7->BackColor = System::Drawing::Color::White;
this->button7->Location = System::Drawing::Point(282, 388);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(75, 48);
this->button7->TabIndex = 17;
this->button7->Text = L"Update";
this->button7->UseVisualStyleBackColor = false;
this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click);
//
// button8
//
this->button8->BackColor = System::Drawing::Color::White;
this->button8->Location = System::Drawing::Point(375, 388);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(75, 48);
this->button8->TabIndex = 18;
this->button8->Text = L"Delete";
this->button8->UseVisualStyleBackColor = false;
this->button8->Click += gcnew System::EventHandler(this, &MyForm::button8_Click);
//
// button9
//
this->button9->BackColor = System::Drawing::Color::Red;
this->button9->Location = System::Drawing::Point(471, 388);
this->button9->Name = L"button9";
this->button9->Size = System::Drawing::Size(75, 48);
this->button9->TabIndex = 19;
this->button9->Text = L"Quit";
this->button9->UseVisualStyleBackColor = false;
this->button9->Click += gcnew System::EventHandler(this, &MyForm::button9_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor =
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)),
static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(192)));
this->ClientSize = System::Drawing::Size(612, 461);
this->Controls->Add(this->button9);
this->Controls->Add(this->button8);
this->Controls->Add(this->button7);
this->Controls->Add(this->button6);
this->Controls->Add(this->button5);
this->Controls->Add(this->button4);
this->Controls->Add(this->textBox5);
this->Controls->Add(this->label10);
this->Controls->Add(this->label9);
this->Controls->Add(this->label8);
this->Controls->Add(this->button3);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->label3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->groupBox1->ResumeLayout(false);
this->groupBox1->PerformLayout();
this->groupBox2->ResumeLayout(false);
this->groupBox2->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from drink", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlConnection^ ZZZ = gcnew MySqlConnection(xxx);

MySqlCommand^ nnn = gcnew MySqlCommand("select * from food", yyy);


MySqlCommand^ mmm = gcnew MySqlCommand("select * from drink", yyy);

MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data ");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("makan"));
}
yyy->Close();

yyy->Open();
myReader = mmm->ExecuteReader();
MessageBox::Show("Load Data ");
while (myReader->Read())
{
comboBox2->Items->Add(myReader->GetString("minum"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from food where makan = '" + comboBox1-
>Text + "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{
kode = (myReader->GetInt32("id"));
textBox1->Text = (myReader->GetInt32("harga").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void comboBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";
MySqlConnection^ zzz = gcnew MySqlConnection(xxx);
MySqlCommand^ mmm = gcnew MySqlCommand("select * from drink where minum = '" + comboBox2-
>Text + "';", zzz);
MySqlDataReader^ myReader;
try
{
zzz->Open();
myReader = mmm->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox4->Text = (myReader->GetInt32("rego").ToString());
}
zzz->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

float f, z1, d, z2, t;

z1 = Convert::ToDouble(textBox2->Text);
z2 = Convert::ToDouble(textBox3->Text);

f = Convert::ToDouble(textBox1->Text);
d = Convert::ToDouble(textBox4->Text);

t = (f*z1) + (d*z2);

label10->Text = Convert::ToString(t);
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlConnection^ zzz = gcnew MySqlConnection(xxx);

MySqlCommand^ nnn = gcnew MySqlCommand("select * from food where makan like '%" + textBox5-
>Text + "%';", yyy);
MySqlCommand^ mmm = gcnew MySqlCommand("select * from drink where minum like '%" + textBox5-
>Text + "%';", yyy);

MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("makan"));
}
yyy->Close();

yyy->Open();
myReader = mmm->ExecuteReader();
while (myReader->Read())
{
comboBox2->Items->Add(myReader->GetString("minum"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
textBox2->Text = "";
comboBox2->Items->Clear();
comboBox2->Text = "";
textBox3->Text = "";
textBox4->Text = "";
textBox5->Text = "";
label10->Text = "";

}
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlConnection^ zzz = gcnew MySqlConnection(xxx);

MySqlCommand^ nnn = gcnew MySqlCommand("insert into food(makan,harga) values('" + this-


>comboBox1->Text + "','" + this->textBox1->Text + "') ; ", yyy);
MySqlCommand^ mmm = gcnew MySqlCommand("insert into drink(minum,rego) values('" + this-
>comboBox2->Text + "','" + this->textBox4->Text + "') ; ", zzz);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Makanan Disimpan");
while (myReader->Read())
{

}
yyy->Close();

zzz->Open();
myReader = mmm->ExecuteReader();
MessageBox::Show("Data Minuman Disimpan");
while (myReader->Read())
{

}
zzz->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlConnection^ zzz = gcnew MySqlConnection(xxx);

MySqlCommand^ nnn = gcnew MySqlCommand("update food set makan ='" + this->comboBox1->Text +


"', harga = '" + this->textBox1->Text + "' where id = " + kode + " ; ", yyy);
MySqlCommand^ mmm = gcnew MySqlCommand("update drink set minum ='" + this->comboBox2->Text
+ "', rego = '" + this->textBox4->Text + "' where id = " + kode + " ; ", zzz);

MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Food Diupdate");
while (myReader->Read())
{

}
yyy->Close();

zzz->Open();
myReader = mmm->ExecuteReader();
MessageBox::Show("Data Minuman Diupdate");
while (myReader->Read())
{

}
zzz->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=tugas1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlConnection^ zzz = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("delete from food where makan = '" + this->comboBox1-
>Text + "' and harga = '" + this->textBox1->Text + "' ; ", yyy);
MySqlCommand^ mmm = gcnew MySqlCommand("delete from drink where minum = '" + this-
>comboBox2->Text + "' and rego = '" + this->textBox4->Text + "' ; ", zzz);

MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Makanan Dihapus");
while (myReader->Read())
{

}
yyy->Close();

zzz->Open();
myReader = mmm->ExecuteReader();
MessageBox::Show("Data Minuman Dihapus");
while (myReader->Read())
{

}
zzz->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e) {

Close();
}
};
}

PR 1 12237
Cek Koneksi

Load Data
Hitung

Reset
Program
#pragma once

namespace pr1tgtg {
int kode;

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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::RadioButton^ radioButton1;
private: System::Windows::Forms::RadioButton^ radioButton2;
private: System::Windows::Forms::Label^ label5;
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::Label^ label6;

private: System::Windows::Forms::Button^ button4;


private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::Label^ label9;

protected:

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->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
this->label5 = (gcnew System::Windows::Forms::Label());
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->label6 = (gcnew System::Windows::Forms::Label());
this->button4 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->label7 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(128, 30);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(202, 24);
this->label1->TabIndex = 0;
this->label1->Text = L"Menghitung Hidrostatik";
this->label1->Click += gcnew System::EventHandler(this, &MyForm::label1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(33, 101);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(50, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"Jenis Zat";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(33, 136);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(54, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"Nama Zat";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(33, 168);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(115, 13);
this->label4->TabIndex = 3;
this->label4->Text = L"Massa Jenis ( Kg/m^3)";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(155, 98);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 4;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(155, 133);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(121, 20);
this->textBox1->TabIndex = 5;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(154, 165);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(121, 20);
this->textBox2->TabIndex = 6;
//
// radioButton1
//
this->radioButton1->AutoSize = true;
this->radioButton1->Location = System::Drawing::Point(313, 155);
this->radioButton1->Name = L"radioButton1";
this->radioButton1->Size = System::Drawing::Size(48, 17);
this->radioButton1->TabIndex = 7;
this->radioButton1->TabStop = true;
this->radioButton1->Text = L"Bumi";
this->radioButton1->UseVisualStyleBackColor = true;
//
// radioButton2
//
this->radioButton2->AutoSize = true;
this->radioButton2->Location = System::Drawing::Point(313, 178);
this->radioButton2->Name = L"radioButton2";
this->radioButton2->Size = System::Drawing::Size(52, 17);
this->radioButton2->TabIndex = 8;
this->radioButton2->TabStop = true;
this->radioButton2->Text = L"Bulan";
this->radioButton2->UseVisualStyleBackColor = true;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(34, 210);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(36, 13);
this->label5->TabIndex = 9;
this->label5->Text = L"Tinggi";
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(154, 203);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(121, 20);
this->textBox3->TabIndex = 10;
//
// button1
//
this->button1->Location = System::Drawing::Point(37, 30);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(50, 29);
this->button1->TabIndex = 11;
this->button1->Text = L"CEK!!!";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(313, 98);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(68, 51);
this->button2->TabIndex = 12;
this->button2->Text = L"LOAD";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// button3
//
this->button3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F));
this->button3->Location = System::Drawing::Point(83, 286);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(65, 43);
this->button3->TabIndex = 13;
this->button3->Text = L"HITUNG";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// label6
//
this->label6->AutoSize = true;
this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label6->Location = System::Drawing::Point(156, 296);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(18, 20);
this->label6->TabIndex = 14;
this->label6->Text = L"=";
//
// button4
//
this->button4->Location = System::Drawing::Point(271, 237);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(52, 33);
this->button4->TabIndex = 16;
this->button4->Text = L"RESET";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
//
// button5
//
this->button5->Location = System::Drawing::Point(329, 237);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(52, 33);
this->button5->TabIndex = 17;
this->button5->Text = L"QUIT";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
//
// label7
//
this->label7->AutoSize = true;
this->label7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label7->Location = System::Drawing::Point(180, 292);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(60, 24);
this->label7->TabIndex = 18;
this->label7->Text = L"xxxxx";
//
// label8
//
this->label8->AutoSize = true;
this->label8->Location = System::Drawing::Point(151, 226);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(88, 13);
this->label8->TabIndex = 19;
this->label8->Text = L"nb: Isi Ketinggian";
//
// label9
//
this->label9->AutoSize = true;
this->label9->Location = System::Drawing::Point(314, 198);
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(51, 13);
this->label9->TabIndex = 20;
this->label9->Text = L"pilih zona";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(446, 341);
this->Controls->Add(this->label9);
this->Controls->Add(this->label8);
this->Controls->Add(this->label7);
this->Controls->Add(this->button5);
this->Controls->Add(this->button4);
this->Controls->Add(this->label6);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->label5);
this->Controls->Add(this->radioButton2);
this->Controls->Add(this->radioButton1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=prtermo1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from tek", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=prtermo1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from tek", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data ");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("flu"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=prtermo1;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from tek where flu = '" + comboBox1->Text +
"';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox1->Text = (myReader->GetString("flu"));
textBox2->Text = (myReader->GetInt32("rho").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

float rho, g, h,p;

rho= Convert::ToDouble(textBox2->Text);
h = Convert::ToDouble(textBox3->Text);

if (radioButton1->Checked) g=9.8;
if (radioButton2->Checked) g=1.6;

p = rho*g*h;

label7->Text = Convert::ToString(p);

}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
textBox2->Text = "";
textBox3->Text = "";
label7->Text = "";

}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
};
}

PR 2_12237
Database
Tes Koneksi

Load Data
Reset
Program
#pragma once

namespace thermo {
int kode;

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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
protected:

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->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(129, 33);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(120, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"MENGHITUNG KALOR";
this->label1->Click += gcnew System::EventHandler(this, &MyForm::label1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(21, 81);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(68, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"MASSA (KG)";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(21, 114);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(120, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"KALOR JENIS (J/KG C)";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(21, 146);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(43, 13);
this->label4->TabIndex = 3;
this->label4->Text = L"KALOR";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(201, 114);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(121, 20);
this->textBox1->TabIndex = 4;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(201, 143);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(121, 20);
this->textBox2->TabIndex = 5;
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(201, 81);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 6;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// button1
//
this->button1->Location = System::Drawing::Point(24, 203);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(99, 43);
this->button1->TabIndex = 7;
this->button1->Text = L"TES KONEKSI";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(169, 203);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(93, 43);
this->button2->TabIndex = 8;
this->button2->Text = L"LOAD DATA";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(21, 272);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(133, 13);
this->label5->TabIndex = 9;
this->label5->Text = L"nb: kalor air 4200 (J/KG C)";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(39, 295);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(98, 13);
this->label6->TabIndex = 10;
this->label6->Text = L"delta T stabil (20 C)";
//
// button3
//
this->button3->Location = System::Drawing::Point(307, 203);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(93, 43);
this->button3->TabIndex = 11;
this->button3->Text = L"Reset";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// button4
//
this->button4->Location = System::Drawing::Point(307, 299);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(93, 43);
this->button4->TabIndex = 12;
this->button4->Text = L"Quit";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(412, 354);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=termo;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from suhu", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=termo;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from suhu", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data ");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("massa"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=termo;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from suhu where massa = '" + comboBox1-
>Text + "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox1->Text = (myReader->GetString("kalor jenis"));
textBox2->Text = (myReader->GetInt32("kalor").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
textBox2->Text = "";
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
};
}
PR 3 12237
Database
Cek Koneksi

Load Data
Hitung

Reset
Cari

Insert
Update
Delete
Program
#pragma once

namespace pr3elmes {
int kode;

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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
protected:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Button^ button6;
private: System::Windows::Forms::Button^ button7;
private: System::Windows::Forms::Button^ button8;
private: System::Windows::Forms::Button^ button9;

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->label1 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label4 = (gcnew System::Windows::Forms::Label());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->button6 = (gcnew System::Windows::Forms::Button());
this->button7 = (gcnew System::Windows::Forms::Button());
this->button8 = (gcnew System::Windows::Forms::Button());
this->button9 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F,
System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
this->label1->Location = System::Drawing::Point(12, 27);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(445, 25);
this->label1->TabIndex = 0;
this->label1->Text = L"CARA MENGHITUNG MODUL RODA GIGI";
//
// button1
//
this->button1->Location = System::Drawing::Point(34, 59);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 25);
this->button1->TabIndex = 1;
this->button1->Text = L"CEKK";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
this->label2->Location = System::Drawing::Point(31, 110);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(49, 13);
this->label2->TabIndex = 2;
this->label2->Text = L"Diameter";
//
// label3
//
this->label3->AutoSize = true;
this->label3->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
this->label3->Location = System::Drawing::Point(31, 146);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(88, 13);
this->label3->TabIndex = 3;
this->label3->Text = L"Jumlah Roda gigi";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(123, 107);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 4;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(123, 143);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(121, 20);
this->textBox1->TabIndex = 5;
//
// label4
//
this->label4->AutoSize = true;
this->label4->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
this->label4->Location = System::Drawing::Point(31, 236);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(36, 13);
this->label4->TabIndex = 6;
this->label4->Text = L"Modul";
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(123, 233);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(121, 20);
this->textBox2->TabIndex = 7;
//
// button2
//
this->button2->Location = System::Drawing::Point(143, 178);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 40);
this->button2->TabIndex = 8;
this->button2->Text = L"HITUNG";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(348, 57);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(75, 27);
this->button3->TabIndex = 9;
this->button3->Text = L"LOAD";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// button5
//
this->button5->Location = System::Drawing::Point(300, 172);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(75, 23);
this->button5->TabIndex = 11;
this->button5->Text = L"INSERT";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
//
// button4
//
this->button4->Location = System::Drawing::Point(300, 143);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(75, 23);
this->button4->TabIndex = 12;
this->button4->Text = L"CARI";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(287, 110);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(100, 20);
this->textBox3->TabIndex = 13;
//
// button6
//
this->button6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F));
this->button6->Location = System::Drawing::Point(300, 201);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(75, 23);
this->button6->TabIndex = 14;
this->button6->Text = L"UPDATE";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
//
// button7
//
this->button7->Location = System::Drawing::Point(300, 233);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(75, 23);
this->button7->TabIndex = 15;
this->button7->Text = L"DELETE";
this->button7->UseVisualStyleBackColor = true;
this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click);
//
// button8
//
this->button8->Location = System::Drawing::Point(82, 262);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(87, 47);
this->button8->TabIndex = 16;
this->button8->Text = L"RESET";
this->button8->UseVisualStyleBackColor = true;
this->button8->Click += gcnew System::EventHandler(this, &MyForm::button8_Click);
//
// button9
//
this->button9->Location = System::Drawing::Point(213, 262);
this->button9->Name = L"button9";
this->button9->Size = System::Drawing::Size(87, 47);
this->button9->TabIndex = 17;
this->button9->Text = L"QUIT";
this->button9->UseVisualStyleBackColor = true;
this->button9->Click += gcnew System::EventHandler(this, &MyForm::button9_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::Highlight;
this->ClientSize = System::Drawing::Size(484, 321);
this->Controls->Add(this->button9);
this->Controls->Add(this->button8);
this->Controls->Add(this->button7);
this->Controls->Add(this->button6);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->button4);
this->Controls->Add(this->button5);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->label4);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->button1);
this->Controls->Add(this->label1);
this->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ xxx = L"database=pr3elmes;datasource=localhost;port=3306;username=root;password=";
MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from modul", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=pr3elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from modul", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data ");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("dia"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=pr3elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from modul where dia = '" + comboBox1->Text
+ "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));

textBox1->Text = (myReader->GetInt32("gigi").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

float d, m, z;

if (comboBox1->SelectedIndex == 0) d=50;
if (comboBox1->SelectedIndex == 1) d=100;
if (comboBox1->SelectedIndex == 2) d=120;
if (comboBox1->SelectedIndex == 3) d=200;

z = Convert::ToDouble(textBox1->Text);

m = d / z;

textBox2->Text = Convert::ToString(m);

}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=pr3elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from modul where dia like '%" + textBox3-
>Text + "%';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("dia"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {
String^ xxx = L"database=pr3elmes;datasource=localhost;port=3306;username=root;password=";
MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("insert into modul(dia,gigi) values('" + this->comboBox1-
>Text + "','" + this->textBox1->Text + "') ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Disimpan");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=pr3elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("update modul set dia ='" + this->comboBox1->Text + "',
gigi = '" + this->textBox1->Text + "' where id = " + kode + " ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Diupdate");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=pr3elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("delete from modul where dia = '" + this->comboBox1-
>Text + "' and gigi = '" + this->textBox1->Text + "' ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Dihapus");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
textBox2->Text = "";
textBox3->Text = "";

}
private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
};
}

PR4 12237
Cek Koneksi
Load Data
Hitung
Reset
Cari
Update
Insert
Delete
Program
#pragma once

namespace pe3elmes {
int kode;

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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
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::Label^ label4;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
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::Label^ label5;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::TextBox^ textBox4;
private: System::Windows::Forms::Button^ button6;
private: System::Windows::Forms::Button^ INPUT;
private: System::Windows::Forms::Button^ button7;
private: System::Windows::Forms::Button^ button8;

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->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (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->label5 = (gcnew System::Windows::Forms::Label());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label6 = (gcnew System::Windows::Forms::Label());
this->button5 = (gcnew System::Windows::Forms::Button());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
this->button6 = (gcnew System::Windows::Forms::Button());
this->INPUT = (gcnew System::Windows::Forms::Button());
this->button7 = (gcnew System::Windows::Forms::Button());
this->button8 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12,
static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)),
System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(137, 34);
this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(298, 20);
this->label1->TabIndex = 0;
this->label1->Text = L"MENGHITUNG RPM MESIN BUBUT";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->Location = System::Drawing::Point(33, 90);
this->label2->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(56, 16);
this->label2->TabIndex = 1;
this->label2->Text = L"Material";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label3->Location = System::Drawing::Point(33, 138);
this->label3->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(73, 16);
this->label3->TabIndex = 2;
this->label3->Text = L"CS (m/min)";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label4->Location = System::Drawing::Point(33, 178);
this->label4->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(96, 16);
this->label4->TabIndex = 3;
this->label4->Text = L"Diameter (mm)";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(141, 82);
this->comboBox1->Margin = System::Windows::Forms::Padding(4);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(160, 24);
this->comboBox1->TabIndex = 4;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(141, 132);
this->textBox1->Margin = System::Windows::Forms::Padding(4);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(160, 22);
this->textBox1->TabIndex = 5;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(141, 176);
this->textBox2->Margin = System::Windows::Forms::Padding(4);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(160, 22);
this->textBox2->TabIndex = 6;
//
// button1
//
this->button1->Location = System::Drawing::Point(363, 80);
this->button1->Margin = System::Windows::Forms::Padding(4);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(100, 28);
this->button1->TabIndex = 7;
this->button1->Text = L"CEK!!!";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(363, 116);
this->button2->Margin = System::Windows::Forms::Padding(4);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(100, 28);
this->button2->TabIndex = 8;
this->button2->Text = L"LOAD";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(168, 242);
this->button3->Margin = System::Windows::Forms::Padding(4);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(100, 55);
this->button3->TabIndex = 9;
this->button3->Text = L"HITUNG";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// button4
//
this->button4->Location = System::Drawing::Point(363, 204);
this->button4->Margin = System::Windows::Forms::Padding(4);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(100, 28);
this->button4->TabIndex = 10;
this->button4->Text = L"RESET";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(43, 311);
this->label5->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(46, 16);
this->label5->TabIndex = 11;
this->label5->Text = L"HASIL";
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(140, 305);
this->textBox3->Margin = System::Windows::Forms::Padding(4);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(160, 22);
this->textBox3->TabIndex = 12;
this->textBox3->TextChanged += gcnew System::EventHandler(this,
&MyForm::textBox3_TextChanged);
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(137, 204);
this->label6->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(131, 16);
this->label6->TabIndex = 13;
this->label6->Text = L"nb: isi diameter (mm)";
//
// button5
//
this->button5->Location = System::Drawing::Point(216, 402);
this->button5->Margin = System::Windows::Forms::Padding(4);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(100, 28);
this->button5->TabIndex = 14;
this->button5->Text = L"CARI";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(141, 358);
this->textBox4->Margin = System::Windows::Forms::Padding(4);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(252, 22);
this->textBox4->TabIndex = 15;
//
// button6
//
this->button6->Location = System::Drawing::Point(363, 240);
this->button6->Margin = System::Windows::Forms::Padding(4);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(100, 28);
this->button6->TabIndex = 16;
this->button6->Text = L"UPDATE";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
//
// INPUT
//
this->INPUT->Location = System::Drawing::Point(363, 278);
this->INPUT->Margin = System::Windows::Forms::Padding(4);
this->INPUT->Name = L"INPUT";
this->INPUT->Size = System::Drawing::Size(100, 28);
this->INPUT->TabIndex = 17;
this->INPUT->Text = L"INPUT";
this->INPUT->UseVisualStyleBackColor = true;
this->INPUT->Click += gcnew System::EventHandler(this, &MyForm::INPUT_Click);
//
// button7
//
this->button7->Location = System::Drawing::Point(363, 322);
this->button7->Margin = System::Windows::Forms::Padding(4);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(100, 28);
this->button7->TabIndex = 18;
this->button7->Text = L"DELETE";
this->button7->UseVisualStyleBackColor = true;
this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click);
//
// button8
//
this->button8->Location = System::Drawing::Point(384, 391);
this->button8->Margin = System::Windows::Forms::Padding(4);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(139, 69);
this->button8->TabIndex = 19;
this->button8->Text = L"QUIT";
this->button8->UseVisualStyleBackColor = true;
this->button8->Click += gcnew System::EventHandler(this, &MyForm::button8_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::Info;
this->ClientSize = System::Drawing::Size(539, 475);
this->Controls->Add(this->button8);
this->Controls->Add(this->button7);
this->Controls->Add(this->INPUT);
this->Controls->Add(this->button6);
this->Controls->Add(this->textBox4);
this->Controls->Add(this->button5);
this->Controls->Add(this->label6);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->label5);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F,
System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->Margin = System::Windows::Forms::Padding(4);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from rpm", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from rpm", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data ");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("bahan"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from rpm where bahan = '" + comboBox1->Text
+ "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox1->Text = (myReader->GetInt32("cs").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

float ca, d, n,hsl;

ca = Convert::ToDouble(textBox1->Text);
d = Convert::ToDouble(textBox2->Text);

hsl = (ca * 1000) / (3.14*d);

textBox3->Text = Convert::ToString(hsl);

}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
textBox2->Text = "";
textBox3->Text = "";

}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from rpm where bahan like '%" + textBox3-
>Text + "%';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("bahan"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("update rpm set bahan ='" + this->comboBox1->Text + "',
cs = '" + this->textBox1->Text + "' where id = " + kode + " ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Diupdate");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void INPUT_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("insert into rpm(bahan,cs) values('" + this->comboBox1-
>Text + "','" + this->textBox1->Text + "') ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Disimpan");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=elmes;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("delete from rpm where bahan = '" + this->comboBox1-
>Text + "' and cs = '" + this->textBox1->Text + "' ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Dihapus");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
private: System::Void textBox3_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
};
}

PR1_12361
1. PR1_ELMES_12361
Database

Tampilan form
Cek koneksi

Load data
Hasil
Program
#pragma once
int kode;

namespace elmes {

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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
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::Label^ label4;
private: System::Windows::Forms::ComboBox^ comboBox1;

private: System::Windows::Forms::Button^ button2;


private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Label^ label6;

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->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->label5 = (gcnew System::Windows::Forms::Label());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label6 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(163, 9);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(115, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"MENENTUKAN GAYA";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(12, 48);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(88, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"DIAMETER (CM)";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(12, 87);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(96, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"TEBAL PLAT (CM)";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(12, 130);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(151, 13);
this->label4->TabIndex = 3;
this->label4->Text = L"TEGANGAN GESER (N/CM^)";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(173, 48);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(105, 21);
this->comboBox1->TabIndex = 4;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// button2
//
this->button2->Location = System::Drawing::Point(324, 48);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(101, 33);
this->button2->TabIndex = 10;
this->button2->Text = L"tes koneksi";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(324, 120);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(101, 33);
this->button3->TabIndex = 11;
this->button3->Text = L"Load Data";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(173, 87);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(105, 20);
this->textBox1->TabIndex = 12;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(173, 127);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(105, 20);
this->textBox2->TabIndex = 13;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(12, 169);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(53, 13);
this->label5->TabIndex = 14;
this->label5->Text = L"GAYA (N)";
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(173, 169);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(105, 20);
this->textBox3->TabIndex = 15;
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(12, 238);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(126, 13);
this->label6->TabIndex = 16;
this->label6->Text = L"nb=tegangan geser tetap";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::ActiveCaption;
this->ClientSize = System::Drawing::Size(473, 276);
this->Controls->Add(this->label6);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->label5);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=elemen;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from diameter", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses Bro !!!");
while (myReader->Read())
{
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
comboBox1->Items->Clear();
comboBox1->Text = "";
String^ xxx = L"database=elemen;datasource=localhost;port=3306; username = root; password = " ;
MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from diameter", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data Service");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("ukuran"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
{
String^ xxx = L"database=elemen;datasource=localhost;port=3306;username=root;password=";
MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from diameter where ukuran = '" + comboBox1-
>Text + "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox1->Text = (myReader->GetString("tebal"));
textBox2->Text = (myReader->GetString("tegser"));
textBox3->Text = (myReader->GetInt32("gaya").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
};
}

2. PR2_THERMO_12361
Database
Tampilan form

Cek koneksi
Load data

Hasil
Program
#pragma once

namespace thermoku {
int kode;
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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
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::ComboBox^ comboBox1;
private: System::Windows::Forms::ComboBox^ comboBox2;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Button^ button3;

private: System::Windows::Forms::Button^ button5;


private: System::Windows::Forms::Button^ button6;

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->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label4 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Modern No. 20", 15.75F,
System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(53, 9);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(286, 24);
this->label1->TabIndex = 0;
this->label1->Text = L"Menentukan Kapasitas Kalor";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F));
this->label2->Location = System::Drawing::Point(3, 66);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(77, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"Temperatur (C)";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(3, 98);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(131, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"Kalor Yang Dibutuhkan (J)";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(135, 66);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 3;
//
// comboBox2
//
this->comboBox2->FormattingEnabled = true;
this->comboBox2->Location = System::Drawing::Point(135, 98);
this->comboBox2->Name = L"comboBox2";
this->comboBox2->Size = System::Drawing::Size(121, 21);
this->comboBox2->TabIndex = 4;
//
// button1
//
this->button1->Location = System::Drawing::Point(291, 66);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(65, 21);
this->button1->TabIndex = 5;
this->button1->Text = L"cek";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(291, 98);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(65, 21);
this->button2->TabIndex = 6;
this->button2->Text = L"load";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(3, 138);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(106, 13);
this->label4->TabIndex = 7;
this->label4->Text = L"Kapasitas Kalor (J/C)";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(135, 138);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(121, 20);
this->textBox1->TabIndex = 8;
//
// button3
//
this->button3->Location = System::Drawing::Point(291, 138);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(65, 20);
this->button3->TabIndex = 9;
this->button3->Text = L"hitung";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// button5
//
this->button5->Location = System::Drawing::Point(100, 183);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(75, 23);
this->button5->TabIndex = 11;
this->button5->Text = L"reset";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
//
// button6
//
this->button6->Location = System::Drawing::Point(181, 183);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(75, 23);
this->button6->TabIndex = 12;
this->button6->Text = L"keluar";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::InactiveCaption;
this->ClientSize = System::Drawing::Size(378, 251);
this->Controls->Add(this->button6);
this->Controls->Add(this->button5);
this->Controls->Add(this->button3);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label4);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->comboBox2);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from kapasitas", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}

}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from kapasitas", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data ");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("temperatur"));
comboBox2->Items->Add(myReader->GetString("kalor"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
float a, b, c;

if (comboBox1->SelectedIndex == 0) a = 10;
if (comboBox1->SelectedIndex == 1) a = 50;
if (comboBox1->SelectedIndex == 2) a = 70;

if (comboBox2->SelectedIndex == 0) b = 25000;
if (comboBox2->SelectedIndex == 1) b = 50000;
if (comboBox2->SelectedIndex == 2) b = 70000;

c = b / a;

textBox1->Text = Convert::ToString(c);

}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
comboBox2->Items->Clear();
comboBox2->Text = "";
}
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {

Close();
}
};
}

3. PR3_ELMES_12361
Database

Tampilan form
Cek koneksi

Load data
Hitung
Input

Update

Hapus
Search

Program
#pragma once

namespace usaha {
int kode;
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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
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::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::ComboBox^ comboBox2;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;

private: System::Windows::Forms::Button^ button7;


private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button6;
private: System::Windows::Forms::Button^ button8;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Button^ button9;
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->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
this->textBox1 = (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->button7 = (gcnew System::Windows::Forms::Button());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->button4 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->button8 = (gcnew System::Windows::Forms::Button());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->button9 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F,
static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)),
System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(112, 9);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(209, 25);
this->label1->TabIndex = 0;
this->label1->Text = L"Menghitung Usaha";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(16, 70);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(96, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"volume awal (M^3)";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(16, 102);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(97, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"volume akhir (M^3)";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(16, 138);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(88, 13);
this->label4->TabIndex = 3;
this->label4->Text = L"tekanan gas (Pa)";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(16, 174);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(62, 13);
this->label5->TabIndex = 4;
this->label5->Text = L"hasil (Joule)";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(135, 70);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 5;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// comboBox2
//
this->comboBox2->FormattingEnabled = true;
this->comboBox2->Location = System::Drawing::Point(135, 99);
this->comboBox2->Name = L"comboBox2";
this->comboBox2->Size = System::Drawing::Size(121, 21);
this->comboBox2->TabIndex = 6;
this->comboBox2->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox2_SelectedIndexChanged);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(135, 138);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(121, 20);
this->textBox1->TabIndex = 8;
this->textBox1->TextChanged += gcnew System::EventHandler(this,
&MyForm::textBox1_TextChanged);
//
// button1
//
this->button1->Location = System::Drawing::Point(276, 68);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 9;
this->button1->Text = L"cek";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(368, 70);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 10;
this->button2->Text = L"load";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(321, 102);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(75, 23);
this->button3->TabIndex = 11;
this->button3->Text = L"hitung";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// button7
//
this->button7->Location = System::Drawing::Point(321, 204);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(75, 23);
this->button7->TabIndex = 15;
this->button7->Text = L"reset";
this->button7->UseVisualStyleBackColor = true;
this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click);
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(135, 177);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(121, 20);
this->textBox2->TabIndex = 16;
//
// button4
//
this->button4->Location = System::Drawing::Point(368, 136);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(75, 23);
this->button4->TabIndex = 17;
this->button4->Text = L"update";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this,
&MyForm::button4_Click_1);
//
// button5
//
this->button5->Location = System::Drawing::Point(321, 175);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(75, 23);
this->button5->TabIndex = 18;
this->button5->Text = L"hapus";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this,
&MyForm::button5_Click_1);
//
// button6
//
this->button6->Location = System::Drawing::Point(276, 135);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(75, 23);
this->button6->TabIndex = 19;
this->button6->Text = L"input";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this,
&MyForm::button6_Click_1);
//
// button8
//
this->button8->Location = System::Drawing::Point(157, 252);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(75, 23);
this->button8->TabIndex = 20;
this->button8->Text = L"search";
this->button8->UseVisualStyleBackColor = true;
this->button8->Click += gcnew System::EventHandler(this, &MyForm::button8_Click);
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(135, 215);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(121, 20);
this->textBox3->TabIndex = 21;
//
// button9
//
this->button9->Location = System::Drawing::Point(321, 252);
this->button9->Name = L"button9";
this->button9->Size = System::Drawing::Size(75, 23);
this->button9->TabIndex = 22;
this->button9->Text = L"keluar";
this->button9->UseVisualStyleBackColor = true;
this->button9->Click += gcnew System::EventHandler(this, &MyForm::button9_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::GradientActiveCaption;
this->ClientSize = System::Drawing::Size(470, 323);
this->Controls->Add(this->button9);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->button8);
this->Controls->Add(this->button6);
this->Controls->Add(this->button5);
this->Controls->Add(this->button4);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->button7);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->comboBox2);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from usaha", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from usaha", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data ");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("vol_awal"));
comboBox2->Items->Add(myReader->GetString("vol_akhir"));

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

float v1, v2, p, dv,w;


if (comboBox1->SelectedIndex == 0) v1 = 3;
if (comboBox1->SelectedIndex == 1) v1 = 5;
if (comboBox1->SelectedIndex == 2) v1 = 6;

if (comboBox2->SelectedIndex == 0) v2 = 6;
if (comboBox2->SelectedIndex == 1) v2 = 7;
if (comboBox2->SelectedIndex == 2) v2 = 10;

p = Convert::ToDouble(textBox1->Text);
dv = v2 - v1;
w = p*dv;

textBox2->Text = Convert::ToString(w);

}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("update usaha set vol_awal ='" + this->comboBox1->Text
+ "', vol_akhir = '" + this->comboBox2->Text + "' where id = " + kode + " ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Diupdate");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {

}
private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
textBox2->Text = "";
comboBox2->Items->Clear();
comboBox2->Text = "";

}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

}
private: System::Void comboBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

}
private: System::Void button4_Click_1(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("update usaha set vol_awal ='" + this->comboBox1->Text
+ "', vol_akhir = '" + this->comboBox2->Text + "' where id = " + kode + " ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Diupdate");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button6_Click_1(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("insert into usaha(vol_awal,vol_akhir) values('" + this-
>comboBox1->Text + "','" + this->comboBox2->Text + "') ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Disimpan");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button5_Click_1(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("delete from usaha where vol_awal = '" + this-
>comboBox1->Text + "' and vol_akhir = '" + this->comboBox2->Text + "' ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Dihapus");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from usaha where vol_awal like '%" + textBox3-
>Text + "%';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("vol_awal"));

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e) {

{
Close();
}
}
};
}

4. PR4_THERMO_12361
Database
Tampilan form
Cek koneksi

Load data
Hitung

Update
Input
Search
Program
#pragma once

namespace energi {
int kode;
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();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
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::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::TextBox^ textBox4;
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::Button^ button6;
private: System::Windows::Forms::TextBox^ textBox5;
private: System::Windows::Forms::Button^ button7;

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->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->textBox4 = (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->button6 = (gcnew System::Windows::Forms::Button());
this->textBox5 = (gcnew System::Windows::Forms::TextBox());
this->button7 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(104, 9);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(180, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"menentukan energi yang dibutuhkan";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(49, 71);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(45, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"jenis zat";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(49, 111);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(64, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"masasa (kg)";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(49, 149);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(72, 13);
this->label4->TabIndex = 3;
this->label4->Text = L"temperatur (c)";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(49, 188);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(91, 13);
this->label5->TabIndex = 4;
this->label5->Text = L"kalor jenis (j/kg c)";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(49, 235);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(28, 13);
this->label6->TabIndex = 5;
this->label6->Text = L"hasil";
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Location = System::Drawing::Point(163, 68);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(144, 21);
this->comboBox1->TabIndex = 6;
this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this,
&MyForm::comboBox1_SelectedIndexChanged);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(163, 104);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(100, 20);
this->textBox1->TabIndex = 7;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(163, 149);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(100, 20);
this->textBox2->TabIndex = 8;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(163, 188);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(100, 20);
this->textBox3->TabIndex = 9;
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(163, 228);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(100, 20);
this->textBox4->TabIndex = 10;
//
// button1
//
this->button1->Location = System::Drawing::Point(324, 66);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 11;
this->button1->Text = L"cek";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(324, 147);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 12;
this->button2->Text = L"hitung";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(324, 225);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(75, 23);
this->button3->TabIndex = 13;
this->button3->Text = L"input";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// button4
//
this->button4->Location = System::Drawing::Point(324, 102);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(75, 23);
this->button4->TabIndex = 14;
this->button4->Text = L"load";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
//
// button5
//
this->button5->Location = System::Drawing::Point(324, 188);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(75, 23);
this->button5->TabIndex = 15;
this->button5->Text = L"update";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
//
// button6
//
this->button6->Location = System::Drawing::Point(324, 263);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(75, 23);
this->button6->TabIndex = 16;
this->button6->Text = L"reset";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
//
// textBox5
//
this->textBox5->Location = System::Drawing::Point(163, 263);
this->textBox5->Name = L"textBox5";
this->textBox5->Size = System::Drawing::Size(100, 20);
this->textBox5->TabIndex = 17;
//
// button7
//
this->button7->Location = System::Drawing::Point(176, 289);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(75, 23);
this->button7->TabIndex = 18;
this->button7->Text = L"search";
this->button7->UseVisualStyleBackColor = true;
this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(411, 372);
this->Controls->Add(this->button7);
this->Controls->Add(this->textBox5);
this->Controls->Add(this->button6);
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->textBox4);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";
MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from energi", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from energi", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Load Data ");
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("jenis"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from energi where jenis = '" + comboBox1-
>Text + "';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{

kode = (myReader->GetInt32("id"));
textBox1->Text = (myReader->GetString("massa"));
textBox2->Text = (myReader->GetString("temperatur"));
textBox3->Text = (myReader->GetInt32("kalor_jenis").ToString());
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

float m, c, t, q;

m = Convert::ToDouble(textBox1->Text);
t = Convert::ToDouble(textBox2->Text);
c = Convert::ToDouble(textBox3->Text);

q = m*c*t;

textBox4->Text = Convert::ToString(q);
}

private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("update energi set massa ='" + this->textBox1->Text + "',
temperatur = '" + this->textBox2->Text + "',kalor_jenis ='" + this->textBox3->Text + "' where id = " + kode + " ; ",
yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Diupdate");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("insert into energi(jenis,massa,temperatur,kalor_jenis)
values('" + this->comboBox1->Text + "','" + this->textBox1->Text + "','" + this->textBox2->Text + "','" + this-
>textBox3->Text + "') ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Disimpan");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->Items->Clear();
comboBox1->Text = "";
textBox1->Text = "";
textBox2->Text = "";
textBox3->Text = "";
textBox4->Text = "";
}
private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from energi where jenis like '%" + textBox5-
>Text + "%';", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
while (myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("jenis"));
}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {

String^ xxx = L"database=thermoku2;datasource=localhost;port=3306;username=root;password=";


MySqlConnection^ yyy = gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("delete from energi where jenis = '" + this->comboBox1-
>Text + "',massa = '" + this->textBox1->Text + "' ,temperatur = '" + this->textBox2->Text + "' and kalor_jenis = '" +
this->textBox3->Text + "' ; ", yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader = nnn->ExecuteReader();
MessageBox::Show("Data Dihapus");
while (myReader->Read())
{

}
yyy->Close();
}
catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}
}
;
}

You might also like