Exemple #1
0
        private ObservableCollection <DisplayStaffModel> GenerateNewModels(List <StaffModel> staffs)
        {
            ObservableCollection <DisplayStaffModel> newStaffs = new ObservableCollection <DisplayStaffModel>();

            foreach (var staff in staffs)
            {
                DisplayStaffModel newStaff = new DisplayStaffModel();
                newStaff.id        = staff.id;
                newStaff.firstName = staff.firstName;
                newStaff.lastName  = staff.lastName;
                if (branchNameMapper.ContainsKey(staff.branch_id))
                {
                    newStaff.branchName = branchNameMapper[staff.branch_id];
                }
                else
                {
                    newStaff.branchName = "Устсан тасаг";
                }
                newStaffs.Add(newStaff);
                if (!staffMapper.ContainsKey(newStaff))
                {
                    staffMapper[newStaff] = staff;
                }
            }
            return(newStaffs);
        }
Exemple #2
0
        private StaffModel ValidateStaffModel(DisplayStaffModel model)
        {
            StaffModel nModel = new StaffModel();

            nModel.firstName   = model.firstName;
            nModel.lastName    = model.lastName;
            nModel.branch_id   = branchNameMapper.FirstOrDefault(x => x.Value == model.branchName).Key;
            nModel.fingerPrint = fpTemplate;
            return(nModel);
        }
Exemple #3
0
        private void GetFP()
        {
            DisplayStaffModel selectedItem = new DisplayStaffModel();

            this.Dispatcher.Invoke(() =>
            {
                selectedItem = (DisplayStaffModel)staffDataGrid.SelectedItem;
            });
            if (selectedItem == null)
            {
                return;
            }
            if (selectedItem.firstName == null || selectedItem.lastName == null || selectedItem.branchName == null)
            {
                MessageBox.Show("Нэр эсвэл тасаг хоосон байна.");
                return;
            }
            try
            {
                if (selectedItem.id == 0)
                {
                    var w = new ScanWindow();

                    if (w.ShowDialog() == true)
                    {
                        fpTemplate = w.ReturnFP;
                    }
                    if (fpTemplate == null)
                    {
                        MessageBox.Show("Ажилтан нэмэлт амжилтгүй");
                        return;
                    }
                    var newStaff = ValidateStaffModel(selectedItem);
                    var t        = Task.Run(async() => await ApiProcessor.SaveStaff(newStaff));
                    var res      = t.Result;

                    if (res == "success")
                    {
                        Task.Run(async() => await InsertToAttendanceSheet(newStaff));
                        //await InsertToAttendanceSheet(newStaff);
                        Task.Run(async() => await this.LoadStaffDataGrid());
                    }
                }
            }
            catch (Exception e) { MessageBox.Show(e.ToString()); }
        }
Exemple #4
0
        private void deleteSelectedItemButton_Click_1(object sender, RoutedEventArgs e)
        {
            if (staffDataGrid.SelectedItem == null)
            {
                MessageBox.Show("Устгах ажилтнаа сонгоно уу?");
                return;
            }

            try
            {
                DisplayStaffModel selectedDisplayStaff = (DisplayStaffModel)staffDataGrid.SelectedItem;
                StaffModel        selectedStaff        = staffMapper[selectedDisplayStaff];

                DeleteUserControl deleteControl = new DeleteUserControl();
                deleteControl.selectedStaff        = selectedStaff;
                externalContents.Content           = deleteControl;
                deleteControl.UpdateDataGridEvent += DeleteControl_UpdateDataGridEvent;
            }
            catch { }
        }
Exemple #5
0
        private void EditSelectedItemButton_Click(object sender, RoutedEventArgs e)
        {
            if (staffDataGrid.SelectedItem == null)
            {
                MessageBox.Show("Янзлах ажилтнаа сонгоно уу?");
                return;
            }

            try
            {
                DisplayStaffModel selectedDisplayStaff = (DisplayStaffModel)staffDataGrid.SelectedItem;
                StaffModel        selectedStaff        = staffMapper[selectedDisplayStaff];

                EditUserControl editControl = new EditUserControl();
                editControl.selectedStaff        = selectedStaff;
                externalContents.Content         = editControl;
                editControl.UpdateDataGridEvent += EditControl_UpdateDataGridEvent;
            }
            catch
            {
            }
        }