Ejemplo n.º 1
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(lblNomorAgenda.Text.Replace("\0", "")))
            {
                MessageBox.Show(this, "\"Nomor Agenda\" tidak boleh kosong.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                lblNomorAgenda.Focus();
                return;
            }

            if (!SuratQuery.IsSuratMasuk(lblNomorAgenda.Text.Replace("\0", "")))
            {
                MessageBox.Show(this, "Data surat tidak ditemukan.", "Input Kosong", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                lblNomorAgenda.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtDiteruskanKepada.Text))
            {
                MessageBox.Show(this, "Disposisi tidak boleh kosong.", "Data tidak lengkap", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                txtDiteruskanKepada.Focus();
                return;
            }

            if (MessageBox.Show(this, "Apakah Anda yakin akan melakukan disposisi pada surat ini?", "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
                == System.Windows.Forms.DialogResult.No)
            {
                return;
            }
            SuratBusiness.InsertDisposisi
                (GlobalFunction.SqlCharChecker((lblNomorAgenda.Text.Replace("\0", ""))), dtTanggalDisposisi.Value,
                GlobalFunction.SqlCharChecker(txtDiteruskanKepada.Text), GlobalFunction.SqlCharChecker(txtKeterangan.Text), T8UserLoginInfo.Username);
            MessageBox.Show(this, "Data disposisi sudah disimpan.", "Simpan Disposisi", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

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

            if (chkOtomatisCetakLembarDisposisi.Checked)
            {
                PrintAgenda();
            }

            clearInput();
        }
Ejemplo n.º 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();
                }
            }
        }