private void btnSimpan_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ddKategori.Text)) { MessageBox.Show(this, "\"Kategori surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); ddKategori.Focus(); return; } if (string.IsNullOrEmpty(txtTujuan.Text)) { MessageBox.Show(this, "\"Tujuan surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtTujuan.Focus(); return; } if (string.IsNullOrEmpty(txtTujuan.Text)) { MessageBox.Show(this, "\"Asal surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtTujuan.Focus(); return; } if (string.IsNullOrEmpty(txtPerihalSurat.Text)) { MessageBox.Show(this, "\"Perihal surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtPerihalSurat.Focus(); return; } if (string.IsNullOrEmpty(dropDownTingkatKeamanan.Text)) { MessageBox.Show(this, "\"Tingkat Keamanan\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); dropDownTingkatKeamanan.Focus(); return; } if (MessageBox.Show(this, "Anda yakin akan menginputkan data surat?", "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { try { string resetValue = ""; string reset_id = ""; if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "kategori".ToLower()) resetValue = ddKategori.Text; else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "tkkeamanan".ToLower()) resetValue = dropDownTingkatKeamanan.Text; if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "kategori".ToLower()) reset_id = AppDefaultSetting.surat_keluar_reset_role; else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "tkkeamanan".ToLower()) reset_id = AppDefaultSetting.surat_keluar_reset_role; else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "daily".ToLower()) reset_id = string.Format("{0:yyyy-MM-dd}", dtTanggalKirim.Value); else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "monthly".ToLower()) reset_id = string.Format("{0:yyyy-MM-dd}", dtTanggalKirim.Value); else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "yearly".ToLower()) reset_id = string.Format("{0:yyyy-MM-dd}", dtTanggalKirim.Value); else reset_id = ""; start_index = 1; if (JumlahSurat(reset_id, resetValue) == 0) { if (AppDefaultSetting.surat_keluar_index_start.ToString().ToLower() != "Flat (Value = 1)".ToLower()) { Surat.FrmStartIndexSuratKeluar frmStartIndex = new Surat.FrmStartIndexSuratKeluar(this); frmStartIndex.ShowDialog(); } } if (this.start_index == 0) return; if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "kategori".ToLower()) resetValue = ddKategori.Text; else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "tkkeamanan".ToLower()) resetValue = dropDownTingkatKeamanan.Text; this.nomor_surat = InsertSurat(resetValue); if (!string.IsNullOrEmpty(ddJenisPengiriman.Text)) { SuratBusiness.InsertJenisPengiriman(nomor_surat, GlobalFunction.SqlCharChecker(ddJenisPengiriman.Text), GlobalFunction.SqlCharChecker(txtInfoPengiriman.Text)); } if (!string.IsNullOrEmpty(txtReferensiSurat.Text)) { if (SuratQuery.IsSuratMasuk(GlobalFunction.SqlCharChecker(txtReferensiSurat.Text.Replace("\0", "")))) SuratBusiness.InsertReferensiSuratKeluar(nomor_surat, GlobalFunction.SqlCharChecker(txtReferensiSurat.Text.Replace("\0", ""))); } MessageBox.Show(this, "Nomor agenda surat: " + nomor_surat, "Data Disimpan", MessageBoxButtons.OK, MessageBoxIcon.Information); this.frmMain.insertSingleSuratKeluar(this); MessageBox.Show(this, "Data surat sudah disimpan di database.", "Input sukses", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); if (chkOtomatisCetakLembarDisposisi.Checked) PrintAgenda(); clearInput(); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnSimpan_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ddKategori.Text)) { MessageBox.Show(this, "\"Kategori surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); ddKategori.Focus(); return; } if (string.IsNullOrEmpty(txtTujuan.Text)) { MessageBox.Show(this, "\"Tujuan surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtTujuan.Focus(); return; } if (string.IsNullOrEmpty(txtTujuan.Text)) { MessageBox.Show(this, "\"Asal surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtTujuan.Focus(); return; } if (string.IsNullOrEmpty(txtPerihalSurat.Text)) { MessageBox.Show(this, "\"Perihal surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtPerihalSurat.Focus(); return; } if (string.IsNullOrEmpty(dropDownTingkatKeamanan.Text)) { MessageBox.Show(this, "\"Tingkat Keamanan\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop); dropDownTingkatKeamanan.Focus(); return; } if (MessageBox.Show(this, "Anda yakin akan menginputkan data surat?", "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { try { string resetValue = ""; string reset_id = ""; if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "kategori".ToLower()) { resetValue = ddKategori.Text; } else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "tkkeamanan".ToLower()) { resetValue = dropDownTingkatKeamanan.Text; } if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "kategori".ToLower()) { reset_id = AppDefaultSetting.surat_keluar_reset_role; } else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "tkkeamanan".ToLower()) { reset_id = AppDefaultSetting.surat_keluar_reset_role; } else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "daily".ToLower()) { reset_id = string.Format("{0:yyyy-MM-dd}", dtTanggalKirim.Value); } else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "monthly".ToLower()) { reset_id = string.Format("{0:yyyy-MM-dd}", dtTanggalKirim.Value); } else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "yearly".ToLower()) { reset_id = string.Format("{0:yyyy-MM-dd}", dtTanggalKirim.Value); } else { reset_id = ""; } start_index = 1; if (JumlahSurat(reset_id, resetValue) == 0) { if (AppDefaultSetting.surat_keluar_index_start.ToString().ToLower() != "Flat (Value = 1)".ToLower()) { Surat.FrmStartIndexSuratKeluar frmStartIndex = new Surat.FrmStartIndexSuratKeluar(this); frmStartIndex.ShowDialog(); } } if (this.start_index == 0) { return; } if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "kategori".ToLower()) { resetValue = ddKategori.Text; } else if (AppDefaultSetting.surat_keluar_reset_role.ToLower() == "tkkeamanan".ToLower()) { resetValue = dropDownTingkatKeamanan.Text; } this.nomor_surat = InsertSurat(resetValue); if (!string.IsNullOrEmpty(ddJenisPengiriman.Text)) { SuratBusiness.InsertJenisPengiriman(nomor_surat, GlobalFunction.SqlCharChecker(ddJenisPengiriman.Text), GlobalFunction.SqlCharChecker(txtInfoPengiriman.Text)); } if (!string.IsNullOrEmpty(txtReferensiSurat.Text)) { if (SuratQuery.IsSuratMasuk(GlobalFunction.SqlCharChecker(txtReferensiSurat.Text.Replace("\0", "")))) { SuratBusiness.InsertReferensiSuratKeluar(nomor_surat, GlobalFunction.SqlCharChecker(txtReferensiSurat.Text.Replace("\0", ""))); } } MessageBox.Show(this, "Nomor agenda surat: " + nomor_surat, "Data Disimpan", MessageBoxButtons.OK, MessageBoxIcon.Information); this.frmMain.insertSingleSuratKeluar(this); MessageBox.Show(this, "Data surat sudah disimpan di database.", "Input sukses", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); if (chkOtomatisCetakLembarDisposisi.Checked) { PrintAgenda(); } clearInput(); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }