コード例 #1
0
        private void cb_Month_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int i = Convert.ToInt32(cb_Month.Text);
            }
            catch
            {
                return;
            }

            try
            {
                SalaryController.CaculateSalaryByMY(Convert.ToInt32(cb_Month.Text), Convert.ToInt32(cb_Year.Text));

                List <SalaryEmployee> salaries = SalaryController.GetListSalary(Convert.ToInt32(cb_Month.Text), Convert.ToInt32(cb_Year.Text));
                if (salaries == null)
                {
                    MessageBox.Show("Không có dữ liệu");
                    return;
                }
                dtgv_Payroll.DataSource = salaries;
            }
            catch { }
        }
コード例 #2
0
 private void Resest_Click(object sender, EventArgs e)
 {
     dataSalary.AutoGenerateColumns = false;
     source                = new BindingSource();
     source.DataSource     = SalaryController.getListSalary();
     dataSalary.DataSource = source;
 }
コード例 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dataSalary.SelectedRows.Count <= 0)
            {
                return;
            }
            string            message = "Bạn chắc chắn muốn xóa ?";
            string            title   = "Delete salary";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      result  = MessageBox.Show(message, title, buttons);

            if (result == DialogResult.Yes)
            {
                Salary salary = SalaryController.getSalary(Convert.ToInt32(this.dataSalary.SelectedRows[0].Cells[0].Value), Convert.ToDateTime(this.dataSalary.SelectedRows[0].Cells[8].Value));
                SalaryController.DeleteSalary(salary);
                dataSalary.AutoGenerateColumns = false;
                source                = new BindingSource();
                source.DataSource     = SalaryController.getListSalary();
                dataSalary.DataSource = source;
            }
            else
            {
                return;
            }
        }
コード例 #4
0
 public frmListSalary()
 {
     InitializeComponent();
     dataSalary.AutoGenerateColumns = false;
     source                = new BindingSource();
     source.DataSource     = SalaryController.getListSalary();
     dataSalary.DataSource = source;
 }
コード例 #5
0
        public void S2_Schedule_sel()
        {
            SalaryController controller = new SalaryController();

            List <Schedule> result  = controller.Get();
            Schedule        result2 = result.Find(x => x.ID == 999);

            Assert.IsNotNull(result2);
        }
コード例 #6
0
        private void cLocDuLieu_Click(object sender, EventArgs e)
        {
            DateTime month = Convert.ToDateTime(dtpLocDulieu.Value.ToString());

            dataSalary.AutoGenerateColumns = false;
            source                = new BindingSource();
            source.DataSource     = SalaryController.getSalary(month);
            dataSalary.DataSource = source;
        }
コード例 #7
0
        public void S1_Schedule_ins()
        {
            SalaryController controller = new SalaryController();
            Schedule         schedule   = new Schedule();

            schedule.ID    = 999;
            schedule.Hours = 1;
            schedule.Type  = "2";

            controller.Post(schedule);
        }
コード例 #8
0
        private void buttonTest_Click(object sender, EventArgs e)
        {
            SalaryController    salaryController = new SalaryController();
            IQueryable <object> test             = salaryController.GetAllSalary();

            //AuthController authController = new AuthController();
            AltelierController altelierController = new AltelierController();

            DepartmentController departmentController = new DepartmentController();

            IQueryable <object> test1 = departmentController.GetAllDepartment(null, "");

            dataGridView1.DataSource = test1.ToList();
        }
コード例 #9
0
        public void S4_Schedule_del()
        {
            SalaryController controller = new SalaryController();
            Schedule         schedule   = new Schedule();

            schedule.ID = 999;

            List <Schedule> result = ScheduleServices.sel(schedule);

            foreach (Schedule vr in result)
            {
                controller.Delete(vr.Inum);
            }

            result   = controller.Get();
            schedule = result.Find(x => x.ID == 999);
            Assert.IsNull(schedule);
        }
コード例 #10
0
        public void S3_Schedule_upd()
        {
            SalaryController controller = new SalaryController();
            Schedule         schedule   = new Schedule();

            schedule.ID = 999;

            List <Schedule> result = ScheduleServices.sel(schedule);

            foreach (Schedule vr in result)
            {
                vr.Hours = 777;
                controller.Put(vr);
            }

            result   = controller.Get();
            schedule = result.Find(x => x.ID == 999);

            Assert.AreEqual(777, schedule.Hours);
        }
コード例 #11
0
        private void dataSalary_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            Salary          salary   = new Salary();
            List <Employee> employee = SalaryController.GetIDEmployee(Convert.ToInt32(this.dataSalary.CurrentRow.Cells[0].Value));

            if (employee == null)
            {
                MessageBox.Show("Không tồn tại ID này ! Yêu cầu nhập lại ", "Lỗi");
                this.dataSalary.CurrentRow.Cells[0].Value = 0;
                return;
            }
            else
            {
                salary.IDEmployee = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[0].Value);
            }
            DateTime t = Convert.ToDateTime(this.dataSalary.CurrentRow.Cells[8].Value);

            if (t.Year == 1)
            {
                MessageBox.Show("Bạn chưa nhập Tháng Năm", "Thông báo");
                return;
            }
            else
            {
                salary.Month = Convert.ToDateTime(this.dataSalary.CurrentRow.Cells[8].Value.ToString());
            }
            Salary salarys = SalaryController.getSalary(Convert.ToInt32(this.dataSalary.CurrentRow.Cells[0].Value), Convert.ToDateTime(this.dataSalary.CurrentRow.Cells[8].Value));

            if (e.ColumnIndex == 8 || e.ColumnIndex == 0)
            {
                if (salarys != null)
                {
                    MessageBox.Show("Trùng dữ liệu", "Lỗi");
                    source.DataSource = SalaryController.getListSalary();
                    return;
                }
            }
            salary.UserName = employee[0].UserName.ToString();
            if (this.dataSalary.CurrentRow.Cells[2].Value is null)
            {
                salary.LuongCoBan = 0;
            }
            else
            {
                salary.LuongCoBan = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[2].Value);
            }
            if (this.dataSalary.CurrentRow.Cells[3].Value is null)
            {
                salary.Phat = 0;
            }
            else
            {
                salary.Phat = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[3].Value);
            }
            if (this.dataSalary.CurrentRow.Cells[4].Value is null)
            {
                salary.Thuong = 0;
            }
            else
            {
                salary.Thuong = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[4].Value);
            }
            if (this.dataSalary.CurrentRow.Cells[6].Value is null)
            {
                salary.LuongDaNhan = 0;
            }
            else
            {
                salary.LuongDaNhan = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[6].Value);
            }
            this.dataSalary.AutoGenerateColumns = false;
            SalaryController.UpdateSalary(salary);
            source.DataSource = SalaryController.getListSalary();
        }
コード例 #12
0
        private void initializeForm(Payslip payslip)
        {
            RequestControllerInterface       requestController       = new RequestController();
            MiscellaneousControllerInterface miscellaneousController = new MiscellaneousController();
            SalaryControllerInterface        salaryController        = new SalaryController();
            AttendanceControllerInterface    attendanceController    = new AttendanceController();

            employeeFullName.Text = payslip.employee.fullName;
            dateEmployed.Text     = payslip.employee.dateEmployed;
            employeeNumber.Text   = payslip.employee.employeeId.ToString();
            position.Text         = payslip.employee.jobPosition.name;
            startDatePeriod.Text  = payslip.startDatePeriod.ToString();
            endDatePeriod.Text    = payslip.endDatePeriod.ToString();
            datePayable.Text      = payslip.dateCreated.ToString();
            positionName.Text     = payslip.employee.jobPosition.name;
            dailyRate.Text        = payslip.employee.jobPosition.salary.ToString("0.##");
            hourlyRate.Text       = calculateHourlyRate(payslip.employee.jobPosition.salary).ToString("0.##");
            TimeSpan timeSpent = fetchTotalHoursSpent(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, attendanceController);

            hoursSpent.Text = Math.Round(timeSpent.TotalHours, 2).ToString();
            decimal totalBasePayAmount = calculateTotalBasePay(timeSpent, payslip.employee.jobPosition.salary);

            totalBasePay.Text = totalBasePayAmount.ToString("0.##");
            decimal foodAllowanceAmount      = fetchFoodAllowance(payslip, miscellaneousController);
            decimal totalFoodAllowanceAmount = calculateTotalSpecificAllowance(foodAllowanceAmount, timeSpent);

            foodAllowance.Text = totalFoodAllowanceAmount.ToString("0.##");
            decimal transpoAllowanceAmount      = fetchTranspoAllowance(payslip, miscellaneousController);
            decimal totalTranspoAllowanceAmount = calculateTotalSpecificAllowance(transpoAllowanceAmount, timeSpent);            transportation.Text = totalTranspoAllowanceAmount.ToString("0.##");
            decimal thirteenMonth = 0.00M;

            overtimeHours.Text = Math.Round(fetchTotalHoursOvertimeSpent(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController).TotalHours, 2).ToString();
            decimal totalOvertimeAmount = calculateDailyBasedSalaryWithOvertimeRequests(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController);

            overtimeAmount.Text = totalOvertimeAmount.ToString("0.##");

            List <Request> leaveRequests     = requestController.fetchLeaveRequest(payslip.employee, payslip.startDatePeriod, payslip.endDatePeriod);
            decimal        totalLeaveRequest = salaryController.calculateDailBasedSalaryWithLeaveRequest(leaveRequests, payslip.employee.jobPosition.salary);

            if (hasLeaveRequests(totalLeaveRequest))
            {
                showLeaveFields();
                daysOfLeave.Text   = leaveRequests.Count.ToString();
                totalLeavePay.Text = totalLeaveRequest.ToString("0.##");
            }
            decimal cashAdvanceDeci = calculateTotalCashAdvanceAmount(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController);

            cashAdvanceAmount.Text = cashAdvanceDeci.ToString("0.##");
            tax.Text                   = payslip.taxDeduction.ToString("0.##");
            sss.Text                   = payslip.sssDeduction.ToString("0.##");
            pagIbig.Text               = payslip.pagIbigDeduction.ToString("0.##");
            philHealth.Text            = payslip.philHealthDeduction.ToString("0.##");
            thirteenthMonthPay.Visible = false;
            if (payslip.thirteenMonthPay > 0.00M)
            {
                thirteenthMonthPay.Visible = true;
                thirteenthMonthPay.Text    = payslip.thirteenMonthPay.ToString("0.##") + " day/s";
            }

            earnings.Text          = totalBasePayAmount.ToString("0.##");
            benefits.Text          = (totalFoodAllowanceAmount + totalTranspoAllowanceAmount).ToString("0.##");
            extrasTotalAmount.Text = (totalOvertimeAmount + thirteenMonth + totalLeaveRequest).ToString("0.##");
            deductions.Text        = ((decimal.Round(payslip.taxDeduction, 2) + decimal.Round(payslip.sssDeduction, 2) + decimal.Round(payslip.pagIbigDeduction, 2) + decimal.Round(payslip.philHealthDeduction, 2) + decimal.Round(cashAdvanceDeci, 2)) * -1).ToString("0.##");
            decimal totalSalary = Convert.ToDecimal(earnings.Text) + Convert.ToDecimal(benefits.Text) + Convert.ToDecimal(deductions.Text);

            netPay.Text = totalSalary.ToString("0.##");
        }