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 {
/// <summary>
/// Description of MainForm. /// </summary>
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();
}
{
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 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();
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.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data;
namespace ronianggara {
/// <summary>
/// Description of inputdata. /// </summary>
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 = "";
} } }
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 {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing) {
if (components != null) { components.Dispose(); }
}
base.Dispose(disposing); }
/// <summary>
/// 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.
/// </summary>
private void InitializeComponent() {
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.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.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.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 System.Windows.Forms.DataGridView dataGridView2; private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7; private System.Windows.Forms.TextBox textBox6; private System.Windows.Forms.TextBox textBox5; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label5; private System.Windows.Forms.TextBox textBox4; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox textBox1; private 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.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Data;
using MySql.Data.MySqlClient;
namespace ronianggara {
/// <summary>
/// Description of TOPSIS. /// </summary>
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[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++) {
} }
//d- dan d+
double[] dmin = new double[nama.Length], dmax = new double[nama.Length];
for (int i = 0; i < nama.Length; i++) {
double totaldmax=0, totaldmin=0; for (int j = 0; j < 4; j++) {
totaldmax = totaldmax + Math.Pow(vmax[j]-r[i,j],2); totaldmin = totaldmin + Math.Pow(r[i,j]-vmin[j],2); }
dmax[i] = Math.Round(Math.Sqrt(totaldmax),3); dmin[i] = Math.Round(Math.Sqrt(totaldmin),3); }
//RPI
double[] rpi = new double[nama.Length]; for (int i = 0; i < nama.Length; i++) {
rpi[i] = Math.Round(dmin[i]/(dmax[i]+dmin[i]),3); }
dataGridView1.ColumnCount = 4;
dataGridView1.Columns[0].Name = "Nama"; dataGridView1.Columns[1].Name = "d+"; dataGridView1.Columns[2].Name = "d-"; dataGridView1.Columns[3].Name = "RPI";
for (int i = 0; i < nama.Length; i++) {
dataGridView1.Rows.Add(nama[i],dmax[i],dmin[i],rpi[i]); }
dataGridView1.Sort(dataGridView1.Columns[3], ListSortDirection.De scending);
} } }
Form Perbandingan
/*
* Created by SharpDevelop. * User: Roni Anggara
* Date: 10/20/2016 * Time: 8:38 PM *
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using MySql.Data.MySqlClient;
namespace ronianggara {
/// <summary>
/// Description of Perbandingan. /// </summary>
public partial class Perbandingan : Form {
string[] nama;
double[] fasilitas,harga,kenyamanan,keamanan; MySqlConnection c
= new MySqlConnection("Server=localhost;Database=gym;Uid=root;"); public Perbandingan()
{ //
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
// }
public double bobota(double n) {
if (n == 0) return 5; else if(n == 1) return 4.5; else if(n == -1) return 4; else if(n == 2) return 3.5; else if(n == -2) return 3; else if(n == 3) return 2.5; else if(n == -3) return 2; else if(n == 4) return 1.5; else
return 1; }
void Button1Click(object sender, EventArgs e) {
Stopwatch watch1 = new Stopwatch(); 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);
dataGridView3.Columns.Clear();
dataGridView3.DataSource = dt.DefaultView; c.Close();
nama = new string[banyakdata]; fasilitas = new double[banyakdata]; harga = new double[banyakdata]; kenyamanan = new double[banyakdata]; keamanan = new double[banyakdata]; for (int i = 0; i < banyakdata; i++) {
nama[i] = dataGridView3[0, i].Value.ToString(); fasilitas[i] =
Convert.ToDouble(dataGridView3[1, i].Value.ToString()); harga[i] =
Convert.ToDouble(dataGridView3[2, i].Value.ToString()); kenyamanan[i] =
Convert.ToDouble(dataGridView3[3, i].Value.ToString()); keamanan[i] =
Convert.ToDouble(dataGridView3[4, i].Value.ToString()); }
watch1.Restart(); dataGridView1.ColumnCount = 2;
dataGridView1.Columns[0].Name = "Nama";
dataGridView1.Columns[1].Name = "Nilai Akhir";
//gap
for (int i = 0; i < nama.Length; i++) {
fasilitas[i] = fasilitas[i] - 8; harga[i] = harga[i] - 7;
kenyamanan[i] = kenyamanan[i] - 7; keamanan[i] = keamanan[i] - 6; }
//bobot
for (int i = 0; i < nama.Length; i++) {
fasilitas[i] = bobota(fasilitas[i]); harga[i] = bobota(harga[i]);
kenyamanan[i] = bobota(kenyamanan[i]); keamanan[i] = bobota(keamanan[i]); }
//nilai total
double[] na = new double[nama.Length], ni = new double[nama.Length];
na[i] = 0.6*fasilitas[i] + 0.4*harga[i]; ni[i] = 0.6*kenyamanan[i] + 0.4*keamanan[i]; }
//nilai akhir
double[] nt = new double[nama.Length]; for (int i = 0; i < nama.Length; i++) {
nt[i] = 0.6*na[i] + 0.4*ni[i]; }
for (int i = 0; i < nama.Length; i++) {
dataGridView1.Rows.Add(nama[i],nt[i]); }
dataGridView1.Sort(dataGridView1.Columns[1], ListSortDirection.De scending);
watch1.Stop(); textBox3.Text =
Math.Round(Convert.ToDecimal(watch1.Elapsed.TotalMilliseconds),4).ToString();
dataGridView2.Columns.Clear(); nama = new string[banyakdata]; fasilitas = new double[banyakdata]; harga = new double[banyakdata]; kenyamanan = new double[banyakdata]; keamanan = new double[banyakdata]; for (int i = 0; i < banyakdata; i++) {
nama[i] = dataGridView3[0, i].Value.ToString(); fasilitas[i] =
Convert.ToDouble(dataGridView3[1, i].Value.ToString()); harga[i] =
Convert.ToDouble(dataGridView3[2, i].Value.ToString()); kenyamanan[i] =
Convert.ToDouble(dataGridView3[3, i].Value.ToString()); keamanan[i] =
Convert.ToDouble(dataGridView3[4, i].Value.ToString()); }
watch1.Restart();
//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];
}
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]) vmax[j] = r[i,j]; }
}
//d- dan d+
double[] dmin = new double[nama.Length], dmax = new double[nama.Length];
for (int i = 0; i < nama.Length; i++) {
double totaldmax=0, totaldmin=0; for (int j = 0; j < 4; j++) {
totaldmax = totaldmax + Math.Pow(vmax[j]-r[i,j],2); totaldmin = totaldmin + Math.Pow(r[i,j]-vmin[j],2); }
dmax[i] = Math.Round(Math.Sqrt(totaldmax),3); dmin[i] = Math.Round(Math.Sqrt(totaldmin),3); }
double[] rpi = new double[nama.Length]; for (int i = 0; i < nama.Length; i++) {
rpi[i] = Math.Round(dmin[i]/(dmax[i]+dmin[i]),3); }
dataGridView2.ColumnCount = 2;
dataGridView2.Columns[0].Name = "Nama"; dataGridView2.Columns[1].Name = "RPI";
for (int i = 0; i < nama.Length; i++) {
dataGridView2.Rows.Add(nama[i],rpi[i]); }
dataGridView2.Sort(dataGridView2.Columns[1], ListSortDirection.De scending);
watch1.Stop(); textBox2.Text =
Math.Round(Convert.ToDecimal(watch1.Elapsed.TotalMilliseconds),4).ToString(); }