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();
            }
        }
        private void BtnTambah_Click(object sender, RoutedEventArgs e)
        {
            /*
            string jenishewan = NamaJenisHewanText.Text;

            if(jenishewan == "")
            {
                MessageBox.Show("Masukkan data pada field yang tersedia!");
            }
            else
            {
                bool a = tambahJenisHewan(jenishewan);
                try
                {
                    if (a)
                    {
                        MessageBox.Show("Berhasil Diinputkan!");
                        conn.Close();
                    }
                }
                catch(Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }*/
            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    conn.Open();
                    cmd.CommandText = "INSERT INTO JENIS_HEWAN(NAMA_JENIS) VALUES(@jenis)";
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection = conn;

                    cmd.Parameters.AddWithValue("@jenis", NamaJenisHewanText.Text);


                    cmd.ExecuteNonQuery();
                    conn.Close();
                    GetRecords();
                    MessageBox.Show("Berhasil ditambahkan");
                    NamaJenisHewanText.Clear();
                   // conn.Close();
                }
                catch(Exception err)
                {
                    MessageBox.Show(err.Message);
                } 
            }
        }
示例#3
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);
     }
 }
示例#4
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);
     }
 }
示例#6
0
        private void BtnTambah_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (MySqlCommand cmd = new MySqlCommand())
                {
                    try
                    {
                        conn.Open();
                        cmd.CommandText = "INSERT INTO JENIS_HEWAN(NAMA_JENIS) VALUES(@jenis)";
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = conn;

                        if (NamaJenisHewanText.Text == "")
                        {
                            MessageBox.Show("Field tidak boleh kosong", "Warning");
                            conn.Close();
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@jenis", NamaJenisHewanText.Text);
                            cmd.ExecuteNonQuery();
                            conn.Close();
                            GetRecords();
                            GetLogsRecords();
                            MessageBox.Show("Berhasil ditambahkan");
                            NamaJenisHewanText.Clear();
                        }
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
示例#7
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);
            }
        }
示例#8
0
 private void ClearData()
 {
     NamaJenisHewanText.Clear();
     IdJenisHewanText.Clear();
 }