Пример #1
0
        /// <summary>
        /// 新增承运单位承运价格数据
        /// </summary>
        /// <param name="data"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool InsertCarrierTransportPrice(CarrierTransportPrice data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            //创建存储过程参数
            SqlParameter[] Params =
                {
                    MakeParam(CARRIERID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.CarrierId),
                    MakeParam(STARTCOUNTRY_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.StartCountry),
                    MakeParam(STARTPROVINCE_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.StartProvince),
                    MakeParam(STARTCITY_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.StartCity),
                    MakeParam(DESTCOUNTRY_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.DestCountry),
                    MakeParam(DESTPROVINCE_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.DestProvince),
                    MakeParam(DESTCITY_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.DestCity),
                    MakeParam(PLANTYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.PlanType),
                    MakeParam(STARTTIME_PARAM, SqlDbType.DateTime, 8, ParameterDirection.Input, (object)data.StartTime),
                    MakeParam(ENDTIME_PARAM, SqlDbType.DateTime, 8, ParameterDirection.Input, (object)data.EndTime),
                    MakeParam(TRANSPORTPRICE_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.TransportPrice),
                    MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId),
                    MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName),
                };

            if (Execute("InsertCarrierTransportPrice", Params, out strErrText) >= 0)
                return true;
            else
                return false;
        }
Пример #2
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);
        }