public static string Tree(int coloumAndGain, int AtributMahasiswa) // Membuat Tree { int[] YesNo = new int[2]; YesNo = DatabaseScript.treeScript(coloumAndGain, AtributMahasiswa); if (YesNo[0] > 0 && YesNo[1] == 0) { DatabaseScript.logForm.addText("Ya => " + YesNo[0] + "\n" + "No =>" + YesNo[1] + "\nResult is Ya", Color.LawnGreen); return("Ya"); } else if (YesNo[0] == 0 && YesNo[1] > 0) { DatabaseScript.logForm.addText("Ya => " + YesNo[0] + "\n" + "No =>" + YesNo[1] + "\nResult is No", Color.Red); return("Tidak"); } else if (YesNo[0] > 0 && YesNo[1] > 0 && coloumAndGain == Rumus.coloumAndGain.Count - 1) { DatabaseScript.logForm.addText("Ya => " + YesNo[0] + "\n" + "No =>" + YesNo[1] + "\nData Ambigu", Color.MediumPurple); return("-"); // Data Ambigu } else if (YesNo[0] > 0 && YesNo[1] > 0) { DatabaseScript.logForm.addText("Ya => " + YesNo[0] + "\n" + "No =>" + YesNo[1] + "\n", Color.MediumSpringGreen); return(Tree(coloumAndGain + 1, AtributMahasiswa + 1)); } else { DatabaseScript.logForm.addText("Ya => " + YesNo[0] + "\n" + "No =>" + YesNo[1] + "\nData is not Found", Color.Yellow); return("-"); // Data belum tercukupi } }
private void RunScript() { object temp = new object(); sql = Script.Text; if (sql.IndexOf("*/") > 0) { sql = sql.Remove(0, sql.IndexOf("*/") + 2); } sql = HapusLineEnding(sql); temp = DatabaseScript.SQLscriptExecute(sql); if (temp != null) { DatabaseScript.data.DataView.DataSource = temp; } else { Script.Text = deletecommnet(Script.Text); Script.Text = addcomment(Script.Text); Script.AppendText(" "); } }
private void AddData_Click(object sender, EventArgs e) // Run Program { if (Algoritm.SelectedItem == Algoritm.Items[0]) { DatabaseScript.AddData(); ValueView(); foreach (DatabaseScript.Mahasiswa mhs in DatabaseScript.mahasiswa) { DatabaseScript.AddToDatabase(mhs); } Refresh.PerformClick(); } else { DatabaseScript.AddData(); int error = 0; DialogResult dialog = MessageBox.Show("Add now to databases?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { DatabaseScript.AddData(); foreach (DatabaseScript.Mahasiswa mhs in DatabaseScript.mahasiswa) { if (mhs.diterima == "-" || mhs.diterima == null) { error += 1; } } if (error > 0) { DialogResult result = MessageBox.Show("We Find " + error + " data that dont have result, we will ignore it do you want to Process?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.Yes) { foreach (DatabaseScript.Mahasiswa mhs in DatabaseScript.mahasiswa) { if (mhs.diterima != "-" && mhs.diterima != null) { DatabaseScript.AddToDatabase(mhs); } } } } else { foreach (DatabaseScript.Mahasiswa mhs in DatabaseScript.mahasiswa) { DatabaseScript.AddToDatabase(mhs); } } Refresh.PerformClick(); ValueView(); } } }
public static void EditData() // Edit Data From Database { DialogResult result = MessageBox.Show("Data will be deleted first. Do you want to process?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { int rows = data.DataView.SelectedRows.Count; int PrimaryKey = 0; bool FoundPK = false; for (int i = 0; i < data.DataView.ColumnCount; i++) { if (data.DataView.Columns[i].Name == "Npm") { PrimaryKey = i; FoundPK = true; } } if (rows > 0 && FoundPK == true) { data.ClearData.PerformClick(); string script = "select *from beasiswa where "; bool Can = true; foreach (DataGridViewRow Current in data.DataView.SelectedRows) { string NPM = data.DataView[0, Current.Index].Value.ToString(); if (Can) { script += " NPM = '" + NPM + "' "; Can = false; } else { script += "or NPM = '" + NPM + "' "; } } script += ";"; DataTable dt = DatabaseScript.SQLscriptExecute(script); DataTableReader read = dt.CreateDataReader(); data.InputData.Rows.Add(rows); int i = 0; while (read.Read()) { for (int j = 0; j < 8; j++) { data.InputData[j, i].Value = read.GetValue(j).ToString(); } DatabaseScript.SQLscriptExecute("DELETE FROM `db_ai`.`beasiswa` WHERE `Npm`='" + data.InputData[0, i].Value.ToString() + "';"); i++; } } data.Refresh.PerformClick(); } }
private void ExecuteSQL_Click(object sender, EventArgs e) // Menjalankan SQL Script { object temp = DatabaseScript.SQLscriptExecute(sqlScript.Text); if (temp != null) { DataView.DataSource = temp; } }
public static void Delete() // Delete Data from Database { DialogResult result = MessageBox.Show("Are you sure want to delete?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (data.DataView.SelectedRows.Count > 0) { foreach (DataGridViewRow Current in data.DataView.SelectedRows) { string NPM = data.DataView[0, Current.Index].Value.ToString(); DatabaseScript.SQLscriptExecute("DELETE FROM `db_ai`.`beasiswa` WHERE `Npm`='" + NPM + "';"); } } data.Refresh.PerformClick(); data.ValueView(); } }
private void Password_KeyDown(object sender, KeyEventArgs e) // Login { if (e.KeyCode == Keys.CapsLock) { e.SuppressKeyPress = true; CheckCapslock(); } if (e.KeyCode == Keys.Enter) { ErorMessage.Text = ""; DatabaseScript.Login(Password.Text); Password.Clear(); ErorMessage.Text = DatabaseScript.errorMessage; SetLocation(); } }
private void Data_Load(object sender, EventArgs e) // Action / Trigger { DataView.DataSource = DatabaseScript.SQLscriptExecute("select *from beasiswa;"); Algoritm.SelectedItem = Algoritm.Items[0]; ValueView(); }
private void Refresh_Click(object sender, EventArgs e) // Refresh Table Beasiswa { DataView.DataSource = DatabaseScript.SQLscriptExecute("select *from beasiswa;"); }
private void Import_Click(object sender, EventArgs e) { DatabaseScript.Import(); }
private void Export_Click(object sender, EventArgs e) { DatabaseScript.BackUp(); }
public void ValueView() { int[] temp; tree.ExpandAll(); Rumus.SearchAllGain(); for (int i = 0; i < 5; i++) { tree.Nodes[0].Nodes[i].Text = SetText(Rumus.coloumAndGain[i].Coloum, Rumus.coloumAndGain[i].Gain.ToString(), 18); } //double test = Rumus.Entropy(3,0,3); //jenis beasiswa; temp = DatabaseScript.SearchDataEntropy("Jenis_beasiswa", "BBM"); tree.Nodes[1].Nodes[0].Nodes[0].Text = SetText("BBM", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 5); temp = DatabaseScript.SearchDataEntropy("Jenis_beasiswa", "PPA"); tree.Nodes[1].Nodes[0].Nodes[1].Text = SetText("PPA", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 5); //prestasi temp = DatabaseScript.SearchDataEntropy("Prestasi", "Internasional"); tree.Nodes[1].Nodes[4].Nodes[0].Text = SetText("Internasional", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 14); temp = DatabaseScript.SearchDataEntropy("Prestasi", "Nasional"); tree.Nodes[1].Nodes[4].Nodes[1].Text = SetText("Nasional", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 14); temp = DatabaseScript.SearchDataEntropy("Prestasi", "Regional"); tree.Nodes[1].Nodes[4].Nodes[2].Text = SetText("Regional", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 14); temp = DatabaseScript.SearchDataEntropy("Prestasi", "Lokal"); tree.Nodes[1].Nodes[4].Nodes[3].Text = SetText("Lokal", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 14); //aktif anggota temp = DatabaseScript.SearchDataEntropy("Aktif_Organisasi", "Ketua"); tree.Nodes[1].Nodes[2].Nodes[0].Text = SetText("Ketua", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 10); temp = DatabaseScript.SearchDataEntropy("Aktif_Organisasi", "Pengurus"); tree.Nodes[1].Nodes[2].Nodes[1].Text = SetText("Pengurus", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 10); temp = DatabaseScript.SearchDataEntropy("Aktif_Organisasi", "Anggota"); tree.Nodes[1].Nodes[2].Nodes[2].Text = SetText("Anggota", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 10); //Semesta temp = DatabaseScript.SearchDataEntropy("Select count(IF(Diterima ='ya',1,Null)) as ya,count(IF(Diterima ='tidak',1,Null)) as tidak,count(IF(Diterima,1,Null)) as total from beasiswa;"); tree.Nodes[1].Nodes[5].Text = SetText("Semesta", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 10); //Financial temp = DatabaseScript.SearchDataEntropy("select count(if(Financial <= 1000000,1,Null) AND if(Diterima='Ya',1,Null))as Ya,count(if(Financial <= 1000000,1,Null) AND if(Diterima='Tidak',1,Null))as Tidak,count(if(Financial <= 1000000,1,Null)) Total from beasiswa;"); tree.Nodes[1].Nodes[3].Nodes[0].Text = SetText(" <=1jt", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); temp = DatabaseScript.SearchDataEntropy("select count(if(Financial <= 5000000,1,Null) AND if(Financial > 1000000,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(Financial <= 5000000,1,Null) AND if(Financial > 1000000,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(Financial <= 5000000,1,Null) AND if(Financial > 1000000,1,Null)) as Total from beasiswa;"); tree.Nodes[1].Nodes[3].Nodes[1].Text = SetText(" 1jt - 5jt", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); temp = DatabaseScript.SearchDataEntropy("select count(if(Financial <= 7500000,1,Null) AND if(Financial > 5000000,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(Financial <= 7500000,1,Null) AND if(Financial > 5000000,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(Financial <= 7500000,1,Null) AND if(Financial > 5000000,1,Null)) as Total from beasiswa;"); tree.Nodes[1].Nodes[3].Nodes[2].Text = SetText(" 5jt - 7.5jt", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); temp = DatabaseScript.SearchDataEntropy("select count(if(Financial <= 10000000,1,Null) AND if(Financial > 7500000,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(Financial <= 10000000,1,Null) AND if(Financial > 7500000,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(Financial <= 10000000,1,Null) AND if(Financial > 7500000,1,Null)) as Total from beasiswa;"); tree.Nodes[1].Nodes[3].Nodes[3].Text = SetText("7.5jt - 10jt", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); temp = DatabaseScript.SearchDataEntropy("select count(if(Financial > 10000000,1,Null) AND if(Diterima='Ya',1,Null))as Ya,count(if(Financial > 10000000,1,Null) AND if(Diterima='Tidak',1,Null))as Tidak,count(if(Financial > 10000000,1,Null)) Total from beasiswa;"); tree.Nodes[1].Nodes[3].Nodes[4].Text = SetText(" > 10jt", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); //IPK temp = DatabaseScript.SearchDataEntropy("select count(if(ipk = '4',1,Null) AND if(Diterima='Ya',1,Null))as Ya,count(if(ipk = '4',1,Null) AND if(Diterima='Tidak',1,Null))as Tidak,count(if(ipk = '4',1,Null)) Total from beasiswa;"); tree.Nodes[1].Nodes[1].Nodes[0].Text = SetText(" 4 ", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); temp = DatabaseScript.SearchDataEntropy("select count(if(ipk < 4,1,Null) AND if(ipk >= 3.5,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(ipk < 4,1,Null) AND if(ipk >= 3.5,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(ipk < 4,1,Null) AND if(ipk >= 3.5,1,Null)) as Total from beasiswa;"); tree.Nodes[1].Nodes[1].Nodes[1].Text = SetText(" 4 - 3.5 ", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); temp = DatabaseScript.SearchDataEntropy("select count(if(ipk < 3.5,1,Null) AND if(ipk >= 3.25,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(ipk < 3.5,1,Null) AND if(ipk >= 3.25,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(ipk < 3.5,1,Null) AND if(ipk >= 3.25,1,Null)) as Total from beasiswa;"); tree.Nodes[1].Nodes[1].Nodes[2].Text = SetText("3.5 - 3.25", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); temp = DatabaseScript.SearchDataEntropy("select count(if(ipk < 3.25,1,Null) AND if(ipk >= 3,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(ipk < 3.25,1,Null) AND if(ipk >= 3,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(ipk < 3.25,1,Null) AND if(ipk >= 3,1,Null)) as Total from beasiswa;"); tree.Nodes[1].Nodes[1].Nodes[3].Text = SetText("3.25- 3 ", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); temp = DatabaseScript.SearchDataEntropy("select count(if(ipk < 3,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(ipk < 3,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(ipk < 3,1,Null))as Total from beasiswa;"); tree.Nodes[1].Nodes[1].Nodes[4].Text = SetText(" < 3 ", Rumus.Entropy(temp[0], temp[1], temp[2]).ToString(), 15); }
private void DeleteMenu_Click(object sender, EventArgs e) { DatabaseScript.Delete(); }
private void EditMenu_Click(object sender, EventArgs e) { DatabaseScript.EditData(); ValueView(); }
public static float SearchGain(int coloum) //Mencari Gain sesuai colom; { float Hasil = 0.0f; int[,] data = new int[1, 3]; int[] temp = new int[3]; switch (coloum) { case 1: { data = new int[3, 3]; for (int i = 1; i < 3; i++) { if (i == 1) { temp = DatabaseScript.SearchDataEntropy("Jenis_beasiswa", "PPA"); } else { temp = DatabaseScript.SearchDataEntropy("Jenis_beasiswa", "BBM"); } data[i, 0] = temp[0]; data[i, 1] = temp[1]; data[i, 2] = temp[2]; } break; } case 2: { data = new int[6, 3]; for (int i = 1; i < 4; i++) { if (i == 1) { //ipk 4 temp = DatabaseScript.SearchDataEntropy("select count(if(ipk = '4',1,Null) AND if(Diterima='Ya',1,Null))as Ya,count(if(ipk = '4',1,Null) AND if(Diterima='Tidak',1,Null))as Tidak,count(if(ipk = '4',1,Null)) Total from beasiswa;"); } else if (i == 2) { temp = DatabaseScript.SearchDataEntropy("select count(if(ipk < 4,1,Null) AND if(ipk >= 3.5,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(ipk < 4,1,Null) AND if(ipk >= 3.5,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(ipk < 4,1,Null) AND if(ipk >= 3.5,1,Null)) as Total from beasiswa;"); } else if (i == 3) { temp = DatabaseScript.SearchDataEntropy("select count(if(ipk < 3.5,1,Null) AND if(ipk >= 3.25,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(ipk < 3.5,1,Null) AND if(ipk >= 3.25,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(ipk < 3.5,1,Null) AND if(ipk >= 3.25,1,Null)) as Total from beasiswa;"); } else if (i == 4) { temp = DatabaseScript.SearchDataEntropy("select count(if(ipk < 3.25,1,Null) AND if(ipk >= 3,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(ipk < 3.25,1,Null) AND if(ipk >= 3,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(ipk < 3.25,1,Null) AND if(ipk >= 3,1,Null)) as Total from beasiswa;"); } else if (i == 5) { temp = DatabaseScript.SearchDataEntropy("select count(if(ipk < 3,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(ipk < 3,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(ipk < 3,1,Null))as Total from beasiswa;"); } data[i, 0] = temp[0]; data[i, 1] = temp[1]; data[i, 2] = temp[2]; } break; } case 3: { data = new int[4, 3]; for (int i = 1; i < 4; i++) { if (i == 1) { temp = DatabaseScript.SearchDataEntropy("Aktif_Organisasi", "Ketua"); } else if (i == 2) { temp = DatabaseScript.SearchDataEntropy("Aktif_Organisasi", "Pengurus"); } else if (i == 3) { temp = DatabaseScript.SearchDataEntropy("Aktif_Organisasi", "Anggota"); } data[i, 0] = temp[0]; data[i, 1] = temp[1]; data[i, 2] = temp[2]; } break; } case 4: { data = new int[6, 3]; for (int i = 1; i < 4; i++) { if (i == 1) { temp = DatabaseScript.SearchDataEntropy("select count(if(Financial <= 1000000,1,Null) AND if(Diterima='Ya',1,Null))as Ya,count(if(Financial <= 1000000,1,Null) AND if(Diterima='Tidak',1,Null))as Tidak,count(if(Financial <= 1000000,1,Null)) Total from beasiswa;"); } else if (i == 2) { temp = DatabaseScript.SearchDataEntropy("select count(if(Financial <= 5000000,1,Null) AND if(Financial > 1000000,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(Financial <= 5000000,1,Null) AND if(Financial > 1000000,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(Financial <= 5000000,1,Null) AND if(Financial > 1000000,1,Null)) as Total from beasiswa;"); } else if (i == 3) { temp = DatabaseScript.SearchDataEntropy("select count(if(Financial <= 7500000,1,Null) AND if(Financial > 5000000,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(Financial <= 7500000,1,Null) AND if(Financial > 5000000,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(Financial <= 7500000,1,Null) AND if(Financial > 5000000,1,Null)) as Total from beasiswa;"); } else if (i == 4) { temp = DatabaseScript.SearchDataEntropy("select count(if(Financial <= 10000000,1,Null) AND if(Financial > 7500000,1,Null) AND if(Diterima='Ya',1,Null)) as Ya,count(if(Financial <= 10000000,1,Null) AND if(Financial > 7500000,1,Null) AND if(Diterima='Tidak',1,Null)) as Tidak,count(if(Financial <= 10000000,1,Null) AND if(Financial > 7500000,1,Null)) as Total from beasiswa;"); } else if (i == 5) { temp = DatabaseScript.SearchDataEntropy("select count(if(Financial > 10000000,1,Null) AND if(Diterima='Ya',1,Null))as Ya,count(if(Financial > 10000000,1,Null) AND if(Diterima='Tidak',1,Null))as Tidak,count(if(Financial > 10000000,1,Null)) Total from beasiswa;"); } data[i, 0] = temp[0]; data[i, 1] = temp[1]; data[i, 2] = temp[2]; } break; } case 5: { data = new int[6, 3]; for (int i = 1; i < 4; i++) { if (i == 1) { temp = DatabaseScript.SearchDataEntropy("select count(if(Prestasi is null,1,Null) AND if(Diterima='Ya',1,Null))as Ya,count(if(Prestasi is null,1,Null) AND if(Diterima='Tidak',1,Null))as Tidak,count(if(Prestasi is null,1,Null)) Total from beasiswa;"); } else if (i == 2) { temp = DatabaseScript.SearchDataEntropy("Prestasi", "Internasional"); } else if (i == 3) { temp = DatabaseScript.SearchDataEntropy("Prestasi", "Nasional"); } else if (i == 4) { temp = DatabaseScript.SearchDataEntropy("Prestasi", "Regional"); } else if (i == 5) { temp = DatabaseScript.SearchDataEntropy("Prestasi", "Lokal"); } data[i, 0] = temp[0]; data[i, 1] = temp[1]; data[i, 2] = temp[2]; } break; } default: { break; } } temp = DatabaseScript.SearchDataEntropy("Select count(IF(Diterima ='ya',1,Null)) as ya,count(IF(Diterima ='tidak',1,Null)) as tidak,count(IF(Diterima,1,Null)) as total from beasiswa;"); data[0, 0] = temp[0]; data[0, 1] = temp[1]; data[0, 2] = temp[2]; Hasil = Gain(data); return(Hasil); }
private void LoginButton_MouseClick(object sender, MouseEventArgs e) // Login { DatabaseScript.Login(Password.Text); }