private void Insert(int id, string name, int age, DateTime?hiringDate, decimal grossSalary) { try { using (var employees = new EmployeesBusiness()) { var entity = new EmployeesEntity(); entity.Id = id; entity.Name = name; entity.Age = age; entity.HiringDate = hiringDate; entity.GrossSalary = grossSalary; var opSuccessful = employees.InsertEmployee(entity); var resultMessage = opSuccessful ? "Done Successfully" : "Error happened!"; MessageBox.Show(resultMessage, "Success", MessageBoxButtons.OK); } } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); MessageBox.Show("UserInterface:EmployeesForm::Insert::Error occured." + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK); } }
private void InsertEmployee(int id, string name, int age, DateTime?hiringDate, decimal grossSalary) { try { using (var employees = new EmployeesBusiness()) { var entity = new EmployeesEntity(); entity.Id = id; entity.Name = name; entity.Age = age; entity.HiringDate = hiringDate; entity.GrossSalary = grossSalary; var opSuccessful = employees.InsertEmployee(entity); } } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { tb_employees emp = this.ReadEmployees(); tb_deptfunction defu = this.ReadDeptFunction(); tb_timecard ticd = this.ReadTimeCard(); tb_financial fin = this.ReadFinancial(); tb_benefits ben = this.ReadBenefits(); tb_bankaccount bank = this.ReadBankAccount(); tb_discounts dis = this.ReadDiscounts(); EmployeesBusiness EB = new EmployeesBusiness(); string res = EB.InsertEmployee(emp, defu, ticd, fin, ben, bank, dis); MessageBox.Show(res, "liriou's Burguer", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ocorreu um Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }