private void btnCancel_Click(object sender, RoutedEventArgs e) { try { db = new LetranIntegratedSystemEntities(); var x = ((ApprovedList)dgApproved.SelectedItem); Leave leaveapp = db.Leaves.Find(x.LeaveID); var empid = db.Employees.Where(m => m.EmployeeNo == x.EmployeeNo).FirstOrDefault(); HRiS.Model.LeaveBalance leavebal = db.LeaveBalances.Where(m => m.EmployeeID == empid.EmployeeID).FirstOrDefault(); if (leaveapp != null) { //// DISAPPROVED PART //leaveapp.LeaveApprovedStatusID = 5; //leaveapp.CancellationDate = DateTime.Now; //RETURN OF LEAVE CREDITS //EL if (leaveapp.LeaveType.LeaveTypeID == 1) { leavebal.VacationLeaveBalance = leavebal.VacationLeaveBalance + x.Days; //leavebal.EmergencyLeaveBalance = leavebal.EmergencyLeaveBalance + x.Days; } //SL else if (leaveapp.LeaveType.LeaveTypeID == 4) { leavebal.SickLeaveBalance = leavebal.SickLeaveBalance + x.Days; } //VL else if (leaveapp.LeaveType.LeaveTypeID == 5) { leavebal.VacationLeaveBalance = leavebal.VacationLeaveBalance + x.Days; } //SPL else if (leaveapp.LeaveType.LeaveTypeID == 7) { //leavebal.SoloParentLeaveBalance = leavebal.SoloParentLeaveBalance + x.Days; } //BL else if (leaveapp.LeaveType.LeaveTypeID == 10) { //leavebal.BereavementLeaveBalance = leavebal.BereavementLeaveBalance + x.Days; } db.SaveChanges(); MessageBox.Show("Leave Cancelled", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information); GetLeave(); } else { MessageBox.Show("Cannot find leave transaction.", "System Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } } catch (Exception) { MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { db = new LetranIntegratedSystemEntities(); HRiS.Model.LeaveBalance lb = new Model.LeaveBalance(); int EmpID = Convert.ToInt32(cbEmp.SelectedValue); lb.EmployeeID = EmpID; lb.SickLeaveBalance = Convert.ToDecimal(txtSL.Text); lb.VacationLeaveBalance = Convert.ToDecimal(txtVL.Text); lb.ServiceIncentiveLeave = Convert.ToDecimal(txtSIL.Text); db.LeaveBalances.Add(lb); db.SaveChanges(); MessageBox.Show("Added Succesful", "System Succes!", MessageBoxButton.OK, MessageBoxImage.Information); this.Close(); } catch (Exception) { MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnApproved_Click(object sender, RoutedEventArgs e) { try { db = new LetranIntegratedSystemEntities(); var x = ((OnProcessList)dgOnProcess.SelectedItem); Leave leaveapp = db.Leaves.Find(x.LeaveID); if (x.IsOverdue == true) { if (leaveapp != null) { var empid = db.Employees.Where(m => m.EmployeeNo == x.EmployeeNo).FirstOrDefault(); HRiS.Model.LeaveBalance leavebal = db.LeaveBalances.Where(m => m.EmployeeID == empid.EmployeeID).FirstOrDefault(); // APPROVED PART //leaveapp.LeaveApprovedStatusID = 2; //leaveapp.ApprovedBy = db.Employees.Where(m => m.EmployeeNo == App.EmployeeNumber).FirstOrDefault().EmployeeID; //leaveapp.ApprovedDate = DateTime.Now; // LEAVE DEDUCTION //EL if (leaveapp.LeaveType.LeaveTypeID == 1) { leavebal.VacationLeaveBalance = leavebal.VacationLeaveBalance - x.Days; //leavebal.EmergencyLeaveBalance = leavebal.EmergencyLeaveBalance - x.Days; } //SL else if (leaveapp.LeaveType.LeaveTypeID == 4) { //leavebal.SickLeaveBalance = leavebal.SickLeaveBalance - x.Days; } //VL else if (leaveapp.LeaveType.LeaveTypeID == 5) { //leavebal.VacationLeaveBalance = leavebal.VacationLeaveBalance - x.Days; } //SPL else if (leaveapp.LeaveType.LeaveTypeID == 7) { //leavebal.SoloParentLeaveBalance = leavebal.SoloParentLeaveBalance - x.Days; } //BL else if (leaveapp.LeaveType.LeaveTypeID == 10) { // leavebal.BereavementLeaveBalance = leavebal.BereavementLeaveBalance - x.Days; } db.SaveChanges(); //Transfer leave to Softrak using (var sof = new softrakEntities()) { LEAf sofleav = new LEAf(); sofleav.USERNAME = App.EmployeeUserName; sofleav.EMPN = leaveapp.Employee.EmployeeNo; sofleav.DATE_FROM = leaveapp.StartDate.Value; sofleav.DATE_TO = leaveapp.EndDate.Value; //sofleav.TYPE sofleav.CODE = leaveapp.LeaveType.LeaveCode; //sofleav.ENTRYDATE = leaveapp.FiledDate.Value; sofleav.CREDITS = Convert.ToDouble(leaveapp.Days.Value); sof.LEAVES.Add(sofleav); sof.SaveChanges(); } MessageBox.Show("Leave Approved", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information); GetLeave(); } else { MessageBox.Show("Cannot find leave transaction.", "System Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Cannot approve leave.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning); } } catch (Exception) { MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }