示例#1
0
        public StoringCannibalize()
        {
            InitializeComponent();

            RadGridView1.ItemsSource = BillStoringCannibalizeVM.SearchBillCannibalizeForStoring();
        }
示例#2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as RadButton;

            btn.IsEnabled = false;

            var grid = btn.GetVisualParent <Grid>();
            BillStoringCannibalizeVM context = grid.DataContext as BillStoringCannibalizeVM;
            //var cbxStorage = (RadComboBox)View.Extension.UIHelper.GetVisualChild<DataFormComboBoxField>(grid).Content;
            //if (context.StorageID == default(int))
            //{
            //    MessageBox.Show("请选择入库仓库");
            //    btn.IsEnabled = true;
            //    return;
            //}
            ////var gvDatas = View.Extension.UIHelper.GetVisualChild<RadGridView>(grid);
            ////var ckScan = View.Extension.UIHelper.GetVisualChild<CheckBox>(grid);
            //var details = new List<BillStoringDetails>();
            ////IEnumerable<BillSnapshotDetailsWithUniqueCode> ssdetails = null;
            //if (context.IsChecked)
            //{
            //    //var tempssdetails = new List<BillSnapshotDetailsWithUniqueCode>();
            //    foreach (var product in context.GridDataItems)
            //    {
            //        if (product.ReceiveQuantity != 0)
            //        {
            //            //tempssdetails.AddRange(product.UniqueCodes.Select(o => new BillSnapshotDetailsWithUniqueCode
            //            //{
            //            //    UniqueCode = o,
            //            //    ProductID = product.ProductID
            //            //}));
            //            details.Add(new BillStoringDetails { ProductID = product.ProductID, Quantity = product.ReceiveQuantity });
            //        }
            //    }
            //    //ssdetails = tempssdetails;
            //}
            //else
            //{
            //    //ssdetails = _dicSnapshotDetails[((CannibalizeSearchEntity)btn.DataContext).ID];
            //    foreach (var product in context.GridDataItems)
            //    {
            //        if (product.Quantity != 0)
            //        {
            //            details.Add(new BillStoringDetails { ProductID = product.ProductID, Quantity = product.Quantity });
            //        }
            //    }
            //}
            //if (details.Count == 0)
            //{
            //    MessageBox.Show("没有需要保存的数据");
            //    btn.IsEnabled = true;
            //    return;
            //}
            var opresult = context.CheckWhenSave();

            if (!opresult.IsSucceed)
            {
                MessageBox.Show(opresult.Message);
                btn.IsEnabled = true;
                return;
            }
            BillStoring bill = new BillStoring();

            bill.OrganizationID   = VMGlobal.CurrentUser.OrganizationID;
            bill.StorageID        = context.StorageID;
            bill.RefrenceBillCode = ((CannibalizeSearchEntity)grid.Tag).Code;
            bill.BillType         = (int)BillTypeEnum.BillCannibalize;
            bill.Remark           = "调拨入库";
            bill.BrandID          = ((CannibalizeSearchEntity)grid.Tag).BrandID;
            context.Master        = bill;

            opresult = context.Save();
            if (opresult.IsSucceed)
            {
                MessageBox.Show("入库成功");
            }
            else
            {
                btn.IsEnabled = true;
                MessageBox.Show("入库失败\n失败原因:" + opresult.Message);
            }
        }