/// <summary> /// 加载宝贝库存信息 /// </summary> /// <param name="outerid">宝贝商家编码</param> private void LoadStockItem(string outerid) { List <Alading.Entity.View_StockItemProduct> stockitemList = View_StockItemProductService.GetView_StockItemProductItem(outerid); if (stockitemList != null) { gridControlStock.DataSource = stockitemList; gridViewStock.BestFitColumns(); } }
/// <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); } } }
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> /// <param name="value"></param> /// <param name="si"></param> void GetStockItem(string value, StockItemElement si) { WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA); waitForm.Show(); try { table.Rows.Clear(); List <string> skuOuterIDList = new List <string>(); List <StockHouseProduct> houseProList = new List <StockHouseProduct>();//StockHouseService.GetSHProBySkuOuterID(skuOuterIDList); if (stockHouseCode == null) { List <View_StockItemProduct> stockItemList; if (si == StockItemElement.Name && !string.IsNullOrEmpty(value)) { Func <View_StockItemProduct, bool> func = new Func <View_StockItemProduct, bool>(c => c.Name.Contains(value) || c.SkuOuterID.Contains(value)); stockItemList = View_StockItemProductService.GetView_StockItemProduct(func, currentIndex, dataPerPage, out allIndex); } else { stockItemList = View_StockItemProductService.GetView_StockItemProduct(value, currentIndex, dataPerPage, ref allIndex); } if (stockItemList == null) { waitForm.Close(); XtraMessageBox.Show("没有找到对应的商品!", Constants.SYSTEM_PROMPT); return; } foreach (View_StockItemProduct stockItem in stockItemList) { DataRow row = table.NewRow(); StockHouseProduct houseProduct = houseProList.Find(c => c.SkuOuterID == stockItem.SkuOuterID); /*读取选中的节点显示名称*/ row["Select"] = false; row["CatName"] = stockItem.CatName; //淘宝类目 row["Cid"] = stockItem.Cid; //淘宝类目 row["StockCatName"] = stockItem.StockCatName; //库存类目名称 row["Name"] = stockItem.Name; //商品名称 row["Num"] = stockItem.SkuQuantity; //商品库存总数量 row["SaleProps"] = stockItem.SkuProps_Str; //销售属性 row["SkuOuterID"] = stockItem.SkuOuterID; // row["Model"] = stockItem.Model; row["Specification"] = stockItem.Specification; row["StockUnitName"] = stockItem.StockUnitName; row["OuterID"] = stockItem.OuterID;// row[gcTaxCode.FieldName] = stockItem.Tax; //用于展示所选商品的属性 row["StockCid"] = stockItem.StockCid; // row["Props"] = stockItem.Props; // row["InputPids"] = stockItem.InputPids; // row["InputStr"] = stockItem.InputStr; // row["Property_Alias"] = stockItem.Property_Alias; // #region 入库需要信息 row["SkuPrice"] = stockItem.SkuPrice;//销售价 if (houseProduct != null) { row["HouseName"] = houseProduct.HouseName; //仓库名称 row["LayoutName"] = houseProduct.LayoutName; //库位名称 row["HouseCode"] = houseProduct.HouseCode; //仓库编号 row["LayoutCode"] = houseProduct.LayoutCode; //库位编号 } #endregion table.Rows.Add(row); skuOuterIDList.Add(stockItem.SkuOuterID); } } else { if (stockHouseCode.Trim() != string.Empty) { List <View_StockProductHouse> stockItemList = View_StockItemProductService.GetView_StockProductHouse(value, stockHouseCode, currentIndex, dataPerPage, ref allIndex); if (stockItemList == null) { return; } if (stockHouseCode != string.Empty) { foreach (View_StockProductHouse stockItem in stockItemList) { DataRow row = table.NewRow(); StockHouseProduct houseProduct = houseProList.Find(c => c.SkuOuterID == stockItem.SkuOuterID); /*读取选中的节点显示名称*/ row["Select"] = false; row["CatName"] = stockItem.CatName; //淘宝类目 row["StockCatName"] = stockItem.StockCatName; //库存类目名称 row["Cid"] = stockItem.Cid; //淘宝类目 row["Name"] = stockItem.Name; //商品名称 row["Num"] = stockItem.SkuQuantity; //商品库存总数量 row["SaleProps"] = stockItem.SkuProps_Str; //销售属性 row["SkuOuterID"] = stockItem.SkuOuterID; // row["Model"] = stockItem.Model; row["Specification"] = stockItem.Specification; row["OuterID"] = stockItem.OuterID; // row["StockUnitName"] = stockItem.StockUnitName; //计量单位 row[gcTaxCode.FieldName] = stockItem.Tax; //用于展示所选商品的属性 row["StockCid"] = stockItem.StockCid; // row["Props"] = stockItem.Props; // row["InputPids"] = stockItem.InputPids; // row["InputStr"] = stockItem.InputStr; // row["Property_Alias"] = stockItem.Property_Alias; // #region 入库需要信息 row["SkuPrice"] = stockItem.SkuPrice;//销售价 if (houseProduct != null) { row["HouseName"] = houseProduct.HouseName; //仓库名称 row["LayoutName"] = houseProduct.LayoutName; //库位名称 row["HouseCode"] = houseProduct.HouseCode; //仓库编号 row["LayoutCode"] = houseProduct.LayoutCode; //库位编号 } #endregion table.Rows.Add(row); skuOuterIDList.Add(stockItem.SkuOuterID); } } } } gridCtrlStockItem.DataSource = table; gridViewSelected.BestFitColumns(); gridViewStockItem.BestFitColumns(); #region 判断4个分页按钮哪个的enable应为false*/ if (allIndex <= 1) { /*若页码总数为1,则所有分页按钮都为false*/ bbtnFirstIndex.Enabled = false; bbtnNextIndex.Enabled = false; bbtnPriviousIndex.Enabled = false; bbtnLastIndex.Enabled = false; } else if (currentIndex == 1) { /*若页码总数不为1但当前页码为1*/ bbtnFirstIndex.Enabled = false; bbtnNextIndex.Enabled = true; bbtnPriviousIndex.Enabled = false; bbtnLastIndex.Enabled = true; } else if (currentIndex < allIndex) { /*若页码总数不为1且当前页码不等于1且小于页码总数*/ bbtnFirstIndex.Enabled = true; bbtnNextIndex.Enabled = true; bbtnPriviousIndex.Enabled = true; bbtnLastIndex.Enabled = true; } else if (currentIndex == allIndex) { bbtnFirstIndex.Enabled = true; bbtnNextIndex.Enabled = false; bbtnPriviousIndex.Enabled = true; bbtnLastIndex.Enabled = false; } #endregion /*显示当前页码,末尾加个空格避免触发事件*/ bbtnComboxChangeTo.EditValue = "第" + currentIndex.ToString() + "页" + " "; waitForm.Close(); } catch (Exception ex) { waitForm.Close(); XtraMessageBox.Show(ex.ToString(), Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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); }
//初始化赠品列表 private void InitGiftList() { gcGiftList.DataSource = View_StockItemProductService.GetView_StockItemProductByType((int)Alading.Core.Enum.StockItemType.GiftGoods); gcGiftList.ForceInitialize(); }