LISTING PROGRAM
1. home.cs
using System; using System.Drawing;
using System.Windows.Forms; namespace home1
{ public partial class home : Form
{ public home
{ InitializeComponent;
} void Button1Clickobject sender, EventArgs e
{ if username_box.Text==admin pass_box.Text==123{
Form m=new MainForm; this.Hide;
m.ShowDialog;
} }
void Button2Clickobject sender, EventArgs e
{ DialogResult button= MessageBox.ShowEXIT from the
app?,EXIT, MessageBoxButtons.YesNo,MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2; ifbutton==DialogResult.Yes
Application.Exit; }
} }
2. MainForm.cs
using System; using System.Collections.Generic;
using System.Drawing; using System.Windows.Forms;
namespace home1 {
public partial class MainForm : Form {
public MainForm {
InitializeComponent; }
Universitas Sumatera Utara
void ABOUTToolStripMenuItemClickobject sender, EventArgs e {
Form c=new about; c.Show;
} void METODEToolStripMenuItemClickobject sender, EventArgs e
{ Form f=new metode;
f.Show; }
void DATAToolStripMenuItemClickobject sender, EventArgs e {
Form a=new datalahan; a.Show;
} void HELPToolStripMenuItemClickobject sender, EventArgs e
{ Form h=new help;
h.Show; }
} }
3. datalahan.cs
using System; using System.Collections.Generic;
using System.Drawing; using System.Linq.Expressions;
using System.Windows.Forms; using MySql.Data.MySqlClient;
using System.Data; using System.Data.OleDb;
namespace home1 {
public partial class datalahan : Form {
string konfigur= server=localhost;uid=root;password=;database =db_pasar;;
double c1,c2,c3,c4,c5,c6,c7,c8; double c1_pm,c2_pm,c3_pm,c4_pm,c5_pm,c6_pm,c7_pm,c8_pm;
double c1_pm_ideal,c2_pm_ideal,c3_pm_ideal,c4_pm_ideal,c5_pm_i deal,c6_pm_ideal,c7_pm_ideal,c8_pm_ideal;
double c1_pm_gap,c2_pm_gap,c3_pm_gap,c4_pm_gap,c5_pm_gap,c6_pm _gap,c7_pm_gap,c8_pm_gap;
double cf,sf,skor; double waktupmfix1=0,waktupmfix2=0;
DateTime waktupmawal,waktupmakhir; string TimePM;
void Button1Clickobject sender, EventArgs e {
try {
Universitas Sumatera Utara
waktupmawal=DateTime.Now; hitungCF;
hitungSF; hitungskor;
string MyConnection2 = datasource=localhost;port=3306 ;username=root;password=;
string Query = insert into db_pasar.pasarnama,C1,C2,C3,C4,C5,C6,C7,C8
values +this.namapasar.Text+ , +c1+ , +c2+ , +c3+ , +c4+ , +c5+ , +c6+ , +c7+ , +c8+ ;;
string Query2 = insert into db_pasar.pasar_pmnama,C1,C2,C3,C4,C5,C6,C7,C8,ideal_c1,ideal_c2,ideal
_c3,ideal_c4,ideal_c5,ideal_c6,ideal_c7,ideal_c8,gap_c1,gap_c2,gap_c3, gap_c4,gap_c5,gap_c6,gap_c7,gap_c8,core_factor,secondary_factor,skor
values +this.namapasar.Text+ , +c1_pm+ , +c2_pm+ , +c3_ pm+ , +c4_pm+ , +c5_pm+ , +c6_pm+ , +c7_pm+ , +c8_
pm+ , +c1_pm_ideal+ , +c2_pm_ideal+ , +c3_pm_ideal+ , +c4_pm_ideal+ , +c5_pm_ideal+ , +c6_pm_ideal+ , +c7_pm_ide
al+ , +c8_pm_ideal+ , +c1_pm_gap+ , +c2_pm_gap+ , +c3_ pm_gap+ , +c4_pm_gap+ , +c5_pm_gap+ , +c6_pm_gap+ , +c
7_pm_gap+ , +c8_pm_gap+ , +cf+ , +sf+ , +skor+ ;; MySqlConnection MyConn2
= new MySqlConnectionMyConnection2; MySqlCommand MyCommand2
= new MySqlCommandQuery, MyConn2; MySqlDataReader MyReader2;
MyConn2.Open; MyReader2 = MyCommand2.ExecuteReader;
MessageBox.ShowSave Data; MyConn2.Close;
MySqlConnection konekpm = new MySqlConnectionMyConnection2;
MySqlCommand mycomand_pm= new MySqlCommandQuery2,konekpm;
MySqlDataReader baca_pm; konekpm.Open;
baca_pm=mycomand_pm.ExecuteReader; konekpm.Close;
insertpasar; waktupmakhir=DateTime.Now;
TimeSpan waktupm=waktupmakhir.Subtractwaktupmawal; waktupmfix2=waktupm.TotalSeconds;
} catch Exception ex{
MessageBox.Showex.Message; }
} void insertpasar
{ try
{ string MyConnection2
= datasource=localhost;port=3306;username=root;password=; string query2=insert into
db_pasar.rankingpasarnama,skor values +this.namapasar.Text+ ,0;;
MySqlConnection MyConn2 = new MySqlConnectionMyConnection2;
Universitas Sumatera Utara
MySqlCommand MyCommand3 = new MySqlCommandquery2, MyConn2;
MySqlDataReader MyReader2; MyConn2.Open;
MyReader2 = MyCommand3.ExecuteReader; MyConn2.Close;
} catch Exception ex{
MessageBox.Showex.Message; }
} void statuslahanSelectedIndexChangedobject sender, EventArgs
e
{ if statuslahan.SelectedIndex==0{
c1=2; c1_pm=2;
c1_pm_ideal=2-4; c1_pm_gap=3;
} else if statuslahan.SelectedIndex==1{
c1=4; c1_pm=4;
c1_pm_ideal=4-4; c1_pm_gap=5;
} }
void Unsur1SelectedIndexChangedobject sender, EventArgs e
{
if unsur1.SelectedIndex==0{ c2=1;
c2_pm=1; c2_pm_ideal=1-4;
c2_pm_gap=2; }
else if unsur1.SelectedIndex==1{ c2=2;
c2_pm=2; c2_pm_ideal=2-4;
c2_pm_gap=3; }
else if unsur1.SelectedIndex==2{ c2=3;
c2_pm=3; c2_pm_ideal=3-4;
c2_pm_gap=4; }
else if unsur1.SelectedIndex==3{ c2=4;
c2_pm=4; c2_pm_ideal=4-4;
c2_pm_gap=5; }
Universitas Sumatera Utara
else if unsur1.SelectedIndex==4{ c2=5;
c2_pm=5; c2_pm_ideal=5-4;
c2_pm_gap=4.5; }
} void Unsur2SelectedIndexChangedobject sender, EventArgs e
{ if unsur2.SelectedIndex==0{
c3=0; c3_pm=0;
c3_pm_ideal=0-3; c3_pm_gap=3;
} else if unsur2.SelectedIndex==1{
c3=1; c3_pm=1;
c3_pm_ideal=1-3; c3_pm_gap=3;
} else if unsur2.SelectedIndex==2{
c3=2; c3_pm=2;
c3_pm_ideal=2-3; c3_pm_gap=4;
} else if unsur2.SelectedIndex==3{
c3=3; c3_pm=3;
c3_pm_ideal=3-3; c3_pm_gap=5;
} else if unsur2.SelectedIndex==4{
c3=4; c3_pm=4;
c3_pm_ideal=4-3; c3_pm_gap=4.5;
} else if unsur2.SelectedIndex==5{
c3=5; c3_pm=5;
c3_pm_ideal=5-3; c3_pm_gap=3.5;
} }
void Unsur3SelectedIndexChangedobject sender, EventArgs e {
if unsur3.SelectedIndex==0{ c4=1;
c4_pm=1;
Universitas Sumatera Utara
c4_pm_ideal=1-3; c4_pm_gap=3;
} else if unsur3.SelectedIndex==1{
c4=2; c4_pm=2;
c4_pm_ideal=2-3; c4_pm_gap=4;
} else if unsur3.SelectedIndex==2{
c4=3; c4_pm=3;
c4_pm_ideal=3-3; c4_pm_gap=5;
} else if unsur3.SelectedIndex==3{
c4=4; c4_pm=4;
c4_pm_ideal=4-3; c4_pm_gap=4.5;
} else if unsur3.SelectedIndex==4{
c4=5; c4_pm=5;
c4_pm_ideal=5-3; c4_pm_gap=3.5;
} }
void Persentase1SelectedIndexChangedobject sender, EventArgs e
{ if persentase1.SelectedIndex==0{
c5=1; c5_pm=1;
c5_pm_ideal=1-4; c5_pm_gap=2;
} else if persentase1.SelectedIndex==1{
c5=2; c5_pm=2;
c5_pm_ideal=2-4; c5_pm_gap=3;
} else if persentase1.SelectedIndex==2{
c5=3; c5_pm=3;
c5_pm_ideal=3-4; c5_pm_gap=4;
} else if persentase1.SelectedIndex==3{
c5=4; c5_pm=4;
Universitas Sumatera Utara
c5_pm_ideal=4-4; c5_pm_gap=5;
} }
void Persentase2SelectedIndexChangedobject sender, EventArgs e
{ if persentase2.SelectedIndex==0{
c6=1; c6_pm=1;
c6_pm_ideal=1-4; c6_pm_gap=2;
} else if persentase2.SelectedIndex==1{
c6=2; c6_pm=2;
c6_pm_ideal=2-4; c6_pm_gap=3;
} else if persentase2.SelectedIndex==2{
c6=3; c6_pm=3;
c6_pm_ideal=3-4; c6_pm_gap=4;
} else if persentase2.SelectedIndex==3{
c6=4; c6_pm=4;
c6_pm_ideal=4-4; c6_pm_gap=5;
} }
void Persentase3SelectedIndexChangedobject sender, EventArgs e
{ if persentase3.SelectedIndex==0{
c7=1; c7_pm=1;
c7_pm_ideal=1-4; c7_pm_gap=2;
} else if persentase3.SelectedIndex==1{
c7=2; c7_pm=2;
c7_pm_ideal=2-4; c7_pm_gap=3;
} else if persentase3.SelectedIndex==2{
c7=3; c7_pm=3;
c7_pm_ideal=3-4; c7_pm_gap=4;
Universitas Sumatera Utara
} else if persentase3.SelectedIndex==3{
c7=4; c7_pm=4;
c7_pm_ideal=4-4; c7_pm_gap=5;
} }
void Persentase4SelectedIndexChangedobject sender, EventArgs e
{ if persentase4.SelectedIndex==0{
c8=1; c8_pm=1;
c8_pm_ideal=1-4; c8_pm_gap=2;
} else if persentase4.SelectedIndex==1{
c8=2; c8_pm=2;
c8_pm_ideal=2-4; c8_pm_gap=3;
} else if persentase4.SelectedIndex==2{
c8=3; c8_pm=3;
c8_pm_ideal=3-4; c8_pm_gap=4;
} else if persentase4.SelectedIndex==3{
c8=4; c8_pm=4;
c8_pm_ideal=4-4; c8_pm_gap=5;
} }
void Button4Clickobject sender, EventArgs e {
try {
string MyConnection2 = server=localhost;port=3306;username=root;password=;
string Query = select from db_pasar.pasar;; MySqlConnection MyConn2
= new MySqlConnectionMyConnection2; MySqlCommand MyCommand2
= new MySqlCommandQuery, MyConn2; MyConn2.Open;
MySqlDataAdapter MyAdapter = new MySqlDataAdapter; MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable; MyAdapter.FilldTable;
dataGridView1.DataSource = dTable; MyConn2.Close;
Universitas Sumatera Utara
string MyConnectionpm = server=localhost;port=3306;username=root;password=;
string Querypm = select nama,c1,c2,c3,c4,c5,c6,c7,c8 from db_pasar.pasar_pm;;
MySqlConnection MyConnpm = new MySqlConnectionMyConnectionpm;
MySqlCommand MyCommandpm = new MySqlCommandQuerypm, MyConnpm;
MyConnpm.Open; MySqlDataAdapter MyAdapterpm
= new MySqlDataAdapter; MyAdapterpm.SelectCommand = MyCommandpm;
DataTable dTablepm = new DataTable; MyAdapterpm.FilldTablepm;
dataGridView2.DataSource = dTablepm; MyConnpm.Close;
} catch Exception ex{
MessageBox.Showex.Message; }
} void pm_ideal{
try { string MyConnectionpm
= server=localhost;port=3306;username=root;password=; string Querypm = select
nama,ideal_c1,ideal_c2,ideal_c3,ideal_c4,ideal_c5,ideal_c6,ideal_c7,id eal_c8 from db_pasar.pasar_pm;;
MySqlConnection MyConnpm = new MySqlConnectionMyConnectionpm;
MySqlCommand MyCommandpm = new MySqlCommandQuerypm, MyConnpm;
MyConnpm.Open; MySqlDataAdapter MyAdapterpm = new MySqlDataAdapter;
MyAdapterpm.SelectCommand = MyCommandpm; DataTable dTablepm = new DataTable;
MyAdapterpm.FilldTablepm; dataGridView3.DataSource = dTablepm;
MyConnpm.Close; }
catchException ex{ MessageBox.Showex.Message;
} }
void pm_gap{ try {
string MyConnectionpm = server=localhost;port=3306;username=root;password=;
string Querypm = select nama,gap_c1,gap_c2,gap_c3,gap_c4,gap_c5,gap_c6,gap_c7,gap_c8 from
db_pasar.pasar_pm;; MySqlConnection MyConnpm
= new MySqlConnectionMyConnectionpm; MySqlCommand MyCommandpm
= new MySqlCommandQuerypm, MyConnpm; MyConnpm.Open;
Universitas Sumatera Utara
MySqlDataAdapter MyAdapterpm = new MySqlDataAdapter;
MyAdapterpm.SelectCommand = MyCommandpm; DataTable dTablepm = new DataTable;
MyAdapterpm.FilldTablepm; dataGridView4.DataSource = dTablepm;
MyConnpm.Close; }
catch Exception ex
{
MessageBox.Showex.Message; }
} void hitungCF{
try{ cf=c2_pm_gap+c3_pm_gap+c4_pm_gap+c5_pm_gap4;
} catchException ex
{
MessageBox.Showex.Message; }
} void hitungSF{
try{ sf=c1_pm_gap+c6_pm_gap+c7_pm_gap+c8_pm_gap4;
}
catchException ex {
MessageBox.Showex.Message; }
} void hitungskor{
try{ skor=cf0.6+sf0.4;
}
catchException ex {
MessageBox.Showex.Message; }
} void Button3Clickobject sender, EventArgs e
{ string namahapus =
dataGridView1.CurrentRow.Cells[0].Value.ToString; string hapus=DELETE FROM pasar WHERE
nama=+ namahapus + ; string hapusrankSAW=DELETE FROM rankingpasar WHERE
nama=+ namahapus + ; string hapuspm=DELETE FROM pasar_pm WHERE
nama=+ namahapus + ; DialogResult result = MessageBox.Showhapus
?,konfirmasi,MessageBoxButtons.OKCancel,MessageBoxIcon.Warning; ifresult==DialogResult.OK
{ MySqlConnection konek = new MySqlConnectionkonfigur;
MySqlCommand cmd = new MySqlCommandhapus,konek;
Universitas Sumatera Utara
konek.Open; cmd.ExecuteNonQuery;
konek.Close; MySqlConnection konek1 = newMySqlConnectionkonfigur;
MySqlCommand cmd1 = new MySqlCommandhapusrankSAW,konek1;
konek1.Open; cmd1.ExecuteNonQuery;
MySqlConnection konek2 = new MySqlConnectionkonfigur;
MySqlCommand cmd2 = new MySqlCommandhapuspm,konek2; konek2.Open;
cmd2.ExecuteNonQuery; konek2.Close;
} }
void Button5Clickobject sender, EventArgs e {
Form a=new MainForm; a.Show;
this.Dispose; }
} }
4. metode.cs