Beispiel #1
0
        private void Simpan(enumStatusGiro _GiroStatusNew, string _ketStatus)
        {
            bool lOk = true;

            DateTime dTgl = GlobalVar.GetServerDate;

            //Guid _rekeningRowID = Guid.Empty;
            switch (_GiroStatusNew)
            {
            case enumStatusGiro.Cair:
                lOk = ((_GiroStatusLast == enumStatusGiro.Diserahkan) || (_GiroStatusLast == enumStatusGiro.Cair) || _GiroStatusLast == enumStatusGiro.BatalCair);
                break;

            case enumStatusGiro.BatalCair:
                lOk = (_GiroStatusLast == enumStatusGiro.Cair);
                break;

            case enumStatusGiro.Ditolak:
                break;

            case enumStatusGiro.Batal:
                break;

            default: lOk = false; break;
            }
            if (lOk)
            {
                dlgProsesGiroStatus dlg = new dlgProsesGiroStatus(_ketStatus, false, MataUangID, _rekeningRowID, _TglJTGiro);
                dlg.ShowDialog();
                lOk = (dlg.DialogResult == DialogResult.Yes);

                if (lOk)
                {
                    dTgl = (DateTime)dlg.dtTanggal.DateValue;

                    if (((DateTime)Tools.isNull(dTgl, DateTime.MinValue) == DateTime.MinValue) || (dTgl < _GiroStatusTanggal))
                    {
                        lOk = false;
                    }
//                    if (lRekening) _rekeningRowID = (Guid)dlg.cboRekening.SelectedValue;
                }
            }

            if (lOk == true)
            {
                try
                {
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_GiroHistory_INSERT"));
                        db.Commands[0].Parameters.Add(new Parameter("@RefID", SqlDbType.UniqueIdentifier, _rowID));
                        db.Commands[0].Parameters.Add(new Parameter("@JnsGiro", SqlDbType.TinyInt, 0));
                        db.Commands[0].Parameters.Add(new Parameter("@NoGiro", SqlDbType.VarChar, lblNoGiro.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, dTgl));
                        db.Commands[0].Parameters.Add(new Parameter("@StatusGiro", SqlDbType.TinyInt, _GiroStatusNew));
                        //if (lRekening)
                        //{
                        db.Commands[0].Parameters.Add(new Parameter("@RekeningRowID", SqlDbType.UniqueIdentifier, _rekeningRowID));
                        //}
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();

                        RefreshData();
                    }
                }
                catch (Exception ex)
                {
                    Error.LogError(ex);
                }
            }
        }
Beispiel #2
0
        private void Simpan(Class.enumStatusGiro _GiroStatusNew, string _ketStatus, bool lRekening)
        {
            bool lOk = true;

            DateTime dTgl = GlobalVar.GetServerDate;

            //Guid _rekeningRowID = Guid.Empty;
            switch (_GiroStatusNew)
            {
            case Class.enumStatusGiro.Disetor:
                lOk = ((_GiroStatusLast == Class.enumStatusGiro.Diterima) || (_GiroStatusLast == Class.enumStatusGiro.BatalSetor));
                break;

            case Class.enumStatusGiro.BatalSetor:
                lOk = (_GiroStatusLast == Class.enumStatusGiro.Disetor);
                break;

            case Class.enumStatusGiro.Cair:
                if (_GiroStatusLast != Class.enumStatusGiro.Cair)
                {
                    lOk = true;
                }
                else
                {
                    lOk = ((_GiroStatusLast == Class.enumStatusGiro.Disetor) || (_GiroStatusLast == Class.enumStatusGiro.Cair));
                }

                break;

            case Class.enumStatusGiro.BatalCair:
                lOk = (_GiroStatusLast == Class.enumStatusGiro.Cair);
                break;

            case Class.enumStatusGiro.Ditolak:
                break;

            case Class.enumStatusGiro.Batal:
                break;

            default: lOk = false; break;
            }
            if (lOk)
            {
                dlgProsesGiroStatus dlg = new dlgProsesGiroStatus(_ketStatus, lRekening, MataUangID, _rekeningRowID, _TglJTGiro);
                dlg.ShowDialog();
                lOk = (dlg.DialogResult == DialogResult.Yes);

                if (lOk)
                {
                    dTgl = (DateTime)dlg.dtTanggal.DateValue;

                    if (((DateTime)Tools.isNull(dTgl, DateTime.MinValue) == DateTime.MinValue) || (dTgl < _GiroStatusTanggal))
                    {
                        lOk = false;
                    }

                    if (_ketStatus == "Batal Cair" || _ketStatus == "BatalSetor" || _ketStatus == "Cair" || _ketStatus == "Ditolak")
                    {
                        DataTable dt = new DataTable();
                        using (Database db = new Database())
                        {
                            db.Commands.Add(db.CreateCommand("usp_GetLastRekeningRowIDGiroHistory"));
                            db.Commands[0].Parameters.Add(new Parameter("@NoGiro", SqlDbType.VarChar, lblNoGiro.Text));
                            dt = db.Commands[0].ExecuteDataTable();

                            if (lRekening)
                            {
                                _rekeningRowID = (Guid)dt.Rows[0]["RekeningRowID"];
                            }
                        }
                    }
                    else
                    {
                        if (lRekening)
                        {
                            _rekeningRowID = (Guid)dlg.lookUpRekening1.RekeningRowID;
                        }
                    }
                }
            }

            if (lOk == true)
            {
                try
                {
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_GiroHistory_INSERT"));
                        db.Commands[0].Parameters.Add(new Parameter("@RefID", SqlDbType.UniqueIdentifier, _rowID));

                        // sebelum akhirnya ubah sp
                        //db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, Guid.NewGuid()));

                        if (_GiroStatusNew == Class.enumStatusGiro.Cair)
                        {
                            String   tempBentukPenerimaan = "B";
                            Database dbfNumerator         = new Database(GlobalVar.DBFinanceOto);
                            String   NoTransPenerimaan    = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                                      "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                                      string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                                      , 4, false, true);

                            // buatin parameter, kirimin numeratornya
                            db.Commands[0].Parameters.Add(new Parameter("@NoBukti", SqlDbType.VarChar, NoTransPenerimaan));
                        }
                        db.Commands[0].Parameters.Add(new Parameter("@JnsGiro", SqlDbType.TinyInt, 1));
                        db.Commands[0].Parameters.Add(new Parameter("@NoGiro", SqlDbType.VarChar, lblNoGiro.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Tanggal", SqlDbType.Date, dTgl));
                        db.Commands[0].Parameters.Add(new Parameter("@StatusGiro", SqlDbType.TinyInt, _GiroStatusNew));
                        if (lRekening)
                        {
                            db.Commands[0].Parameters.Add(new Parameter("@RekeningRowID", SqlDbType.UniqueIdentifier, _rekeningRowID));
                        }
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();

                        RefreshData();
                    }
                }
                catch (Exception ex)
                {
                    Error.LogError(ex);
                }
            }
        }