/// <summary> /// 新增出库单数据 /// </summary> /// <param name="data"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public long InsertOutWarehouseBill(OutWarehouseBill data, long nOpStaffId, string strOpStaffName, out string strErrText) { //创建存储过程参数 SqlParameter[] Params = { MakeParam(ID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Output, (object)data.Id), MakeParam(PLANID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.PlanId), MakeParam(CUSTOMERID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.CustomerId), MakeParam(CUSTOMERNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.CustomerName), MakeParam(DELIVERYNO_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.DeliveryNo??System.DBNull.Value), MakeParam(OUTTYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.OutType), MakeParam(RECEIVERNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.ReceiverName), MakeParam(RECEIVERCOUNTRY_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.ReceiverCountry), MakeParam(RECEIVERPROVINCE_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.ReceiverProvince), MakeParam(RECEIVERCITY_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.ReceiverCity), MakeParam(RECEIVERADDRESS_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.ReceiverAddress), MakeParam(RECEIVERCONTACT_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.ReceiverContact??System.DBNull.Value), MakeParam(RECEIVERCONTACTTEL_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.ReceiverContactTel??System.DBNull.Value), MakeParam(RECEIVETYPE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.ReceiveType), MakeParam(CARNO_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.CarNo??System.DBNull.Value), MakeParam(TRAILERNO_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.TrailerNo??System.DBNull.Value), MakeParam(CARRIERID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.CarrierId), MakeParam(CARRIERNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.CarrierName??System.DBNull.Value), MakeParam(PAYERID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.PayerId), MakeParam(PAYERNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.PayerName), MakeParam(ISCONSIGNING_PARAM, SqlDbType.Bit, 1, ParameterDirection.Input, (object)data.IsConsigning??System.DBNull.Value), MakeParam(CONSIGNEDDELIVERYNO_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.ConsignedDeliveryNo??System.DBNull.Value), MakeParam(WAREHOUSE_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.Warehouse??string.Empty), MakeParam(FORCEFEE_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.ForceFee), MakeParam(REMARK_PARAM, SqlDbType.NVarChar, 200, ParameterDirection.Input, (object)data.Remark??System.DBNull.Value), 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), }; SqlParameterCollection outParams; if (Execute("InsertOutWarehouseBill", Params, out outParams, out strErrText) < 0) { return 0; } else { return (long)outParams[ID_PARAM].Value; } }
/// <summary> /// 修改出库单数据 /// </summary> /// <param name="bill"></param> /// <param name="listGoods"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool UpdateOutWarehouseBill(OutWarehouseBill bill, List<OutWarehouseBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText) { try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (StockDAO dao = new StockDAO()) { //修改出库单数据 if (!dao.UpdateOutWarehouseBill(bill, nOpStaffId, strOpStaffName, out strErrText)) { return false; } //修改出库货物数据 foreach (OutWarehouseBillGoods goods in listGoods) { if (!dao.UpdateOutWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } } using (CustomerDAO dao = new CustomerDAO()) { //修改上力支费价格数据 List<CustomerForceFeePrice> listForceFeePrice = dao.LoadCustomerForceFeePricesByCustomerId(bill.CustomerId, nOpStaffId, strOpStaffName, out strErrText); if (listForceFeePrice.Count == 0) { //新增力支费价格数据 CustomerForceFeePrice data = new CustomerForceFeePrice(); data.CustomerId = bill.CustomerId; data.StartTime = bill.CreateTime; data.EndTime = DateTime.Parse("9999-12-31"); data.LoadingForceFeePrice = bill.LoadingForceFeePrice; data.UnloadingForceFeePrice = 0; if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } else { int i = 0; while (i < listForceFeePrice.Count) { if (bill.CreateTime.Date >= listForceFeePrice[i].StartTime.Date && bill.CreateTime.Date <= listForceFeePrice[i].EndTime.Date) { break; } i++; } if (i < listForceFeePrice.Count) { //修改力支费价格数据 listForceFeePrice[i].LoadingForceFeePrice = bill.LoadingForceFeePrice; if (!dao.UpdateCustomerForceFeePrice(listForceFeePrice[i], nOpStaffId, strOpStaffName, out strErrText)) { return false; } } else { //新增力支费价格数据 CustomerForceFeePrice data = new CustomerForceFeePrice(); data.CustomerId = bill.CustomerId; data.StartTime = bill.CreateTime; data.LoadingForceFeePrice = bill.LoadingForceFeePrice; data.UnloadingForceFeePrice = 0; //计算截止时间 i = 0; while (i < listForceFeePrice.Count) { if (bill.CreateTime.Date < listForceFeePrice[i].StartTime.Date) { break; } i++; } if (i < listForceFeePrice.Count) { data.EndTime = listForceFeePrice[i].StartTime.Date.AddDays(-1); } else { data.EndTime = DateTime.Parse("9999-12-31"); } if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } } } transScope.Complete(); } return true; } catch (Exception e) { strErrText = e.Message; return false; } }
public ActionResult OutWarehouse(OutWarehouseBillViewModel model) { if (ModelState.IsValid) { //检查承运单位 if (model.OutType == InnoSoft.LS.Resources.Options.DeliverGoods) { if (model.CarrierId == 0 || model.CarrierName == string.Empty) { return Json(InnoSoft.LS.Resources.Strings.NotEnterCarrierInfoWhenDeliverGoods); } } //创建数据 OutWarehouseBill bill = new OutWarehouseBill(); bill.Id = model.Id; bill.BillNo = model.BillNo; bill.PlanId = model.PlanId; bill.CustomerId = model.CustomerId; bill.CustomerName = model.CustomerName; bill.DeliveryNo = model.DeliveryNo; bill.OutType = model.OutType; bill.ReceiverName = model.ReceiverName; bill.ReceiverCountry = model.ReceiverCountry; bill.ReceiverProvince = model.ReceiverProvince; bill.ReceiverCity = model.ReceiverCity; bill.ReceiverAddress = model.ReceiverAddress; bill.ReceiverContact = model.ReceiverContact; bill.ReceiverContactTel = model.ReceiverContactTel; bill.ReceiveType = model.ReceiveType; bill.CarNo = model.CarNo; bill.TrailerNo = model.TrailerNo; bill.CarrierId = model.CarrierId; bill.CarrierName = model.CarrierName; bill.PayerId = model.PayerId; bill.PayerName = model.PayerName; bill.IsConsigning = model.IsConsigning; bill.ConsignedDeliveryNo = model.ConsignedDeliveryNo; bill.Warehouse = model.Warehouse; bill.LoadingForceFeePrice = model.LoadingForceFeePrice; bill.ForceFee = model.ForceFee; bill.Remark = model.Remark; bill.CreateTime = DateTime.Parse(model.CreateTime); List<OutWarehouseBillGoods> listGoods = new List<OutWarehouseBillGoods>(); foreach (OutWarehouseBillGoodsViewModel m in model.Goods) { OutWarehouseBillGoods g = new OutWarehouseBillGoods(); g.Id = m.Id; g.OutWarehouseBillId = m.OutWarehouseBillId; g.GoodsId = m.GoodsId; g.GoodsName = m.GoodsName; g.GoodsNo = m.GoodsNo; g.Brand = m.Brand; g.SpecModel = m.SpecModel; g.GWeight = m.GWeight; g.Grade = m.Grade; g.PieceWeight = m.PieceWeight; g.Packing = m.Packing; g.BatchNo = m.BatchNo; g.Location = m.Location; g.Packages = m.Packages; g.Tunnages = m.Tunnages; g.Piles = m.Piles; g.TenThousands = m.TenThousands; g.ProductionDate = m.ProductionDate; g.EnterWarehouseBillId = m.EnterWarehouseBillId; listGoods.Add(g); } string strErrText; StockSystem stock = new StockSystem(); if (bill.Id > 0) { if (stock.UpdateOutWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText)) { return Json(string.Empty); } else { return Json(strErrText); } } else { if (stock.InsertOutWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText) > 0) { return Json(string.Empty); } else { return Json(strErrText); } } } return View(model); }
/// <summary> /// 修改出库单数据 /// </summary> /// <param name="bill"></param> /// <param name="listGoods"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool UpdateOutWarehouseBill(OutWarehouseBill bill, List<OutWarehouseBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText) { StockRule rule = new StockRule(); return rule.UpdateOutWarehouseBill(bill, listGoods, nOpStaffId, strOpStaffName, out strErrText); }