public ReturnType RemovePayCharge(string paychargeCode) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*List<PayCharge> list = alading.PayCharge.Where(p => p.PayChargeID == paychargeID).ToList();*/ List <PayCharge> list = alading.PayCharge.Where(p => p.PayChargeCode == paychargeCode).ToList(); if (list.Count == 0) { return(ReturnType.NotExisted); } else { PayCharge sy = list.First(); alading.DeleteObject(sy); alading.SaveChanges(); return(ReturnType.Success); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (System.Exception ex) { return(ReturnType.OthersError); } }
private void btnSave_Click(object sender, EventArgs e) { List <StockHouseProduct> shpList = new List <StockHouseProduct>(); List <View_StockItemProduct> vsipList = new List <View_StockItemProduct>(); PayCharge payCharge = new PayCharge(); try { if (purchaseIn1.GetData(stockInOut, payCharge, sdList, shpList, vsipList)) { StockInOutService.AddInOutAndDetails(stockInOut, payCharge, sdList, shpList, vsipList); this.Close(); } else { stockInOut = new Alading.Entity.StockInOut(); sdList = new List <StockDetail>(); return; } } catch (Exception ex) { return; } }
public ReturnType AddPayCharge(PayCharge paycharge) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { alading.AddToPayCharge(paycharge); if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.PropertyExisted); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public ReturnType AddInOutAndDetails(StockInOut stockInOut, PayCharge payChage, List <StockDetail> sdList, List <StockHouseProduct> shpList, List <View_StockItemProduct> vsipList) { System.Data.Common.DbTransaction tran = null; using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { try { alading.Connection.Open(); tran = alading.Connection.BeginTransaction(); alading.AddToPayCharge(payChage); alading.AddToStockInOut(stockInOut); foreach (StockDetail sd in sdList) { alading.AddToStockDetail(sd); } foreach (StockHouseProduct shp in shpList) { StockHouseProduct tmpshp = alading.StockHouseProduct.FirstOrDefault(c => c.HouseProductCode == shp.HouseProductCode); if (tmpshp != null) { tmpshp.Num = shp.Num; } else { alading.AddToStockHouseProduct(shp); } } foreach (View_StockItemProduct vsip in vsipList) { StockItem stockItem = alading.StockItem.FirstOrDefault(s => s.OuterID == vsip.OuterID); StockProduct stockProduct = alading.StockProduct.FirstOrDefault(s => s.SkuOuterID == vsip.SkuOuterID); stockItem.TotalQuantity = Math.Round(vsip.TotalQuantity, 3); stockProduct.SkuQuantity = vsip.SkuQuantity; stockProduct.LastStockPrice = vsip.LastStockPrice; stockProduct.AvgStockPrice = vsip.AvgStockPrice; } alading.SaveChanges(); tran.Commit(); return(ReturnType.Success); } catch (System.Exception ex) { if (tran != null) { tran.Rollback(); } return(ReturnType.SaveFailed); } finally { if (alading != null && alading.Connection.State != System.Data.ConnectionState.Closed) { alading.Connection.Close(); } } } }
public ReturnType UpdatePayCharge(string paychargeCode, PayCharge paycharge) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*var result = alading.PayCharge.Where(p => p.PayChargeID == paychargeID).ToList();*/ var result = alading.PayCharge.Where(p => p.PayChargeCode == paychargeCode).ToList(); if (result.Count == 0) { return(ReturnType.NotExisted); } PayCharge ob = result.First(); ob.PayChargeCode = paycharge.PayChargeCode; ob.PayChargeType = paycharge.PayChargeType; ob.InOutCode = paycharge.InOutCode; ob.PayerCode = paycharge.PayerCode; ob.PayerName = paycharge.PayerName; ob.ChargerCode = paycharge.ChargerCode; ob.ChargerName = paycharge.ChargerName; ob.OperateTime = paycharge.OperateTime; ob.OperatorCode = paycharge.OperatorCode; ob.OperatorName = paycharge.OperatorName; ob.PayThisTime = paycharge.PayThisTime; ob.PayerName = paycharge.PayerName; ob.AmountTax = paycharge.AmountTax; ob.TotalFee = paycharge.TotalFee; ob.DiscountFee = paycharge.DiscountFee; ob.NeedToPay = paycharge.NeedToPay; ob.PayThisTime = paycharge.PayThisTime; ob.PayChargeRemark = paycharge.PayChargeRemark; if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.OthersError); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (System.Exception ex) { return(ReturnType.OthersError); } }
public ReturnType UpdatePayCharge(PayCharge paycharge) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*PayCharge result = alading.PayCharge.Where(p => p.PayChargeID == paycharge.PayChargeID).FirstOrDefault();*/ PayCharge result = alading.PayCharge.Where(p => p.PayChargeCode == paycharge.PayChargeCode).FirstOrDefault(); if (result == null) { return(ReturnType.NotExisted); } #region Using Attach() Function Update,Default USE; alading.Attach(result); alading.ApplyPropertyChanges("PayCharge", paycharge); #endregion #region Using All Items Replace To Update ,Default UnUse /* * * result.PayChargeCode = paycharge.PayChargeCode; * * result.PayChargeType = paycharge.PayChargeType; * * result.InOutCode = paycharge.InOutCode; * * result.PayerCode = paycharge.PayerCode; * * result.PayerName = paycharge.PayerName; * * result.ChargerCode = paycharge.ChargerCode; * * result.ChargerName = paycharge.ChargerName; * * result.OperateTime = paycharge.OperateTime; * * result.OperatorCode = paycharge.OperatorCode; * * result.OperatorName = paycharge.OperatorName; * * result.RealFee = paycharge.RealFee; * * result.PayChargeRemark = paycharge.PayChargeRemark; * */ #endregion if (alading.SaveChanges() == 1) { return(ReturnType.Success); } return(ReturnType.OthersError); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public static ReturnType UpdatePayCharge(string paychargeCode, PayCharge paycharge) { return(DataProviderClass.Instance().UpdatePayCharge(paychargeCode, paycharge)); }
public static ReturnType AddPayCharge(PayCharge paycharge) { return(DataProviderClass.Instance().AddPayCharge(paycharge)); }
public static ReturnType AddInOutAndDetails(StockInOut stockInOut, PayCharge payChage, List <StockDetail> sdList, List <StockHouseProduct> shpList, List <View_StockItemProduct> vsipList) { return(DataProviderClass.Instance().AddInOutAndDetails(stockInOut, payChage, sdList, shpList, vsipList)); }
public ReturnType UpdateTradeRefund(List <TradeRefund> tradeRefundList, List <StockProduct> stockProductList, List <StockHouseProduct> houseProList , List <StockInOut> stockInOutList, List <StockDetail> stockDetailList, PayCharge payCharge, List <string> refundIdList , List <string> outerSkuIdList, List <string> outerIdList) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*更新TradeRefund*/ var refundResult = alading.TradeRefund.Where(BuildWhereInExpression <TradeRefund, string>(v => v.refund_id, refundIdList)); if (refundResult == null) { return(ReturnType.NotExisted); } foreach (TradeRefund tradeRefund in tradeRefundList)//需要更新的新数据 { TradeRefund oldRefund = refundResult.Where(c => c.refund_id == tradeRefund.refund_id).FirstOrDefault(); //TradeRefundCopydata(oldRefund, tradeRefund); oldRefund.IsRecieved = tradeRefund.IsRecieved; oldRefund.LocalPrivyC = tradeRefund.LocalPrivyC; } /*更新StockProduct 和 StockItem*/ var stockProductResult = alading.StockProduct.Where(BuildWhereInExpression <StockProduct, string>(v => v.SkuOuterID, outerSkuIdList)); var stockItemResult = alading.StockItem.Where(BuildWhereInExpression <StockItem, string>(v => v.OuterID, outerIdList)); if (stockProductResult == null || stockItemResult == null) { return(ReturnType.NotExisted); } foreach (StockProduct stockProduct in stockProductList) { //获取StockProduct的原始数据 StockProduct oldStockProduct = stockProductResult.Where(c => c.SkuOuterID == stockProduct.SkuOuterID).FirstOrDefault(); //获取StockItem的原始数据 StockItem oldStockItem = stockItemResult.Where(c => c.OuterID == stockProduct.OuterID).FirstOrDefault(); if (oldStockProduct != null && oldStockItem != null) { //获取StockProduct的相关原始数据的商品数量 oldStockProduct.SkuQuantity = oldStockProduct.SkuQuantity + stockProduct.SkuQuantity; //获取oldStockItem的相关原始数据的商品数量 oldStockItem.TotalQuantity = oldStockItem.TotalQuantity + stockProduct.SkuQuantity; } else { return(ReturnType.NotExisted); } } /*添加或更新StockHouseProduct*/ var stockHouseProResult = alading.StockHouseProduct.Where(BuildWhereInExpression <StockHouseProduct, string>(v => v.SkuOuterID, outerSkuIdList)); foreach (StockHouseProduct stockHousePro in houseProList) { StockHouseProduct oldPro = stockHouseProResult.Where(c => c.SkuOuterID == stockHousePro.SkuOuterID && c.HouseCode == stockHousePro.HouseCode && c.LayoutCode == stockHousePro.LayoutCode).FirstOrDefault(); if (oldPro != null) { oldPro.Num += stockHousePro.Num; } else { stockHousePro.HouseProductCode = Guid.NewGuid().ToString(); alading.AddToStockHouseProduct(stockHousePro); } } /*添加StockInOut*/ foreach (StockInOut stockInOut in stockInOutList) { alading.AddToStockInOut(stockInOut); } /*添加StockDetail*/ foreach (StockDetail stockDetail in stockDetailList) { alading.AddToStockDetail(stockDetail); } alading.AddToPayCharge(payCharge); alading.SaveChanges(); return(ReturnType.Success); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
/// <summary> /// 保存数据 /// </summary> /// <param name="gridView"></param> /// <param name="dateEditInTime"></param> public bool Save(GridView gridView, InOutData inoutData) { if (gridView == null || gridView.RowCount == 0) { XtraMessageBox.Show("没有可保存的数据", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } bool isSelectHouse = HouseSelect(gridView); if (!isSelectHouse) { XtraMessageBox.Show("需要选择仓库", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } bool isSelectLayout = LayoutSelect(gridView); if (!isSelectLayout) { XtraMessageBox.Show("需要选择库位", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } //用于存放要保存到数据库的StockProduct List <Alading.Entity.StockProduct> stockProductList = new List <StockProduct>(); //用于存放要保存到数据库的StockHouseProduct List <Alading.Entity.StockHouseProduct> stockHouseProList = new List <StockHouseProduct>(); //用于存放要保存到数据库的StockDetail List <Alading.Entity.StockDetail> stockDetailList = new List <StockDetail>(); List <string> outerSkuIdList = new List <string>(); List <string> outerIdList = new List <string>(); for (int rowHandle = 0; rowHandle < gridView.RowCount; rowHandle++) { DataRow dataRow = gridView.GetDataRow(rowHandle); #region 更新StockItem StockProduct StockHouseProduct Alading.Entity.StockProduct stockProduct = new StockProduct(); stockProduct.SkuOuterID = dataRow["SkuOuterID"] == null ? string.Empty : dataRow["SkuOuterID"].ToString(); stockProduct.OuterID = dataRow["OuterId"] == null ? string.Empty : dataRow["OuterId"].ToString(); //获取入库数量 double inOutNum = 0.0; if (dataRow["Count"] == null || string.IsNullOrEmpty(dataRow["Count"].ToString())) { stockProduct.SkuQuantity = 0; } else if (inoutData.isIn) { inOutNum = double.Parse(dataRow["Count"].ToString()); stockProduct.SkuQuantity = int.Parse(inOutNum.ToString()); } else { inOutNum = double.Parse(dataRow["Count"].ToString()); stockProduct.SkuQuantity = -int.Parse(inOutNum.ToString()); } //存放以准备保存到数据库 stockProductList.Add(stockProduct); outerSkuIdList.Add(dataRow["SkuOuterID"].ToString()); outerIdList.Add(dataRow["OuterId"].ToString()); #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 = stockProduct.SkuOuterID; stockHousePro.Num = stockProduct.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 = stockProduct.SkuOuterID; stockDetail.InOutCode = inoutData.InOutCode; //仓库编号 stockDetail.StockHouseCode = dataRow["HouseCode"] == null ? string.Empty : dataRow["HouseCode"].ToString(); //库位编号 stockDetail.StockLayOutCode = dataRow["LayoutCode"] == null ? string.Empty : dataRow["LayoutCode"].ToString(); //商品价格 stockDetail.Price = (float)stockProduct.SkuPrice; stockDetail.Quantity = int.Parse(inOutNum.ToString()); stockDetail.DetailType = inoutData.InOutType; stockDetail.DetailRemark = dataRow["DetailRemark"] == null ? string.Empty : dataRow["DetailRemark"].ToString(); //税率 stockDetail.Tax = dataRow["Tax"] == null ? string.Empty : dataRow["Tax"].ToString(); stockDetail.TotalFee = dataRow["TotalMoney"] == null ? 0 : float.Parse(dataRow["TotalMoney"].ToString()); //商品的保质期 stockDetail.DurabilityDate = System.DateTime.MaxValue; stockDetailList.Add(stockDetail); #endregion } #region 添加StockInOut //用于存放StockInOut List <Alading.Entity.StockInOut> stockInOutList = new List <Alading.Entity.StockInOut>(); Alading.Entity.StockInOut stockInOut = new Alading.Entity.StockInOut(); //进出库单编号 stockInOut.InOutCode = inoutData.InOutCode; stockInOut.InOutTime = inoutData.InOutDateTime; stockInOut.OperatorCode = inoutData.OperatorCode; //经办人员 stockInOut.OperatorName = inoutData.Operator; stockInOut.InOutType = inoutData.InOutType; //oid赋值 stockInOut.TradeOrderCode = string.Empty; //付款方式 stockInOut.PayType = inoutData.PayType; //保存现金折扣 stockInOut.DiscountFee = float.Parse(inoutData.DiscountFee.ToString()); //保存应付应收金额 stockInOut.DueFee = float.Parse(inoutData.NeedToPay.ToString()); stockInOut.InOutStatus = inoutData.InOutStatus; stockInOut.IsSettled = true; stockInOut.PayThisTime = float.Parse(inoutData.PayThisTime.ToString()); stockInOut.PayTerm = inoutData.PayTerm; stockInOut.IncomeTime = inoutData.IncomeTime; stockInOut.AmountTax = float.Parse(inoutData.AmountTax.ToString()); stockInOut.FreightCompany = inoutData.FreightCompany; stockInOut.FreightCode = inoutData.FreightCode; stockInOutList.Add(stockInOut); #endregion #region 添加或更新PayCharge PayCharge payCharge = new PayCharge(); payCharge.PayChargeCode = Guid.NewGuid().ToString(); //付款收款方式 payCharge.PayChargeType = inoutData.InOutType; payCharge.InOutCode = inoutData.InOutCode; //付款人编号 payCharge.PayerCode = string.Empty; //付款人名字 payCharge.PayerName = string.Empty; //收款人编号 payCharge.ChargerCode = string.Empty; //收款人名字 payCharge.ChargerName = string.Empty; //操作时间 payCharge.OperateTime = DateTime.Parse(DateTime.Now.ToShortDateString()); payCharge.OperatorCode = inoutData.OperatorCode; payCharge.OperatorName = inoutData.Operator; payCharge.PayChargeRemark = string.Empty; payCharge.TotalFee = inoutData.TotalFee; payCharge.NeedToPay = inoutData.NeedToPay; payCharge.AmountTax = inoutData.AmountTax; payCharge.PayThisTime = inoutData.PayThisTime; payCharge.DiscountFee = inoutData.DiscountFee; payCharge.IncomeDay = inoutData.PayTerm; payCharge.IncomeTime = inoutData.IncomeTime; #endregion StockProductService.UpdateStock(stockProductList, stockHouseProList, stockInOutList, stockDetailList, payCharge, outerSkuIdList, outerIdList); return(true); }
public ReturnType UpdateStock(List <StockProduct> stockProductList, List <StockHouseProduct> stockHouseProList, List <StockInOut> stockInOutList , List <StockDetail> stockDetailList, PayCharge payCharge, List <string> outerSkuIdList, List <string> outerIdList)//zxl { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { #region 更新StockProduct 和 StockItem var stockProductResult = alading.StockProduct.Where(BuildWhereInExpression <StockProduct, string>(v => v.SkuOuterID, outerSkuIdList)); var stockItemResult = alading.StockItem.Where(BuildWhereInExpression <StockItem, string>(v => v.OuterID, outerIdList)); if (stockProductResult == null || stockItemResult == null) { return(ReturnType.NotExisted); } foreach (StockProduct stockProduct in stockProductList) { //获取StockProduct的原始数据 StockProduct oldStockProduct = stockProductResult.Where(c => c.SkuOuterID == stockProduct.SkuOuterID).FirstOrDefault(); //获取StockItem的原始数据 StockItem oldStockItem = stockItemResult.Where(c => c.OuterID == stockProduct.OuterID).FirstOrDefault(); //获取StockProduct的相关原始数据的商品数量 oldStockProduct.SkuQuantity += stockProduct.SkuQuantity; //获取oldStockItem的相关原始数据的商品数量 oldStockItem.TotalQuantity += stockProduct.SkuQuantity; } #endregion #region 添加或更新StockHouseProduct var stockHouseProResult = alading.StockHouseProduct.Where(BuildWhereInExpression <StockHouseProduct, string>(v => v.SkuOuterID, outerSkuIdList)); foreach (StockHouseProduct stockHousePro in stockHouseProList) { StockHouseProduct oldPro = stockHouseProResult.Where(c => c.SkuOuterID == stockHousePro.SkuOuterID && c.HouseCode == stockHousePro.HouseCode && c.LayoutCode == stockHousePro.LayoutCode).FirstOrDefault(); if (oldPro != null) { oldPro.Num += stockHousePro.Num; } else { stockHousePro.HouseProductCode = Guid.NewGuid().ToString(); alading.AddToStockHouseProduct(stockHousePro); } } #endregion #region 添加StockInOut foreach (StockInOut stockInOut in stockInOutList) { alading.AddToStockInOut(stockInOut); } #endregion #region 添加StockDetail foreach (StockDetail stockDetail in stockDetailList) { alading.AddToStockDetail(stockDetail); } #endregion #region 添加PayCharge alading.AddToPayCharge(payCharge); #endregion alading.SaveChanges(); return(ReturnType.Success); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
/// <summary> /// 同外界交互的接口,生成入库单及明细 /// </summary> public bool GetData(Alading.Entity.StockInOut stockInOut, PayCharge payCharge, List <StockDetail> sdList, List <StockHouseProduct> shpList, List <View_StockItemProduct> vsipList) { #region 验证 /*验证是否选择了商品*/ if (gvProductSJ.RowCount == 0) { XtraMessageBox.Show("请先选择一个商品!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (!IsAllNecessaryInput()) { XtraMessageBox.Show("请填写完整的入库单详情!(带*的为必填。)", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (!IsAllNecessaryCellInput()) { XtraMessageBox.Show("请将列表中的仓库、库位、数量及价格信息输入完整!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } string inoutCode = textEditInOutCode.Text.Trim(); if (StockInOutService.GetAllStockInOut().FirstOrDefault(c => c.InOutCode == inoutCode) != null) { XtraMessageBox.Show("入库单编码与数据库中已有入库单编码重复,请重输!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } #endregion #region StockInOut stockInOut.AmountTax = !string.IsNullOrEmpty(textEditAmountTax.Text)? float.Parse(textEditAmountTax.Text):0; stockInOut.DiscountFee = !string.IsNullOrEmpty(textEditDiscountFee.Text)?float.Parse(textEditDiscountFee.Text):0; stockInOut.DueFee = !string.IsNullOrEmpty(textEditTotalFee.Text)?float.Parse(textEditTotalFee.Text):0; stockInOut.FreightCode = pceFreightCompany.Tag != null?pceFreightCompany.Tag.ToString() : string.Empty; stockInOut.FreightCompany = pceFreightCompany.Text != null?pceFreightCompany.Text:string.Empty; stockInOut.IncomeTime = dateEditIncomeTime.DateTime; stockInOut.InOutCode = textEditInOutCode.Text; stockInOut.InOutStatus = (int)Alading.Core.Enum.InOutStatus.AllReach; stockInOut.InOutTime = DateTime.Now; stockInOut.InOutType = (int)InOutType.PurchaseIn; /*权宜之计*/ //stockInOut.货运单号 stockInOut.OperatorCode = pceOperator.Tag != null?pceOperator.Tag.ToString() : string.Empty; stockInOut.OperatorName = pceOperator.Text != null?pceOperator.Text:string.Empty; stockInOut.PayTerm = 0; stockInOut.PayThisTime = !string.IsNullOrEmpty(textEditPayThisTime.Text)?float.Parse(textEditPayThisTime.Text):0; stockInOut.PayType = comboPayType.SelectedIndex + 1; stockInOut.TradeOrderCode = string.Empty;// stockInOut.IsSettled = stockInOut.PayThisTime >= stockInOut.DueFee; #endregion #region 付款信息 payCharge.AmountTax = !string.IsNullOrEmpty(textEditAmountTax.Text) ? float.Parse(textEditAmountTax.Text) : 0; payCharge.ChargerCode = string.Empty; /*付款编号*/ payCharge.ChargerName = string.Empty; // payCharge.DiscountFee = !string.IsNullOrEmpty(textEditDiscountFee.Text) ? float.Parse(textEditDiscountFee.Text) : 0; payCharge.InOutCode = stockInOut.InOutCode; payCharge.NeedToPay = !string.IsNullOrEmpty(textEditNeedToPay.Text) ? float.Parse(textEditNeedToPay.Text) : 0; payCharge.OperateTime = DateTime.Now; payCharge.OperatorCode = string.Empty; // payCharge.OperatorName = string.Empty; // payCharge.PayChargeCode = string.Empty; // payCharge.PayChargeRemark = string.Empty; payCharge.PayChargeType = comboPayType.SelectedIndex; payCharge.PayerCode = string.Empty; payCharge.PayerName = string.Empty; payCharge.PayThisTime = !string.IsNullOrEmpty(textEditPayThisTime.Text) ? float.Parse(textEditPayThisTime.Text) : 0; payCharge.TotalFee = !string.IsNullOrEmpty(textEditTotalFee.Text) ? float.Parse(textEditTotalFee.Text) : 0; payCharge.IncomeDay = !string.IsNullOrEmpty(textEditPayTerm.Text) ? int.Parse(textEditPayTerm.Text) : 0; payCharge.IncomeTime = dateEditIncomeTime.DateTime; #endregion #region StockHouseProduct,View_StockItemProduct,StockDetail int count = gvProductSJ.RowCount; /*找到商品在仓库中的位置,并更新该仓库中商品的数量*/ List <StockHouseProduct> allShpList = StockHouseService.GetAllStockHouseProduct(); //IEnumerable<View_StockItemProduct> allVispList = View_StockItemProductService.GetAllView_StockItemProduct(); for (int i = 0; i < count; i++) { DataRow row = gvProductSJ.GetDataRow(i); //总金额 double totalMoney = row["TotalMoney"] != null?double.Parse(row["TotalMoney"].ToString()) : 0; //入库数量 int num = row["TotalCount"] != null?int.Parse(row["TotalCount"].ToString()) : 0; /*仓库名称*/ string houseName = row[gcStockHouse.FieldName].ToString(); /*库位名称*/ string layoutName = row[gcStockLayout.FieldName].ToString(); //最新进价 double LastStockPrice = totalMoney / num; /*修改仓库商品表数量增加*/ StockHouseProduct shp = allShpList.FirstOrDefault(c => c.HouseCode == row["StockHouseCode"].ToString() && c.SkuOuterID == row["SkuOuterID"].ToString() && c.LayoutCode == row["StockLayoutCode"].ToString()); if (shp != null) { shp.Num += num; shpList.Add(shp); } else { shp = new StockHouseProduct(); shp.HouseCode = row["StockHouseCode"].ToString(); shp.HouseProductCode = System.Guid.NewGuid().ToString(); shp.LayoutCode = row["StockLayoutCode"].ToString(); shp.Num = num; shp.HouseName = houseName; shp.LayoutName = layoutName; shp.SkuOuterID = row["SkuOuterID"].ToString(); shpList.Add(shp); } View_StockItemProduct vsip = View_StockItemProductService.GetView_StockItemProductBySkuOuterId(row["SkuOuterID"].ToString()); if (vsip != null) { //视图无法直接修改其属性值,所以需要new一个然后给之赋值 View_StockItemProduct tempVsip = new View_StockItemProduct(); tempVsip.SkuOuterID = vsip.SkuOuterID; tempVsip.OuterID = vsip.OuterID; tempVsip.LastStockPrice = LastStockPrice; int lastNum = vsip.SkuQuantity; tempVsip.TotalQuantity = vsip.TotalQuantity + num; tempVsip.SkuQuantity = vsip.SkuQuantity + num; //平均价格=(上次剩余商品的平均价格*上次剩余数量+本次总金额)/本次剩余数量 tempVsip.AvgStockPrice = (vsip.AvgStockPrice * lastNum + totalMoney) / vsip.SkuQuantity; vsipList.Add(tempVsip); } /*价格问题该如何处理???*/ StockDetail sd = new StockDetail(); sd.DetailRemark = string.Empty; sd.DetailType = (int)Alading.Core.Enum.DetailType.PurchaseIn; sd.DurabilityDate = DateTime.MinValue;//有效期? sd.InOutCode = stockInOut.InOutCode; sd.HouseName = houseName; sd.LayoutName = layoutName; sd.Price = float.Parse((totalMoney / num).ToString()); sd.Quantity = num; sd.StockDetailCode = System.Guid.NewGuid().ToString(); sd.ProductSkuOuterId = row["SkuOuterId"].ToString(); sd.StockHouseCode = row["StockHouseCode"].ToString(); sd.StockLayOutCode = row["StockLayOutCode"].ToString(); sd.Tax = string.Empty;//税额?? sd.TotalFee = float.Parse(totalMoney.ToString()); sdList.Add(sd); } #endregion return(true); }
public static ReturnType UpdateTradeRefund(List <TradeRefund> tradeRefundList, List <StockProduct> stockProductList , List <StockHouseProduct> houseProList, List <StockInOut> stockInOutList, List <StockDetail> stockDetailList, PayCharge payCharge , List <string> refundIdList, List <string> outerSkuIdList, List <string> outerIdList) { return(DataProviderClass.Instance().UpdateTradeRefund(tradeRefundList, stockProductList, houseProList, stockInOutList, stockDetailList , payCharge, refundIdList, outerSkuIdList, outerIdList)); }
public static ReturnType UpdateStock(List <StockProduct> stockProductList, List <StockHouseProduct> stockHouseProList, List <StockInOut> stockInOutList , List <StockDetail> stockDetailList, PayCharge payCharge, List <string> outerSkuIdList, List <string> outerIdList)//zxl { return(DataProviderClass.Instance().UpdateStock(stockProductList, stockHouseProList, stockInOutList, stockDetailList , payCharge, outerSkuIdList, outerIdList)); }
/// <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); }