示例#1
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 long InsertCarrier(Carrier data, List<CarrierCar> listCar, List<CarrierDriver> listDriver, List<CarrierSettlementExpression> listExpression, List<CarrierTransportPrice> listTransportPrice, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            long nCarrierId = 0;

            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DDDAO dao = new DDDAO())
                    {
                        //新增承运单位档案数据
                        nCarrierId = dao.InsertCarrier(data, nOpStaffId, strOpStaffName, out strErrText);
                        if (nCarrierId <= 0)
                            return 0;

                        //新增车辆数据
                        foreach (CarrierCar car in listCar)
                        {
                            car.CarrierId = nCarrierId;
                            if (!dao.InsertCarrierCar(car, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return 0;
                            }
                        }

                        //新增驾驶员数据
                        foreach (CarrierDriver driver in listDriver)
                        {
                            driver.CarrierId = nCarrierId;
                            if (!dao.InsertCarrierDriver(driver, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return 0;
                            }
                        }

                        //新增结算公式数据
                        foreach (CarrierSettlementExpression expression in listExpression)
                        {
                            expression.CarrierId = nCarrierId;
                            if (!dao.InsertCarrierSettlementExpression(expression, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return 0;
                            }
                        }

                        //新增承运价格数据
                        foreach (CarrierTransportPrice price in listTransportPrice)
                        {
                            price.CarrierId = nCarrierId;
                            if (!dao.InsertCarrierTransportPrice(price, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return 0;
                            }
                        }
                    }
                    transScope.Complete();
                }
                return nCarrierId;
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return 0;
            }
        }
示例#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;
            }
        }
示例#3
0
文件: DDDAO.cs 项目: zjchenxk/SYLS
        /// <summary>
        /// 新增承运单位档案
        /// </summary>
        /// <param name="data"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public long InsertCarrier(Carrier data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            //创建存储过程参数
            SqlParameter[] Params =
                {
                    MakeParam(ID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Output, (object)data.Id),
                    MakeParam(NAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.Name),
                    MakeParam(BUSINESSTYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.BusinessType),
                    MakeParam(PAYMENTTYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.PaymentType),
                    MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId),
                    MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName),
                };

            SqlParameterCollection outParams;
            if (Execute("InsertCarrier", Params, out outParams, out strErrText) < 0)
            {
                return 0;
            }
            else
            {
                return (long)outParams[ID_PARAM].Value;
            }
        }
示例#4
0
文件: DDDAO.cs 项目: zjchenxk/SYLS
        /// <summary>
        /// 新增承运单位档案
        /// </summary>
        /// <param name="data"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateCarrier(Carrier data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            //创建存储过程参数
            SqlParameter[] Params =
                {
                    MakeParam(ID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.Id),
                    MakeParam(NAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.Name),
                    MakeParam(BUSINESSTYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.BusinessType),
                    MakeParam(PAYMENTTYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.PaymentType),
                    MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId),
                    MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName),
                };

            if (Execute("UpdateCarrier", Params, out strErrText) >= 0)
                return true;
            else
                return false;
        }
示例#5
0
文件: DDSystem.cs 项目: zjchenxk/SYLS
 /// <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 long InsertCarrier(Carrier data, List<CarrierCar> listCar, List<CarrierDriver> listDriver, List<CarrierSettlementExpression> listExpression, List<CarrierTransportPrice> listTransportPrice, long nOpStaffId, string strOpStaffName, out string strErrText)
 {
     CarrierRule rule = new CarrierRule();
     return rule.InsertCarrier(data, listCar, listDriver, listExpression, listTransportPrice, nOpStaffId, strOpStaffName, out strErrText);
 }
示例#6
0
        public ActionResult NewCarrier(CarrierViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                Carrier data = new Carrier();
                data.Name = model.Name;
                data.BusinessType = model.BusinessType;
                data.PaymentType = model.PaymentType;

                List<CarrierCar> listCar = new List<CarrierCar>();
                if (model.Cars != null)
                {
                    foreach (CarrierCarViewModel m in model.Cars)
                    {
                        CarrierCar c = new CarrierCar();
                        c.CarrierId = m.CarrierId;
                        c.CarNo = m.CarNo;
                        c.TrailerNo = m.TrailerNo;
                        c.CarryingCapacity = m.CarryingCapacity;
                        listCar.Add(c);
                    }
                }

                List<CarrierDriver> listDriver = new List<CarrierDriver>();
                if (model.Drivers != null)
                {
                    foreach (CarrierDriverViewModel m in model.Drivers)
                    {
                        CarrierDriver d = new CarrierDriver();
                        d.CarrierId = m.CarrierId;
                        d.CarNo = m.CarNo;
                        d.Name = m.Name;
                        d.LicenseNo = m.LicenseNo;
                        d.MobileTel = m.MobileTel;
                        d.HomeTel = m.HomeTel;
                        listDriver.Add(d);
                    }
                }

                List<CarrierSettlementExpression> listExpression = new List<CarrierSettlementExpression>();
                if (model.SettlementExpressions != null)
                {
                    foreach (CarrierSettlementExpressionViewModel m in model.SettlementExpressions)
                    {
                        CarrierSettlementExpression e = new CarrierSettlementExpression();
                        e.CarrierId = m.CarrierId;
                        e.PlanType = m.PlanType;
                        e.TransportChargeExpression = m.TransportChargeExpression;
                        e.TransportPriceExpression = m.TransportPriceExpression;
                        listExpression.Add(e);
                    }
                }

                List<CarrierTransportPrice> listPrice = new List<CarrierTransportPrice>();
                if (model.TransportPrices != null)
                {
                    foreach (CarrierTransportPriceViewModel m in model.TransportPrices)
                    {
                        CarrierTransportPrice p = new CarrierTransportPrice();
                        p.CarrierId = m.CarrierId;
                        p.StartCountry = m.StartCountry;
                        p.StartProvince = m.StartProvince;
                        p.StartCity = m.StartCity;
                        p.DestCountry = m.DestCountry;
                        p.DestProvince = m.DestProvince;
                        p.DestCity = m.DestCity;
                        p.PlanType = m.PlanType;
                        p.StartTime = DateTime.Parse(m.StartTime);
                        p.EndTime = DateTime.Parse(m.EndTime);
                        p.TransportPrice = m.TransportPrice;
                        listPrice.Add(p);
                    }
                }

                //保存数据
                string strErrText;
                DDSystem dd = new DDSystem();
                if (dd.InsertCarrier(data, listCar, listDriver, listExpression, listPrice, LoginAccountId, LoginStaffName, out strErrText) > 0)
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }