private void btnOpenEmployee_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { var empId = 0; using (var frm = new frmEmployee_Open()) { if (frm.ShowDialog() != DialogResult.OK) { return; } empId = frm.EmployeeId; } var employee = new EmployeeDataReader().GetItemOf(empId); using (var frm = new frmEmployee_Add()) { frm.ItemData = employee; frm.ShowDialog(); } } catch (Exception ex) { MessageDialog.ShowError(ex, this); } }
public void GetIdOfTest() { var reader = new EmployeeDataReader(); var result = reader.GetIdOf(2); Assert.AreEqual(0, result); }
public void LoadAllItemsFromDb() { var query = @"SELECT p.Id PersonId, [Lastname], [Firstname], [Middlename], [MiddleInitial], [NameExtension], [MaidenMiddlename], [Gender], [CameraCounter] , e.Id EmployeeId, [EmpNum], [CivilStatus], [GSIS], [Pagibig], [PhilHealth], [SSS], [Tin] , pe.Id Id, DateHired, Department, TaxId, PositionId, Step, pe.Created, pe.Modified, pe.CreatedBy, pe.ModifiedBy , pos.Id PositionId, pos.Code PositionCode, pos.Description PositionDescription , tax.Id TaxId, tax.ShortDesc, tax.Exemption , tax.Description TaxDescription from Person p inner join Employee e on p.Id = e.PersonId inner join Payroll_Employee pe on pe.EmployeeId = e.Id inner join Payroll_Position pos on pos.Id = pe.PositionId inner join Payroll_TaxTable tax on tax.Id = pe.TaxId"; using (var db = Connection.CreateConnection()) { db.Open(); var results = db.Query(query); var employeeReader = new EmployeeDataReader(); foreach (var reader in results) { var item = new PayrollEmployee(); //Payroll Employee item.DataMapper.Map(reader); //Employee item.EmployeeClass.DataMapper.Map(reader); item.EmployeeClass.DataMapper.Map(_ => _.Id, (int)(reader.EmployeeId)); //Person item.EmployeeClass.PersonClass.DataMapper.Map(reader); item.EmployeeClass.PersonClass.DataMapper.Map(_ => _.Id, (int)reader.PersonId); //Position item.PositionId = reader.PositionId; item.PositionClass.Id = reader.PositionId; item.PositionClass.Code = reader.PositionCode; item.PositionClass.Description = reader.PositionDescription; //Tax item.TaxClass.Id = reader.TaxId; item.TaxClass.Exemption = reader.Exemption; item.TaxClass.ShortDesc = reader.ShortDesc; item.TaxClass.Description = reader.TaxDescription; item.RowStatus = RecordStatus.NoChanges; item.StartTrackingChanges(); } } }
private void btnSearch_Click(object sender, EventArgs e) { FlexGrid.Rows.Count = 1; if (!DataSearchIsValid()) { return; } var searchStyle = new SearchStyleEnum(); switch (cboSearchType.Text) { case "Contains": searchStyle = SearchStyleEnum.Contains; break; case "Starts With": searchStyle = SearchStyleEnum.StartsWith; break; case "Ends With": searchStyle = SearchStyleEnum.EndsWith; break; } var reader = new EmployeeDataReader(); var items = reader.SearchItem(txtSearch.Text, searchStyle); var enumerable = items as IList <Dll.Employee.Employee> ?? items.ToList(); if (!enumerable.Any()) { MessageDialog.ShowValidationError(txtSearch, "No items match your search"); return; } FlexGrid.Rows.Count = enumerable.Count() + 1; var row = 0; foreach (var item in enumerable.OrderBy(_ => _.PersonClass.Name.Fullname)) { row++; FlexGrid[row, "empnum"] = item.EmpNum; FlexGrid[row, "name"] = item.PersonClass.Name.Fullname; FlexGrid[row, "gender"] = item.PersonClass.Gender == GenderType.Male ? "Male" : "Female"; FlexGrid.Select(1, 0); } FlexGrid.Focus(); }
private bool DataIsValid() { if (string.IsNullOrEmpty(txtEmpNum.Text.Trim())) { MessageDialog.ShowValidationError(txtEmpNum, "Employee Number must NOT be blank"); return(false); } if (int.Parse(txtEmpNum.Text) <= 0) { txtEmpNum.Focus(); MessageDialog.ShowValidationError(txtEmpNum, "Invalid Employee Number"); return(false); } var reader = new EmployeeDataReader(); if (reader.HasExistingEmployeeNumber(Convert.ToInt32(txtEmpNum.Text)) && ItemData.EmpNum != Convert.ToInt32(txtEmpNum.Text)) { MessageDialog.ShowValidationError(txtEmpNum, "Employee Number already exists!"); return(false); } if (string.IsNullOrEmpty(txtCitizenship.Text.Trim())) { MessageDialog.ShowValidationError(txtCitizenship, "Citizenship Data is Required"); return(false); } if (txtHeight.Value <= 0) { MessageDialog.ShowValidationError(txtHeight, "Invalid Height Data"); return(false); } if (txtWeight.Value <= 0) { MessageDialog.ShowValidationError(txtWeight, "Invalid Weight Data"); return(false); } return(true); }
private void SaveChanges(BiometricTransaction item) { try { var reader = new EmployeeDataReader(); var emp = reader.GetBasicProfileOf(10); var writer = new BiometricTransactionDataWriter("Device", item); writer.SaveChanges(); } catch (Exception ex) { MessageDialog.ShowError(ex, this); } }
private void btnOk_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { var empnum = 0; if (!int.TryParse(txtIdNum.Text, out empnum)) { MessageDialog.Show("Invalid Employee Number", "You have entered an Invalid Number"); txtIdNum.SelectAll(); return; } ; var empId = new EmployeeDataReader().GetIdOf(empnum); if (empId == 0) { MessageDialog.Show("Invalid Employee Number", "You have entered an Invalid Number"); txtIdNum.SelectAll(); return; } EmployeeId = empId; ItemData = (new EmployeeDataReader()).GetItemOf(empId); DialogResult = DialogResult.OK; } catch (Exception ex) { MessageDialog.ShowError(ex, this); } }
private void cmdOpenEmployee_Click(object sender, EventArgs e) { int empId; using (var frm = new Employee.frmEmployee_Open()) { if (frm.ShowDialog() != DialogResult.OK) { return; } empId = frm.EmployeeId; } var employee = new EmployeeDataReader().GetBasicProfileOf(empId); var link = new LinkAccount() { LinkId = employee.Id, Description = employee.PersonClass.Name.Fullname }; ShowLinkedEmployee(link); lblEmployee.Tag = link; }
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); }
private bool ExistingPersonId(int personId) { var reader = new EmployeeDataReader(); return(reader.HasExistingPersonId(personId)); }