private void btn_hapus_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Anda Yakin Menghapus Data ini ??? ", "Warning !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { query = "delete from classes where kelas = '" + dataGridView1[0,dataGridView1.CurrentRow.Index].Value.ToString() + "'"; koneksi = new Konektor(); byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil Menghapus Data !!!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); Kelas_Load(null, null); } else { MessageBox.Show("Gagal Menghapus Data !!!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_hapus_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Anda Yakin Menghapus Data ini ??? ", "Warning !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { query = "delete from siswa where no_induk = '" + txt_no_induk.Text + "'"; koneksi = new Konektor(); byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil Menghapus Data !!!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); AddSiswa_Load(null, null); } else { MessageBox.Show("Gagal Menghapus Data !!!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_hapus_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Anda Yakin Menghapus Data ini ??? ", "Warning !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { query = "delete from siswa where no_induk = '" +txt_no_induk.Text+ "'"; koneksi = new Konektor(); byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil Menghapus Data !!!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); AddSiswa_Load(null, null); } else { MessageBox.Show("Gagal Menghapus Data !!!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_hapus_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Anda Yakin Menghapus Data ini ??? ", "Warning !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { query = "delete from classes where kelas = '" + dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString() + "'"; koneksi = new Konektor(); byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil Menghapus Data !!!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); Kelas_Load(null, null); } else { MessageBox.Show("Gagal Menghapus Data !!!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void vistaButton3_Click(object sender, EventArgs e) { try { koneksi = new Konektor(); if (dataGridView1.Rows.Count > 0) { for (short i = 0; i < dataGridView1.Rows.Count; i++) { query = "insert into siswa values ('" + dataGridView1[0, i].Value.ToString() + "'," + "'" + dataGridView1[1, i].Value.ToString() + "'," + "'" + dataGridView1[2, i].Value.ToString() + "'," + "'" + dataGridView1[3, i].Value.ToString() + "'," + "'" + dataGridView1[4, i].Value.ToString() + "'," + "'" + dataGridView1[5, i].Value.ToString() + "');"; koneksi.ManipulasiData(query); } MessageBox.Show("Berhasil Menyimpan Data !!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox1.Clear(); dataGridView1.DataSource = null; } else { MessageBox.Show("Tidak ada data yang akan disimpan !!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Guru_Load(object sender, EventArgs e) { try { koneksi = new Konektor(); ds = new DataSet(); btn_bersih.Enabled = false; btn_ubah.Enabled = false; btn_hapus.Enabled = false; btn_cari.Enabled = true; btn_simpan.Enabled = true; btn_delete_all.Enabled = true; txt_kodeguru.Enabled = true; txt_kodeguru.Clear(); txt_namaGuru.Clear(); txt_Alamat.Clear(); txt_hp.Clear(); txt_jabatan.Clear(); textBox5.Enabled = true; txt_kodeguru.Focus(); ds.Clear(); ds = koneksi.GetData("select * from guru"); SetDataGridView(ds); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void vistaButton3_Click(object sender, EventArgs e) { try { koneksi = new Konektor(); if (dataGridView1.Rows.Count > 0) { for (short i = 0; i < dataGridView1.Rows.Count; i++) { query = "insert into siswa values ('"+dataGridView1[0,i].Value.ToString()+"',"+ "'" + dataGridView1[1, i].Value.ToString() + "',"+ "'" + dataGridView1[2, i].Value.ToString() + "',"+ "'" + dataGridView1[3, i].Value.ToString() + "',"+ "'" + dataGridView1[4, i].Value.ToString() + "',"+ "'" + dataGridView1[5, i].Value.ToString() + "');"; koneksi.ManipulasiData(query); } MessageBox.Show("Berhasil Menyimpan Data !!","Informasi",MessageBoxButtons.OK,MessageBoxIcon.Information); textBox1.Clear(); dataGridView1.DataSource = null; } else { MessageBox.Show("Tidak ada data yang akan disimpan !!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void SetDataGridView(string query) { try { koneksi = new Konektor(); dataGridView1.DataSource = koneksi.GetData(query).Tables[0]; dataGridView1.Columns[0].HeaderText = "Kelas"; dataGridView1.Columns[0].Width = 200; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void FormSMS_Load(object sender, EventArgs e) { try { koneksi = new Konektor(); ds = new DataSet(); ds = koneksi.GetData("select * from classes order by kelas desc"); comboBox1.Items.Add("Semua"); for (byte i = 0; i < ds.Tables[0].Rows.Count; i++) { comboBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString()); } comboBox1.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void vistaButton1_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Anda Yakin Menghapus Semua Data ??? \nData akan hilang semua", "Warning !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { query = "delete from siswa"; koneksi = new Konektor(); byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil Menghapus Data !!!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); } AddSiswa_Load(null, null); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_delete_all_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Anda Yakin Menghapus Semua Data ??? \nData akan hilang semua", "Warning !!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { query = "delete from classes"; koneksi = new Konektor(); byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil Menghapus Data !!!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); } Kelas_Load(null, null); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void AddSiswa_Load(object sender, EventArgs e) { try { koneksi = new Konektor(); ds = new DataSet(); ds = koneksi.GetData("select * from classes order by kelas desc"); comboBox1.Items.Clear(); for (byte i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i][0].ToString() != "Semua") { comboBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString()); } } comboBox1.SelectedIndex = 0; btn_bersih.Enabled = false; btn_ubah.Enabled = false; btn_hapus.Enabled = false; btn_cari.Enabled = true; btn_simpan.Enabled = true; btn_delete_all.Enabled = true; txt_no_induk.Enabled = true; txt_no_induk.Clear(); txt_nama.Clear(); txt_alamat.Clear(); txt_namawali.Clear(); txt_hp.Clear(); textBox1.Enabled = true; txt_no_induk.Focus(); ds.Clear(); ds = koneksi.GetData("select * from siswa"); SetDataGridView(ds); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_simpan_Click(object sender, EventArgs e) { try { if (textBox1.Text != "") { koneksi = new Konektor(); ds = new DataSet(); query = "select * from classes where kelas = '" + textBox1.Text + "';"; ds = koneksi.GetData(query); if (ds.Tables[0].Rows.Count == 0) { query = "insert into Classes values ('" + textBox1.Text + "');"; byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil menambah data"); } } else { MessageBox.Show("Kelas sudah terdaftar !!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Mohon Lengkapi Data Dulu !!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Kelas_Load(null, null); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void vistaButton2_Click(object sender, EventArgs e) { try { koneksi = new Konektor(); if (txt_no_induk.Text == "" || txt_nama.Text == "" || txt_namawali.Text == "" || txt_hp.Text == "") { MessageBox.Show("Mohon Lengkapi Data Dulu !!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); txt_no_induk.Focus(); } else { ds = new DataSet(); ds = koneksi.GetData("select * from siswa where no_induk = '" + txt_no_induk.Text + "'"); if (ds.Tables[0].Rows.Count == 0) { query = "insert into siswa values ('" + txt_no_induk.Text + "','" + txt_nama.Text + "','" + txt_alamat.Text + "','" + comboBox1.Text + "','" + txt_namawali.Text + "','" + txt_hp.Text + "');"; byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil menambah data !!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); } AddSiswa_Load(null, null); } else { MessageBox.Show("No Induk sudah terpakai", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); txt_no_induk.Clear(); txt_no_induk.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_simpan_Click(object sender, EventArgs e) { try { koneksi = new Konektor(); if (txt_kodeguru.Text == "" || txt_namaGuru.Text == "" || txt_Alamat.Text == "" || txt_hp.Text == "") { MessageBox.Show("Mohon Lengkapi Data Dulu !!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); txt_kodeguru.Focus(); } else { ds = new DataSet(); ds = koneksi.GetData("select * from guru where no_guru = '" + txt_kodeguru.Text + "'"); if (ds.Tables[0].Rows.Count == 0) { query = "insert into guru values ('" + txt_kodeguru.Text + "','" + txt_namaGuru.Text + "','" + txt_Alamat.Text + "','" + txt_hp.Text + "','" + txt_jabatan.Text + "');"; byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil menambah data !!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); } Guru_Load(null, null); } else { MessageBox.Show("No Induk sudah terpakai", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); txt_kodeguru.Clear(); txt_kodeguru.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private DataTable GetDataSource(string query) { DataTable dTable = new DataTable(); DataRow dRow = null; DateTime dTime; Random rnd = new Random(); dTable.Columns.Add("_Check", System.Type.GetType("System.Boolean")); dTable.Columns.Add("_kode_guru"); dTable.Columns.Add("_nama_guru"); dTable.Columns.Add("alamat"); dTable.Columns.Add("_no_hp"); dTable.Columns.Add("jabatan"); ds = new DataSet(); koneksi = new Konektor(); ds = koneksi.GetData(query); for (int n = 0; n < ds.Tables[0].Rows.Count; ++n) { dRow = dTable.NewRow(); dTime = DateTime.Now; dRow["_Check"] = "true"; dRow["_kode_guru"] = ds.Tables[0].Rows[n][0].ToString(); dRow["_nama_guru"] = ds.Tables[0].Rows[n][1].ToString(); dRow["alamat"] = ds.Tables[0].Rows[n][2].ToString(); dRow["_no_hp"] = ds.Tables[0].Rows[n][3].ToString(); dRow["jabatan"] = ds.Tables[0].Rows[n][4].ToString(); dTable.Rows.Add(dRow); dTable.AcceptChanges(); } return(dTable); }
private void vistaButton2_Click(object sender, EventArgs e) { try { koneksi = new Konektor(); if (txt_no_induk.Text == "" || txt_nama.Text == "" || txt_namawali.Text == "" || txt_hp.Text == "") { MessageBox.Show("Mohon Lengkapi Data Dulu !!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); txt_no_induk.Focus(); } else { ds = new DataSet(); ds = koneksi.GetData("select * from siswa where no_induk = '"+txt_no_induk.Text+"'"); if (ds.Tables[0].Rows.Count == 0) { query = "insert into siswa values ('" + txt_no_induk.Text + "','" + txt_nama.Text + "','" + txt_alamat.Text + "','" + comboBox1.Text + "','" + txt_namawali.Text + "','" + txt_hp.Text + "');"; byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil menambah data !!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); } AddSiswa_Load(null, null); } else { MessageBox.Show("No Induk sudah terpakai","Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning); txt_no_induk.Clear(); txt_no_induk.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private DataTable GetDataSource(string query) { DataTable dTable = new DataTable(); DataRow dRow = null; DateTime dTime; Random rnd = new Random(); dTable.Columns.Add("_Check", System.Type.GetType("System.Boolean")); dTable.Columns.Add("_kode_guru"); dTable.Columns.Add("_nama_guru"); dTable.Columns.Add("alamat"); dTable.Columns.Add("_no_hp"); dTable.Columns.Add("jabatan"); ds = new DataSet(); koneksi = new Konektor(); ds = koneksi.GetData(query); for (int n = 0; n < ds.Tables[0].Rows.Count; ++n) { dRow = dTable.NewRow(); dTime = DateTime.Now; dRow["_Check"] = "true"; dRow["_kode_guru"] = ds.Tables[0].Rows[n][0].ToString(); dRow["_nama_guru"] = ds.Tables[0].Rows[n][1].ToString(); dRow["alamat"] = ds.Tables[0].Rows[n][2].ToString(); dRow["_no_hp"] = ds.Tables[0].Rows[n][3].ToString(); dRow["jabatan"] = ds.Tables[0].Rows[n][4].ToString(); dTable.Rows.Add(dRow); dTable.AcceptChanges(); } return dTable; }
private void btn_simpan_Click(object sender, EventArgs e) { try { if (textBox1.Text != "") { koneksi = new Konektor(); ds = new DataSet(); query = "select * from classes where kelas = '"+textBox1.Text+"';"; ds = koneksi.GetData(query); if (ds.Tables[0].Rows.Count == 0) { query = "insert into Classes values ('" + textBox1.Text + "');"; byte res = (byte)koneksi.ManipulasiData(query); if (res == 1) { MessageBox.Show("Berhasil menambah data"); } } else { MessageBox.Show("Kelas sudah terdaftar !!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Mohon Lengkapi Data Dulu !!", "Warning !!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Kelas_Load(null, null); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }