private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (cbxStorage.SelectedIndex == -1)
            {
                cbxStorage.Focus();
                MessageBox.Show("请选择盘点仓库");
                return;
            }
            if (!rbUpdateAll.IsChecked.Value && !rbUpdatePart.IsChecked.Value && !rbUpdateExact.IsChecked.Value)
            {
                MessageBox.Show("请选择更新方式.");
                return;
            }
            if (RadGridView1.ItemsSource == null || RadGridView1.Items.Count == 0)
            {
                var mbResult = MessageBox.Show("没有盘点数据,如果选择继续将产生如下影响,是否继续?\n全局更新将清空全部库存\n局部更新将清空局部库存\n精确更新将不影响库存", "注意", MessageBoxButton.YesNo);
                if (mbResult == MessageBoxResult.No)
                {
                    return;
                }
            }

            List <DistributionCommonBillVM <BillStocktakeContrast, BillStocktakeContrastDetails> > contrasts = new List <DistributionCommonBillVM <BillStocktakeContrast, BillStocktakeContrastDetails> >();
            var stocktakeDatas = RadGridView1.ItemsSource as IEnumerable <StocktakeAggregationEntityForStockUpdate>;

            if (stocktakeDatas == null)
            {
                stocktakeDatas = new List <StocktakeAggregationEntityForStockUpdate>();
            }
            if (rbUpdateAll.IsChecked.Value)                                         //全局更新
            {
                int[] brandIDs = VMGlobal.PoweredBrands.Select(o => o.ID).ToArray(); //GetBrandIDsForUpdate(stocktakeDatas);
                foreach (int bid in brandIDs)
                {
                    var stocks   = StockLogic.GetStockInStorage((int)cbxStorage.SelectedValue, bid);
                    var contrast = this.GenerateContrast(bid, stocks, stocktakeDatas.Where(o => o.BrandID == bid).ToList());
                    //contrast.SaveWithNoTran();//添加盈亏单
                    contrasts.Add(contrast);
                }
            }
            else if (rbUpdatePart.IsChecked.Value)//局部更新
            {
                if (string.IsNullOrWhiteSpace(txtStyleCodeForPartUpdate.Text))
                {
                    txtStyleCodeForPartUpdate.Focus();
                    MessageBox.Show("请输入局部更新条码区间,多个区间以逗号分隔.");
                    return;
                }
                var pcodes = txtStyleCodeForPartUpdate.Text.Trim().Split(',');
                pcodes         = pcodes.Select(o => o.Trim()).ToArray();
                stocktakeDatas = stocktakeDatas.ToList().Where(StockLogic.GenerateOrElseConditionWithArray <StocktakeAggregationEntityForStockUpdate>("ProductCode", "StartsWith", pcodes).Compile());
                int[] brandIDs = GetBrandIDsForUpdate(stocktakeDatas);
                foreach (int bid in brandIDs)
                {
                    var stocks   = StockLogic.GetStockInStorage((int)cbxStorage.SelectedValue, bid, pcodes);
                    var contrast = this.GenerateContrast(bid, stocks, stocktakeDatas.Where(o => o.BrandID == bid).ToList());
                    contrasts.Add(contrast);
                }
            }
            else if (rbUpdateExact.IsChecked.Value)//精确更新
            {
                if (stocktakeDatas.Count() == 0)
                {
                    return;
                }
                int[] brandIDs = GetBrandIDsForUpdate(stocktakeDatas);
                foreach (int bid in brandIDs)
                {
                    var stocks   = StockLogic.GetStockInStorage((int)cbxStorage.SelectedValue, bid, stocktakeDatas.Where(o => o.BrandID == bid).Select(o => o.ProductID).ToArray());
                    var contrast = this.GenerateContrast(bid, stocks, stocktakeDatas.Where(o => o.BrandID == bid).ToList());
                    contrasts.Add(contrast);
                }
            }
            UpdateStockWithContrast(contrasts);
        }