Example #1
0
        /// <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);
            }
        }
Example #2
0
        /// <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);
        }