private void generateAutoNumber() { sd = new sppdDAO(); int autonumber = (sd.getLastInput()) + 1; txt_autoNumber.Text = autonumber.ToString("D3"); }
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 initTableSppd() { c = new ConnectionUtils(); sd = new sppdDAO(); if (!sd.CheckDBsppd()) { if (sd.CreateTableSPPD()) { Console.WriteLine("table sppd telah dibuat bosku"); } } }
private void btn_hapus_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(); MessageBoxResult re = MessageBox.Show("Apakah anda yakin ingin menghapus Data ini bosku?", "Konfirmasi", MessageBoxButton.YesNo, MessageBoxImage.Question); if (re == MessageBoxResult.Yes) { if (!sd.CheckAgenda(no_agenda)) { if (sd.removeData(no_agenda)) { MessageBox.Show("Berhasil Menghapus Data Bosku", "Succes", MessageBoxButton.OK, MessageBoxImage.Information); emptyFields(); loadTableSPPD(); sd.resetAutoIncrement(); } } else { MessageBox.Show("Data Tidak Ditemukan Bosku", "Gagal Menghapus", MessageBoxButton.OK, MessageBoxImage.Error); } } else { //Exit Selection } }
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); } }