/// <summary> /// 修改调度单数据 /// </summary> /// <param name="data"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool UpdateDispatchBill(DispatchBill data, long nOpStaffId, string strOpStaffName, out string strErrText) { //创建存储过程参数 SqlParameter[] Params = { MakeParam(ID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.Id), MakeParam(CARNO_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.CarNo), MakeParam(TRAILERNO_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.TrailerNo??System.DBNull.Value), MakeParam(CARTYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.CarType??string.Empty), MakeParam(DRIVERNAME_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.DriverName), MakeParam(DRIVERLICENSENO_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.DriverLicenseNo), MakeParam(DRIVERMOBILETEL_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.DriverMobileTel), MakeParam(DRIVERHOMETEL_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.DriverHomeTel??string.Empty), MakeParam(CARRIERID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.CarrierId??System.DBNull.Value), MakeParam(CARRIERNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.CarrierName), MakeParam(CARRYINGCAPACITY_PARAM, SqlDbType.Int, 4, ParameterDirection.Input, (object)data.CarryingCapacity), MakeParam(BUSINESSTYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.BusinessType), MakeParam(PAYMENTTYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.PaymentType), MakeParam(TOTALPACKAGES_PARAM, SqlDbType.Int, 4, ParameterDirection.Input, (object)data.TotalPackages), MakeParam(TOTALTUNNAGES_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.TotalTunnages), MakeParam(TOTALPILES_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.TotalPiles), MakeParam(TOTALTENTHOUSANDS_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.TotalTenThousands), MakeParam(TOTALTRANSPORTCHARGES_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.TotalTransportCharges), MakeParam(CREATETIME_PARAM, SqlDbType.DateTime, 8, ParameterDirection.Input, (object)data.CreateTime), MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId), MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName), }; if (Execute("UpdateDispatchBill", Params, out strErrText) >= 0) return true; else return false; }
/// <summary> /// 修改调度单 /// </summary> /// <param name="data"></param> /// <param name="listPlan"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool UpdateDispatchBill(DispatchBill data, List<DispatchBillDeliverPlan> listPlan, long nOpStaffId, string strOpStaffName, out string strErrText) { DispatchRule rule = new DispatchRule(); return rule.UpdateDispatchBill(data, listPlan, nOpStaffId, strOpStaffName, out strErrText); }
/// <summary> /// 新增调度单数据 /// </summary> /// <param name="bill"></param> /// <param name="listDeliverPlan"></param> /// <param name="listGoods"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public long InsertDispatchBill(DispatchBill bill, List<DispatchBillDeliverPlan> listDeliverPlan, List<DispatchBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText) { DispatchRule rule = new DispatchRule(); return rule.InsertDispatchBill(bill, listDeliverPlan, listGoods, nOpStaffId, strOpStaffName, out strErrText); }
/// <summary> /// 修改调度单 /// </summary> /// <param name="data"></param> /// <param name="listPlan"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool UpdateDispatchBill(DispatchBill data, List<DispatchBillDeliverPlan> listPlan, long nOpStaffId, string strOpStaffName, out string strErrText) { try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (DispatchDAO dao = new DispatchDAO()) { #region 修改调度单数据 DispatchBill oldData = dao.LoadDispatchBill(data.Id, nOpStaffId, strOpStaffName, out strErrText); if (oldData == null) { return false; } data.TotalPackages = oldData.TotalPackages; data.TotalTunnages = oldData.TotalTunnages; data.TotalPiles = oldData.TotalPiles; data.TotalTenThousands = oldData.TotalTenThousands; data.TotalTransportCharges = oldData.TotalTransportCharges; if (!dao.UpdateDispatchBill(data, nOpStaffId, strOpStaffName, out strErrText)) { return false; } #endregion #region 修改调度计划数据 List<DispatchBillDeliverPlan> listOldPlan = dao.LoadDispatchBillDeliverPlans(data.Id, nOpStaffId, strOpStaffName, out strErrText); if (listOldPlan == null) { return false; } if (!dao.DeleteDispatchBillDeliverPlans(data.Id, nOpStaffId, strOpStaffName, out strErrText)) { return false; } foreach (DispatchBillDeliverPlan oldPlan in listOldPlan) { DispatchBillDeliverPlan newPlan = listPlan.Find(delegate(DispatchBillDeliverPlan p) { return p.PlanId == oldPlan.PlanId; }); if (newPlan != null) { oldPlan.ReceiveType = newPlan.ReceiveType; } if (!dao.InsertDispatchBillDeliverPlan(oldPlan, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } #endregion #region 修改调度货物数据 List<DispatchBillGoods> listOldGoods = dao.LoadDispatchBillAllGoods(data.Id, nOpStaffId, strOpStaffName, out strErrText); if (listOldGoods == null) { return false; } if (!dao.DeleteDispatchBillAllGoods(data.Id, nOpStaffId, strOpStaffName, out strErrText)) { return false; } foreach (DispatchBillGoods goods in listOldGoods) { if (!dao.InsertDispatchBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } #endregion #region 校验调度单数据 if (!dao.CheckDispatchBill(data.Id, nOpStaffId, strOpStaffName, out strErrText)) { return false; } #endregion } transScope.Complete(); } return true; } catch (Exception e) { strErrText = e.Message; return false; } }
/// <summary> /// 修改调度单 /// </summary> /// <param name="bill"></param> /// <param name="listDeliverPlan"></param> /// <param name="listGoods"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool UpdateDispatchBill(DispatchBill bill, List<DispatchBillDeliverPlan> listDeliverPlan, List<DispatchBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText) { try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (DispatchDAO dao = new DispatchDAO()) { #region 处理计划和货物数据 int totalOldPackages = 0; decimal totalOldTunnages = 0; decimal totalOldPiles = 0; decimal totalOldTenThousands = 0; decimal totalOldTransportCharges = 0; foreach (DispatchBillDeliverPlan newPlan in listDeliverPlan) { //读取当前调度计划原数据 DispatchBillDeliverPlan oldPlan = dao.LoadDispatchBillDeliverPlan(newPlan.DispatchBillId, newPlan.PlanId, nOpStaffId, strOpStaffName, out strErrText); if (oldPlan == null) { return false; } totalOldPackages += oldPlan.Packages; totalOldTunnages += oldPlan.Tunnages; totalOldPiles += oldPlan.Piles; totalOldTenThousands += oldPlan.TenThousands; totalOldTransportCharges += oldPlan.TransportCharges; //修改当前调度计划新数据 if (!dao.UpdateDispatchBillDeliverPlan(newPlan, nOpStaffId, strOpStaffName, out strErrText)) { return false; } //删除当前调度计划原货物数据 if (!dao.DeleteDispatchBillDeliverPlanAllGoods(newPlan.DispatchBillId, newPlan.PlanId, nOpStaffId, strOpStaffName, out strErrText)) { return false; } //新增当前调度计划货物新数据 foreach (DispatchBillGoods goods in listGoods) { if (goods.DispatchBillId == newPlan.DispatchBillId && goods.PlanId == newPlan.PlanId) { if (!dao.InsertDispatchBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } } } #endregion #region 处理调度单数据 //读取调度单原数据 DispatchBill oldBill = dao.LoadDispatchBill(bill.Id, nOpStaffId, strOpStaffName, out strErrText); if (oldBill == null) { return false; } bill.TotalPackages = oldBill.TotalPackages - totalOldPackages + bill.TotalPackages; bill.TotalTunnages = oldBill.TotalTunnages - totalOldTunnages + bill.TotalTunnages; bill.TotalPiles = oldBill.TotalPiles - totalOldPiles + bill.TotalPiles; bill.TotalTenThousands = oldBill.TotalTenThousands - totalOldTenThousands + bill.TotalTenThousands; bill.TotalTransportCharges = oldBill.TotalTransportCharges - totalOldTransportCharges + bill.TotalTransportCharges; if (!dao.UpdateDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText)) { return false; } #endregion #region 校验调度单数据 if (!dao.CheckDispatchBill(bill.Id, nOpStaffId, strOpStaffName, out strErrText)) { return false; } #endregion } transScope.Complete(); } return true; } catch (Exception e) { strErrText = e.Message; return false; } }
/// <summary> /// 新增调度单数据 /// </summary> /// <param name="bill"></param> /// <param name="listDeliverPlan"></param> /// <param name="listGoods"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public long InsertDispatchBill(DispatchBill bill, List<DispatchBillDeliverPlan> listDeliverPlan, List<DispatchBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText) { long nDispatchBillId = 0; try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (DispatchDAO dao = new DispatchDAO()) { //新增计划数据 nDispatchBillId = dao.InsertDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText); if (nDispatchBillId <= 0) return 0; //新增计划数据 foreach (DispatchBillDeliverPlan deliverPlan in listDeliverPlan) { deliverPlan.DispatchBillId = nDispatchBillId; if (!dao.InsertDispatchBillDeliverPlan(deliverPlan, nOpStaffId, strOpStaffName, out strErrText)) { return 0; } } //新增货物数据 foreach (DispatchBillGoods goods in listGoods) { goods.DispatchBillId = nDispatchBillId; if (!dao.InsertDispatchBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return 0; } } //校验调度单数据 if (!dao.CheckDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText)) { return 0; } } transScope.Complete(); } return nDispatchBillId; } catch (Exception e) { strErrText = e.Message; return 0; } }
public ActionResult ModifyDispatchedPlan(DispatchBillViewModel model) { if (ModelState.IsValid) { //创建调度计划数据 int nTotalPackages = 0; decimal decTotalTunnages = 0; decimal decTotalPiles = 0; decimal decTotalTenThousands = 0; decimal decTotalTransportCharges = 0; List<DispatchBillDeliverPlan> listDeliverPlan = new List<DispatchBillDeliverPlan>(); if (model.DeliverPlans != null) { foreach (DispatchBillDeliverPlanViewModel m in model.DeliverPlans) { DispatchBillDeliverPlan deliverPlan = new DispatchBillDeliverPlan(); deliverPlan.DispatchBillId = model.Id; deliverPlan.PlanId = m.PlanId; deliverPlan.Packages = m.Packages; deliverPlan.Tunnages = m.Tunnages; deliverPlan.Piles = m.Piles; deliverPlan.TenThousands = m.TenThousands; deliverPlan.TransportChargeExpression = m.TransportChargeExpression; deliverPlan.TransportPriceExpression = m.TransportPriceExpression; deliverPlan.KM = m.KM; deliverPlan.TransportPrice = m.ActualTransportPrice; deliverPlan.TransportCharges = m.TransportCharges; deliverPlan.Remark = m.Remark; listDeliverPlan.Add(deliverPlan); nTotalPackages += m.Packages; decTotalTunnages += m.Tunnages; decTotalPiles += m.Piles; decTotalTenThousands += m.TenThousands; decTotalTransportCharges += m.TransportCharges; } } //创建调度货物数据 List<DispatchBillGoods> listGoods = new List<DispatchBillGoods>(); if (model.Goods != null) { foreach (DispatchBillGoodsViewModel m in model.Goods) { DispatchBillGoods goods = new DispatchBillGoods(); goods.DispatchBillId = model.Id; goods.PlanId = m.PlanId; goods.GoodsId = m.GoodsId; goods.GoodsNo = m.GoodsNo; goods.GoodsName = m.GoodsName; goods.Brand = m.Brand; goods.SpecModel = m.SpecModel; goods.GWeight = m.GWeight; goods.Grade = m.Grade; goods.PieceWeight = m.PieceWeight; goods.Packing = m.Packing; goods.BatchNo = m.BatchNo; goods.Location = m.Location; goods.Packages = m.Packages; goods.Tunnages = m.Tunnages; goods.Piles = m.Piles; goods.TenThousands = m.TenThousands; goods.ProductionDate = m.ProductionDate; goods.EnterWarehouseBillId = m.EnterWarehouseBillId; goods.EnterWarehouseBillNo = m.EnterWarehouseBillNo; listGoods.Add(goods); } } //创建调度单数据 DispatchBill bill = new DispatchBill(); bill.Id = model.Id; bill.CarNo = model.CarNo; bill.TrailerNo = model.TrailerNo; bill.CarType = model.CarType; bill.DriverName = model.DriverName; bill.DriverLicenseNo = model.DriverLicenseNo; bill.DriverMobileTel = model.DriverMobileTel; bill.DriverHomeTel = model.DriverHomeTel; bill.CarrierId = model.CarrierId; bill.CarrierName = model.CarrierName; bill.CarryingCapacity = model.CarryingCapacity; bill.BusinessType = model.BusinessType; bill.PaymentType = model.PaymentType; bill.TotalPackages = nTotalPackages; bill.TotalTunnages = decTotalTunnages; bill.TotalPiles = decTotalPiles; bill.TotalTenThousands = decTotalTenThousands; bill.TotalTransportCharges = decTotalTransportCharges; bill.CreateTime = DateTime.Parse(model.CreateTime); //保存数据 string strErrText; DispatchSystem dispatch = new DispatchSystem(); if (dispatch.UpdateDispatchBill(bill, listDeliverPlan, listGoods, LoginAccountId, LoginStaffName, out strErrText)) { return Json(string.Empty); } else { return Json(strErrText); } } return View(model); }
public ActionResult ModifyDispatchBill(DispatchBillViewModel model) { if (ModelState.IsValid) { //创建调度单数据 DispatchBill data = new DispatchBill(); data.Id = model.Id; data.CarNo = model.CarNo; data.TrailerNo = model.TrailerNo; data.CarType = model.CarType; data.DriverName = model.DriverName; data.DriverLicenseNo = model.DriverLicenseNo; data.DriverMobileTel = model.DriverMobileTel; data.DriverHomeTel = model.DriverHomeTel; data.CarrierId = model.CarrierId; data.CarrierName = model.CarrierName; data.CarryingCapacity = model.CarryingCapacity; data.BusinessType = model.BusinessType; data.PaymentType = model.PaymentType; data.CreateTime = DateTime.Parse(model.CreateTime); List<DispatchBillDeliverPlan> listPlan = new List<DispatchBillDeliverPlan>(); foreach (DispatchBillDeliverPlanViewModel m in model.DeliverPlans) { DispatchBillDeliverPlan p = new DispatchBillDeliverPlan(); p.PlanId = m.PlanId; p.ReceiveType = m.ReceiveType; listPlan.Add(p); } //保存数据 string strErrText; DispatchSystem dispatch = new DispatchSystem(); if (dispatch.UpdateDispatchBill(data, listPlan, LoginAccountId, LoginStaffName, out strErrText)) { return Json(string.Empty); } else { return Json(strErrText); } } return View(model); }