Exemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Anda yakin ingin menutup Periode : " + Store.GetMonthName(Store.ActiveMonth) + " " + Store.ActiveYear + "'", "Perhatian",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Application.UseWaitCursor = true;

                if (rbPayroll.Checked == true)
                {
                    workCalendarRepository.UpdateIsPeriod(Store.ActiveMonth, Store.ActiveYear, true);
                    incentiveRepository.UpdateIsPaid(Store.ActiveMonth, Store.ActiveYear, true);
                    payrollRepository.UpdateIsPaid(Store.ActiveMonth, Store.ActiveYear, true);
                    overTimeRepository.UpdateIsPaid(Store.ActiveMonth, Store.ActiveYear, true);
                    employeeDebtItemRepository.UpdateIsPaid(Store.ActiveMonth, Store.ActiveYear, true);

                    Application.UseWaitCursor = false;
                    MessageBox.Show("Proses Tutup Buku \n\n Periode : " + Store.GetMonthName(Store.ActiveMonth) + " " + Store.ActiveYear + "' \n\n Sukses", "Sukses",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    workCalendarRepository.UpdateIsThr(Store.ActiveYear, true);
                    thrRepository.UpdateIsPaid(Store.ActiveYear, true);

                    Application.UseWaitCursor = false;
                    MessageBox.Show("Proses Tutup Buku THR \n\n Periode : " + Store.ActiveYear + "' \n\n Sukses", "Sukses",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }



                this.Close();
            }
        }
Exemplo n.º 2
0
        private void SaveWorkCalendar()
        {
            int workDay     = Convert.ToInt32(txtWorkDay.Text == ""?"0":txtWorkDay.Text);
            int offDay      = Convert.ToInt32(txtDayOff.Text == ""?"0":txtDayOff.Text);
            int month       = Convert.ToInt32(nudMonth.Value);
            int year        = Convert.ToInt32(nudYear.Value);
            int daysInMonth = DateTime.DaysInMonth(year, month);

            if (txtWorkDay.Text == "" || txtWorkDay.Text == "0")
            {
                MessageBox.Show("Hari kerja tidak boleh kosong", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtWorkDay.Focus();
            }
            else if (workDay + offDay != daysInMonth)
            {
                MessageBox.Show("Jumlah hari di bulan " + Store.GetMonthName(month) + " " + year + " adalah : " + daysInMonth, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtWorkDay.Focus();
            }
            else
            {
                var workCalendar = new WorkCalendar();

                workCalendar.MonthPeriod = Convert.ToInt32(nudMonth.Value);
                workCalendar.YearPeriod  = Convert.ToInt32(nudYear.Value);
                workCalendar.WorkDay     = int.Parse(txtWorkDay.Text);
                workCalendar.OffDay      = txtDayOff.Text == ""?0: int.Parse(txtDayOff.Text);
                workCalendar.IsClosed    = chkIsClosed.Checked;
                workCalendar.IsThrClosed = chkIsThrClosed.Checked;

                if (formMode == FormMode.Add)
                {
                    workCalendarRepository.Save(workCalendar);
                    GetLastWorkCalendar();
                }
                else if (formMode == FormMode.Edit)
                {
                    workCalendar.ID = new Guid(txtID.Text);
                    workCalendarRepository.Update(workCalendar);
                }

                incentiveRepository.UpdateIsPaid(workCalendar.MonthPeriod, workCalendar.YearPeriod, workCalendar.IsClosed);
                payrollRepository.UpdateIsPaid(workCalendar.MonthPeriod, workCalendar.YearPeriod, workCalendar.IsClosed);
                employeeDebtItemRepository.UpdateIsPaid(workCalendar.MonthPeriod, workCalendar.YearPeriod, workCalendar.IsClosed);

                if (workCalendar.IsClosed == true && workCalendar.MonthPeriod == Store.ActiveMonth && workCalendar.YearPeriod == Store.ActiveYear)
                {
                    Store.IsPeriodClosed = true;
                }
                else
                {
                    Store.IsPeriodClosed = false;
                }

                if (workCalendar.IsThrClosed == true && workCalendar.YearPeriod == Store.ActiveYear)
                {
                    Store.IsThrClosed = true;
                }
                else
                {
                    Store.IsThrClosed = false;
                }

                LoadWorkCalendar();
                DisableForm();

                formMode  = FormMode.View;
                this.Text = "Kalender Kerja";
                FillID();
            }
        }