示例#1
0
        public GenericFormGl(string tablEname, PermissionItemName userJobsFormGl)
        {
            InitializeComponent();
            _viewModel = new GenericViewModelCollectionGl(tablEname, userJobsFormGl);

            DataContext = _viewModel;
        }
示例#2
0
        public GenericForm(string tablEname, string userJobsForm, PermissionItemName factoryGroupForm)
        {
            InitializeComponent();
            _viewModel = new GenericViewModelCollection(tablEname, factoryGroupForm);

            DataContext = _viewModel;
        }
示例#3
0
 public ViewModelStructuredBase(PermissionItemName screen)
 {
     if (!DesignerProperties.IsInDesignTool)
     {
         GetItemPermissions(screen.ToString());
         InitializeCommands();
     }
 }
示例#4
0
        public GenericViewModelCollection(string tablEname, PermissionItemName userJobsForm)
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }
            TablEname = tablEname;
            Client    = new _Proxy.CRUD_ManagerServiceClient();
            GetItemPermissions(userJobsForm.ToString());

            Client.GetGenericCompleted += (s, ev) =>
            {
                Loading = false;
                GenericMapper.InjectFromObCollection(MainRowList, ev.Result);
                //FullCount = ev.fullCount;
                if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0))
                {
                    SelectedMainRow = MainRowList.FirstOrDefault();
                }
                if (FullCount == 0 && MainRowList.Count == 0)
                {
                    AddNewMainRow(false);
                }

                if (Export)
                {
                    Export = false;
                    ExportGrid.ExportExcel(userJobsForm.ToString());
                }
            };

            MainRowList = new SortableCollectionView <GenericViewModel>();

            Client.GenericUpdateOrInsertCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    MessageBox.Show(ev.Error.Message);
                }
                Loading = false;
                MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
            };

            Client.DeleteGenericCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    MessageBox.Show(ev.Error.Message);
                }
                Loading = false;
                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
                if (!MainRowList.Any())
                {
                    AddNewMainRow(false);
                }
            };
            GetMaindata();
        }