private void userKeyDown(object sender, KeyEventArgs e) { if (sender.Equals(txtSearch)) { if (e.KeyCode == Keys.Enter) { try { try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "name LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception er) { Console.WriteLine(er.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "nomor_induk_anggota LIKE '____" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception es) { Console.WriteLine(es.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "alamat_asli LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception et) { Console.WriteLine(et.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "alamat_kos LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception eu) { Console.WriteLine(eu.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "perguruan_tinggi LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception ev) { Console.WriteLine(ev.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "jurusan LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception ew) { Console.WriteLine(ew.Message); var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "phone_number LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } } } } } } } catch (Exception er) { MessageBox.Show(er.Message, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } } else if (e.KeyCode == Keys.Escape) { txtSearch.Text = ""; } } else if (e.KeyCode == Keys.Delete) { if (_restriction == "admin" || _restriction == "sekertaris") { if (_code == "") { MessageBox.Show("Code Not Selected!", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } else { File.Delete(Application.StartupPath + "\\Picture\\" + _listItem[0].NIA.ToString() + ".jpg"); Console.WriteLine("code = " + _code); var code = _code; var SosCode = _Soscode; var PtCode = _Ptcode; var msg = MessageBox.Show("Are you Sure", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (msg == DialogResult.Yes) { Console.WriteLine("A_id = " + code + ", S_id = " + SosCode + ", P_id = " + PtCode); var data = new Anggota_KMB(code); var cp = new Contact_Person(code, SosCode); var sosmed = new Sosial_Media(SosCode); if (cp.Remove()) { if (sosmed.Remove()) { if (data.Remove()) { MessageBox.Show("Berhasil Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); resetcomponent(); } else { MessageBox.Show("Anggota Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("SosMed Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("CP Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } } }
private void btnClicked(object sender, EventArgs e) { if (sender.Equals(btnInput)) { new loginfrm().Show(); this.Hide(); } else if (sender.Equals(btnSearch)) { try { try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "name LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception er) { Console.WriteLine(er.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "nomor_induk_anggota LIKE '____" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception es) { Console.WriteLine(es.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "alamat_asli LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception et) { Console.WriteLine(et.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "alamat_kos LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception eu) { Console.WriteLine(eu.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "perguruan_tinggi LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception ev) { Console.WriteLine(ev.Message); try { var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "jurusan LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } catch (Exception ew) { Console.WriteLine(ew.Message); var bs = new BindingSource(); bs.DataSource = MemberGridView.DataSource; bs.Filter = "phone_number LIKE '%" + txtSearch.Text + "%'"; MemberGridView.DataSource = bs; } } } } } } } catch (Exception er) { MessageBox.Show(er.Message, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } } else if (sender.Equals(btnAddMember)) { new DataMember(_restriction).Show(); } else if (sender.Equals(btnAddCollege)) { new DataCollege(_restriction).Show(); } else if (sender.Equals(btnDelete)) { Console.WriteLine("code = " + _code); if (_code == "") { MessageBox.Show("Code Not Selected!", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } else { File.Delete(Application.StartupPath + "\\Picture\\" + _listItem[0].NIA.ToString() + ".jpg"); Console.WriteLine("code = " + _code); var code = _code; var SosCode = _Soscode; var PtCode = _Ptcode; var msg = MessageBox.Show("Are you Sure", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (msg == DialogResult.Yes) { Console.WriteLine("A_id = " + code + ", S_id = " + SosCode + ", P_id = " + PtCode); var data = new Anggota_KMB(code); var cp = new Contact_Person(code, SosCode); var sosmed = new Sosial_Media(SosCode); if (cp.Remove()) { if (sosmed.Remove()) { if (data.Remove()) { MessageBox.Show("Berhasil Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); resetcomponent(); } else { MessageBox.Show("Anggota Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("SosMed Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("CP Gagal Dihapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } else if (sender.Equals(btnReset)) { ShowData(); resetcomponent(); } else if (sender.Equals(btnEdit)) { if (_code == "") { MessageBox.Show("No Code Selected", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { new DataMember(_restriction, _code, _Soscode, _Ptcode, _listItem).Show(); } } else if (sender.Equals(btnExit)) { var msg = MessageBox.Show("Are you Sure?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (msg == DialogResult.Yes) { this.Dispose(); } } else if (sender.Equals(btnExport)) { //new KmbMember.View.IOReport("export", MemberGridView).Show(); ExportToExcelWithFormatting(MemberGridView); } }