示例#1
0
        /// <summary>
        /// 删除承运单位档案
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool DeleteCarrier(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())
                    {
                        //删除承运单位档案数据
                        if (!dao.DeleteCarrier(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除车辆数据
                        if (!dao.DeleteCarrierCars(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除驾驶员数据
                        if (!dao.DeleteCarrierDrivers(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除运费价格数据
                        if (!dao.DeleteCarrierTransportPrices(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 修改承运单位档案
        /// </summary>
        /// <param name="data"></param>
        /// <param name="listCar"></param>
        /// <param name="listDriver"></param>
        /// <param name="listExpression"></param>
        /// <param name="listTransportPrice"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateCarrier(Carrier data, List <CarrierCar> listCar, List <CarrierDriver> listDriver, List <CarrierSettlementExpression> listExpression, List <CarrierTransportPrice> listTransportPrice, 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.UpdateCarrier(data, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //修改车辆数据
                        List <CarrierCar> listOldCar = dao.LoadCarrierCars(data.Id, nOpStaffId, strOpStaffName, out strErrText);
                        if (listOldCar == null)
                        {
                            return(false);
                        }
                        foreach (CarrierCar oldCar in listOldCar)
                        {
                            if (!listCar.Exists(delegate(CarrierCar newCar) { return(oldCar.Id == newCar.Id); }))
                            {
                                //删除车辆数据
                                if (!dao.DeleteCarrierCar(oldCar.Id, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                        foreach (CarrierCar newCar in listCar)
                        {
                            if (newCar.Id > 0)
                            {
                                //修改车辆数据
                                if (!dao.UpdateCarrierCar(newCar, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                        foreach (CarrierCar newCar in listCar)
                        {
                            if (newCar.Id == 0)
                            {
                                //新增车辆数据
                                if (!dao.InsertCarrierCar(newCar, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }

                        //修改驾驶员数据
                        if (!dao.DeleteCarrierDrivers(data.Id, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                        foreach (CarrierDriver driver in listDriver)
                        {
                            if (!dao.InsertCarrierDriver(driver, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }

                        //修改结算公式数据
                        if (!dao.DeleteCarrierSettlementExpressions(data.Id, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                        foreach (CarrierSettlementExpression expression in listExpression)
                        {
                            if (!dao.InsertCarrierSettlementExpression(expression, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }

                        //修改承运价格数据
                        if (!dao.DeleteCarrierTransportPrices(data.Id, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                        foreach (CarrierTransportPrice price in listTransportPrice)
                        {
                            if (!dao.InsertCarrierTransportPrice(price, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }