/// <summary> /// 保存 /// </summary> public bool SaveData() { #region 赋值 InOutData inoutData = new InOutData(); inoutData.isIn = true; //出入库类型 inoutData.InOutType = (int)InOutType.OtherIn; //出入库状态 inoutData.InOutStatus = (int)InOutStatus.AllReach; //出入库单号 if (!string.IsNullOrEmpty(textEditInOutCode.Text)) { inoutData.InOutCode = textEditInOutCode.Text; if (inoutHelper.ExistInOutCode(inoutData.InOutCode)) { XtraMessageBox.Show("此单号已存在", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textEditInOutCode.Focus(); return(false); } } else { inoutData.InOutCode = Guid.NewGuid().ToString(); } //出入库时间 if (string.IsNullOrEmpty(dateEditInTime.Text)) { XtraMessageBox.Show("请填写入库日期", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); dateEditInTime.Focus(); return(false); } inoutData.InOutDateTime = DateTime.Parse(dateEditInTime.Text); //业务员及编号 if (string.IsNullOrEmpty(pceOperator.Text)) { XtraMessageBox.Show("请填写业务员", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); pceOperator.Focus(); return(false); } inoutData.Operator = pceOperator.Text; inoutData.OperatorCode = pceOperator.Tag.ToString(); //付款方式 inoutData.PayType = comboPayType.SelectedIndex; //应付金额 if (!string.IsNullOrEmpty(textEditNeedToPay.Text)) { inoutData.NeedToPay = double.Parse(textEditNeedToPay.EditValue.ToString()); } else { inoutData.NeedToPay = 0.0; } //本次付款金额 if (!string.IsNullOrEmpty(textEditPayThisTime.Text)) { inoutData.PayThisTime = double.Parse(textEditPayThisTime.EditValue.ToString()); } else { inoutData.PayThisTime = 0.0; } //到账日期 if (!string.IsNullOrEmpty(dateEditIncomeTime.Text)) { inoutData.IncomeTime = DateTime.Parse(dateEditIncomeTime.Text); } else { inoutData.IncomeTime = DateTime.MinValue; } //合计金额 if (!string.IsNullOrEmpty(textEditTotalFee.Text)) { inoutData.TotalFee = double.Parse(textEditTotalFee.EditValue.ToString()); } else { inoutData.TotalFee = 0.0; } //税率 inoutData.Tax = 0.0; //税额 if (!string.IsNullOrEmpty(textEditAmountTax.Text)) { inoutData.AmountTax = double.Parse(textEditAmountTax.EditValue.ToString()); } else { inoutData.AmountTax = 0.0; } //折扣金额 if (!string.IsNullOrEmpty(textEditDiscountFee.Text)) { inoutData.DiscountFee = double.Parse(textEditDiscountFee.EditValue.ToString()); } else { inoutData.DiscountFee = 0.0; } //支付期限 if (!string.IsNullOrEmpty(textEditPayTerm.Text)) { inoutData.PayTerm = int.Parse(textEditPayTerm.Text); } //快递公司 inoutData.FreightCompany = string.Empty; inoutData.FreightCode = string.Empty; #endregion return(inoutHelper.Save(gvOtherInProduct, inoutData)); }
/// <summary> /// 保存操作 /// </summary> public bool SaveRefund() { //出入库时间 if (string.IsNullOrEmpty(dateEditInTime.Text)) { XtraMessageBox.Show("请填写入库日期", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); dateEditInTime.Focus(); return(false); } //业务员及编号 if (string.IsNullOrEmpty(pceOperator.Text)) { XtraMessageBox.Show("请填写业务员", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); pceOperator.Focus(); return(false); } //用于存放需要退货入库的订单的退款单号 List <string> refundIDList = new List <string>(); //用于存放oid,以通过View_RefundTradeStock获取sku_outerID List <string> oidList = new List <string>(); //存放修要修改库存的sku_outer_id List <string> outerSkuIdList = new List <string>(); //存放修要修改库存的outer_id List <string> outerIdList = new List <string>(); //用于存放需要更新的StockProduct数据 List <StockProduct> stockProductList = new List <StockProduct>(); //用于存放要保存到数据库的StockHouseProduct List <Alading.Entity.StockHouseProduct> stockHouseProList = new List <StockHouseProduct>(); //存放StockDetail List <Alading.Entity.StockDetail> stockDetailList = new List <Alading.Entity.StockDetail>(); //入库单编号 string inOutCode = string.Empty; if (!string.IsNullOrEmpty(textEditInOutCode.Text)) { inOutCode = textEditInOutCode.Text.Trim(); if (inoutHelper.ExistInOutCode(inOutCode)) { XtraMessageBox.Show("此单号已存在", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textEditInOutCode.Focus(); return(false); } } else { inOutCode = Guid.NewGuid().ToString(); } for (int index = 0; index < gvReturnInProduct.RowCount; index++) { DataRow dataRow = gvReturnInProduct.GetDataRow(index); if (dataRow["Select"].ToString() == true.ToString()) { if (dataRow["HouseName"] == null || string.IsNullOrEmpty(dataRow["HouseName"].ToString())) { XtraMessageBox.Show("需要选择仓库", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (dataRow["LayoutName"] == null || string.IsNullOrEmpty(dataRow["LayoutName"].ToString())) { XtraMessageBox.Show("需要选择库位", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } refundIDList.Add(dataRow["refund_id"].ToString()); oidList.Add(dataRow["oid"].ToString()); #region 保存StockProduct信息 outerSkuIdList.Add(dataRow["outer_sku_id"].ToString()); outerIdList.Add(dataRow["OuterID"].ToString()); StockProduct newStockPro = new StockProduct(); newStockPro.SkuOuterID = dataRow["outer_sku_id"].ToString(); newStockPro.OuterID = dataRow["OuterID"].ToString(); //入库数量 if (string.IsNullOrEmpty(dataRow["Count"].ToString())) { newStockPro.SkuQuantity = 0; } else { newStockPro.SkuQuantity = int.Parse(dataRow["Count"].ToString()); } stockProductList.Add(newStockPro); #endregion #region 添加或更新StockHouseProduct StockHouseProduct stockHousePro = new StockHouseProduct(); stockHousePro.HouseCode = dataRow["HouseCode"] == null ? string.Empty : dataRow["HouseCode"].ToString(); stockHousePro.LayoutCode = dataRow["LayoutCode"] == null ? string.Empty : dataRow["LayoutCode"].ToString(); stockHousePro.SkuOuterID = newStockPro.SkuOuterID; stockHousePro.Num = newStockPro.SkuQuantity; stockHousePro.HouseName = dataRow["HouseName"].ToString(); stockHousePro.LayoutName = dataRow["LayoutName"].ToString(); stockHouseProList.Add(stockHousePro); #endregion #region 保存StockDetail Alading.Entity.StockDetail stockDetail = new StockDetail(); stockDetail.StockDetailCode = Guid.NewGuid().ToString(); stockDetail.ProductSkuOuterId = dataRow["outer_sku_id"].ToString(); stockDetail.InOutCode = inOutCode; //仓库编号 if (dataRow["HouseCode"] == null) { stockDetail.StockHouseCode = string.Empty; } else { stockDetail.StockHouseCode = dataRow["HouseCode"].ToString(); } //库位编号 if (dataRow["LayoutCode"] == null) { stockDetail.StockLayOutCode = string.Empty; } else { stockDetail.StockLayOutCode = dataRow["LayoutCode"].ToString(); } //商品价格price stockDetail.Price = float.Parse(dataRow["price"].ToString()); stockDetail.Quantity = int.Parse(dataRow["Count"].ToString()); stockDetail.DetailType = (int)InOutType.SelledReturnIn; stockDetail.DetailRemark = string.Empty; stockDetail.Tax = string.Empty; stockDetail.TotalFee = dataRow["payment"] == null?0:float.Parse(dataRow["payment"].ToString()); stockDetail.DurabilityDate = DateTime.Parse(DateTime.Now.ToShortDateString()); stockDetailList.Add(stockDetail); #endregion } } if (refundIDList.Count == 0) { XtraMessageBox.Show("请先勾选数据", "系统提示", MessageBoxButtons.OK , MessageBoxIcon.Information); return(false); } /*销售退货时间,仓库,库位要求必须填写*/ #region 将要更新的数据保存到oldRefundList List <Alading.Entity.TradeRefund> oldRefundList = TradeRefundService.GetTradeRefund(refundIDList); //用于保存等待更新到数据库表TradeRefund的数据 List <Alading.Entity.TradeRefund> refundUpdateList = new List <Alading.Entity.TradeRefund>(); //修改StockRefund中的IsRecieved 和 LocalPrivyC的状态 foreach (string refundId in refundIDList) { Alading.Entity.TradeRefund refund = new TradeRefund(); refund.refund_id = refundId; //记录当前库管是否收到从买家发回的货物 refund.IsRecieved = true; //经办人 refund.LocalPrivyC = pceOperator.Text; refundUpdateList.Add(refund); } #endregion #region 更新StockInOut string InOutTime = dateEditInTime.Text; //用于存放StockInOut List <Alading.Entity.StockInOut> stockInOutList = new List <Alading.Entity.StockInOut>(); //添加到StockInOut Alading.Entity.StockInOut stockInOut = new Alading.Entity.StockInOut(); stockInOut.InOutCode = inOutCode; //进出库单编号 stockInOut.InOutTime = DateTime.Parse(InOutTime); //进出库时间 stockInOut.OperatorName = pceOperator.Text == null ? string.Empty : pceOperator.Text; stockInOut.OperatorCode = pceOperator.Tag.ToString(); stockInOut.InOutType = (int)InOutType.SelledReturnIn; //oid赋值 stockInOut.TradeOrderCode = string.Empty;; stockInOut.DiscountFee = 0; //保存应付应收金额 if (string.IsNullOrEmpty(textEditTotalFee.EditValue.ToString())) { stockInOut.DueFee = 0; } else { stockInOut.DueFee = float.Parse(textEditTotalFee.EditValue.ToString()); } stockInOut.InOutStatus = (int)InOutStatus.AllRefund; stockInOut.IsSettled = true; stockInOut.PayType = 0;//付款方式 stockInOut.PayThisTime = string.IsNullOrEmpty(textEditTotalFee.EditValue.ToString()) ? 0 : float.Parse(textEditTotalFee.EditValue.ToString()); stockInOut.PayTerm = 0; stockInOut.IncomeTime = DateTime.Parse(DateTime.Now.ToShortDateString());; stockInOut.AmountTax = 0; stockInOut.FreightCompany = string.Empty; stockInOut.FreightCode = string.Empty; stockInOutList.Add(stockInOut); #endregion #region 添加PayCharge PayCharge payCharge = new PayCharge(); payCharge.PayChargeCode = Guid.NewGuid().ToString(); payCharge.PayChargeType = 0; payCharge.InOutCode = inOutCode; payCharge.PayerCode = string.Empty; payCharge.PayerName = string.Empty; payCharge.ChargerCode = string.Empty; payCharge.ChargerName = string.Empty; payCharge.OperateTime = DateTime.Parse(dateEditInTime.Text); payCharge.OperatorCode = pceOperator.Tag.ToString(); payCharge.OperatorName = pceOperator.Text; payCharge.PayChargeRemark = string.Empty; if (!string.IsNullOrEmpty(textEditTotalFee.Text)) { payCharge.TotalFee = double.Parse(textEditTotalFee.EditValue.ToString()); } else { payCharge.TotalFee = 0.0; } payCharge.NeedToPay = 0.0; payCharge.AmountTax = 0.0; payCharge.PayThisTime = payCharge.TotalFee; payCharge.DiscountFee = 0.0; payCharge.IncomeDay = 0; payCharge.IncomeTime = DateTime.MinValue; #endregion //更新Refund StockProduct StockItem StockInOut StockDetail TradeRefundService.UpdateTradeRefund(refundUpdateList, stockProductList, stockHouseProList, stockInOutList, stockDetailList , payCharge, refundIDList, outerSkuIdList, outerIdList); return(true); }