8/18/2019 Prokom Kom
1/26
LAPORAN PRATIKUM
PEMROGRAMAN KOMPUTER II
disusun oleh:
RAMADHAN FEBRIANTO (03714)
KELAS C1
KOMPUTER 3
DEPARTEMEN TEKNIK MESIN SEKOLAH VOKASI
UNIVERSITAS GAJAH MADA YOGYAKARTA
2015
8/18/2019 Prokom Kom
2/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 2
DAFTAR ISI
A. LATIHAN TUGAS
Load Data Produk..................................................................................................... 4
Manage Data Produk................................................................................................ 9
B.
LATIHAN PR
Menghitung Volume Tangki Tabel A5....................................................................18
Menghitung Volume dan Energi Dalam Tabel A7..................................................21
8/18/2019 Prokom Kom
3/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 3
LATIHAN 1 (LOAD DATA)
Database Latihan 2
8/18/2019 Prokom Kom
4/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 4
float a,b,c,d,r,f,w,total;
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;
private: System::Void button5_Click(System::Object^ sender,
System::EventArgs^ e) {
String^ xxx
=L"database=bngkel;datasource=localhost;port=3306;username=root;password
=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select *
from tbl_ban",yyy); MySqlDataReader^ myReader;
try
{ yyy->Open();myReader=nnn->ExecuteReader();
MessageBox::Show("Koneksi Done !!!");
while(myReader->Read()) { } yyy->Close(); }
catch(Exception^ ex) { MessageBox::Show(ex->Message); }}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e) {
comboBox1->Items->Clear();comboBox1->Text="";
textBox1->Text="";textBox2->Text="";
String^ xxx
=L"database=bngkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select *
from tbl_servis",yyy);MySqlDataReader^ myReader;
8/18/2019 Prokom Kom
5/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 5
try {
yyy->Open();
myReader=nnn->ExecuteReader();
MessageBox::Show("Load Data Servis");while(myReader->Read()){ comboBox1->Items->Add(myReader-
>GetString("nama")); }
yyy->Close(); }
catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^
sender, System::EventArgs^ e)
{
String^ xxx = L"database=bngkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("select * from tbl_servis
where nama = '" + comboBox1->Text + "';" ,yyy);
MySqlDataReader^ myReader; try { yyy->Open(); myReader=nnn-
>ExecuteReader();
while(myReader->Read())
{ textBox1->Text = (myReader->GetString("nama")) ;textBox2->Text = (myReader->GetInt32("harga").ToString()) ;
textBox10->Text = (myReader->GetInt32("harga").ToString());
} yyy->Close(); }
catch(Exception^ ex){ MessageBox::Show(ex->Message); }
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e) {
comboBox2->Items->Clear();
comboBox2->Text="";
8/18/2019 Prokom Kom
6/26
8/18/2019 Prokom Kom
7/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 7
String^ xxx =
L"database=bngkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);MySqlCommand^ nnn = gcnew MySqlCommand ("select * from tbl_oli
where nama like '%" + listBox1->Text + "%';" ,yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader=nnn->ExecuteReader();MessageBox::Show("Load Data Oli");
while(myReader->Read())
{
listBox1->Items->Add(myReader->GetString("nama")); }
yyy->Close(); } catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }
}
private: System::Void listBox1_SelectedIndexChanged(System::Object^
sender, System::EventArgs^ e) {
String^ xxx =
L"database=bngkel;datasource=localhost;port=3306;username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("select * from tbl_oli where
nama = '" + listBox1->Text + "';" ,yyy);MySqlDataReader^ myReader;
try
{ yyy->Open(); myReader=nnn->ExecuteReader();
while(myReader->Read())
{ textBox5->Text = (myReader->GetString("nama")) ;textBox6->Text = (myReader->GetInt32("harga").ToString());
textBox7->Text = (myReader->GetInt32("stock").ToString());
} yyy->Close(); }
catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }}
8/18/2019 Prokom Kom
8/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 8
private: System::Void button4_Click(System::Object^ sender,System::EventArgs^ e) {
float a,b,c,d,r,f,w,total;
a=Convert::ToDouble(textBox4->Text); b=Convert::ToDouble(textBox8->Text);
c=a*b;
textBox11->Text = Convert::ToString(c);
d=Convert::ToDouble(textBox6->Text);r=Convert::ToDouble(textBox9->Text);
f=d*r;
textBox12->Text = Convert::ToString(f);
w=Convert::ToDouble(textBox10->Text);
total=f+c+w;
label11->Text = Convert::ToString(total);
}};
}
8/18/2019 Prokom Kom
9/26
8/18/2019 Prokom Kom
10/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 10
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;
private: System::Void button1_Click(System::Object^ sender,System::EventArgs^ e)
{
String^ xxx = L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("select * from tbl_service
where jasa like '%" + textBox1->Text + "%';" ,yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader=nnn->ExecuteReader();while(myReader->Read()) {
comboBox1->Items->Add(myReader->GetString("jasa")); }
yyy->Close(); } catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }
}
private: System::Void button5_Click(System::Object^ sender,
System::EventArgs^ e) {
String^ xxx=L"database=manage_bengkel;datasource=localhost;port=3306;username=root;
password=" ;MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select *
from tbl_service",yyy);
MySqlDataReader^ myReader;
try {
yyy->Open(); myReader=nnn->ExecuteReader();
MessageBox::Show("Koneksi Sukses Bro !!!");while(myReader->Read()) { } yyy->Close(); }
8/18/2019 Prokom Kom
11/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 11
catch(Exception^ ex){ MessageBox::Show(ex->Message); }
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^sender, System::EventArgs^ e) {String^ xxx = L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("select * from tbl_service
where jasa = '" + comboBox1->Text + "';" ,yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open(); myReader=nnn->ExecuteReader();
while(myReader->Read())
{ kode = (myReader->GetInt32("id"));
textBox2->Text = (myReader->GetString("jasa")) ;
textBox3->Text = (myReader->GetInt32("Harga").ToString()) ;
}
yyy->Close(); }
catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e) {
String^ xxx =
L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("insert into tbl_service(Jasa,harga) values('" + this->textBox2->Text + "','"+
this->textBox3->Text +"') ;",yyy);MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader=nnn->ExecuteReader();
MessageBox::Show("Data Disimpan");
while(myReader->Read()){ } yyy->Close(); }
8/18/2019 Prokom Kom
12/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 12
catch(Exception^ ex) { MessageBox::Show(ex->Message); }}
private: System::Void button3_Click(System::Object^ sender,
System::EventArgs^ e)
{String^ xxx = L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand
("update tbl_service set Jasa ='" + this->textBox2->Text + "', harga = '"+ 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 button4_Click(System::Object^ sender,
System::EventArgs^ e){
String^ xxx = L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);MySqlCommand^ nnn = gcnew MySqlCommand
("delete from tbl_service where Jasa = '" + this->textBox2->Text + "' and harga
= '"+ 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); }
8/18/2019 Prokom Kom
13/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 13
} private: System::Void button9_Click(System::Object^ sender,
System::EventArgs^ e) {
String^ xxx =
L"database=manage_bengkel;datasource=localhost;port=3306;username=root;password=" ;
MySqlConnection^ yyy= gcnew
MySqlConnection(xxx); MySqlCommand^ nnn = gcnew MySqlCommand
("select * from tbl_oli where nama like '%" + textBox6->Text + "%';" ,yyy);
MySqlDataReader^ myReader;
try
{yyy->Open();
myReader=nnn->ExecuteReader();
while(myReader->Read())
{listBox1->Items->Add(myReader->GetString("nama"));}
yyy->Close(); } catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }
}
private: System::Void listBox1_SelectedIndexChanged(System::Object^
sender, System::EventArgs^ e) {
String^ xxx =
L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("select * from
tbl_oli where Nama = '" + listBox1->Text + "';" ,yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open(); myReader=nnn->ExecuteReader();
while(myReader->Read()){ kode = (myReader->GetInt32("id"));
textBox5->Text = (myReader->GetString("nama")) ;textBox4->Text = (myReader->GetInt32("Harga").ToString()) ;
textBox7->Text = (myReader->GetInt32("Stock").ToString()) ;}
yyy->Close(); }
catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }
}
8/18/2019 Prokom Kom
14/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 14
private: System::Void button8_Click(System::Object^ sender,System::EventArgs^ e) {
}
private: System::Void button7_Click(System::Object^ sender,System::EventArgs^ e) {String^ xxx = L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("update
tbl_oli set nama ='" + this->textBox5->Text + "', harga = '"+ this->textBox4-
>Text +"',harga = '"+ this->textBox7->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(System::Object^ sender,
System::EventArgs^ e) { String^ xxx =
L"database=manage_bengkel;datasource=localhost;port=3306;username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("delete
from tbl_oli where nama = '" + this->textBox5->Text + "' and harga = '"+ this->textBox4->Text +"',and stock = '"+ this->textBox7->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 button13_Click(System::Object^ sender,
System::EventArgs^ e)
{
String^ xxx = L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
8/18/2019 Prokom Kom
15/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 15
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);MySqlCommand^ nnn = gcnew MySqlCommand ("select * from tbl_part where
nama like '%" + textBox10->Text + "%';" ,yyy);
MySqlDataReader^ myReader;
try { yyy->Open();
myReader=nnn->ExecuteReader(); while(myReader->Read())
{ comboBox2->Items->Add(myReader->GetString("nama")); }
yyy->Close(); }catch(Exception^ ex) { MessageBox::Show(ex->Message); }
}
private: System::Void comboBox2_SelectedIndexChanged(System::Object^
sender, System::EventArgs^ e)
{
String^ xxx = L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ; MySqlConnection^ yyy= gcnew
MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand
("select * from tbl_part where nama = '" + comboBox2->Text + "';" ,yyy);MySqlDataReader^ myReader;
try
{yyy->Open();myReader=nnn->ExecuteReader();
while(myReader->Read())
{ kode = (myReader->GetInt32("id"));
textBox9->Text = (myReader->GetString("nama")) ;
textBox8->Text = (myReader->GetInt32("Harga").ToString()) ; }textBox11->Text = (myReader->GetInt32("Stock").ToString());
yyy->Close(); } catch(Exception^ ex) { MessageBox::Show(ex->Message); }
}
8/18/2019 Prokom Kom
16/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 16
private: System::Void button12_Click(System::Object^ sender,System::EventArgs^ e) {
String^ xxx = L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);MySqlCommand^ nnn = gcnew MySqlCommand ("insert
into tbl_part(Jasa,harga,stock) values('" + this->textBox9->Text + "','"+ this-
>textBox8->Text +"','"+ this->textBox11->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 button11_Click(System::Object^ sender,
System::EventArgs^ e) {
String^ xxx =L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("updatetbl_oli set nama ='" + this->textBox9->Text + "', harga = '"+ this->textBox8-
>Text +"',harga = '"+ this->textBox11->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 button10_Click(System::Object^ sender,
System::EventArgs^ e)
{
String^ xxx = L"database=manage_bengkel;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
8/18/2019 Prokom Kom
17/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 17
MySqlCommand^ nnn = gcnew MySqlCommand ("deletefrom tbl_part where nama = '" + this->textBox9->Text + "' and harga = '"+ this-
>textBox8->Text +"',and stock = '"+ this->textBox11->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 button14_Click(System::Object^ sender,
System::EventArgs^ e) {
comboBox1->Items->Clear();
comboBox1->Text="";
comboBox2->Items->Clear();
comboBox2->Text="";
textBox1->Text="";
textBox2->Text="";
textBox3->Text="";
textBox4->Text="";
textBox5->Text="";textBox6->Text="";
textBox7->Text="";
textBox8->Text="";
textBox9->Text="";textBox10->Text="";
textBox11->Text="";
listBox1->Items->Clear();
listBox1->Text="";
} private: System::Void button15_Click(System::Object^ sender,
System::EventArgs^ e) {Close();}
};
}
8/18/2019 Prokom Kom
18/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 18
Latihan PR 1
Database PR 1
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e) {}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
String^
xxx=L"database=db_thermo1;datasource=localhost;port=3306;username=root;password=" ;
8/18/2019 Prokom Kom
19/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 19
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);MySqlCommand^ nnn = gcnew MySqlCommand("select * from
tbl_a5",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 button2_Click(System::Object^ sender,
System::EventArgs^ e) {
comboBox1->Items->Clear();
comboBox1->Text="";
String^ xxx =L"database=db_thermo1;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select *
from tbl_a5",yyy);MySqlDataReader^ myReader;
try { yyy->Open();
myReader=nnn->ExecuteReader();
MessageBox::Show("Load Data A5");while(myReader->Read())
{ comboBox1->Items->Add(myReader->GetString("T"));
}
yyy->Close(); } catch(Exception^ ex) {MessageBox::Show(ex->Message); }
}
private: System::Void button3_Click(System::Object^ sender,
System::EventArgs^ e) {
float T,p,vf,vg,V,massa;
massa=Convert::ToDouble(textBox1->Text);
8/18/2019 Prokom Kom
20/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 20
if (comboBox1->SelectedIndex == 0) V=massa*0.001033;if (comboBox1->SelectedIndex == 1) V=massa*0.001036;
if (checkBox1->Checked)
label7->Text = Convert::ToString(V);}
private: System::Void textBox1_TextChanged(System::Object^ sender,
System::EventArgs^ e) {
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^
sender, System::EventArgs^ e) {String^ xxx =
L"database=db_thermo1;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("select * from tbl_a5
where T like '%" + comboBox1->Text + "%';" ,yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();
myReader=nnn->ExecuteReader();
while(myReader->Read())
{
textBox2->Text = (myReader->GetDouble("p").ToString()) ;
textBox3->Text = (myReader->GetDouble("vg").ToString()) ;textBox4->Text = (myReader->GetDouble("vf").ToString()) ; }
yyy->Close(); } catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }
}
};}
8/18/2019 Prokom Kom
21/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 21
Latihan PR 2
Database PR 2
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;
8/18/2019 Prokom Kom
22/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 22
private: System::Void button1_Click(System::Object^ sender,System::EventArgs^ e)
{
String^ xxx=L"database=pr2;datasource=localhost;port=3306;username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand("select * from
tbl_a5",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) {
comboBox1->Items->Clear();
comboBox1->Text="";
String^ xxx = L"database=pr2;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand ("select * from tbl_a5where suhu like '%" + comboBox1->Text + "%';" ,yyy);
MySqlDataReader^ myReader;
try
{
yyy->Open();myReader=nnn->ExecuteReader();
MessageBox::Show("Load Data Suhu");while(myReader->Read())
{
comboBox1->Items->Add(myReader->GetString("suhu")); }
yyy->Close(); } catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }
}
8/18/2019 Prokom Kom
23/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 23
private: System::Void comboBox1_SelectedIndexChanged(System::Object^sender, System::EventArgs^ e)
{
String^ xxx = L"database=pr2;datasource=localhost;port=3306;
username=root;password=" ;MySqlConnection^ yyy= gcnew MySqlConnection(xxx);MySqlCommand^ nnn = gcnew MySqlCommand ("select * from tbl_a5 where
suhu = '" + comboBox1->Text + "';" ,yyy);
MySqlDataReader^ myReader; try { yyy->Open(); myReader=nnn-
>ExecuteReader();
while(myReader->Read())
{ textBox1->Text = (myReader->GetDouble("vf").ToString()) ;
textBox2->Text = (myReader->GetDouble("vg").ToString()) ;
textBox3->Text = (myReader->GetDouble("uf").ToString()) ;
textBox4->Text = (myReader->GetDouble("ug").ToString()) ;
} yyy->Close(); }
catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }
}
private: System::Void button3_Click(System::Object^ sender,
System::EventArgs^ e) {
double m,V,uf,ug,vf,vg,x,v1,u;
uf=Convert::ToDouble(textBox3->Text);ug=Convert::ToDouble(textBox4->Text);
x=Convert::ToDouble(textBox8->Text);
u=uf+x*(ug-uf);
label9->Text = Convert::ToString(u);
}
private: System::Void button4_Click(System::Object^ sender,System::EventArgs^ e) {
double m,V,uf,ug,vf,vg,x,v1,u;
vf=Convert::ToDouble(textBox1->Text);
vg=Convert::ToDouble(textBox2->Text);
x=Convert::ToDouble(textBox8->Text);
v1=vf+x*(vg-vf);label10->Text = Convert::ToString(v1);
8/18/2019 Prokom Kom
24/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 24
}
private: System::Void button5_Click(System::Object^ sender,
System::EventArgs^ e) {double Q,m,u,v1;
m=Convert::ToDouble(textBox6->Text);
u=Convert::ToDouble(label9->Text);
v1=Convert::ToDouble(label10->Text);
Q=m*(u-v1);
label7->Text = Convert::ToString(Q);}
private: System::Void button7_Click(System::Object^ sender,
System::EventArgs^ e) {
Close();
}
private: System::Void button6_Click(System::Object^ sender,
System::EventArgs^ e) {
comboBox1->Items->Clear();
comboBox1->Text="";
textBox1->Text="";
textBox2->Text="";textBox3->Text="";
textBox4->Text="";
textBox6->Text="";textBox8->Text="";
label9->Text="";
label7->Text="";
label10->Text="";
} private: System::Void button8_Click(System::Object^ sender,
System::EventArgs^ e){
String^ xxx = L"database=pr2;datasource=localhost;port=3306;
username=root;password=" ;MySqlConnection^ yyy= gcnew
MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand
("insert into tbl_a5(vf,vg,uf,ug) values('" + this->textBox1->Text + "','"+ this-
>textBox2->Text +"','"+ this->textBox3->Text +"','"+ this->textBox4->Text+"') ;",yyy);MySqlDataReader^ myReader;
8/18/2019 Prokom Kom
25/26
DEPARTEMEN TEKNIK MESIN SV UGM | PEMROGRAMAN KOMPUTER II 25
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 button9_Click(System::Object^ sender,
System::EventArgs^ e)
{String^ xxx = L"database=pr2;datasource=localhost;port=3306;
username=root;password=" ;
MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand
("update tbl_a5 set vf ='" + this->textBox1->Text + "', vg = '"+ this->textBox2-
>Text +"', uf = '"+ this->textBox3->Text +"', ug = '"+ this->textBox4->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 button10_Click(System::Object^ sender,
System::EventArgs^ e)
{String^ xxx = L"database=pr2;datasource=localhost;port=3306;
username=root;password=" ;MySqlConnection^ yyy= gcnew MySqlConnection(xxx);
MySqlCommand^ nnn = gcnew MySqlCommand
("delete from tbl_a5 where vf = '" + this->textBox1->Text + "' and vg = '"+ this-
>textBox2->Text +"'and uf ='"+ this->textBox3->Text +"' and ug = '"+ this-
>textBox4->Text +"' ; ",yyy);
MySqlDataReader^ myReader;
8/18/2019 Prokom Kom
26/26
try { yyy->Open();
myReader=nnn->ExecuteReader();
MessageBox::Show("Data Dihapus");
while(myReader->Read()){}
yyy->Close(); }
catch(Exception^ ex)
{ MessageBox::Show(ex->Message); }
}
};}