Perbandingan Metode Profile Matching dan Topsis Dalam Sistem Pendukung Keputusan Untuk Menentukan Tempat Gym Terbaik di Kota Medan

A-1
LISTING PROGRAM

Form Mainform
/*
* Created by SharpDevelop.
* User: Roni Anggara
* Date: 5/17/2016
* Time: 8:52 PM
*
* To change this template use Tools | Options | Coding | Edit Standard
Headers.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data;
namespace ronianggara
{

///
/// Description of MainForm.
///
public partial class MainForm : Form
{
MySqlConnection c
= new MySqlConnection("Server=localhost;Database=gym;Uid=root;");
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms
designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent()
call.
//
}


void BAYESToolStripMenuItemClick(object sender, EventArgs e)
{
Form pindah = new ProfileMatching();
pindah.ShowDialog();
}
void TOPSISToolStripMenuItemClick(object sender, EventArgs e)

Universitas Sumatera Utara

A-2
{
Form pindah = new TOPSIS();
pindah.ShowDialog();
}
void MainFormLoad(object sender, EventArgs e)
{
segar();
}
public void segar()
{

c.Open();
dataGridView1.Columns.Clear();
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter("select * from
data", c);
da.Fill(dt);
dataGridView1.DataSource = dt.DefaultView;
dataGridView1.Columns[0].Width = 50;
dataGridView1.Columns[0].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[1].Width = 150;
dataGridView1.Columns[1].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleLeft;
dataGridView1.Columns[2].Width = 50;
dataGridView1.Columns[2].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[3].Width = 40;
dataGridView1.Columns[3].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[4].Width = 70;

dataGridView1.Columns[4].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[5].Width = 60;
dataGridView1.Columns[5].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
DataGridViewButtonColumn tambah_jumlah
= new DataGridViewButtonColumn();
tambah_jumlah.Text = "Edit Data";
tambah_jumlah.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(tambah_jumlah);
DataGridViewButtonColumn tambah_jumlahh
= new DataGridViewButtonColumn();
tambah_jumlahh.Text = "Delete Data";
tambah_jumlahh.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(tambah_jumlahh);
c.Close();
}
void MetodeToolStripMenuItemClick(object sender, EventArgs e)
{


Universitas Sumatera Utara

A-3
}
void Button3Click(object sender, EventArgs e)
{
Form pindah = new editdata();
pindah.ShowDialog();
}
void PictureBox1Click(object sender, EventArgs e)
{
}
void Button1Click(object sender, EventArgs e)
{
Form pindah = new inputdata();
pindah.ShowDialog();
segar();
}
void Button2Click(object sender, EventArgs e)
{

Form pindah = new deletedata();
pindah.ShowDialog();
}
void PerbandinganToolStripMenuItemClick(object sender, EventArgs e)
{
Form pindah = new Perbandingan();
pindah.ShowDialog();
}
void DataGridView1CellContentClick(object sender, DataGridViewCellEve
ntArgs e)
{
c.Open();
int col = e.ColumnIndex, row = e.RowIndex;
DialogResult dialogResult = MessageBox.Show("Sure", "Some
Title", MessageBoxButtons.YesNo);
if(col.Equals(6))
{
if(dialogResult == DialogResult.Yes)
{
MySqlCommand cmd = new MySqlCommand("update data set nama_gym

='" + dataGridView1[1, row].Value.ToString() + "', fasilitas =
'" + dataGridView1[2, row].Value.ToString() + "', harga
='" + dataGridView1[3, row].Value.ToString() + "', kenyamanan
='" + dataGridView1[4, row].Value.ToString() + "',
keamanan='" + dataGridView1[5, row].Value.ToString() + "'where no
='"+dataGridView1[0, row].Value.ToString()+"'", c);
cmd.ExecuteNonQuery();
MessageBox.Show("Data siswa berhasil

Universitas Sumatera Utara

A-4
diubah","informasi",MessageBoxButtons.OK,MessageBoxIcon.Information,MessageBo
xDefaultButton.Button1);
}
else if (dialogResult == DialogResult.No)
{
//do something else
}
}

else if(col.Equals(7))
{
if(dialogResult == DialogResult.Yes)
{
MySqlCommand cmd = new MySqlCommand("delete from data where no
='"+dataGridView1[0, row].Value.ToString()+"'", c);
cmd.ExecuteNonQuery();
}
else if (dialogResult == DialogResult.No)
{
//do something else
}
}
c.Close();
segar();
}
void MenuStrip1ItemClicked(object sender, ToolStripItemClickedEventAr
gs e)
{
}

void ContextMenuStrip1Opening(object sender, System.ComponentModel.Ca
ncelEventArgs e)
{
}
}
}

Form Inputdata
/*
* Created by SharpDevelop.
* User: Roni Anggara
* Date: 5/21/2016
* Time: 8:33 PM
*
* To change this template use Tools | Options | Coding | Edit Standard
Headers.
*/
using System;
using System.Collections.Generic;
using System.Drawing;


Universitas Sumatera Utara

A-5
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data;
namespace ronianggara
{
///
/// Description of inputdata.
///
public partial class inputdata : Form
{
MySqlConnection c
= new MySqlConnection("Server=localhost;Database=gym;Uid=root;");
public inputdata()
{
//
// The InitializeComponent() call is required for Windows Forms

designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent()
call.
//
}
void Button1Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text
== "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "")
{
MessageBox.Show("ada data yang belum terisi");
}
else
{
c.Open();
MySqlCommand cmd = new MySqlCommand("insert into data
values('"+textBox1.Text+"','" + textBox2.Text + "','" + textBox3.Text + "','"
+ textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')", c);
cmd.ExecuteNonQuery();
MessageBox.Show("data berhasil disimpan");
c.Close();
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
}
}
}

Universitas Sumatera Utara

A-6
Form ProfileMatching
/*
* Created by SharpDevelop.
* User: Roni Anggara
* Date: 11/3/2016
* Time: 7:53 PM
*
* To change this template use Tools | Options | Coding | Edit Standard
Headers.
*/
namespace ronianggara
{
partial class ProfileMatching
{
///
/// Designer variable used to keep track of non-visual components.
///
private System.ComponentModel.IContainer components = null;
///
/// Disposes resources used by the form.
///
/// true if managed resources should be
disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
///
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor.
The Forms designer might
/// not be able to load this method if it was changed manually.
///
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.textBox5 = new System.Windows.Forms.TextBox();
this.textBox6 = new System.Windows.Forms.TextBox();

Universitas Sumatera Utara

A-7
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.button1 = new System.Windows.Forms.Button();
this.dataGridView2 = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).
BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).
BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(36, 89);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 23);
this.label1.TabIndex = 0;
this.label1.Text = "fasilitas";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(164, 83);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "8";
//
// label2
//
this.label2.Location = new System.Drawing.Point(36, 112);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 2;
this.label2.Text = "harga";
//
// label3
//
this.label3.Location = new System.Drawing.Point(36, 135);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 23);
this.label3.TabIndex = 3;
this.label3.Text = "kenyamanan";
//
// label4
//
this.label4.Location = new System.Drawing.Point(36, 158);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(72, 23);
this.label4.TabIndex = 4;
this.label4.Text = "keamanan";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(164, 109);
this.textBox2.Name = "textBox2";

Universitas Sumatera Utara

A-8
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 5;
this.textBox2.Text = "7";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(164, 135);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 20);
this.textBox3.TabIndex = 6;
this.textBox3.Text = "7";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(164, 161);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(100, 20);
this.textBox4.TabIndex = 7;
this.textBox4.Text = "6";
//
// label5
//
this.label5.Location = new System.Drawing.Point(36, 267);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(100, 23);
this.label5.TabIndex = 8;
this.label5.Text = "core factor";
//
// label6
//
this.label6.Location = new System.Drawing.Point(36, 304);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(100, 23);
this.label6.TabIndex = 9;
this.label6.Text = "secondary factor";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(164, 270);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(100, 20);
this.textBox5.TabIndex = 10;
this.textBox5.Text = "60";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(164, 307);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(100, 20);
this.textBox6.TabIndex = 11;
this.textBox6.Text = "40";
//
// label7
//
this.label7.Location = new System.Drawing.Point(82, 47);

Universitas Sumatera Utara

A-9
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(100, 23);
this.label7.TabIndex = 12;
this.label7.Text = "Nilai Ideal";
//
// label8
//
this.label8.Location = new System.Drawing.Point(82, 227);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(100, 23);
this.label8.TabIndex = 13;
this.label8.Text = "Persentase";
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(287, 12);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(439, 198);
this.dataGridView1.TabIndex = 14;
//
// button1
//
this.button1.Location = new System.Drawing.Point(426, 244);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(120, 46);
this.button1.TabIndex = 15;
this.button1.Text = "hitung";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// dataGridView2
//
this.dataGridView2.AllowUserToAddRows = false;
this.dataGridView2.AllowUserToDeleteRows = false;
this.dataGridView2.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView2.Location = new System.Drawing.Point(12, 12);
this.dataGridView2.Name = "dataGridView2";
this.dataGridView2.Size = new System.Drawing.Size(10, 10);
this.dataGridView2.TabIndex = 16;
this.dataGridView2.Visible = false;
//
// ProfileMatching
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(754, 336);
this.Controls.Add(this.dataGridView2);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.textBox6);

Universitas Sumatera Utara

A-10
this.Controls.Add(this.textBox5);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Name = "ProfileMatching";
this.Text = "ProfileMatching";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).
EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).
EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private
private
private
private
private
private
private
private
private
private
private
private
private
private
private
private
private

System.Windows.Forms.DataGridView dataGridView2;
System.Windows.Forms.Button button1;
System.Windows.Forms.DataGridView dataGridView1;
System.Windows.Forms.Label label8;
System.Windows.Forms.Label label7;
System.Windows.Forms.TextBox textBox6;
System.Windows.Forms.TextBox textBox5;
System.Windows.Forms.Label label6;
System.Windows.Forms.Label label5;
System.Windows.Forms.TextBox textBox4;
System.Windows.Forms.TextBox textBox3;
System.Windows.Forms.TextBox textBox2;
System.Windows.Forms.Label label4;
System.Windows.Forms.Label label3;
System.Windows.Forms.Label label2;
System.Windows.Forms.TextBox textBox1;
System.Windows.Forms.Label label1;

}
}

Form TOPSIS
/*
* Created by SharpDevelop.
* User: Roni Anggara
* Date: 5/19/2016
* Time: 8:52 PM
*
* To change this template use Tools | Options | Coding | Edit Standard
Headers.
*/
using System;

Universitas Sumatera Utara

A-11
using
using
using
using
using

System.Drawing;
System.Windows.Forms;
System.ComponentModel;
System.Data;
MySql.Data.MySqlClient;

namespace ronianggara
{
///
/// Description of TOPSIS.
///
public partial class TOPSIS : Form
{
string[] nama;
double[] fasilitas,harga,kenyamanan,keamanan;
MySqlConnection c
= new MySqlConnection("Server=localhost;Database=gym;Uid=root;");
public TOPSIS()
{
//
// The InitializeComponent() call is required for Windows Forms
designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent()
call.
//
}
void Button1Click(object sender, EventArgs e)
{
dataGridView1.Columns.Clear();
c.Open();
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter("select
nama_gym,fasilitas,harga,kenyamanan,keamanan from data", c);
da.Fill(dt);
dataGridView2.Columns.Clear();
dataGridView2.DataSource = dt.DefaultView;
c.Close();
nama = new string[dataGridView2.Rows.Count];
fasilitas = new double[dataGridView2.Rows.Count];
harga = new double[dataGridView2.Rows.Count];
kenyamanan = new double[dataGridView2.Rows.Count];
keamanan = new double[dataGridView2.Rows.Count];
for (int i = 0; i < dataGridView2.Rows.Count; i++)
{
nama[i] = dataGridView2[0, i].Value.ToString();
fasilitas[i]
=
Convert.ToDouble(dataGridView2[1, i].Value.ToString());
harga[i]
=
Convert.ToDouble(dataGridView2[2, i].Value.ToString());
kenyamanan[i]
=

Universitas Sumatera Utara

A-12
Convert.ToDouble(dataGridView2[3, i].Value.ToString());
keamanan[i]
=
Convert.ToDouble(dataGridView2[4, i].Value.ToString());
}

//membangun matriks
double[,] x = new double[nama.Length,4];
for (int i = 0; i < nama.Length; i++)
{
x[i,0] = fasilitas[i];
x[i,1] = harga[i];
x[i,2] = kenyamanan[i];
x[i,3] = keamanan[i];
}
//normalisasi matriks
double[,] r = new double[nama.Length,4];
for (int j = 0; j < 4; j++)
{
double sigma=0;
for (int i = 0; i < nama.Length; i++)
{
sigma = sigma + Math.Pow(x[i,j],2);
}
for (int i = 0; i < nama.Length; i++)
{
r[i,j] = Math.Round(x[i,j]/Math.Sqrt(sigma),3);
}
}
//normalisasi bobot
double[] bobot = {2,3,2,1};
for (int i = 0; i < nama.Length; i++)
{
for (int j = 0; j < 4; j++)
{
r[i,j] = Math.Round(r[i,j] * bobot[j],3);
}
}
//v- dan v+
double[] vmin = new double[4], vmax = new double[4];
for (int j = 0; j < 4; j++)
{
vmin[j] = r[0,j];
vmax[j] = r[0,j];
for (int i = 1; i < nama.Length; i++)
{
if (vmin[j]>r[i,j])
vmin[j] = r[i,j];
if (vmax[j]r[i,j])
vmin[j] = r[i,j];
if (vmax[j]