Exemplo n.º 1
0
        private void CheckOut_Click(object sender, RoutedEventArgs e)
        {
            int? total    = 0;
            bool status   = overtimeService.Update(Settings.Default.Id, total, overtimeParam);
            var  gettotal = _approvalService.GetTotal(Settings.Default.Id);

            foreach (var hitung in gettotal)
            {
                total = total + hitung.Overtime.difference;
            }

            MessageBoxResult result = MessageBox.Show("Yakin ingin Check Out?", "Peringatan", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                if (status == false)
                {
                    LoginPage login = new LoginPage();
                    login.Show();
                    this.Close();
                }
                else
                {
                    overtimeParam.check_out = DateTimeOffset.Now.LocalDateTime;
                    overtimeService.Update(Settings.Default.Id, total, overtimeParam);
                    int selisih = 0;
                    selisih = DateTime.Now.Hour - 17;
                    var approval = _approvalService.Get(Settings.Default.Id);
                    if (approval == null)
                    {
                        if (selisih > 3 && selisih <= 5)
                        {
                            approvalParam.employee_id     = Settings.Default.Id;
                            approvalParam.approval_status = "WAITING";
                            approvalParam.reason          = ReasonTextBox.Text;
                            approvalParam.overtime_id     = overtimeService.GetId(Settings.Default.Id).Id;
                            _approvalService.insert(approvalParam);
                        }
                        int Id = Settings.Default.Id;
                        OvertimeEmployeeGrid.ItemsSource = _approvalService.GetOvertimeAll(Id);
                    }
                    else
                    {
                        MessageBox.Show("Already Check Out For This Day");
                    }
                }
            }
        }