Ejemplo n.º 1
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.º 2
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();
            }
        }