private void buttonTambah_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtUkuranHewan.Text.Trim())) { MessageBox.Show("Ukuran Hewan Tidak Boleh Kosong"); throw null; } if (!Regex.Match(txtUkuranHewan.Text, @"^[a-zA-Z]+$").Success) { MessageBox.Show("Ukuran Hewan Tidak Boleh Mengandung Angka"); throw null; } var list = new UkuranHewanControl(); ukuranHewan = new UkuranHewan(FormLogin.id_pegawai, txtUkuranHewan.Text); list.CreateUkuranHewan(ukuranHewan); MessageBox.Show("Data Berhasil Ditambah"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public List <UkuranHewan> ShowUkuranHewan() { string sql = "SELECT * FROM ukuran"; List <UkuranHewan> UkuranHewanList = new List <UkuranHewan>(); try { MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader result = cmd.ExecuteReader(); if (result != null) { while (result.Read()) { UkuranHewan UH = new UkuranHewan( result.GetInt32("ID_Ukuran"), result.GetInt32("ID_Pegawai"), result.GetString("Ukuran"), result.GetDateTime("Create_At_Ukuran"), result.GetDateTime("Update_At_Ukuran"), result.GetDateTime("Delete_At_Ukuran")); UkuranHewanList.Add(UH); } } } catch (Exception ex) { Console.WriteLine("Failed to read..."); Console.WriteLine(ex.ToString()); } return(UkuranHewanList); }
public UkuranHewan SearchUkuran(String namaUkuran) { string sql = "SELECT * FROM ukuran WHERE Ukuran = '" + namaUkuran + "';"; UkuranHewan ukuranHewan = null; try { MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader result = cmd.ExecuteReader(); if (result != null) { while (result.Read()) { ukuranHewan = new UkuranHewan( result.GetInt32("ID_Ukuran"), result.GetInt32("ID_Pegawai"), result.GetString("Ukuran"), result.GetDateTime("Create_At_Ukuran"), result.GetDateTime("Update_At_Ukuran"), result.GetDateTime("Delete_At_Ukuran")); } } } catch (Exception ex) { Console.WriteLine("Failed to search..."); Console.WriteLine(ex.ToString()); } return(ukuranHewan); }
public UkuranHewan SearchUkuran(String nama) { UkuranHewan ukuranHewan = null; ukDAO.makeConnection(); ukuranHewan = ukDAO.SearchUkuran(nama); ukDAO.closeConnection(); return(ukuranHewan); }
public void CreateUkuranHewan(UkuranHewan uH) { string sql = "INSERT INTO ukuran(ID_PEGAWAI, UKURAN) " + "VALUES('" + uH.ID_Pegawai + "','" + uH.Ukuran + "');"; try { MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.ExecuteReader(); Console.WriteLine("Data Created..."); } catch (Exception ex) { Console.WriteLine("Failed to create..."); Console.WriteLine(ex.ToString()); } }
public void UpdateUkuranHewan(UkuranHewan uH, String namaUkuran) { string sql = "UPDATE ukuran SET UKURAN = '" + uH.Ukuran + "'" + " WHERE UKURAN = '" + namaUkuran + "';"; try { MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.ExecuteReader(); Console.WriteLine("Data Updated..."); } catch (Exception ex) { Console.WriteLine("Failed to update..."); Console.WriteLine(ex.ToString()); } }
private void btnCari_Click(object sender, EventArgs e) { var list = new UkuranHewanControl(); try { if (txtCari.Text != null && list.SearchUkuran(txtCari.Text) != null) { buttonHapus.Enabled = true; ukuranHewan = list.SearchUkuran(txtCari.Text); txtUkuranHewan.Text = ukuranHewan.Ukuran; } else { MessageBox.Show("Pencarian Tidak Ditemukan"); throw null; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void UpdateUkuranHewan(UkuranHewan ukuranHewan, String ukuran) { ukDAO.makeConnection(); ukDAO.UpdateUkuranHewan(ukuranHewan, ukuran); ukDAO.closeConnection(); }
public void CreateUkuranHewan(UkuranHewan ukuranHewan) { ukDAO.makeConnection(); ukDAO.CreateUkuranHewan(ukuranHewan); ukDAO.closeConnection(); }