Пример #1
0
        private void ButtonBrandEdit_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton   btnEdit = sender as HyperlinkButton;
            var               tempVM  = btnEdit.DataContext as FloorSectionBrandVM;
            UCBrandForSection ucBrand = new UCBrandForSection(tempVM.DeepCopy());

            ucBrand.Dialog = CurrentWindow.ShowDialog(ResFloorMaintain.Head_BrandSection, ucBrand, (obj, args) =>
            {
                if (args.DialogResult == DialogResultType.OK)
                {
                    var result = args.Data as FloorSectionBrandVM;
                    FloorSectionItem sectionItem = result.ConvertVM <FloorSectionBrandVM, FloorSectionItem>((s, t) =>
                    {
                        t.ItemBrand = EntityConverter <FloorSectionBrandVM, FloorItemBrand> .Convert(result);
                    });
                    ServiceFacade.UpdateFloorSectionItem(sectionItem, (s, objArgs) =>
                    {
                        if (objArgs.FaultsHandle())
                        {
                            return;
                        }
                        for (int i = 0; i < BrandListVM.Count; i++)
                        {
                            if (BrandListVM[i].SysNo == tempVM.SysNo)
                            {
                                BrandListVM[i]          = result.DeepCopy();
                                BrandResult.ItemsSource = BrandListVM;
                                break;
                            }
                        }
                    });
                }
            });
        }
Пример #2
0
        private void BtnAddBrand_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentVM == null)
            {
                CurrentWindow.Alert(ResFloorMaintain.Info_SectionChecked);
                return;
            }
            UCBrandForSection ucBrand = new UCBrandForSection();

            ucBrand.Dialog = CurrentWindow.ShowDialog(ResFloorMaintain.Head_BrandSection, ucBrand, (obj, args) =>
            {
                if (args.DialogResult == DialogResultType.OK)
                {
                    var result = args.Data as FloorSectionBrandVM;
                    FloorSectionItem sectionItem = LoadSectionItem(result, FloorItemType.Brand);
                    sectionItem.ItemBrand        = result.ConvertVM <FloorSectionBrandVM, FloorItemBrand>();
                    ServiceFacade.CreateFloorSectionItem(sectionItem, (s, objArgs) =>
                    {
                        if (objArgs.FaultsHandle())
                        {
                            return;
                        }
                        result.SysNo = objArgs.Result;
                        BrandListVM.Add(result);
                        BrandResult.ItemsSource = BrandListVM;
                    });
                }
            });
        }