private void btnCari_Click(object sender, EventArgs e) { var list = new PegawaiControl(); try { if (txtCari.Text != null && list.SearchPegawai(txtCari.Text) != null) { buttonHapus.Enabled = true; pegawai = list.SearchPegawai(txtCari.Text); txtNamaPegawai.Text = pegawai.Nama_Pegawai; txtAlamatPegawai.Text = pegawai.Alamat_Pegawai; txtNomorTelponPegawai.Text = pegawai.Phone_Pegawai; txtPassword.Text = pegawai.Password; dateTimePickerPegawai.Value = DateTime.Parse(pegawai.Tgl_Lahir_Pegawai); comboBoxJabatan.Text = pegawai.Jabatan; } else { MessageBox.Show("Pencarian Tidak Ditemukan"); throw null; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void buttonTampilPegawai_Click(object sender, EventArgs e) { txtCari.Enabled = true; btnCari.Enabled = true; stat = "pegawai"; var ctrl = new PegawaiControl(); dataGridViewTampil.DataSource = ctrl.ShowPegawai(); }
private void buttonTambah_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtNamaPegawai.Text.Trim())) { MessageBox.Show("Nama Pegawai Tidak Boleh Kosong"); throw null; } if (!Regex.Match(txtNamaPegawai.Text, @"^[a-zA-Z]+$").Success) { MessageBox.Show("Nama Pegawai Tidak Boleh Mengandung Angka"); throw null; } if (string.IsNullOrEmpty(txtAlamatPegawai.Text.Trim())) { MessageBox.Show("Alamat Pegawai Tidak Boleh Kosong"); throw null; } if (string.IsNullOrEmpty(txtNomorTelponPegawai.Text.Trim())) { MessageBox.Show("Nomor Telpon Pegawai Tidak Boleh Kosong"); throw null; } if (string.IsNullOrEmpty(comboBoxJabatan.Text.Trim())) { MessageBox.Show("Jabatan Tidak Boleh Kosong"); throw null; } if (string.IsNullOrEmpty(txtPassword.Text.Trim())) { MessageBox.Show("Password Tidak Boleh Kosong"); throw null; } var list = new PegawaiControl(); pegawai = new Pegawai(txtNamaPegawai.Text, txtAlamatPegawai.Text, dateTimePickerPegawai.Text, txtNomorTelponPegawai.Text, comboBoxJabatan.Text, txtPassword.Text); ValidateNumberOnly(txtNomorTelponPegawai.Text); list.CreatePegawai(pegawai); MessageBox.Show("Data Berhasil Ditambah"); } catch (NumberOnlyException ex) { Console.WriteLine(ex.ToString()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void buttonHapus_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtCari.Text.Trim())) { MessageBox.Show("Text Pencarian Kosong"); throw null; } var list = new PegawaiControl(); list.DeletePegawai(txtCari.Text); MessageBox.Show("Data Berhasil Dihapus"); buttonHapus.Enabled = false; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void btnCari_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtCari.Text.Trim())) { MessageBox.Show("Text Pencarian Kosong"); throw null; } if (stat == "customer") { var ctrl = new CustomerControl(); if (ctrl.SearchCustomer(txtCari.Text) == null) { MessageBox.Show("Pencarian Tidak Ditemukan"); throw null; } else { List <Customer> CustomerList = new List <Customer>(); CustomerList.Add(ctrl.SearchCustomer(txtCari.Text)); dataGridViewTampil.DataSource = CustomerList; } } else if (stat == "hewan") { var ctrl = new HewanControl(); if (ctrl.SearchHewan(txtCari.Text) == null) { MessageBox.Show("Pencarian Tidak Ditemukan"); throw null; } else { List <Hewan> HewanList = new List <Hewan>(); HewanList.Add(ctrl.SearchHewan(txtCari.Text)); dataGridViewTampil.DataSource = HewanList; } } else if (stat == "jenishewan") { var ctrl = new JenisHewanControl(); if (ctrl.SearchJenisHewan(txtCari.Text) == null) { MessageBox.Show("Pencarian Tidak Ditemukan"); throw null; } else { List <JenisHewan> JenisHewanList = new List <JenisHewan>(); JenisHewanList.Add(ctrl.SearchJenisHewan(txtCari.Text)); dataGridViewTampil.DataSource = JenisHewanList; } } else if (stat == "layanan") { var ctrl = new LayananControl(); if (ctrl.SearchLayanan(txtCari.Text) == null) { MessageBox.Show("Pencarian Tidak Ditemukan"); throw null; } else { List <Layanan> LayananList = new List <Layanan>(); LayananList.Add(ctrl.SearchLayanan(txtCari.Text)); dataGridViewTampil.DataSource = LayananList; } } else if (stat == "pegawai") { var ctrl = new PegawaiControl(); if (ctrl.SearchPegawai(txtCari.Text) == null) { MessageBox.Show("Pencarian Tidak Ditemukan"); throw null; } else { List <Pegawai> PegawaiList = new List <Pegawai>(); PegawaiList.Add(ctrl.SearchPegawai(txtCari.Text)); dataGridViewTampil.DataSource = PegawaiList; } } else if (stat == "produk") { string connStr = "datasource=127.0.0.1;port=3306;username=root;password=;database=kouvee;Convert Zero Datetime=True;"; MySqlConnection conn = new MySqlConnection(connStr); string selectQuery = "SELECT * FROM produk WHERE NAMA_PRODUK = '" + txtCari.Text + "'"; MySqlCommand command = new MySqlCommand(selectQuery, conn); MySqlDataAdapter da = new MySqlDataAdapter(command); DataTable table = new DataTable(); da.Fill(table); if (table.Rows.Count == 0) { MessageBox.Show("Pencarian Tidak Ditemukan"); da.Dispose(); throw null; } else { dataGridViewTampil.DataSource = table; DataGridViewImageColumn imageColumn = new DataGridViewImageColumn(); imageColumn = (DataGridViewImageColumn)dataGridViewTampil.Columns[9]; dataGridViewTampil.Columns[8].Visible = false; imageColumn.ImageLayout = DataGridViewImageCellLayout.Stretch; da.Dispose(); } } else if (stat == "supplier") { var ctrl = new SupplierControl(); if (ctrl.SearchSupplier(txtCari.Text) == null) { MessageBox.Show("Pencarian Tidak Ditemukan"); throw null; } else { List <Supplier> SupplierList = new List <Supplier>(); SupplierList.Add(ctrl.SearchSupplier(txtCari.Text)); dataGridViewTampil.DataSource = SupplierList; } } else if (stat == "ukuranhewan") { var ctrl = new UkuranHewanControl(); if (ctrl.SearchUkuran(txtCari.Text) == null) { MessageBox.Show("Pencarian Tidak Ditemukan"); throw null; } else { List <UkuranHewan> UkuranHewanList = new List <UkuranHewan>(); UkuranHewanList.Add(ctrl.SearchUkuran(txtCari.Text)); dataGridViewTampil.DataSource = UkuranHewanList; } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }