Beispiel #1
0
 private void radButton2_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(ddJenisPengiriman.Text))
     {
         try
         {
             if (this.frmDetailSurat != null)
             {
                 SuratBusiness.InsertJenisPengiriman(nomor_agenda, GlobalFunction.SqlCharChecker(ddJenisPengiriman.Text), GlobalFunction.SqlCharChecker(txtInfoPengiriman.Text));
                 MessageBox.Show(this, "Data pengiriman sudah diubah.", "Data disimpan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.frmDetailSurat.BindingJenis();
                 this.Close();
             }
             else
             {
                 SuratBusiness.InsertJenisPengiriman(nomor_agenda, GlobalFunction.SqlCharChecker(ddJenisPengiriman.Text), GlobalFunction.SqlCharChecker(txtInfoPengiriman.Text));
                 MessageBox.Show(this, "Data pengiriman sudah diubah.", "Data disimpan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.frmDetailSuratKeluar.BindingJenis();
                 this.Close();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show(this, "\"Jenis Pengiriman\" tidak boleh kosong.", "Data Belum lengkap.", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         ddJenisPengiriman.Focus();
         return;
     }
 }
Beispiel #2
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(dropDownTipe.Text))
            {
                MessageBox.Show(this, "\"Kategori surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                dropDownTipe.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtNomorSurat.Text))
            {
                MessageBox.Show(this, "\"Nomor surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                txtNomorSurat.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtAsalSurat.Text))
            {
                MessageBox.Show(this, "\"Asal surat\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                txtAsalSurat.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 (chkOtomatisCetakLembarDisposisi.Checked)
            {
                if (string.IsNullOrEmpty(txtTujuanDisposisi.Text))
                {
                    MessageBox.Show(this, "\"Tujuan Disposisi\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    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_masuk_reset_role.ToLower() == "kategori".ToLower())
                    {
                        resetValue = dropDownTipe.Text;
                    }
                    else if (AppDefaultSetting.surat_masuk_reset_role.ToLower() == "tkkeamanan".ToLower())
                    {
                        resetValue = dropDownTingkatKeamanan.Text;
                    }

                    if (AppDefaultSetting.surat_masuk_reset_role.ToLower() == "kategori".ToLower())
                    {
                        reset_id = AppDefaultSetting.surat_masuk_reset_role;
                    }
                    else if (AppDefaultSetting.surat_masuk_reset_role.ToLower() == "tkkeamanan".ToLower())
                    {
                        reset_id = AppDefaultSetting.surat_masuk_reset_role;
                    }
                    else if (AppDefaultSetting.surat_masuk_reset_role.ToLower() == "daily".ToLower())
                    {
                        reset_id = string.Format("{0:yyyy-MM-dd}", dtTanggalMasuk.Value);
                    }
                    else if (AppDefaultSetting.surat_masuk_reset_role.ToLower() == "monthly".ToLower())
                    {
                        reset_id = string.Format("{0:yyyy-MM-dd}", dtTanggalMasuk.Value);
                    }
                    else if (AppDefaultSetting.surat_masuk_reset_role.ToLower() == "yearly".ToLower())
                    {
                        reset_id = string.Format("{0:yyyy-MM-dd}", dtTanggalMasuk.Value);
                    }
                    else
                    {
                        reset_id = "";
                    }

                    start_index = 1;
                    if (JumlahSurat(reset_id, resetValue) == 0)
                    {
                        if (AppDefaultSetting.surat_masuk_index_start.ToString().ToLower() != "Flat (Value = 1)".ToLower())
                        {
                            Surat.FrmStartIndex frmStartIndex = new Surat.FrmStartIndex(this);
                            frmStartIndex.ShowDialog();
                        }
                    }

                    if (this.start_index == 0)
                    {
                        return;
                    }
                    nomor_agenda = InsertSurat(resetValue);

                    if (!string.IsNullOrEmpty(txtReferensiSurat.Text))
                    {
                        if (SuratQuery.IsSuratKeluar(GlobalFunction.SqlCharChecker(txtReferensiSurat.Text.Replace("\0", ""))))
                        {
                            SuratBusiness.InsertReferensiSurat(nomor_agenda, GlobalFunction.SqlCharChecker(txtReferensiSurat.Text.Replace("\0", "")));
                        }
                    }

                    if (!string.IsNullOrEmpty(txtTujuanDisposisi.Text))
                    {
                        SuratBusiness.InsertDisposisi(nomor_agenda, dtTanggalDisposisi.Value, GlobalFunction.SqlCharChecker(txtTujuanDisposisi.Text),
                                                      GlobalFunction.SqlCharChecker(txtIsisDisposisi.Text), T8UserLoginInfo.Username);
                    }

                    if (!string.IsNullOrEmpty(ddJenisPengiriman.Text))
                    {
                        SuratBusiness.InsertJenisPengiriman(nomor_agenda, GlobalFunction.SqlCharChecker(ddJenisPengiriman.Text),
                                                            GlobalFunction.SqlCharChecker(txtInfoPengiriman.Text));
                    }

                    if (!string.IsNullOrEmpty(ddLokasiFisikSurat.Text))
                    {
                        SuratBusiness.InsertLokasiFisikSurat(nomor_agenda, GlobalFunction.SqlCharChecker(ddLokasiFisikSurat.Text),
                                                             GlobalFunction.SqlCharChecker(txtKeteranganLokasi.Text), T8UserLoginInfo.Username);
                    }

                    MessageBox.Show(this, "Nomor agenda surat: " + nomor_agenda, "Data Disimpan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.frmMain.insertSingleSurat(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);
                    T8CoreEnginee.T8Application.DBConnection.Close();
                }
            }
        }