コード例 #1
0
ファイル: ReceiverRule.cs プロジェクト: zjchenxk/SYLS
        /// <summary>
        /// 删除收货单位数据
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool DeleteReceiver(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DDDAO dao = new DDDAO())
                    {
                        //读取收货单位档案数据
                        Receiver data = dao.LoadReceiver(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (data == null)
                            return false;

                        //删除收货单位档案数据
                        if (!dao.DeleteReceiver(nId, nOpStaffId, strOpStaffName, out strErrText))
                            return false;

                        //删除距离数据
                        if (!dao.DeleteReceiverDistances(data.Name, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return false;
                        }
                    }
                    transScope.Complete();
                }
                return true;
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return false;
            }
        }
コード例 #2
0
ファイル: ReceiverRule.cs プロジェクト: zjchenxk/SYLS
        /// <summary>
        /// 修改收货单位数据
        /// </summary>
        /// <param name="data"></param>
        /// <param name="listDistance"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateReceiver(Receiver data, List<ReceiverDistance> listDistance, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DDDAO dao = new DDDAO())
                    {
                        //修改收货单位档案数据
                        if (!dao.UpdateReceiver(data, nOpStaffId, strOpStaffName, out strErrText))
                            return false;

                        //修改距离数据
                        if (!dao.DeleteReceiverDistances(data.Name, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return false;
                        }
                        foreach (ReceiverDistance distance in listDistance)
                        {
                            if (!dao.InsertReceiverDistance(distance, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return false;
                            }
                        }
                    }
                    transScope.Complete();
                }
                return true;
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return false;
            }
        }