Exemple #1
0
        /// <summary>
        /// 新增冲帐记录
        /// </summary>
        /// <param name="data"></param>
        /// <param name="listDetail"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public long InsertContractReverse(ContractReverse data, List <ContractReverseDetail> listDetail, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            long nReverseId = 0;

            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (ContractDAO dao = new ContractDAO())
                    {
                        //新增冲帐数据
                        nReverseId = dao.InsertContractReverse(data, nOpStaffId, strOpStaffName, out strErrText);
                        if (nReverseId <= 0)
                        {
                            return(0);
                        }

                        //新增冲帐明细数据
                        foreach (ContractReverseDetail detail in listDetail)
                        {
                            detail.ReverseId = nReverseId;

                            if (!dao.InsertContractReverseDetail(detail, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(0);
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(nReverseId);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(0);
            }
        }