Esempio n. 1
0
        private async Task UpdateSelectedUserAsync()
        {
            ucUsers1.txtFullName.Text    = Users.GetInstance().fullName;
            ucUsers1.txtGrossSalary.Text = Users.GetInstance().grossSalary.ToString();
            ucUsers1.txtNetSalary.Text   = Users.GetInstance().netSalary.ToString();
            ucUsers1.txtDob.Text         = Users.GetInstance().dob.ToString();
            ucUsers1.txtHomeAddress.Text = Users.GetInstance().homeAddress;
            ucUsers1.txtNote.Text        = Users.GetInstance().note;
            ucUsers1.txtPIN.Text         = Users.GetInstance().pin;

            Departments tempDepartment = new Departments();

            tempDepartment = await _departmentRepository.GetByIdAsync(Users.GetInstance().departmentId);

            ucUsers1.cbbDepartment.Items.Add(tempDepartment.id + "." + tempDepartment.departmentName);

            Roles tempRole = new Roles();

            tempRole = await _rolesRepository.GetByIdAsync(Users.GetInstance().roleId);

            ucUsers1.cbbRole.Items.Add(tempRole.id + "." + tempRole.roleName);

            Shifts tempShift = new Shifts();

            tempShift = await _shiftsRepository.GetByIdAsync(Users.GetInstance().shiftId);

            ucUsers1.cbbShift.Items.Add(tempShift.id + "." + tempShift.shiftName);
        }
Esempio n. 2
0
        private async void btnConfirm_Click(object sender, EventArgs e)
        {
            if (isPinMode == true && txtPin.Text != null && txtPin.Text != "")
            {
                Users userResult = await _userRepository.GetByPinAsync(txtPin.Text);

                if (userResult != null)
                {
                    Attendances attendance = await GetAttendanceForRequestAsync(userResult);

                    Shifts shifts = await _shiftsRepository.GetByIdAsync(userResult.shiftId);

                    if (attendance != null)
                    {
                        // Time <= 0 when check-in meanwhile > 0 when checkout
                        if (attendance.workingHours <= 0)
                        {
                            MessageBox.Show($"Check in success! Welcome {userResult.fullName}!");
                        }
                        else
                        {
                            MessageBox.Show($"Check out success! Good bye {userResult.fullName}!");

                            JObject      json         = JObject.Parse(File.ReadAllText(Config.ConfigFile));
                            ConfigSalary configSalary = JsonConvert.DeserializeObject <ConfigSalary>(json.ToString());

                            _payslipsRepository.Add(CalcualteTodayPayslips(attendance, shifts, userResult.roles.fixedSalary, new DateTime(DateTime.Now.Ticks), configSalary, userResult.id));
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please choose PIN Mode!!!");
            }
            isPinMode = false;
        }