/// <summary>
    /// release the employee from project & then Exit the employee.
    /// If employee is last resource on project then project should get closed.
    /// Mail should be send for all above activities.
    /// </summary>
    /// <param name="employee">Employee Details</param>
    /// <created By>Yagendra Sharnagat </created By>
    private void ExitEmployee(BusinessEntities.Employee employee, bool B_ClientName)
    {
        RaveHRCollection raveHRCollection = new RaveHRCollection();

        Rave.HR.BusinessLayer.Employee.Employee employeeBL = new Rave.HR.BusinessLayer.Employee.Employee();

        //Get the allocated project details of employee
        raveHRCollection = employeeBL.IsAllocatedToProject(employee);

        //Issue Id : 28572 Mahendra START
        //Check if any employee's line manager or functional manager is resigned employee.
        RaveHRCollection raveHRCollectionReportingEmployee = new RaveHRCollection();

        raveHRCollectionReportingEmployee = employeeBL.IsRepotingManager(employee);
        if (raveHRCollectionReportingEmployee.Count != 0)
        {
            lblMessage.Visible = true;
            lblMessage.Text    = "Resigned Employee is a Line Manager or Functional Manager of some of employees. Please change Manager for that employees.";
            return;
        }
        //Issue Id : 28572 Mahendra END


        int     ProjectCount      = 0;
        Boolean IsProjectClosed   = false;
        string  projectAllocation = string.Empty;
        Boolean IsRoleHR          = false;

        // Check whether employee is allocated to project.
        if (raveHRCollection.Count != 0)
        {
            RaveHRCollection newRaveHRCollection = new RaveHRCollection();
            BusinessEntities.ParameterCriteria newObjParameter = new BusinessEntities.ParameterCriteria();

            //As this parameter required for the method.
            newObjParameter.PageNumber = 1;
            newObjParameter.PageSize   = 10;
            newObjParameter.SortExpressionAndDirection = "EMPId ASC";
            IsRoleHR = true;

            employee.StatusId = 142;//active emp

            //Get the employee details of allocated projects.
            newRaveHRCollection = employeeBL.GetEmployeesProjectDetails(newObjParameter, employee, ref ProjectCount);

            //To release Employee project wise.
            foreach (BusinessEntities.Employee empDetails in newRaveHRCollection)
            {
                empDetails.EmpReleasedStatus = 1;

                empDetails.StatusId = Convert.ToInt32(ddlStatus.SelectedItem.Value.ToString());

                //For mail get current date for release
                //30920-Subhra-Start
                //empDetails.ProjectReleaseDate = System.DateTime.Now;
                empDetails.ProjectReleaseDate = ucDatePickerLastWorkDay.Text.Trim() == string.Empty ? DateTime.MinValue : Convert.ToDateTime(ucDatePickerLastWorkDay.Text);
                //30920-Subhra-End

                //Release the employee from project.
                employeeBL.UpdateEmployeeReleaseStatus(empDetails, ref IsProjectClosed);

                //Siddharth 7 April 2015 Start
                //Set isActive =0 for projects of resigned employees
                employeeBL.Employee_UpdateEmpCostCodeProjRelease(empDetails);
                //Siddharth 7 April 2015 End

                if (empDetails.ProjectId != 0)
                {   //Send mail for project release.
                    employeeBL.SendMailToEmployeeReleasedFromProject(empDetails, IsRoleHR);

                    projectAllocation += empDetails.ProjectName + ", ";
                }
                else
                {
                    //Send mail for department release.
                    employeeBL.SendMailToEmployeeReleasedFromDepartment(empDetails, IsRoleHR);
                }

                //If last employee then close the project.
                if (IsProjectClosed)
                {
                    //then send Email for closed project
                    int ProjectId = empDetails.ProjectId;

                    Rave.HR.BusinessLayer.Projects.Projects objProjectsBAL = new Rave.HR.BusinessLayer.Projects.Projects();;
                    BusinessEntities.Projects objRaveHR = new BusinessEntities.Projects();;
                    //Get the prooject details for email functionality.
                    objRaveHR = objProjectsBAL.RetrieveProjectDetails(ProjectId);
                    //--Call the BL method to send Emails.
                    employeeBL.SendMailToEmployeeForClosedProject(objRaveHR);
                }
            }
        }

        //Inactive employee Id.
        employee.StatusId = 143;

        //Resign the employee from company (exit).
        employeeBL.UpdateEmployeeResignationDetails(employee);

        //Remove last appended comma.
        if (projectAllocation.EndsWith(", "))
        {
            projectAllocation = projectAllocation.Substring(0, projectAllocation.Length - 2);
        }

        //Also get project name with department.
        if (projectAllocation.Trim() != string.Empty)
        {
            employee.Department = employee.Department + " (" + projectAllocation.Trim() + ") ";
        }


        //Send mail for exit.
        employeeBL.SendMailEmployeeResignFromCompany(employee, B_ClientName);

        lblConfirmMsg.Text = "Employee Resignation Details saved successfully and email notification is sent.";

        lblMessage.Visible = true;
    }
Ejemplo n.º 2
0
 /// <summary>
 /// View the Seminars Training Summary details.
 /// </summary>
 /// <param name="RaiseTraining"></param>
 /// <returns></returns>
 public BusinessEntities.RaveHRCollection ApproveRejectViewSeminarsTraining(BusinessEntities.RaiseTrainingRequest RaiseTraining, BusinessEntities.ParameterCriteria objParameter, ref int pageCount, ref int CurrentIndexCount)
 {
     try
     {
         saveTrainingDL = new Rave.HR.DataAccessLayer.Training.RaiseTrainingRequest();
         BusinessEntities.RaveHRCollection raveHRCollection = new BusinessEntities.RaveHRCollection();
         raveHRCollection = saveTrainingDL.ApproveRejectViewSeminarsTraining(RaiseTraining, objParameter, ref pageCount, ref CurrentIndexCount);
         return(raveHRCollection);
     }
     catch (RaveHRException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw new RaveHRException(ex.Message, ex, Sources.BusinessLayer, RaiseTrainingRqst, "FunctionApproveRejectViewSeminarsTraining", EventIDConstants.TRAINING_BUSINESS_ACCESS_LAYER);
     }
 }