private void UpdateLeaveBalance()
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    int empid       = Convert.ToInt32(cbEmp.SelectedValue);
                    int leavetypeid = Convert.ToInt32(cbLeaveType.SelectedValue);

                    var leavebalance = db.LeaveBalances.Where(m => m.EmployeeID == empid).FirstOrDefault();

                    if (leavetypeid == 1)
                    {
                        leavebalance.SickLeaveBalance = leavebalance.SickLeaveBalance - Convert.ToDecimal(cbDays.Text);
                        db.SaveChanges();
                    }
                    else if (leavetypeid == 2)
                    {
                        leavebalance.VacationLeaveBalance = leavebalance.VacationLeaveBalance - Convert.ToDecimal(cbDays.Text);
                        db.SaveChanges();
                    }
                    else if (leavetypeid == 3)
                    {
                        leavebalance.ServiceIncentiveLeave = leavebalance.ServiceIncentiveLeave - Convert.ToDecimal(cbDays.Text);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        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
            {
                if (cbEmp.Text != null && startTime.Text != null && endTime.Text != null && dateFiled.SelectedDate != null && otdate.SelectedDate != null && tbCalendarDay.Text != null)
                {
                    using (var db = new LetranIntegratedSystemEntities())
                    {
                        var empid = Convert.ToInt32(cbEmp.SelectedValue);
                        //var empid = 3029;
                        HRISOvertime       ho = new HRISOvertime();
                        HRISOvertimeDetail hd = new HRISOvertimeDetail();
                        ho.EmployeeID = empid;
                        ho.DateFiled  = dateFiled.SelectedDate.Value;
                        db.HRISOvertimes.Add(ho);
                        ho.HRISOvertimeDetails.Add(new HRISOvertimeDetail()
                        {
                            Date = otdate.SelectedDate.Value.Date, CalendarDay = tbCalendarDay.Text, Reason = tbReason.Text, StartTime = startTime.Text, EndTime = endTime.Text
                        });
                        db.SaveChanges();
                        MessageBox.Show("OT successfully filed.", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                        Clear();
                    }
                }

                else
                {
                    MessageBox.Show("Complete the required data.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dgLvl.SelectedItem != null)
                {
                    using (var db = new LetranIntegratedSystemEntities())
                    {
                        var selectedItem = (LevelList)(dgLvl.SelectedItem);

                        var findlvl = db.EmployeeLevels.Find(selectedItem.LevelID);

                        findlvl.EmployeeLevel1 = txtEmpLvl.Text;
                        db.SaveChanges();
                        MessageBox.Show("Update Successful", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                        TextClear();
                        GetLevel();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dgAcaDept.SelectedItem != null)
                {
                    using (var db = new LetranIntegratedSystemEntities())
                    {
                        var selectedItem = (AcademicDepartmentList)(dgAcaDept.SelectedItem);

                        var finddep = db.AcademicDepartments.Find(selectedItem.DepartmentID);

                        finddep.AcaDepartmentName = txtDeptName.Text;
                        finddep.AcaAcronym        = txtDeptAcro.Text;
                        if (cbIsAcad.Text == "True")
                        {
                            finddep.IsAcad = true;
                        }
                        else
                        {
                            finddep.IsAcad = false;
                        }
                        db.SaveChanges();
                        MessageBox.Show("Update Successful", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                        TextClear();
                        GetAcaDepartment();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 private void btnAddBionumber_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         LetranIntegratedSystemEntities db = new LetranIntegratedSystemEntities();
         var result = db.Employees.Where(m => m.EmployeeID == EmpId).FirstOrDefault();
         if (!String.IsNullOrEmpty(tbBionumber.Text))
         {
             if (result != null)
             {
                 result.bioid = Convert.ToInt16(tbBionumber.Text);
                 db.SaveChanges();
                 MessageBox.Show("Biometrics Number has been updated.", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
             }
             else
             {
                 MessageBox.Show("Employee not found.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
         }
         else
         {
             MessageBox.Show("Input biometrics number!", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    HRISEmployeeSchedule hRISEmployeeSchedule = new HRISEmployeeSchedule();
                    var empSched = db.HRISEmployeeSchedules.Where(m => m.EmployeeNumber == empnumber).FirstOrDefault();

                    if (empSched != null)
                    {
                        empSched.ShiftCode = cbShiftCode.Text;
                        db.SaveChanges();
                        MessageBox.Show("Successfully Updated.", "System Success", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("Employee Schedule not found.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #8
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             if (!String.IsNullOrEmpty(txtLeaveName.Text) || !String.IsNullOrEmpty(txtLeaveCode.Text))
             {
                 LeaveType lt = new LeaveType();
                 lt.LeaveCode        = txtLeaveCode.Text;
                 lt.LeaveDescription = txtLeaveName.Text;
                 db.LeaveTypes.Add(lt);
                 db.SaveChanges();
                 MessageBox.Show("Add Successful", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                 TextClear();
                 GetLeave();
             }
             else
             {
                 MessageBox.Show("Required fields cannot be empty.", "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
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             var             empid    = Convert.ToInt32(cbEmployee.SelectedValue);
             var             employee = db.Employees.Where(m => m.EmployeeID == empid).FirstOrDefault();
             var             dept     = db.AcademicDepartments.Where(m => m.AcaDeptID == employee.EmployeeDepartmentID).FirstOrDefault();
             var             pos      = db.EmployeePositions.Where(m => m.EmployeePositionID == employee.EmployeePositionID).FirstOrDefault();
             EmployeeHistory eh       = new EmployeeHistory();
             eh.EmployeeID         = empid;
             eh.DepartmentID       = dept.AcaDeptID;
             eh.EmployeePositionID = pos.EmployeePositionID;
             eh.StartDate          = startDate.SelectedDate;
             eh.Remark             = txtRemark.Text;
             eh.EndDate            = endDate.SelectedDate;
             db.EmployeeHistories.Add(eh);
             db.SaveChanges();
             Clear();
             MessageBox.Show("Successfully added.", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
             this.Close();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemple #10
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             if (txtShiftCode.Text != null && startTimeComboBox.SelectedItem != null && endTimeComboBox.SelectedItem != null)
             {
                 HRISShift hrisShift = new HRISShift();
                 hrisShift.ShiftCode   = txtShiftCode.Text;
                 hrisShift.Description = txtDescription.Text;
                 hrisShift.StartTime   = startTimeComboBox.Text;
                 hrisShift.EndTime     = endTimeComboBox.Text;
                 db.HRISShifts.Add(hrisShift);
                 db.SaveChanges();
                 GetShifts();
                 Clear();
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             if (!String.IsNullOrEmpty(txtEmpLvl.Text))
             {
                 EmployeeLevel el = new EmployeeLevel();
                 el.EmployeeLevel1 = txtEmpLvl.Text;
                 db.EmployeeLevels.Add(el);
                 db.SaveChanges();
                 MessageBox.Show("Add Successful", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                 TextClear();
                 GetLevel();
             }
             else
             {
                 MessageBox.Show("Required fields cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        private void addFaculty_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    var x = ((EmployeeClass)dgEmployeeList.SelectedItem);

                    if (db.Faculties.Where(m => m.EmpNo == x.EmployeeNumber).FirstOrDefault() == null)
                    {
                        Faculty f = new Faculty();
                        f.EmpNo       = x.EmployeeNumber;
                        f.EmployeeID  = db.Employees.Where(m => m.EmployeeNo == x.EmployeeNumber).FirstOrDefault().EmployeeID;
                        f.FacultyCode = x.EmployeeNumber;
                        db.Faculties.Add(f);
                        db.SaveChanges();
                        MessageBox.Show("Faculty successfully added.", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("Faculty already exists.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        private void btnSaveSeminar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    var selectedItem = (EmployeeSeminarList)(dgSeminars.SelectedItem);
                    if (selectedItem != null)
                    {
                        var empSeminar = db.EmployeeSeminars.Where(m => m.EmployeeSeminarID == selectedItem.id).FirstOrDefault();
                        empSeminar.Title         = txtSeminar.Text;
                        empSeminar.Venue         = txtVenue.Text;
                        empSeminar.InclusiveDate = txtSeminarInclusiveDate.Text;

                        db.SaveChanges();
                        GetEmployeeSeminar();
                        btnSaveSeminar.IsEnabled = false;
                        MessageBox.Show("Update Successfully.", "System Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        ClearSeminar();
                    }
                    else
                    {
                        MessageBox.Show("Select a record", "System Warning.", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong!", "System Warning.", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        public void ResetPassword()
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    string userid = "";
                    var    a      = ((HRiSClass.AccountManagementList)dgAdmin.SelectedItem);
                    var    b      = ((HRiSClass.AccountManagementList)dgEmployee.SelectedItem);
                    var    c      = ((HRiSClass.AccountManagementList)dgFaculty.SelectedItem);
                    var    d      = ((HRiSClass.AccountManagementList)dgFacultyHead.SelectedItem);
                    var    f      = ((HRiSClass.AccountManagementList)dgGuidance.SelectedItem);
                    var    g      = ((HRiSClass.AccountManagementList)dgHR.SelectedItem);
                    var    h      = ((HRiSClass.AccountManagementList)dgRegistrar.SelectedItem);

                    if (a != null)
                    {
                        userid = a.AccountID;
                    }
                    else if (b != null)
                    {
                        userid = b.AccountID;
                    }
                    else if (c != null)
                    {
                        userid = c.AccountID;
                    }
                    else if (d != null)
                    {
                        userid = d.AccountID;
                    }
                    else if (f != null)
                    {
                        userid = f.AccountID;
                    }
                    else if (g != null)
                    {
                        userid = g.AccountID;
                    }
                    else if (h != null)
                    {
                        userid = h.AccountID;
                    }

                    if (!String.IsNullOrEmpty(userid))
                    {
                        AspNetUser search         = db.AspNetUsers.Where(m => m.Id == userid).FirstOrDefault();
                        var        passwordHasher = new Microsoft.AspNet.Identity.PasswordHasher();
                        search.PasswordHash = passwordHasher.HashPassword("letran1620");
                        db.SaveChanges();
                        MessageBox.Show("Password has been reset.", "Successful", MessageBoxButton.OK, MessageBoxImage.Information);
                        GetAccount();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnSaveEducational_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    var selectedItem = (EmployeeEducationList)(dgEmpEduc.SelectedItem);
                    if (selectedItem != null)
                    {
                        var empeduc = db.EmployeeEducations.Where(m => m.EmployeeEducationID == selectedItem.id).FirstOrDefault();
                        empeduc.EducationType  = txtEducationType.Text;
                        empeduc.Institution    = txtInstitution.Text;
                        empeduc.Degree         = txtDegree.Text;
                        empeduc.GraduationDate = txtGraduationDate.Text;
                        empeduc.Awards         = txtAwards.Text;

                        db.SaveChanges();
                        GetEmployeeEducation();
                        btnSaveEducational.IsEnabled = false;
                        MessageBox.Show("Update Successfully.", "System Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        ClearEducationInfo();
                    }
                    else
                    {
                        MessageBox.Show("Select a record", "System Warning.", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong!", "System Warning.", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        private void btnSaveWorkExp_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    var selectedItem = (EmployeeWorkList)(dgWorkExp.SelectedItem);
                    var empWork      = db.EmployeeWorks.Where(m => m.EmployeeWorkID == selectedItem.id).FirstOrDefault();
                    if (empWork != null)
                    {
                        empWork.Company       = txtCompany.Text;
                        empWork.WorkPosition  = txtPosition.Text;
                        empWork.InclusiveDate = txtWorkExpInclusivedate.Text;
                        empWork.Salary        = txtSalary.Text;
                        empWork.ReasonLeaving = txtReasonForLeaving.Text;

                        db.SaveChanges();
                        GetEmployeeWorkExp();
                        btnSaveWorkExp.IsEnabled = false;
                        MessageBox.Show("Update Successfully.", "System Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        ClearWorkExp();
                    }
                    else
                    {
                        MessageBox.Show("Select a record", "System Warning.", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong!", "System Warning.", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
 private void btnAddEducational_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             if (txtEducationType.Text != "" && txtInstitution.Text != "" && txtDegree.Text != "" && txtGraduationDate.Text != "")
             {
                 EmployeeEducation ed = new EmployeeEducation();
                 ed.EmployeeID     = EmpID;
                 ed.EducationType  = txtEducationType.Text;
                 ed.Institution    = txtInstitution.Text;
                 ed.Degree         = txtDegree.Text;
                 ed.Awards         = txtAwards.Text;
                 ed.GraduationDate = txtGraduationDate.Text;
                 db.EmployeeEducations.Add(ed);
                 db.SaveChanges();
                 MessageBox.Show("Add Successfully.", "System Success", MessageBoxButton.OK, MessageBoxImage.Information);
                 ClearEducationInfo();
                 GetEmployeeEducation();
             }
             else
             {
                 MessageBox.Show("Fill the required fields.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong!", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
 private void btnAddSeminar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             if (txtSeminar.Text != "" && txtVenue.Text != "" && txtSeminarInclusiveDate.Text != "")
             {
                 EmployeeSeminar es = new EmployeeSeminar();
                 es.EmployeeID    = EmpID;
                 es.Title         = txtSeminar.Text;
                 es.Venue         = txtVenue.Text;
                 es.InclusiveDate = txtSeminarInclusiveDate.Text;
                 db.EmployeeSeminars.Add(es);
                 db.SaveChanges();
                 MessageBox.Show("Add Successfully.", "System Success", MessageBoxButton.OK, MessageBoxImage.Information);
                 ClearSeminar();
                 GetEmployeeSeminar();
             }
             else
             {
                 MessageBox.Show("Fill the required fields.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong!", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
 private void btnAddWorkExp_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             if (txtCompany.Text != "" && txtPosition.Text != "")
             {
                 EmployeeWork ew = new EmployeeWork();
                 ew.EmployeeID    = EmpID;
                 ew.Company       = txtCompany.Text;
                 ew.WorkPosition  = txtPosition.Text;
                 ew.InclusiveDate = txtWorkExpInclusivedate.Text;
                 ew.Salary        = txtSalary.Text;
                 ew.ReasonLeaving = txtReasonForLeaving.Text;
                 db.EmployeeWorks.Add(ew);
                 db.SaveChanges();
                 MessageBox.Show("Add Successfully.", "System Success", MessageBoxButton.OK, MessageBoxImage.Information);
                 ClearWorkExp();
                 GetEmployeeWorkExp();
             }
             else
             {
                 MessageBox.Show("Fill the required fields.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong!", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Exemple #20
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    if (dgLeave.SelectedItem != null)
                    {
                        var selectedItem = (LeaveType)(dgLeave.SelectedItem);

                        var find = db.LeaveTypes.Find(selectedItem.LeaveTypeID);

                        find.LeaveCode        = txtLeaveCode.Text;
                        find.LeaveDescription = txtLeaveName.Text;

                        db.SaveChanges();
                        MessageBox.Show("Update Successful", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                        TextClear();
                        GetLeave();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnDeleteSeminar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    var selectedItem = (EmployeeSeminarList)(dgSeminars.SelectedItem);
                    var empseminar   = db.EmployeeSeminars.Where(m => m.EmployeeSeminarID == selectedItem.id).FirstOrDefault();
                    if (empseminar != null)
                    {
                        db.EmployeeSeminars.Remove(empseminar);
                        db.SaveChanges();
                        GetEmployeeSeminar();
                        ClearSeminar();
                        MessageBox.Show("Remove Successfully.", "System Success", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("No record found.", "System Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }

                    btnDeleteSeminar.IsEnabled = false;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong!", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemple #22
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             HRISOffCampusActivity oca = new HRISOffCampusActivity();
             oca.EmployeeID = Convert.ToInt32(cbEmp.SelectedValue);
             oca.DateStart  = startDate.SelectedDate;
             oca.DateEnd    = startDate.SelectedDate;
             oca.DateFiled  = dateFile.SelectedDate;
             oca.Reason     = txtReason.Text;
             TimeSpan duration = DateTime.Parse(endTime.Text).Subtract(DateTime.Parse(startTime.Text));
             oca.TotalHours = duration.ToString(@"h\:mm");
             oca.StartTime  = startTime.Text;
             oca.EndTime    = endTime.Text;
             db.HRISOffCampusActivities.Add(oca);
             db.SaveChanges();
             MessageBox.Show("Success!.", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
             Clear();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemple #23
0
 private void delete_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             var selectedItem = (BiometricList)(dgTurnstile.SelectedItem);
             var id           = selectedItem.AttendanceID;
             var attendance   = db.BiometricsLogDatas.Where(m => m.Id == id).FirstOrDefault();
             if (attendance != null)
             {
                 db.BiometricsLogDatas.Remove(attendance);
                 db.SaveChanges();
                 MessageBox.Show("Deleted Successfully.", "System Success", MessageBoxButton.OK, MessageBoxImage.Information);
                 GetBiometrics();
             }
             else
             {
                 MessageBox.Show("No record found!", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong!", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemple #24
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                db = new LetranIntegratedSystemEntities();
                var L = db.Leaves.Find(LeaveID);

                if (L != null)
                {
                    var typeid = Convert.ToInt32(cbLeaveType.SelectedValue);
                    L.StartDate   = Convert.ToDateTime(dpStart.SelectedDate);
                    L.EndDate     = Convert.ToDateTime(dpEnd.SelectedDate);
                    L.LeaveTypeID = typeid;
                    L.Reason      = txtReason.Text;
                    L.Days        = Convert.ToDecimal(txtDays.Text);
                    //if (!String.IsNullOrEmpty(cbSickLeaveType.Text))
                    //    L.SickLeaveReasonID = Convert.ToInt32(cbSickLeaveType.SelectedValue);
                    //L.LeaveApprovedStatusID = 3;
                    db.SaveChanges();
                    MessageBox.Show("Save Successful", "System Sucess!", MessageBoxButton.OK, MessageBoxImage.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Leave not found", "System Warning.", MessageBoxButton.OK, MessageBoxImage.Warning);
                    this.Close();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #25
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    if (dgAnnouncement.SelectedItem != null)
                    {
                        var selectedItem = (HRiS.Model.EmployeeAnnouncement)(dgAnnouncement.SelectedItem);
                        var ann          = db.EmployeeAnnouncements.Find(selectedItem.EmployeeAnnoucementID);

                        ann.Title       = txtTitle.Text;
                        ann.Annoucement = txtAnnouncement.Text;
                        ann.CreatedBy   = txtCreatedBy.Text;
                        ann.DateCreated = dpDate.SelectedDate;
                        if (cbIsActive.Text == "True")
                        {
                            ann.Active = true;
                        }
                        else
                        {
                            ann.Active = false;
                        }
                        db.SaveChanges();
                        MessageBox.Show("Update Successful", "System Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                        TextClear();
                        GetAnnouncementFeedback();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #26
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            this.Cursor = Cursors.Wait;
            db          = new LetranIntegratedSystemEntities();
            var passwordHasher = new Microsoft.AspNet.Identity.PasswordHasher();

            AspNetUser search  = db.AspNetUsers.Where(m => m.UserName == App.EmployeeNumber).FirstOrDefault();
            string     compare = passwordHasher.VerifyHashedPassword(search.PasswordHash, pbCurrent.Password).ToString();

            if (compare != "Success")
            {
                MessageBox.Show("Incorrect current password.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (pbNew.Password != pbVerify.Password)
            {
                MessageBox.Show("Verify password does not match.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (String.IsNullOrEmpty(pbCurrent.Password) || String.IsNullOrEmpty(pbNew.Password) || String.IsNullOrEmpty(pbVerify.Password))
            {
                MessageBox.Show("Password cannot be empty.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            search.PasswordHash = passwordHasher.HashPassword(pbVerify.Password);
            db.SaveChanges();
            MessageBox.Show("Password has been changed.", "Successful", MessageBoxButton.OK);
            pbCurrent.Clear();
            pbNew.Clear();
            pbVerify.Clear();
            this.Cursor = Cursors.Arrow;
        }
Exemple #27
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    if (String.IsNullOrEmpty(cbEmployee.Text))
                    {
                        MessageBox.Show("Employee cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }

                    if (String.IsNullOrEmpty(cbShiftCode.Text))
                    {
                        MessageBox.Show("Shift cannot be empty.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }

                    var empId       = Convert.ToInt32(cbEmployee.SelectedValue);
                    var emp         = db.Employees.Where(m => m.EmployeeID == empId).FirstOrDefault();
                    var empSchedule = db.HRISEmployeeSchedules.Where(m => m.EmployeeNumber == emp.EmployeeNo).FirstOrDefault();
                    var shiftCode   = Convert.ToString(cbShiftCode.SelectedValue);
                    if (emp != null)
                    {
                        HRISEmployeeSchedule hrisEmployeeSchedule = new HRISEmployeeSchedule();
                        hrisEmployeeSchedule.EmployeeNumber = emp.EmployeeNo;
                        hrisEmployeeSchedule.ShiftCode      = shiftCode;
                        db.HRISEmployeeSchedules.Add(hrisEmployeeSchedule);
                        db.SaveChanges();
                        emp.EmployeeScheduleId = hrisEmployeeSchedule.EmployeeScheduleId;
                        db.SaveChanges();
                        clear();
                        MessageBox.Show("Add Success.", "System Sucess!", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("Employee not found.", "System Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new LetranIntegratedSystemEntities())
                {
                    if (timeinID != 0)
                    {
                        var biolog = db.BiometricsLogDatas.Where(m => m.Id == timeinID).FirstOrDefault();

                        biolog.REG       = tbTotalHours.Text;
                        biolog.LATE      = tbLate.Text;
                        biolog.UNDERTIME = tbUnderTime.Text;

                        db.SaveChanges();
                    }

                    if (timeoutID != 0)
                    {
                        var biolog = db.BiometricsLogDatas.Where(m => m.Id == timeoutID).FirstOrDefault();

                        biolog.REG       = tbTotalHours.Text;
                        biolog.LATE      = tbLate.Text;
                        biolog.UNDERTIME = tbUnderTime.Text;

                        db.SaveChanges();
                    }

                    MessageBox.Show("Updating attendance was successful", "System Successs!", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public void InsertoDB(int empno, DateTime dtime, string mode)
 {
     try
     {
         BiometricsLogData biometricsLogData = new BiometricsLogData();
         biometricsLogData.MODE  = mode;
         biometricsLogData.EMPN  = empno;
         biometricsLogData.DTIME = dtime;
         db.BiometricsLogDatas.Add(biometricsLogData);
         db.SaveChanges();
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong!", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemple #30
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (var db = new LetranIntegratedSystemEntities())
         {
             HRISShift hrisShfit = new HRISShift();
             hrisShfit.Description = txtDescription.Text;
             hrisShfit.StartTime   = startTimeComboBox.Text;
             hrisShfit.EndTime     = endTimeComboBox.Text;
             hrisShfit.ShiftCode   = txtShiftCode.Text;
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }