public StoringWhenReceiving() { InitializeComponent(); //Loaded事件会在页签切换时触发,因此会导致侦听方法的反复调用 //this.Loaded += delegate //{ // RadGridView1.ItemsSource = ReportDataContext.SearchBillDeliveryForStoring(); //}; RadGridView1.ItemsSource = BillStoringWhenReceivingVM.SearchBillDeliveryForStoring(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { var btn = sender as RadButton; btn.IsEnabled = false; var grid = btn.GetVisualParent <Grid>(); BillStoringWhenReceivingVM context = grid.DataContext as BillStoringWhenReceivingVM; 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 = ((DeliverySearchEntity)grid.Tag).Code; bill.BillType = (int)BillTypeEnum.BillDelivery; bill.Remark = "收货入库"; bill.BrandID = ((DeliverySearchEntity)grid.Tag).BrandID; context.Master = bill; var result = context.Save(); if (result.IsSucceed) { MessageBox.Show("保存成功"); } else { btn.IsEnabled = true; MessageBox.Show("保存失败\n失败原因:" + result.Message); } }