private void CreateOrderRow(TradeOrder createOrder, View_StockItemProduct item) { createOrder.CustomTid = _customTid; createOrder.iid = string.Empty; createOrder.sku_id = string.Empty; createOrder.TradeOrderCode = Guid.NewGuid().ToString(); createOrder.oid = createOrder.TradeOrderCode; createOrder.outer_sku_id = item.SkuOuterID; createOrder.outer_iid = item.OuterID; createOrder.sku_properties_name = item.SkuProps_Str; createOrder.price = item.SkuPrice; createOrder.total_fee = 0.0; createOrder.discount_fee = 0.0;//淘宝系统优惠价 为 0. 0 createOrder.adjust_fee = 0.0; createOrder.payment = 0.0; createOrder.item_meal_name = string.Empty; createOrder.num = 1; createOrder.title = "赠送礼品"; createOrder.pic_path = string.Empty; createOrder.seller_nick = string.Empty; createOrder.buyer_nick = string.Empty; createOrder.created = DateTime.Now; createOrder.refund_status = Alading.Core.Enum.RefundStatus.NO_REFUND; createOrder.status = TradeEnum.WAIT_SELLER_SEND_GOODS; createOrder.snapshot_url = string.Empty; createOrder.snapshot = string.Empty; createOrder.timeout_action_time = DateTime.MinValue; createOrder.OrderType = Alading.Core.Enum.emumOrderType.GiftGoods;//系统配置订单类型 createOrder.type = string.Empty; createOrder.seller_type = string.Empty; createOrder.HouseCode = string.Empty; createOrder.LayoutCode = string.Empty; createOrder.IsSelected = false; }
/// 向交易添加赠品 private void barGiftAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { int totalRowCount = gvGiftList.RowCount; //循环获取需要提交的Trade List <TradeOrder> orderList = new List <TradeOrder>(); //批量提交数据 View_StockItemProduct giftItem = null; WaitDialogForm waitFrm = new WaitDialogForm(Alading.Taobao.Constants.OPERATE_DB_DATA); for (int runner = 0; runner < totalRowCount; runner++) { giftItem = gvGiftList.GetRow(runner) as Alading.Entity.View_StockItemProduct; if (Convert.ToBoolean(giftItem.IsSelected)) { int existFlag = (gvGiftOrders.DataSource as List <TradeOrder>).Count(p => p.outer_sku_id == giftItem.SkuOuterID); if (existFlag != 0) { XtraMessageBox.Show("交易中已经含有赠品:" + giftItem.Name); } else { TradeOrder createOrder = new TradeOrder(); CreateOrderRow(createOrder, giftItem); orderList.Add(createOrder); } } } TradeOrderService.AddTradeOrder(orderList); waitFrm.Close(); InitTradeList(); XtraMessageBox.Show("添加赠品成功!"); }
/// <summary> /// 响应条形码回车事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void repositoryItemTextEdit1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { TextEdit textEdit = (TextEdit)sender; if (!string.IsNullOrEmpty(textEdit.Text)) { WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); try { string skuOuterID = textEdit.Text; List <View_StockItemProduct> vsipList = View_StockItemProductService.GetView_StockItemProduct(v => v.SkuOuterID == skuOuterID); if (vsipList.Count > 0) { View_StockItemProduct vsip = vsipList.First(); DataRow dRow = dTable.NewRow(); int rowCount = gvProductSJ.RowCount; for (int i = 0; i < rowCount; i++) { DataRow row = gvProductSJ.GetDataRow(i); if (row["SkuOuterID"].ToString() == vsip.SkuOuterID) { return; } } dRow["CatName"] = vsip.CatName; dRow["ProductName"] = vsip.Name; dRow["SkuOuterID"] = vsip.SkuOuterID; dRow["StockCatName"] = vsip.StockCatName; dRow["OuterID"] = vsip.OuterID; dRow["SaleProps"] = vsip.SkuProps_Str; dRow["TotalMoney"] = vsip.SkuPrice; dTable.Rows.Add(dRow); waitForm.Close(); gvProductSJ.BestFitColumns(); } else { waitForm.Close(); XtraMessageBox.Show("找不到相应的商品", Constants.SYSTEM_PROMPT); } } catch (Exception ex) { waitForm.Close(); XtraMessageBox.Show(ex.ToString(), Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { XtraMessageBox.Show("请输入条形码", Constants.SYSTEM_PROMPT); } } }
///辅助函数 判断之前是否已经加入了本项Sku_Out_Id private bool HasExist(View_StockItemProduct item) { foreach (DataRow row in _dTbRecord.Rows) { if (row["OuterID"].ToString() == item.OuterID && row["SkuProps_Str"].ToString() == item.SkuProps_Str) { return(true);//只要匹配,即true } } return(false);//程序执行到此,一定是false }
private void gvGiftList_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { GridView senderIn = sender as GridView; View_StockItemProduct item = senderIn.GetRow(e.RowHandle) as Alading.Entity.View_StockItemProduct; if (e.Column == giftSelected) { item.IsSelected = bool.Parse(e.Value.ToString()); gvGiftList.UpdateCurrentRow(); } }
void Get() { if (bEditBarCode.EditValue != null && !string.IsNullOrEmpty(bEditBarCode.EditValue.ToString())) { WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); try { string skuOuterID = bEditBarCode.EditValue.ToString(); List <View_StockItemProduct> vsipList = View_StockItemProductService.GetView_StockItemProduct(v => v.SkuOuterID == skuOuterID); if (vsipList.Count > 0) { View_StockItemProduct vsip = vsipList.First(); DataRow dRow = dTable.NewRow(); int rowCount = gvProductSJ.RowCount; for (int i = 0; i < rowCount; i++) { DataRow row = gvProductSJ.GetDataRow(i); if (row["SkuOuterID"].ToString() == vsip.SkuOuterID) { return; } } dRow["CatName"] = vsip.CatName; dRow["ProductName"] = vsip.Name; dRow["SkuOuterID"] = vsip.SkuOuterID; dRow["StockCatName"] = vsip.StockCatName; dRow["OuterID"] = vsip.OuterID; dRow["SaleProps"] = vsip.SkuProps_Str; dRow["TotalMoney"] = vsip.SkuPrice; dTable.Rows.Add(dRow); waitForm.Close(); gvProductSJ.BestFitColumns(); } else { waitForm.Close(); XtraMessageBox.Show("找不到相应的商品", Constants.SYSTEM_PROMPT); } } catch (Exception ex) { waitForm.Close(); XtraMessageBox.Show(ex.ToString(), Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { XtraMessageBox.Show("请输入条形码", Constants.SYSTEM_PROMPT); } }
/// <summary> /// 通过条形码获取商品 /// </summary> /// <param name="barCode"></param> /// <param name="gridView"></param> /// <param name="dataTable"></param> /// <returns></returns> public bool GetProByBarCode(string barCode, GridView gridView, DataTable dataTable) { View_StockItemProduct vsip = View_StockItemProductService.GetView_StockItemProductBySkuOuterId(barCode); StockHouseProduct houseProduct = StockHouseService.GetStockHouseProduct(barCode); if (vsip != null) { DataRow dRow = dataTable.NewRow(); int rowCount = gridView.RowCount; for (int i = 0; i < rowCount; i++) { DataRow row = gridView.GetDataRow(i); if (row["SkuOuterID"].ToString() == vsip.SkuOuterID) { return(true); } } //dRow["Select"] = false; dRow["CatName"] = vsip.CatName; dRow["StockCatName"] = vsip.StockCatName; dRow["ProductName"] = vsip.Name; dRow["Num"] = vsip.SkuQuantity; dRow["HouseName"] = houseProduct.HouseName; dRow["LayoutName"] = houseProduct.LayoutName; dRow["SaleProps"] = vsip.SkuProps_Str; dRow["Specification"] = vsip.Specification; dRow["Model"] = vsip.Model; dRow["SkuOuterID"] = barCode; dRow["OuterID"] = vsip.OuterID; dRow["HouseCode"] = houseProduct.HouseCode; dRow["LayoutCode"] = houseProduct.LayoutCode; //dRow["Count"] = 0.0; dRow["price"] = vsip.SkuPrice; dRow["StockUnitName"] = vsip.StockUnitName; dataTable.Rows.Add(dRow); gridView.BestFitColumns(); return(true); } else { return(false); } }
/// <summary> /// 展示商品属性的方法 /// </summary> /// <param name="gv"></param> void ShowProps(GridView gv) { /*如果显示的是属性panel才去加载属性*/ if (panelContainer1.ActiveChild.Name == dockPanel1.Name) { DataRow row = gv.GetFocusedDataRow(); if (row != null && row["OuterID"] != null && row["SkuOuterID"] != null) { List <View_StockItemProduct> tempVsipList = View_StockItemProductService.GetView_StockItemProduct(v => v.OuterID == row["OuterID"].ToString() && v.SkuOuterID == row["SkuOuterID"].ToString()); if (tempVsipList.Count > 0) { View_StockItemProduct vsip = tempVsipList.First(); View_ShopItem item = new View_ShopItem(); item.props = vsip.Props; item.input_pids = vsip.InputPids; item.input_str = vsip.InputStr; item.property_alias = vsip.PropsAlias; item.cid = vsip.Cid; UIHelper.LoadItemPropValue(item, categoryRowKeyProps, categoryRowSaleProps, categoryNotKeyProps, categoryRowInputProps); } } } }
/// <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); }