예제 #1
0
파일: POPayManager.cs 프로젝트: ue96/ue96
        public void AuditPoPayItem(POPayItemInfo oInfo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if (oInfo.Status != (int)AppEnum.POPayItemStatus.WaitingAudit)
                    throw new BizException("pay bill is not WaitingAudit status now, Audit failed");

                POPayInfo oPay = LoadPay(oInfo.POSysNo);
                //����Ƿ���ڸ��ɹ�δ��˵�
                if (oPay.POAmt > 0)
                {
                    POInfo po = PurchaseManager.GetInstance().LoadPO(oInfo.POSysNo);
                    if (IsExistsUnAuditPO(po.VendorSysNo, -1, oInfo.SysNo))
                    {
                        throw new BizException("����δ��˵ĸ��ɹ������ܸ��");
                    }
                }

                //POPayInfo oPay = LoadPay(oPayItem.POSysNo);

                //Hashtable htPay = new Hashtable(3);
                //htPay.Add("SysNo", oPay.SysNo);
                //htPay.Add("AlreadyPayAmt", oPay.AlreadyPayAmt);
                //htPay.Add("PayStatus", oPay.PayStatus);
                //new POPayDac().UpdateMaster(htPay);

                Hashtable htPayItem = new Hashtable(2);
                htPayItem.Add("SysNo", oInfo.SysNo);
                htPayItem.Add("Status", (int)AppEnum.POPayItemStatus.WaitingPay);
                htPayItem.Add("AuditUserSysNo", oInfo.AuditUserSysNo);
                htPayItem.Add("AuditTime", oInfo.AuditTime);
                new POPayDac().UpdateItem(htPayItem);

                scope.Complete();
            }
        }
예제 #2
0
        public void InStock(int masterSysNo, int userSysNo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                //�����dz�ʼ״̬
                POInfo dbInfo = LoadPO(masterSysNo);
                if ( dbInfo == null )
                    throw new BizException("does not exist this po sysno");
                if ( dbInfo.Status != (int)AppEnum.POStatus.WaitingInStock )
                    throw new BizException("status is not waiting instock now, in stock failed");

                //���� ���š�״̬�������
                Hashtable ht = new Hashtable(4);

                ht.Add("SysNo", masterSysNo);
                ht.Add("Status", (int)AppEnum.POStatus.InStock);
                ht.Add("InTime", DateTime.Now);
                ht.Add("InUserSysNo", userSysNo);
                if ( 1!=new PODac().UpdateMaster(ht))
                    throw new BizException("expected one-row update failed, verify failed ");

                //�����������(��������ɹ���;), �ɱ�, ���һ�βɹ��ۣ����һ�βɹ���
                CurrencyInfo oCurrency = CurrencyManager.GetInstance().Load(dbInfo.CurrencySysNo);

                foreach(POItemInfo item in dbInfo.itemHash.Values)
                {
                    UnitCostManager.GetInstance().SetCost(item.ProductSysNo, item.Quantity, item.UnitCost);
                    InventoryManager.GetInstance().SetPOInStockQty(dbInfo.StockSysNo, item.ProductSysNo, item.Quantity);
                    ProductManager.GetInstance().SetLastOrderPrice(item.ProductSysNo, Decimal.Round(item.OrderPrice*oCurrency.ExchangeRate,2));
                    ProductManager.GetInstance().SetLastVendor(item.ProductSysNo, dbInfo.VendorSysNo);
                }

                //��û��֧���Ľ�����ɸ��
                POPayInfo  oPay = POPayManager.GetInstance().LoadPay(dbInfo.SysNo);

                //���㸶��Ľ�poamt���Ѿ�֧���IJ��֣�
                decimal payItemAmt = 0;
                if ( oPay == null )
                    payItemAmt = dbInfo.TotalAmt;
                else if ( oPay.POAmt - oPay.AlreadyPayAmt > 0)
                    payItemAmt = oPay.POAmt - oPay.AlreadyPayAmt;

                if ( payItemAmt != 0)
                {
                    POPayItemInfo oPayItem = new Icson.Objects.Finance.POPayItemInfo();
                    oPayItem.POSysNo = dbInfo.SysNo;
                    oPayItem.PayStyle = (int)AppEnum.POPayItemStyle.Normal;
                    oPayItem.PayAmt =  payItemAmt;
                    oPayItem.CreateTime = DateTime.Now;
                    oPayItem.CreateUserSysNo = userSysNo;
                    oPayItem.Note = "auto create during in stock";
                    oPayItem.Status = (int)AppEnum.POPayItemStatus.Origin;
                    POPayManager.GetInstance().InsertPOPayItem(oPayItem);
                }

                //���ɵ���֪ͨ�ʼ�
                ProductNotifyManager.GetInstance().DoNotify(masterSysNo);

                scope.Complete();
            }
        }
예제 #3
0
파일: POPayManager.cs 프로젝트: ue96/ue96
        /// <summary>
        /// ���û��ͨ����������
        /// </summary>
        /// <param name="oInfo"></param>
        public void CancelRequestPoPayItem(POPayItemInfo oInfo, int userSysNo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if (oInfo.Status != (int)AppEnum.POPayItemStatus.WaitingAudit)
                    throw new BizException("pay bill is not WaitingAudit status now, CancelRequest failed");

                Hashtable htPayItem = new Hashtable(2);
                htPayItem.Add("SysNo", oInfo.SysNo);
                htPayItem.Add("Status", (int)AppEnum.POPayItemStatus.Origin);
                new POPayDac().UpdateItem(htPayItem);

                POPayItemErrRequestInfo errRequestInfo = POPayManager.GetInstance().LoadPOPayItemErrRequest(oInfo.SysNo, true);
                if (errRequestInfo != null)
                {
                    errRequestInfo.LastAuditUserSysNo = userSysNo;
                    errRequestInfo.LastAuditTime = DateTime.Now;
                    errRequestInfo.Status = (int)AppEnum.POPayItemErrRequestStatus.PMDReturn;
                    errRequestInfo.LastAuditNote = "���û��ͨ����ϵͳ�Զ�����";
                    ReturnErrRequest(errRequestInfo);
                }

                scope.Complete();
            }
        }
예제 #4
0
파일: POPayManager.cs 프로젝트: ue96/ue96
        public void Import()
        {
            if (!AppConfig.IsImportable)
                throw new BizException("Is Importable is false");

            string sql = " select top 1 sysno from finance_popay";
            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            if (Util.HasMoreRow(ds))
                throw new BizException("the table finance_popay is not empty");

            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                #region �Ȳ���Ӧ�տ��Ϊ�ϵļ�¼���ж����⣬����Ҫ�ϲ���
                string sqlPOPay = @"select
                                        ordersysno as posysno, foreignamt as poamt,
                                        foreignalreadypay as alreadypayamt,
                                        invoicestatus, a.status as paystatus, instocksysno,
                                        b.newsysno as currencysysno, '1' as sysno, '' as note
                                    from
                                        ipp2003..finance_will_pay as a,
                                        ippconvert..currency as b
                                    where
                                        a.currencysysno = b.oldsysno
                                    and a.status <> -1
                                    order by ordersysno";

                DataSet dsPOPay = SqlHelper.ExecuteDataSet(sqlPOPay);
                if (!Util.HasMoreRow(dsPOPay))
                    return;

                POPayInfo oLastPOPay = new POPayInfo();

                foreach (DataRow drPOPay in dsPOPay.Tables[0].Rows)
                {
                    /* old paystatus
                     * -1 abandan
                     * 0 unpay
                     * 1 partly pay
                     * 2 pay
                     * 3 close
                     */
                    /*old invoice status
                     * 0 absent
                     * 1 incomplete
                     * 2 complete
                     */
                    POPayInfo oCurrentPOPay = new POPayInfo();
                    map(oCurrentPOPay, drPOPay);
                    switch (oCurrentPOPay.PayStatus)
                    {
                        case -1:
                            oCurrentPOPay.PayStatus = (int)AppEnum.POPayStatus.Abandon;
                            break;
                        case 0:
                            oCurrentPOPay.PayStatus = (int)AppEnum.POPayStatus.UnPay;
                            break;
                        case 1:
                            oCurrentPOPay.PayStatus = (int)AppEnum.POPayStatus.PartlyPay;
                            break;
                        case 2:
                        case 3:
                            oCurrentPOPay.PayStatus = (int)AppEnum.POPayStatus.FullPay;
                            break;
                        default:
                            break;
                    }
                    switch (oCurrentPOPay.InvoiceStatus)
                    {
                        case 0:
                            oCurrentPOPay.InvoiceStatus = (int)AppEnum.POPayInvoiceStatus.Absent;
                            break;
                        case 1:
                            oCurrentPOPay.InvoiceStatus = (int)AppEnum.POPayInvoiceStatus.Incomplete;
                            break;
                        case 2:
                            oCurrentPOPay.InvoiceStatus = (int)AppEnum.POPayInvoiceStatus.Complete;
                            break;
                        default:
                            break;
                    }

                    if (oLastPOPay.POSysNo == AppConst.IntNull)
                    {

                        oLastPOPay = oCurrentPOPay;
                    }
                    else if (oLastPOPay.POSysNo != oCurrentPOPay.POSysNo)
                    {
                        new POPayDac().InsertMaster(oLastPOPay);
                        oLastPOPay = oCurrentPOPay;
                    }
                    else
                    {
                        oLastPOPay.POAmt += oCurrentPOPay.POAmt;
                        oLastPOPay.AlreadyPayAmt += oCurrentPOPay.AlreadyPayAmt;
                        oLastPOPay.PayStatus = oCurrentPOPay.PayStatus;
                        oLastPOPay.InvoiceStatus = oCurrentPOPay.InvoiceStatus;
                    }
                }
                if (oLastPOPay != null)
                {
                    new POPayDac().InsertMaster(oLastPOPay);
                }
                #endregion

                #region �ٲ����տ
                string sqlPOPayItem = @"select
                                            posysno, paytype, foreignamt,
                                            paytime, note, b.newsysno as accountsysno, a.status
                                        from
                                            ipp2003..purchase_order_pay as a,
                                            ippconvert..sys_user as b
                                        where a.accountsysno = b.oldsysno";
                DataSet dsPOPayItem = SqlHelper.ExecuteDataSet(sqlPOPayItem);
                if (!Util.HasMoreRow(dsPOPayItem))
                    throw new BizException("no pay item records in ipp2003 db");
                foreach (DataRow drPOPayItem in dsPOPayItem.Tables[0].Rows)
                {
                    /* old paytype
                     * 0 normal
                     * 1 advanced
                     * ����Ҫת��
                     */
                    POPayItemInfo oPOPayItem = new POPayItemInfo();
                    oPOPayItem.POSysNo = Util.TrimIntNull(drPOPayItem["posysno"]);
                    oPOPayItem.PayStyle = Util.TrimIntNull(drPOPayItem["paytype"]);
                    oPOPayItem.PayAmt = Util.TrimDecimalNull(drPOPayItem["foreignamt"]);
                    oPOPayItem.CreateUserSysNo = Util.TrimIntNull(drPOPayItem["accountsysno"]);
                    oPOPayItem.CreateTime = Util.TrimDateNull(drPOPayItem["paytime"]);
                    oPOPayItem.PayTime = Util.TrimDateNull(drPOPayItem["paytime"]);
                    oPOPayItem.PayUserSysNo = Util.TrimIntNull(drPOPayItem["accountsysno"]);
                    oPOPayItem.Status = Util.TrimIntNull(drPOPayItem["status"]);
                    switch (oPOPayItem.Status)
                    {
                        case 0:
                            oPOPayItem.Status = (int)AppEnum.POPayItemStatus.Paid;
                            break;
                        case -1:
                            oPOPayItem.Status = (int)AppEnum.POPayItemStatus.Abandon;
                            break;
                        default:
                            throw new BizException("unknown popayitem status");
                    }
                    new POPayDac().InsertItem(oPOPayItem);
                }
                #endregion

                scope.Complete();
            }
        }
예제 #5
0
파일: POPayManager.cs 프로젝트: ue96/ue96
 private void map(POPayItemInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.POSysNo = Util.TrimIntNull(tempdr["POSysNo"]);
     oParam.PayStyle = Util.TrimIntNull(tempdr["PayStyle"]);
     oParam.PayAmt = Util.TrimDecimalNull(tempdr["PayAmt"]);
     oParam.CreateTime = Util.TrimDateNull(tempdr["CreateTime"]);
     oParam.CreateUserSysNo = Util.TrimIntNull(tempdr["CreateUserSysNo"]);
     oParam.EstimatePayTime = Util.TrimDateNull(tempdr["EstimatePayTime"]);
     oParam.ReferenceID = Util.TrimNull(tempdr["ReferenceID"]);
     oParam.PayTime = Util.TrimDateNull(tempdr["PayTime"]);
     oParam.PayUserSysNo = Util.TrimIntNull(tempdr["PayUserSysNo"]);
     oParam.Note = Util.TrimNull(tempdr["Note"]);
     oParam.Status = Util.TrimIntNull(tempdr["Status"]);
     oParam.IsPrintPOPayBill = Util.TrimIntNull(tempdr["IsPrintPOPayBill"]);
     oParam.RequestUserSysNo = Util.TrimIntNull(tempdr["RequestUserSysNo"]);
     oParam.RequestTime = Util.TrimDateNull(tempdr["RequestTime"]);
     oParam.AuditUserSysNo = Util.TrimIntNull(tempdr["AuditUserSysNo"]);
     oParam.AuditTime = Util.TrimDateNull(tempdr["AuditTime"]);
     oParam.VoucherTime = Util.TrimDateNull(tempdr["VoucherTime"]);
 }
예제 #6
0
파일: POPayManager.cs 프로젝트: ue96/ue96
        public void CancelAuditPoPayItem(POPayItemInfo oInfo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if (oInfo.Status != (int)AppEnum.POPayItemStatus.WaitingPay)
                    throw new BizException("pay bill is not WaitingPay status now, CancelAudit failed");

                //POPayInfo oPay = LoadPay(oPayItem.POSysNo);

                //Hashtable htPay = new Hashtable(3);
                //htPay.Add("SysNo", oPay.SysNo);
                //htPay.Add("AlreadyPayAmt", oPay.AlreadyPayAmt);
                //htPay.Add("PayStatus", oPay.PayStatus);
                //new POPayDac().UpdateMaster(htPay);

                Hashtable htPayItem = new Hashtable(2);
                htPayItem.Add("SysNo", oInfo.SysNo);
                htPayItem.Add("Status", (int)AppEnum.POPayItemStatus.WaitingAudit);
                new POPayDac().UpdateItem(htPayItem);
                UpdateDailyPayAmtRestrict(oInfo, "-");
                scope.Complete();
            }
        }
예제 #7
0
파일: POPayManager.cs 프로젝트: ue96/ue96
 /// <summary>
 /// ���ݸ��֧��������ÿ���ѷ�����
 /// </summary>
 /// <param name="paramInfo">���</param>
 /// <param name="operation">������("+"��"-")</param>
 public void UpdateDailyPayAmtRestrict(POPayItemInfo paramInfo, string operation)
 {
     POInfo oPO = PurchaseManager.GetInstance().LoadPO(paramInfo.POSysNo);
     if (oPO != null)
     {
         DailyPayAmtRestrictInfo restrictInfo = POPayManager.GetInstance().LoadDailyPayAmtRestrict(AppConst.IntNull, DateTime.Now);
         if (oPO.POInvoiceType == (int)AppEnum.POInvoiceType.ValueAddedInvoice)
         {
             if (operation == "+")
                 restrictInfo.AllocatedPublicAmt += paramInfo.PayAmt;
             else if (operation == "-")
                 restrictInfo.AllocatedPublicAmt -= paramInfo.PayAmt;
         }
         else
         {
             if (operation == "+")
                 restrictInfo.AllocatedPrivateAmt += paramInfo.PayAmt;
             else if (operation == "-")
                 restrictInfo.AllocatedPrivateAmt -= paramInfo.PayAmt;
         }
         UpdateDailyPayAmtRestrict(restrictInfo);
     }
 }
예제 #8
0
파일: POPayManager.cs 프로젝트: ue96/ue96
 public POPayItemInfo LoadPayItem(int sysno)
 {
     string sql = "select * from finance_popay_item where sysno =" + sysno;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if (!Util.HasMoreRow(ds))
         return null;
     POPayItemInfo oPayItem = new POPayItemInfo();
     map(oPayItem, ds.Tables[0].Rows[0]);
     return oPayItem;
 }
예제 #9
0
파일: POPayManager.cs 프로젝트: ue96/ue96
        /// <summary>
        /// ��˸��
        /// </summary>
        /// <param name="oInfo">���</param>
        /// <param name="isIgnoreErr">�Ƿ�����쳣���</param>
        public void AuditPoPayItem(POPayItemInfo oInfo, bool isIgnoreErr, int auditUserSysNo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if (oInfo.Status != (int)AppEnum.POPayItemStatus.WaitingAudit)
                    throw new BizException("pay bill is not WaitingAudit status now, Audit failed");

                if (!isIgnoreErr)
                {
                    string errmsg = "";
                    if (IsPayTotalAmtLessThanZero(PurchaseManager.GetInstance().LoadPO(oInfo.POSysNo).VendorSysNo))
                    {
                        errmsg += "���ζԵ�ǰ��Ӧ�̵�֧���ܺ�С��0 <br />";
                    }
                    POInfo poInfo = PurchaseManager.GetInstance().LoadPO(oInfo.POSysNo);
                    if (poInfo != null)
                    {
                        if (IsExistsUnAuditPO(poInfo.VendorSysNo, -1, oInfo.SysNo))
                        {
                            errmsg += "���ڶ�Ӧ��Ӧ�̵�δ��˵ĸ��ɹ�";
                        }
                    }
                    if (errmsg != "")
                        throw new BizException(errmsg);
                }

                Hashtable htPayItem = new Hashtable(2);
                htPayItem.Add("SysNo", oInfo.SysNo);
                htPayItem.Add("Status", (int)AppEnum.POPayItemStatus.WaitingPay);
                htPayItem.Add("AuditUserSysNo", auditUserSysNo);
                htPayItem.Add("AuditTime", DateTime.Now);
                new POPayDac().UpdateItem(htPayItem);
                UpdateDailyPayAmtRestrict(oInfo, "+");

                scope.Complete();
            }
        }
예제 #10
0
파일: POPayManager.cs 프로젝트: ue96/ue96
        /// <summary>
        /// ���븶�
        /// 1 waiting apportion �� waiting instock ��poֻ������Ԥ���ĸ��
        /// 2 InStock��poֻ�ܼ�������֧���ĸ��
        /// 3 ���������ĸ���������г�ʼ״̬��Ԥ�����
        /// 4 �Ƿ���Ӧ���a���û�У�����֮��b��������ϵ�Ӧ�������Ϊunpay״̬��c���Ӧ�����Ѿ���ȫ֧�������ܼ��븶��ˡ�
        /// 5 �����븶�
        /// </summary>
        /// <param name="oParam"></param>
        public void InsertPOPayItem(POPayItemInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                POInfo oPO = PurchaseManager.GetInstance().LoadPO(oParam.POSysNo);
                if (oPO.Status == (int)AppEnum.POStatus.WaitingApportion || oPO.Status == (int)AppEnum.POStatus.WaitingReceive || oPO.Status == (int)AppEnum.POStatus.WaitingInStock)
                {
                    if (oParam.PayStyle != (int)AppEnum.POPayItemStyle.Advanced)
                        throw new BizException("this po status allow only advanced pay");
                }
                else if (oPO.Status == (int)AppEnum.POStatus.InStock)
                {
                    if (oParam.PayStyle != (int)AppEnum.POPayItemStyle.Normal)
                        throw new BizException("this po status allow only normal pay");
                }
                else
                {
                    throw new BizException("this po status allow no pay");
                }

                if (oParam.PayStyle == (int)AppEnum.POPayItemStyle.Normal)
                {
                    string sqlExist = "select top 1 sysno from finance_popay_item where posysno=" + oParam.POSysNo
                        + " and status=" + (int)AppEnum.POPayItemStatus.Origin
                        + " and paystyle=" + (int)AppEnum.POPayItemStyle.Advanced;
                    DataSet ds = SqlHelper.ExecuteDataSet(sqlExist);
                    if (Util.HasMoreRow(ds))
                        throw new BizException("there is an bill - status(origin), paystyle(advanced), insert normal pay failed");
                }

                POPayInfo oPay = LoadPay(oParam.POSysNo);
                if (oPay == null)
                {
                    oPay = new POPayInfo();
                    oPay.POSysNo = oPO.SysNo;
                    oPay.CurrencySysNo = oPO.CurrencySysNo;
                    oPay.POAmt = oPO.TotalAmt;
                    oPay.AlreadyPayAmt = 0;
                    oPay.PayStatus = (int)AppEnum.POPayStatus.UnPay;
                    oPay.InvoiceStatus = (int)AppEnum.POPayInvoiceStatus.Absent;
                    oPay.Note = "auto create";
                    new POPayDac().InsertMaster(oPay);
                }
                else if (oPay.PayStatus == (int)AppEnum.POPayStatus.FullPay)
                {
                    throw new BizException("Full Pay already, need no pay bill");
                }
                else if (oPay.PayStatus == (int)AppEnum.POPayStatus.Abandon)
                {
                    Hashtable ht = new Hashtable(2);
                    ht.Add("SysNo", oPay.SysNo);
                    ht.Add("PayStatus", (int)AppEnum.POPayStatus.UnPay);
                    new POPayDac().UpdateMaster(ht);
                }

                new POPayDac().InsertItem(oParam);

                scope.Complete();
            }
        }
예제 #11
0
파일: POPayDac.cs 프로젝트: ue96/ue96
        public int InsertItem(POPayItemInfo oParam)
        {
            string sql = @"INSERT INTO Finance_POPay_Item
                            (
                            POSysNo, PayStyle, PayAmt, CreateTime,
                            CreateUserSysNo, EstimatePayTime, ReferenceID, PayTime,
                            PayUserSysNo, Note, Status, IsPrintPOPayBill,
                            RequestUserSysNo, RequestTime, AuditUserSysNo, AuditTime,
                            VoucherTime
                            )
                            VALUES (
                            @POSysNo, @PayStyle, @PayAmt, @CreateTime,
                            @CreateUserSysNo, @EstimatePayTime, @ReferenceID, @PayTime,
                            @PayUserSysNo, @Note, @Status, @IsPrintPOPayBill,
                            @RequestUserSysNo, @RequestTime, @AuditUserSysNo, @AuditTime,
                            @VoucherTime
                            );set @SysNo = SCOPE_IDENTITY();";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramPOSysNo = new SqlParameter("@POSysNo", SqlDbType.Int, 4);
            SqlParameter paramPayStyle = new SqlParameter("@PayStyle", SqlDbType.Int, 4);
            SqlParameter paramPayAmt = new SqlParameter("@PayAmt", SqlDbType.Decimal, 9);
            SqlParameter paramCreateTime = new SqlParameter("@CreateTime", SqlDbType.DateTime);
            SqlParameter paramCreateUserSysNo = new SqlParameter("@CreateUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramEstimatePayTime = new SqlParameter("@EstimatePayTime", SqlDbType.DateTime);
            SqlParameter paramReferenceID = new SqlParameter("@ReferenceID", SqlDbType.NVarChar, 20);
            SqlParameter paramPayTime = new SqlParameter("@PayTime", SqlDbType.DateTime);
            SqlParameter paramPayUserSysNo = new SqlParameter("@PayUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramNote = new SqlParameter("@Note", SqlDbType.NVarChar, 200);
            SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4);
            SqlParameter paramIsPrintPOPayBill = new SqlParameter("@IsPrintPOPayBill", SqlDbType.Int, 4);
            SqlParameter paramRequestUserSysNo = new SqlParameter("@RequestUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramRequestTime = new SqlParameter("@RequestTime", SqlDbType.DateTime);
            SqlParameter paramAuditUserSysNo = new SqlParameter("@AuditUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramAuditTime = new SqlParameter("@AuditTime", SqlDbType.DateTime);
            SqlParameter paramVoucherTime = new SqlParameter("@VoucherTime", SqlDbType.DateTime);
            paramSysNo.Direction = ParameterDirection.Output;
            if (oParam.POSysNo != AppConst.IntNull)
                paramPOSysNo.Value = oParam.POSysNo;
            else
                paramPOSysNo.Value = System.DBNull.Value;
            if (oParam.PayStyle != AppConst.IntNull)
                paramPayStyle.Value = oParam.PayStyle;
            else
                paramPayStyle.Value = System.DBNull.Value;
            if (oParam.PayAmt != AppConst.DecimalNull)
                paramPayAmt.Value = oParam.PayAmt;
            else
                paramPayAmt.Value = System.DBNull.Value;
            if (oParam.CreateTime != AppConst.DateTimeNull)
                paramCreateTime.Value = oParam.CreateTime;
            else
                paramCreateTime.Value = System.DBNull.Value;
            if (oParam.CreateUserSysNo != AppConst.IntNull)
                paramCreateUserSysNo.Value = oParam.CreateUserSysNo;
            else
                paramCreateUserSysNo.Value = System.DBNull.Value;
            if (oParam.EstimatePayTime != AppConst.DateTimeNull)
                paramEstimatePayTime.Value = oParam.EstimatePayTime;
            else
                paramEstimatePayTime.Value = System.DBNull.Value;
            if (oParam.ReferenceID != AppConst.StringNull)
                paramReferenceID.Value = oParam.ReferenceID;
            else
                paramReferenceID.Value = System.DBNull.Value;
            if (oParam.PayTime != AppConst.DateTimeNull)
                paramPayTime.Value = oParam.PayTime;
            else
                paramPayTime.Value = System.DBNull.Value;
            if (oParam.PayUserSysNo != AppConst.IntNull)
                paramPayUserSysNo.Value = oParam.PayUserSysNo;
            else
                paramPayUserSysNo.Value = System.DBNull.Value;
            if (oParam.Note != AppConst.StringNull)
                paramNote.Value = oParam.Note;
            else
                paramNote.Value = System.DBNull.Value;
            if (oParam.Status != AppConst.IntNull)
                paramStatus.Value = oParam.Status;
            else
                paramStatus.Value = System.DBNull.Value;
            if (oParam.IsPrintPOPayBill != AppConst.IntNull)
                paramIsPrintPOPayBill.Value = oParam.IsPrintPOPayBill;
            else
                paramIsPrintPOPayBill.Value = System.DBNull.Value;
            if (oParam.RequestUserSysNo != AppConst.IntNull)
                paramRequestUserSysNo.Value = oParam.RequestUserSysNo;
            else
                paramRequestUserSysNo.Value = System.DBNull.Value;
            if (oParam.RequestTime != AppConst.DateTimeNull)
                paramRequestTime.Value = oParam.RequestTime;
            else
                paramRequestTime.Value = System.DBNull.Value;
            if (oParam.AuditUserSysNo != AppConst.IntNull)
                paramAuditUserSysNo.Value = oParam.AuditUserSysNo;
            else
                paramAuditUserSysNo.Value = System.DBNull.Value;
            if (oParam.AuditTime != AppConst.DateTimeNull)
                paramAuditTime.Value = oParam.AuditTime;
            else
                paramAuditTime.Value = System.DBNull.Value;
            if (oParam.VoucherTime != AppConst.DateTimeNull)
                paramVoucherTime.Value = oParam.VoucherTime;
            else
                paramVoucherTime.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramPOSysNo);
            cmd.Parameters.Add(paramPayStyle);
            cmd.Parameters.Add(paramPayAmt);
            cmd.Parameters.Add(paramCreateTime);
            cmd.Parameters.Add(paramCreateUserSysNo);
            cmd.Parameters.Add(paramEstimatePayTime);
            cmd.Parameters.Add(paramReferenceID);
            cmd.Parameters.Add(paramPayTime);
            cmd.Parameters.Add(paramPayUserSysNo);
            cmd.Parameters.Add(paramNote);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramIsPrintPOPayBill);
            cmd.Parameters.Add(paramRequestUserSysNo);
            cmd.Parameters.Add(paramRequestTime);
            cmd.Parameters.Add(paramAuditUserSysNo);
            cmd.Parameters.Add(paramAuditTime);
            cmd.Parameters.Add(paramVoucherTime);

            return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo);
        }