Exemplo n.º 1
0
 public UCProductForSection(FloorSectionProductVM vm)
 {
     InitializeComponent();
     model = vm;
     LayoutRoot.DataContext = model;
     Loaded += new RoutedEventHandler(UCProductForSection_Loaded);
 }
Exemplo n.º 2
0
        private void BtnBatchAddProduct_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentVM == null)
            {
                CurrentWindow.Alert(ResFloorMaintain.Info_SectionChecked);
                return;
            }
            UCProductSearch ucProduct = new UCProductSearch();

            ucProduct.SelectionMode = SelectionMode.Multiple;
            ucProduct.DialogHandler = CurrentWindow.ShowDialog(ResFloorMaintain.Head_ProductAdd, ucProduct, (obj, args) =>
            {
                if (args.DialogResult == DialogResultType.OK)
                {
                    List <ProductVM> products = args.Data as List <ProductVM>;
                    if (products != null && products.Count > 0)
                    {
                        List <FloorSectionItem> sectionItems    = new List <FloorSectionItem>();
                        List <FloorSectionProductVM> proVMItems = new List <FloorSectionProductVM>();

                        products.ForEach(p =>
                        {
                            FloorSectionProductVM vm = EntityConverter <ProductVM, FloorSectionProductVM> .Convert(p, (s, t) =>
                            {
                                t.Priority     = 0;
                                t.ItemPosition = 0;
                                t.IsSelfPage   = 0;
                                t.ProductTitle = s.ProductName;
                                t.ProductPrice = s.CurrentPrice;
                                t.ProductID    = s.ProductID;
                                t.ProductSysNo = s.SysNo.Value;
                            });
                            FloorSectionItem sectionItem = LoadSectionItem(vm, FloorItemType.Product);
                            sectionItem.ItemProudct      = vm.ConvertVM <FloorSectionProductVM, FloorItemProduct>();
                            sectionItems.Add(sectionItem);
                            proVMItems.Add(vm);
                        });

                        ServiceFacade.BtnBatchCreateFloorSectionItem(sectionItems, (s, objArgs) =>
                        {
                            if (objArgs.FaultsHandle())
                            {
                                return;
                            }
                            for (int i = 0; i < objArgs.Result.Count; i++)
                            {
                                proVMItems[i].SysNo = objArgs.Result[i];
                                ProductListVM.Add(proVMItems[i]);
                                productResult.ItemsSource = ProductListVM;
                            }
                        });
                    }
                }
            });
        }