コード例 #1
0
        private void TCSelectionchanged(object sender, SelectionChangedEventArgs e)
        {
            TabControl tc = sender as TabControl;

            if (tc != null)
            {
                if (tc.SelectedItem == Tabcreate)
                {
                    if (currenttab == "Update")
                    {
                        UCC = new UCCreate(EmployeePositions);
                    }
                    UCCreateContent.Content = UCC;
                    DataGridEmployees.UnselectAll();
                    TabController.SelectedIndex = 0;
                    TabUpdate.Header            = "View Employee";
                    currenttab = "Create";
                }
                if (tc.SelectedItem == TabUpdate)
                {
                    if (DataGridEmployees.SelectedItem != null)
                    {
                        UCUpdateContent.Content     = UCU = new UCUpdate(SelectedEmployee, TabUpdate, EmployeePositions);
                        TabUpdate.Header            = "View Employee";
                        TabController.SelectedIndex = 1;
                        currenttab = "Update";
                    }
                }
            }
        }
コード例 #2
0
        //private void btnEdit_Click(object sender, RoutedEventArgs e)
        //{
        //    EditMode = true;
        //    TabUpdate.Header = "Update Employee";
        //    UCUpdateContent.Content = UCU = new UCUpdate(SelectedEmployee, TabUpdate);
        //}

        private void BtnForceRefresh_Click(object sender, RoutedEventArgs e)
        {
            DataGridEmployees.UnselectAll();
            TabController.SelectedIndex = 0;
            TabUpdate.Header            = "View Employee";
            ForceRefresh();
        }
コード例 #3
0
        private void RefreshDtgMain()
        {
            var index = DataGridEmployees.SelectedIndex;

            if (SmpUcLookup.LookupText.Trim() == string.Empty)
            {
                EmployeesAll = new ObservableCollection <Employee>(_context.Employees.ToList());
            }
            else
            {
                var lookups = SmpUcLookup.LookupText.Split(' ');
                var lists   = lookups.Select(strLookup => (from x in _context.Employees
                                                           where x.FName.Contains(strLookup) || x.LName.Contains(strLookup) || x.PersonnelCode.Contains(strLookup) || x.DossierNo.Contains(strLookup) || x.NationalCardNo.Contains(strLookup) || x.IdCardNo.Contains(strLookup)
                                                           select x).ToList()).ToList();

                var lookedUpList = _context.Employees.ToList();
                lists.ForEach(x => lookedUpList.RemoveAll(employee => lookedUpList.Except(x).Contains(employee)));
                EmployeesAll = new ObservableCollection <Employee>(lookedUpList);
            }

            DataGridEmployees.GetBindingExpression(DataContextProperty)?.UpdateTarget();

            if (DataGridEmployees.Items.Count > index)
            {
                DataGridEmployees.SelectedIndex = index;
            }
        }
コード例 #4
0
        public void GetEmployee()
        {
            DataGridEmployees = EmployeeModel.GetEmployee();

            if (ids != null)
            {
                ids.Clear();
            }
            ids = DataGridEmployees.Select(x => x.Id).ToList();
        }
コード例 #5
0
        private void Add_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            SmpUcFormStateLabel.CurrentState = FormCurrentState.Add;
            var newItem = new Employee
            {
                FName = ResourceAccessor.Labels.GetString("New")
            };

            EmployeesAll.Add(newItem);
            DataGridEmployees.SelectedItem = newItem;
            DataGridEmployees.ScrollIntoView(newItem);
        }
コード例 #6
0
        private void Reload()
        {
            var selectedId = (DataGridEmployees.SelectedItem as Employee)?.Id;

            Context = new PaySysContext();
            Context.MainGroups.Include(mg => mg.SubGroups).Load();
            Context.SubGroups.Load();
            Context.Jobs.Load();
            Context.Employees.Include(employee => employee.ContractMasters).Load();

            SmpUcContractMasterEdit.MainGroups = Context.MainGroups.Local;
            SmpUcContractMasterEdit.SubGroups  = Context.SubGroups.Local;
            SmpUcContractMasterEdit.Jobs       = Context.Jobs.Local;

            EmployeesAll = Context.Employees.Local;
            DataGridEmployees.GetBindingExpression(ItemsControl.ItemsSourceProperty)?.UpdateTarget();
            DataGridEmployees.GetBindingExpression(DataContextProperty)?.UpdateTarget();
            if (selectedId.HasValue)
            {
                DataGridEmployees.SelectedItem = EmployeesAll.FirstOrDefault(emp => emp.Id == selectedId.Value);
            }
            SmpUcLookup_OnLookupTextChanged(null, null);
        }