/// <summary> /// 修改综合查询数据 /// </summary> /// <param name="nPlanId"></param> /// <param name="strShipmentNo"></param> /// <param name="strDeliveryNo"></param> /// <param name="nPayerId"></param> /// <param name="strPayerName"></param> /// <param name="nContractId"></param> /// <param name="strOriginalContractNo"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool SyntheticalSearchModifyData(long nPlanId, string strShipmentNo, string strDeliveryNo, long nPayerId, string strPayerName, long nContractId, string strOriginalContractNo, long nOpStaffId, string strOpStaffName, out string strErrText) { try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { //修改发货计划 using (PlanDAO dao = new PlanDAO()) { DeliverPlan data = dao.LoadDeliverPlan(nPlanId, nOpStaffId, strOpStaffName, out strErrText); if (data == null) { return false; } data.ShipmentNo = strShipmentNo; data.DeliveryNo = strDeliveryNo; data.PayerId = nPayerId; data.PayerName = strPayerName; if (!dao.UpdateDeliverPlan(data, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } //修改出仓单和送货单数据 using (DeliverDAO dao = new DeliverDAO()) { List<ShipmentBill> listShipmentBill = dao.LoadShipmentBillsByPlanId(nPlanId, nOpStaffId, strOpStaffName, out strErrText); foreach (ShipmentBill data in listShipmentBill) { if (!dao.UpdateShipmentBillDeliveryNo(data.Id, strDeliveryNo, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } List<DeliverBill> listDeliverBill = dao.LoadDeliverBillsByPlanId(nPlanId, nOpStaffId, strOpStaffName, out strErrText); foreach (DeliverBill data in listDeliverBill) { if (!dao.UpdateDeliverBillDeliveryNo(data.Id, strDeliveryNo, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } } //修改出库单、入库单和库存数据 using (StockDAO dao = new StockDAO()) { List<OutWarehouseBill> listOutWarehouseBill = dao.LoadOutWarehouseBillsByPlanId(nPlanId, nOpStaffId, strOpStaffName, out strErrText); foreach (OutWarehouseBill data in listOutWarehouseBill) { data.DeliveryNo = strDeliveryNo; data.PayerId = nPayerId; data.PayerName = strPayerName; if (!dao.UpdateOutWarehouseBill(data, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } } //修改合同数据 using (ContractDAO dao = new ContractDAO()) { if (nContractId > 0) { Contract data = dao.LoadContract(nContractId, nOpStaffId, strOpStaffName, out strErrText); if (data == null) { return false; } data.OriginalContractNo = strOriginalContractNo; if (!dao.UpdateContract(data, nOpStaffId, strOpStaffName, out strErrText)) { return false; } } } transScope.Complete(); } return true; } catch (Exception e) { strErrText = e.Message; return false; } }
/// <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; } }