Exemple #1
0
        private void btnApplyIncrease_Click(object sender, EventArgs e)
        {
            try
            {
                //Gets the employee IDs selected in the grid
                var empIdList = new List <int>();
                foreach (DataGridViewRow row in dgvEmployees.Rows)
                {
                    if (row.Cells["Chk"].Value != null && (bool)row.Cells["Chk"].Value == true)
                    {
                        empIdList.Add(employeeList[row.Index].EmployeeId);
                    }
                }

                if (empIdList.Count == 0)
                {
                    throw new DataException("No employees selected.");
                }

                //Validates the entry
                checkSalaryChange();

                //Gets the percent increase amount
                var increasePercent = nudPercent.Value / 100;

                //Get the effective date
                var effectiveDate = cmbEffectiveDate.SelectedItem;

                //Create Salary Adjustment
                var salaryAdj = SalaryAdjustment.Create();
                salaryAdj.PercentIncrease = increasePercent;
                salaryAdj.EffectiveDate   = Convert.ToDateTime(effectiveDate);

                //Apply increase
                if (SalaryAdjustmentCUD.Create(empIdList, salaryAdj))
                {
                    MessageBox.Show("Salary adjustment successful.");
                    salaryIncreasePending.Add(salaryAdj);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
 private void dgvSalaryIncrease_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.ColumnIndex == dgvSalaryIncrease.Columns["colRemovePending"].Index)
         {
             DialogResult = MessageBox.Show("Are you sure you want to remove this salary increase?", "Confirm", MessageBoxButtons.OKCancel);
             if (DialogResult == DialogResult.OK)
             {
                 //Delete the salary increase
                 if (SalaryAdjustmentCUD.DeleteSingleEmployeeSalaryAdjustment(
                         Convert.ToInt32(txtEmpIdDisplay.Text), salaryIncreasePending[e.RowIndex].SalaryAdjustmentId))
                 {
                     salaryIncreasePending.RemoveAt(e.RowIndex);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }