private void btn_update_Click(object sender, RoutedEventArgs e) { c = new ConnectionUtils(); pd = new PerangkatDAO(); if (!edit) { edit = true; btn_hapus.IsEnabled = true; labelUbah.Content = "Simpan"; iconUbah.Kind = MaterialDesignThemes.Wpf.PackIconKind.ContentSaveOutline; } else { edit = false; btn_hapus.IsEnabled = false; labelUbah.Content = "Ubah"; iconUbah.Kind = MaterialDesignThemes.Wpf.PackIconKind.SquareEditOutline; if (Properties.Settings.Default.tempJabatan != string.Empty) { if (pd.updateData(txt_namaPerangkat.Text.ToString(), IntegerExtensions.ParseInt(txt_Nip.Text), cmb_jabatan.Text.ToString())) { MessageBox.Show("Berhasil Mengubah Data Bosku", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } } Properties.Settings.Default.tempJabatan = ""; Properties.Settings.Default.Save(); emptyFields(); loadTablePerangkat(); pd.resetAutoIncrement(); } }
private void btn_baru_Click(object sender, RoutedEventArgs e) { c = new ConnectionUtils(); pd = new PerangkatDAO(); string a = "- Pilih Jabatan -"; if (txt_namaPerangkat.Text != string.Empty && cmb_jabatan.Text.ToString() != a) { if (!pd.CheckJabatan(cmb_jabatan.Text.ToString())) { if (pd.insertData(txt_namaPerangkat.Text.ToString(), IntegerExtensions.ParseInt(txt_Nip.Text), cmb_jabatan.Text.ToString())) { MessageBox.Show("Data Perangkat Berhasil ditambahkan Bosku!", "Sukses", MessageBoxButton.OK, MessageBoxImage.Information); emptyFields(); loadTablePerangkat(); } } } else { MessageBox.Show("Nama Perangkat dan Jabatan Wajib di isi Bosku!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btn_edit_Click(object sender, RoutedEventArgs e) { c = new ConnectionUtils(); sd = new sppdDAO(); var na = new StringBuilder(); na.Append(agenda.Text); na.Append(txt_separator1.Text); na.Append(txt_autoNumber.Text); na.Append(txt_separator2.Text); na.Append(txt_currentMonth.Text); na.Append(txt_separator3.Text); na.Append(txt_currentYear.Text); string no_agenda = na.ToString(); if (!edit) { edit = true; btn_hapus.IsEnabled = true; iconUbah.Kind = MaterialDesignThemes.Wpf.PackIconKind.ContentSaveOutline; } else { edit = false; btn_hapus.IsEnabled = false; iconUbah.Kind = MaterialDesignThemes.Wpf.PackIconKind.BriefcaseEditOutline; if (sd.updateDataSPPD(no_agenda.ToString(), txt_ds.Text.ToString(), dp_ts.Text.ToString(), cmb_namaPerangkat.Text.ToString(), IntegerExtensions.ParseInt(txt_nip.Text), txt_jabatan.Text.ToString(), txt_maksud.Text.ToString(), cmb_alat.Text.ToString(), txt_tempatBerangkat.Text.ToString(), txt_tempatTujuan.Text.ToString(), dp_tb.Text.ToString(), dp_tk.Text.ToString(), txt_lk.Text.ToString(), cmb_pengikut1.Text.ToString(), txt_jabatan_pengikut1.Text.ToString(), cmb_pengikut2.Text.ToString(), txt_jabatan_pengikut2.Text.ToString(), txt_sumberAnggaran.Text.ToString(), txt_ket.Text.ToString())) { MessageBox.Show("Berhasil Mengubah Data Bosku", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } emptyFields(); loadTableSPPD(); sd.resetAutoIncrement(); } }
private void btn_new_Click(object sender, RoutedEventArgs e) { edit = false; c = new ConnectionUtils(); sd = new sppdDAO(); var na = new StringBuilder(); try { na.Append(agenda.Text); na.Append(txt_separator1.Text); na.Append(txt_autoNumber.Text); na.Append(txt_separator2.Text); na.Append(txt_currentMonth.Text); na.Append(txt_separator3.Text); na.Append(txt_currentYear.Text); string no_agenda = na.ToString(); try { if (txt_autoNumber.Text != string.Empty && txt_ds.Text != string.Empty && dp_ts.Text.ToString() != string.Empty && cmb_namaPerangkat.Text.ToString() != string.Empty && txt_maksud.Text != string.Empty && cmb_alat.Text.ToString() != string.Empty && txt_tempatBerangkat.Text != string.Empty && txt_tempatTujuan.Text != string.Empty && dp_tb.Text != string.Empty && dp_tk.Text != string.Empty && txt_sumberAnggaran.Text != string.Empty ) { sppdModel sm = new sppdModel(); try { sm.no_agenda = no_agenda.ToString(); sm.dasar_surat = txt_ds.Text.ToString(); sm.tanggal_surat = dp_ts.Text.ToString(); sm.nama_perangkat = cmb_namaPerangkat.Text.ToString(); sm.nip = IntegerExtensions.ParseInt(txt_nip.Text); sm.jabatan = txt_jabatan.Text.ToString(); sm.maksud_sppd = txt_maksud.Text.ToString(); sm.alat_transportasi = cmb_alat.Text.ToString(); sm.tempat_berangkat = txt_tempatBerangkat.Text.ToString(); sm.tempat_tujuan = txt_tempatTujuan.Text.ToString(); sm.tanggal_berangkat = dp_tb.Text.ToString(); sm.tanggal_kembali = dp_tk.Text.ToString(); sm.lama_keberangkatan = txt_lk.Text.ToString(); sm.pengikut1 = cmb_pengikut1.Text.ToString(); sm.jabatan_pengikut1 = txt_jabatan_pengikut1.Text.ToString(); sm.pengikut2 = cmb_pengikut2.Text.ToString(); sm.jabatan_pengikut2 = txt_jabatan_pengikut2.Text.ToString(); sm.sumber_anggaran = txt_sumberAnggaran.Text.ToString(); sm.keterangan = txt_ket.Text.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { try { using (SQLiteConnection con = new SQLiteConnection(c.getConnection())) { try { con.Open(); } catch (Exception ex) { throw ex; } using (SQLiteTransaction trn = con.BeginTransaction(IsolationLevel.ReadCommitted)) { try { sd.insertDataSPPD(sm, trn); } catch (Exception ex) { trn.Rollback(); MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { emptyFields(); loadTableSPPD(); } } } else { MessageBox.Show("Semua yang terdapat tanda (*) wajib diisi Bosku!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }