//int _docType = 0;

        protected override string DoIt()
        {
            try
            {
                MVA027PostDatedCheck _pdc = new MVA027PostDatedCheck(GetCtx(), GetRecord_ID(), null);
                int _id = _pdc.GetVA027_PostDatedCheck_ID();
                _sql.Append(@"SELECT C_PAYMENT_ID FROM VA027_POSTDATEDCHECK WHERE VA027_POSTDATEDCHECK_ID=" + _id + "AND AD_Client_ID = " + GetAD_Client_ID());
                int _payID = Util.GetValueOfInt(DB.ExecuteScalar(_sql.ToString()));
                if (_payID > 0)
                {
                    return(Msg.GetMsg(GetCtx(), "VA027_PaymentAlreadyGenerated"));
                }
                string _docStatus = _pdc.GetDocStatus();
                if (_docStatus == "CO")
                {
                    ViennaAdvantage.Process.VA027_GenPayment _genPayment = new ViennaAdvantage.Process.VA027_GenPayment();
                    _genPayment.GenratePayment(GetCtx(), GetRecord_ID(), Get_TrxName());
                    return(Msg.GetMsg(GetCtx(), "VA027_PaymentGenerated"));
                }
                return(Msg.GetMsg(GetCtx(), "VA027_PDCNotCompleted"));
            }
            catch (Exception ex)
            {
                log.Severe(ex.ToString());
            }

            return("");
        }
Example #2
0
        /// <summary>
        /// Create Payment
        /// </summary>
        /// <returns></returns>
        public string Create()
        {
            StringBuilder sbRet       = new StringBuilder();
            string        _systemDate = _sysDate.Value.ToShortDateString();

            _Sql.Clear();
            _Sql.Append(@"SELECT PDC.VA027_CheckDate, PDC.VA027_POSTDATEDCHECK_ID,PDC.DOCUMENTNO FROM VA027_PostDatedCheck PDC WHERE PDC.IsActive = 'Y' AND PDC.VA027_PAYMENTGENERATED='N' AND PDC.DOCSTATUS ='CO' AND PDC.VA027_MULTICHEQUE='N' AND PDC.AD_Client_ID = " + GetCtx().GetAD_Client_ID() + " AND PDC.AD_Org_ID=" + GetCtx().GetAD_Org_ID());
            DataSet _date = new DataSet();

            _date = DB.ExecuteDataset(_Sql.ToString(), null, Get_TrxName());
            for (int i = 0; i < _date.Tables[0].Rows.Count; i++)
            {
                DateTime _checkdt   = Convert.ToDateTime(_date.Tables[0].Rows[i]["VA027_CheckDate"]);
                int      record_ID  = Util.GetValueOfInt(_date.Tables[0].Rows[i]["VA027_PostDatedCheck_ID"]);
                string   _checkDate = _checkdt.ToShortDateString();
                if (Convert.ToDateTime(_checkDate) <= Convert.ToDateTime(_systemDate)) //changes made by arpit
                {
                    ViennaAdvantage.Process.VA027_GenPayment _genPayment = new ViennaAdvantage.Process.VA027_GenPayment();
                    string result = _genPayment.GenratePaymentHdr(GetCtx(), record_ID, paymentDocumentTypeId, Get_TrxName());
                    if (result == "E")
                    {
                        if (sbRet.Length != 0)
                        {
                            sbRet.Append(", " + Util.GetValueOfInt(_date.Tables[0].Rows[i]["DocumentNo"]));
                        }
                        else
                        {
                            sbRet.Append(Msg.GetMsg(GetCtx(), "VA027_PaymentsNotSaved") + Util.GetValueOfInt(_date.Tables[0].Rows[i]["DocumentNo"]));
                        }
                    }
                }
            }

            _Sql.Clear();
            _date.Dispose();

            _Sql.Append(@"SELECT PDC.VA027_CheckDate, PDC.VA027_POSTDATEDCHECK_ID,PDC.DOCUMENTNO FROM VA027_PostDatedCheck PDC WHERE PDC.IsActive = 'Y' AND PDC.VA027_PAYMENTGENERATED='N' AND PDC.DOCSTATUS ='CO' AND PDC.VA027_MULTICHEQUE='Y' AND PDC.AD_Client_ID = " + GetCtx().GetAD_Client_ID() + " AND PDC.AD_Org_ID=" + GetCtx().GetAD_Org_ID());
            _date = DB.ExecuteDataset(_Sql.ToString(), null, Get_TrxName());
            for (int i = 0; i < _date.Tables[0].Rows.Count; i++)
            {
                int record_ID = Util.GetValueOfInt(_date.Tables[0].Rows[i]["VA027_PostDatedCheck_ID"]);
                ViennaAdvantage.Process.VA027_GenPayment _genPayment = new ViennaAdvantage.Process.VA027_GenPayment();
                string result = _genPayment.GenratePaymentLine(GetCtx(), record_ID, paymentDocumentTypeId, Get_TrxName());
                if (result == "E")
                {
                    if (sbRet.Length != 0)
                    {
                        sbRet.Append(", " + Util.GetValueOfInt(_date.Tables[0].Rows[i]["DocumentNo"]));
                    }
                    else
                    {
                        sbRet.Append(Msg.GetMsg(GetCtx(), "VA027_PaymentsNotSaved") + Util.GetValueOfInt(_date.Tables[0].Rows[i]["DocumentNo"]));
                    }
                }
            }
            if (sbRet.Length != 0)
            {
                sbRet.Append(Msg.GetMsg(GetCtx(), "VA027_PaymentGenerated"));
            }
            _Sql.Clear();
            return(sbRet.ToString());
        }