protected void OnDelete(PayrollEmployee item, out string message, ref Action <Entity> afterConfirm) { if (afterConfirm == null) { throw new ArgumentNullException(nameof(afterConfirm)); } message = item.EmployeeClass.PersonClass.Name.Fullname; afterConfirm = currentItem => { try { var deletedItem = (PayrollEmployee)currentItem; deletedItem.RowStatus = RecordStatus.DeletedRecord; //Save to Database var dataWriter = new PayrollEmployeeDataWriter(App.CurrentUser.User.Username, deletedItem); dataWriter.SaveChanges(); ItemDataCollection.Remove((PayrollEmployee)currentItem); App.LogAction("Payroll", "Deleted Employee : " + deletedItem.EmployeeClass.EmpNum); } catch (Exception ex) { MessageDialog.ShowError(ex, this); } }; }
protected void Show_DataOnRow(GridRow row, PayrollEmployee item) { var currentItem = item; row.Cells["Empnum"].Value = currentItem.EmployeeClass.EmpNum; row.Cells["Name"].Value = currentItem.EmployeeClass.PersonClass.Name.Fullname; row.Cells["Gender"].Value = currentItem.EmployeeClass.PersonClass.Gender == GenderType.Male ? "Male" : "Female"; row.Cells["Position"].Value = currentItem.PositionClass.Description; row.Cells["SG"].Value = currentItem.SG; row.Cells["Step"].Value = currentItem.Step; row.Cells["Department"].Value = currentItem.Department; row.Cells["TaxCode"].Value = currentItem.TaxClass.ShortDesc; row.Cells["Exemption"].Value = currentItem.TaxClass.Exemption; row.Cells["BasicSalary"].Value = currentItem.BasicSalary; row.Cells["Active"].Value = currentItem.Active; row.CellStyles.Default = currentItem.Active ? null : new CellVisualStyle { Background = new Background(Color.LightGray) }; row.ShowRecordInfo(currentItem); }
public PrintPayrollEmployee(PayrollEmployee payroll) { Payroll = payroll; Fullname = CreateFullname(); ToPdf = new PrintToPdf(Fullname); PdfFile = new Pdf(Fullname); }
public async Task <ActionResult <PayrollEmployee> > Insert([FromBody] PayrollEmployee _payrollEmployee) { PayrollEmployee _payrollEmployeeq = new PayrollEmployee(); try { _payrollEmployeeq = _payrollEmployee; _context.PayrollEmployee.Add(_payrollEmployeeq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(_payrollEmployeeq))); }
public async Task <ActionResult <PayrollEmployee> > Delete([FromBody] PayrollEmployee _payrollEmployee) { PayrollEmployee _payrollEmployeeq = new PayrollEmployee(); try { _payrollEmployeeq = _context.PayrollEmployee .Where(x => x.IdPlanillaempleado == (Int64)_payrollEmployee.IdPlanillaempleado) .FirstOrDefault(); _context.PayrollEmployee.Remove(_payrollEmployeeq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(_payrollEmployeeq))); }
protected bool OnEdit(PayrollEmployee item) { var selectedItem = item; using (var frm = new frmPayrollEmployee_Add()) { if (selectedItem.Id != 0) { selectedItem.RowStatus = RecordStatus.ModifiedRecord; } frm.ItemData = selectedItem; if (frm.ShowDialog() != DialogResult.OK) { return(false); } } App.LogAction("Payroll", "Updated Employee : " + selectedItem.EmployeeClass.EmpNum); return(true); }
public async Task <ActionResult <PayrollEmployee> > Update([FromBody] PayrollEmployee _payrollEmployee) { PayrollEmployee _payrollEmployeeq = _payrollEmployee; try { _payrollEmployeeq = await(from c in _context.PayrollEmployee .Where(q => q.IdPlanillaempleado == _payrollEmployee.IdPlanillaempleado) select c ).FirstOrDefaultAsync(); _context.Entry(_payrollEmployeeq).CurrentValues.SetValues((_payrollEmployee)); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(_payrollEmployeeq))); }
protected PayrollEmployee OnAdd() { // Find Employee Id var employeeId = 0; using (var frm = new frmEmployee_Open()) { if (frm.ShowDialog() != DialogResult.OK) { return(null); } employeeId = frm.EmployeeId; } // Check for Duplicate var duplicate = new PayrollEmployeeDataReader().HasExistingId(employeeId); if (duplicate) { MessageDialog.Show("Duplicate Record", "An existing Record with same employee already exists"); return(null); } // Get Employee Profile var employee = new EmployeeDataReader().GetBasicProfileOf(employeeId); if (employee == null) { throw new Exception("Record NOT found"); } // Create New Payroll Employee var newItem = new PayrollEmployee { EmployeeId = employee.Id, EmployeeClass = employee, Active = true }; // Mandatory Deductions newItem.Deductions.AddMandatoryDeductions(); DeductionGenerator.UpdateMandatoryDeductions(newItem); using (var frm = new frmPayrollEmployee_Add()) { frm.ItemData = newItem; if (frm.ShowDialog() != DialogResult.OK) { return(null); } } App.LogAction("Payroll", "Added Employee : " + newItem.EmployeeClass.EmpNum); return(newItem); }