Ejemplo n.º 1
0
        /// <summary>
        /// 初始化/刷新
        /// </summary>
        private void Init()
        {
            int rowHandle = gvStockCheck.FocusedRowHandle;
            List <View_StockCheck> stockCheckList = StockProductService.GetAllViewStockCheck();

            gridStockCheck.DataSource = stockCheckList;
            if (rowHandle == 0 && gvStockCheck.FocusedRowHandle > -1)
            {
                FocusedRowChange();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 焦点行改变触发
        /// </summary>
        private void FocusedRowChange()
        {
            View_StockCheck stockCheck = gvStockCheck.GetFocusedRow() as View_StockCheck;

            if (stockCheck != null)
            {
                List <View_CheckDetail> checkDetailList = StockProductService.GetViewCheckDetail(stockCheck.StockCheckCode);
                gridCtrlProductCheck.DataSource = checkDetailList;
            }
            gvStockCheck.BestFitColumns();
            gridViewProductCheck.BestFitColumns();
        }
Ejemplo n.º 3
0
        //创建下拉列biao
        private void InitCmbDetails()
        {
            DataSet dataSet = new DataSet();

            //从XML文件读出暂存数据库表格框架 包含TradeList表和OrderList表
            MemoryStream stream = new MemoryStream(Resources.ModifyOrderSchema);

            try
            {
                dataSet.ReadXmlSchema(stream);
            }
            finally
            {
                stream.Close();
            }

            if (_tradeStock.ItemType != "组合商品")
            {
                List <StockProduct> sipList =
                    StockProductService.GetStockProduct(p => p.OuterID == _tradeStock.outer_id);
                foreach (StockProduct sip in sipList)
                {
                    DataRow sipRow     = dataSet.Tables["ProductList"].NewRow();
                    double  conversion = _tradeStock.Conversion.Value;
                    sipRow["SkuProps_Str"]     = sip.SkuProps_Str;
                    sipRow["LeftQuantity"]     = Math.Floor((sip.SkuQuantity - sip.OccupiedQuantity) / conversion);
                    sipRow["lackProductOrNot"] =
                        sip.SkuQuantity - sip.OccupiedQuantity - _tradeStock.num * _tradeStock.Conversion >= 0 ? LackProductOrNot.Normal : LackProductOrNot.Lack;
                    dataSet.Tables["ProductList"].Rows.Add(sipRow);
                }
            }
            else
            {
                List <AssembleItem> sipList =
                    AssembleItemService.GetAssembleItem(p => p.OuterID == _tradeStock.outer_id);
                foreach (AssembleItem sip in sipList)
                {
                    List <View_AssembleProduct> detailAssemble = AssembleItemService.GetView_AssembleProduct(p => p.AssembleOuterID == _tradeStock.outer_id && p.AssembleProps_Str == sip.SkuProps_Str);
                    DataRow sipRow = dataSet.Tables["ProductList"].NewRow();
                    sipRow["SkuProps_Str"]     = sip.SkuProps_Str;
                    sipRow["LeftQuantity"]     = detailAssemble.Min(p => (p.SkuQuantity - p.OccupiedQuantity) / p.Count);
                    sipRow["lackProductOrNot"] =
                        detailAssemble.Min(p => p.SkuQuantity - p.OccupiedQuantity - p.Count * _tradeStock.num) >= 0 ? LackProductOrNot.Normal : LackProductOrNot.Lack;
                    dataSet.Tables["ProductList"].Rows.Add(sipRow);
                }
            }
            cmbProperties.Properties.DataSource = dataSet.Tables["ProductList"];
        }
Ejemplo n.º 4
0
        //属性改变时相应的处理
        private void cmbProperties_EditValueChanged(object sender, EventArgs e)
        {
            string skuProsName = cmbProperties.EditValue.ToString();

            if (_tradeStock.ItemType == "组合商品")
            {
                List <View_AssembleProduct> detailAssemble = AssembleItemService.GetView_AssembleProduct(p => p.AssembleOuterID == _tradeStock.outer_id &&
                                                                                                         p.AssembleProps_Str == skuProsName);
                txtStockNum.Text = detailAssemble.Min(p => (p.SkuQuantity - p.OccupiedQuantity) / p.Count).ToString();
            }
            else
            {
                StockProduct product = StockProductService.GetStockProduct(_tradeStock.SkuOuterID);
                txtStockNum.Text = (product.SkuQuantity - product.OccupiedQuantity).ToString();
            }
        }
Ejemplo n.º 5
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            int rowHandle = gvStockCheck.FocusedRowHandle;

            if (textKeyWord.Text == string.Empty)
            {
                XtraMessageBox.Show("请输入关键词", Constants.SYSTEM_PROMPT);
                return;
            }
            List <View_StockCheck> stockCheckList = StockProductService.GetAllViewStockCheck();

            gridStockCheck.DataSource = stockCheckList.Where(i => i.StockCheckCode.Contains(textKeyWord.Text) || i.HouseName.Contains(textKeyWord.Text) ||
                                                             i.nick.Contains(textKeyWord.Text) || i.Created.ToString().Contains(textKeyWord.Text)).ToList();
            if (rowHandle == 0 && gvStockCheck.FocusedRowHandle > -1)
            {
                FocusedRowChange();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 点击显示商品属性
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gvProductSJ_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            DataRow row = gvProductSJ.GetFocusedDataRow();

            if (row != null && row["OuterID"] != null && row["SkuOuterID"] != null)
            {
                StockItem    stockItem    = StockItemService.GetStockItemByOutId(row["OuterID"].ToString());
                StockProduct stockProduct = StockProductService.GetStockProduct(row["SkuOuterID"].ToString());
                if (stockItem != null && stockProduct != null)
                {
                    View_ShopItem item = new View_ShopItem();
                    item.props          = stockItem.Props;
                    item.input_pids     = stockItem.InputPids;
                    item.input_str      = stockItem.InputStr;
                    item.property_alias = stockProduct.PropsAlias;
                    item.cid            = stockItem.Cid;
                    UIHelper.LoadItemPropValue(item, categoryKeyProps, categorySaleProps, categoryNotKeyProps, categoryInputProps);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 加载库位和商品属性
        /// </summary>
        /// <param name="repositoryItemComboBoxLayout"></param>
        /// <param name="houseCode"></param>
        /// <param name="skuOuterID"></param>
        /// <param name="outerID"></param>
        /// <param name="categoryRowKeyProps"></param>
        /// <param name="categoryRowSaleProps"></param>
        /// <param name="categoryRowNotKeyProps"></param>
        /// <param name="categoryRowStockProps"></param>
        public void LoadLayoutAndProps(RepositoryItemComboBox repositoryItemComboBoxLayout, GridView gridView
                                       , CategoryRow categoryRowKeyProps, CategoryRow categoryRowSaleProps, CategoryRow categoryRowNotKeyProps, CategoryRow categoryRowStockProps)
        {
            DataRow row = gridView.GetFocusedDataRow();

            if (row == null)
            {
                return;
            }

            string houseCode  = row["HouseCode"] == null ? string.Empty : row["HouseCode"].ToString();
            string outerID    = row["OuterID"] == null ? string.Empty : row["OuterID"].ToString();
            string skuOuterID = row["SkuOuterID"] == null ? string.Empty : row["SkuOuterID"].ToString();

            repositoryItemComboBoxLayout.Items.Clear();
            if (!string.IsNullOrEmpty(houseCode))
            {
                LoadLayout(repositoryItemComboBoxLayout, houseCode);
            }

            /*点击显示商品属性*/
            if (!string.IsNullOrEmpty(outerID) && !string.IsNullOrEmpty(skuOuterID))
            {
                StockItem    stockItem    = StockItemService.GetStockItemByOutId(outerID);
                StockProduct stockProduct = StockProductService.GetStockProduct(skuOuterID);
                if (stockItem != null && stockProduct != null)
                {
                    View_ShopItem item = new View_ShopItem();
                    item.props          = stockItem.Props;
                    item.input_pids     = stockItem.InputPids;
                    item.input_str      = stockItem.InputStr;
                    item.property_alias = stockProduct.PropsAlias;
                    item.cid            = stockItem.Cid;
                    UIHelper.LoadItemPropValue(item, categoryRowKeyProps, categoryRowSaleProps, categoryRowNotKeyProps, categoryRowStockProps);
                }
            }
        }
Ejemplo n.º 8
0
        /// <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);
        }