private void BtnHapus_Click(object sender, RoutedEventArgs e)
        {
            conn.Open();
            try
            {
                using (MySqlCommand cmd = new MySqlCommand())
                {
                    cmd.CommandText = "DELETE FROM JENIS_HEWAN WHERE ID_JENIS_HEWAN = @idjenis";
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection = conn;

                    cmd.Parameters.AddWithValue("@idjenis", IdJenisHewanText.Text);
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    GetRecords();
                    MessageBox.Show("Berhasil Dihapus!");
                    NamaJenisHewanText.Clear();
                    IdJenisHewanText.Clear();
                }
            }
            catch(Exception err)
            {
                MessageBox.Show(err.Message);
                conn.Close();
            }
        }
예제 #2
0
 private void DeleteButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ds      = new DataSet();
         adapter = new MySqlDataAdapter("delete from jenis_hewan where ID_JENIS_HEWAN = " + IdJenisHewanText.Text, conn);
         adapter.Fill(ds, "jenis_hewan");
         GetRecords();
         MessageBox.Show("Berhasil Dihapus!");
         IdJenisHewanText.Clear();
         IdPegawaiText.Clear();
         NamaJenisHewanText.Clear();
     }
     catch (Exception d)
     {
         MessageBox.Show(d.Message);
     }
 }
예제 #3
0
 private void EditButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ds      = new DataSet();
         adapter = new MySqlDataAdapter("update jenis_hewan set ID_PEGAWAI = '" + IdPegawaiText.Text + "', NAMA_JENIS = '" + NamaJenisHewanText.Text + "'where ID_JENIS_HEWAN = " + IdJenisHewanText.Text + "", conn);
         adapter.Fill(ds, "jenis_hewan");
         GetRecords();
         MessageBox.Show("Berhasil Diedit!");
         IdJenisHewanText.Clear();
         IdPegawaiText.Clear();
         NamaJenisHewanText.Clear();
     }
     catch (Exception d)
     {
         MessageBox.Show(d.Message);
     }
 }
 private void BtnEdit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         conn.Open();
         ds = new DataSet();
         adapter = new MySqlDataAdapter("update jenis_hewan set NAMA_JENIS = '" + NamaJenisHewanText.Text + "'where ID_JENIS_HEWAN = '" + IdJenisHewanText.Text +"'", conn);
         adapter.Fill(ds, "jenis_hewan");
         conn.Close();
         GetRecords();
         MessageBox.Show("Berhasil Diedit!");
         NamaJenisHewanText.Clear();
         IdJenisHewanText.Clear();
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
 }
예제 #5
0
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (NamaJenisHewanText.Text == "")
                {
                    MessageBox.Show("Field tidak boleh kosong", "Warning");
                }
                else
                {
                    conn.Open();
                    ds = new DataSet();
                    string tanggalUpdate = tanggal.ToString("yyyy-MM-dd H:mm:ss");

                    adapter = new MySqlDataAdapter("update jenis_hewan set NAMA_JENIS = '" + NamaJenisHewanText.Text + "', UPDATE_AT = '" + tanggalUpdate + "' where ID_JENIS_HEWAN = '" + IdJenisHewanText.Text + "'", conn);

                    if (NamaJenisHewanText.Text == "")
                    {
                        MessageBox.Show("Field tidak boleh kosong", "Warning");
                        conn.Close();
                    }
                    else
                    {
                        adapter.Fill(ds, "jenis_hewan");
                        conn.Close();
                        GetRecords();
                        GetLogsRecords();
                        MessageBox.Show("Berhasil Diedit!");
                        NamaJenisHewanText.Clear();
                        IdJenisHewanText.Clear();
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
예제 #6
0
 private void ClearData()
 {
     NamaJenisHewanText.Clear();
     IdJenisHewanText.Clear();
 }