Ejemplo n.º 1
0
        public void WriteLogForUpdateCompany(Employee newInfo, ELogAction action)
        {
            try
            {
                bool isUpdated = false;
                if (newInfo == null)
                {
                    return;
                }
                MasterLog objMasterLog = new MasterLog();
                string logId = commonDao.UniqueId;
                commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString());
                Employee oldInfo = new EmployeeDao().GetById(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.JR != oldInfo.JR)
                    {
                        commonDao.InsertLogDetail(logId, "JR", "Job Request", oldInfo.JR, newInfo.JR);
                        isUpdated = true;
                    }
                    if (newInfo.Project != oldInfo.Project)
                    {
                        commonDao.InsertLogDetail(logId, "Project", "JProject", oldInfo.Project, newInfo.Project);
                        isUpdated = true;
                    }
                    if (newInfo.ManagerId != oldInfo.ManagerId)
                    {
                        commonDao.InsertLogDetail(logId, "Manager", "Manager", oldInfo.ManagerId, newInfo.ManagerId);
                        isUpdated = true;
                    }
                    if (newInfo.JRApproval != oldInfo.JRApproval)
                    {
                        commonDao.InsertLogDetail(logId, "JRApproval", "Job Request Approval", oldInfo.JRApproval, newInfo.JRApproval);
                        isUpdated = true;
                    }
                    if (newInfo.StartDate != oldInfo.StartDate)
                    {
                        commonDao.InsertLogDetail(logId, "StartDate", "Start Date", oldInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW));
                        isUpdated = true;
                    }
                    if (newInfo.ContractedDate != oldInfo.ContractedDate)
                    {
                        commonDao.InsertLogDetail(logId, "ContractedDate", "Contracted Date",oldInfo.ContractedDate.HasValue?oldInfo.ContractedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"", newInfo.ContractedDate.HasValue?newInfo.ContractedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"");
                        isUpdated = true;
                    }
                    if (newInfo.DepartmentId != oldInfo.DepartmentId)
                    {
                        Department sub = new DepartmentDao().GetById(newInfo.DepartmentId);
                        commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", oldInfo.Department.DepartmentName, sub.DepartmentName);
                        isUpdated = true;
                    }
                    if (newInfo.TitleId != oldInfo.TitleId)
                    {
                        JobTitleLevel title = new JobTitleLevelDao().GetById(newInfo.TitleId);
                        commonDao.InsertLogDetail(logId, "TitleId", "Job Title", oldInfo.JobTitleLevel.DisplayName, title.DisplayName);
                        isUpdated = true;
                    }
                    if (newInfo.LaborUnion != oldInfo.LaborUnion)
                    {
                        commonDao.InsertLogDetail(logId, "LaborUnion", "Labor Union",oldInfo.LaborUnion.HasValue?(oldInfo.LaborUnion == true?"Yes":"No"):"", newInfo.LaborUnion.HasValue?(newInfo.LaborUnion == true?"Yes":"No"):"");
                        isUpdated = true;
                    }
                    if (newInfo.LaborUnionDate != oldInfo.LaborUnionDate)
                    {
                        commonDao.InsertLogDetail(logId, "LaborUnionDate", "Labor Union date", oldInfo.LaborUnionDate.HasValue?oldInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.LaborUnionDate.HasValue?newInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"");
                        isUpdated = true;
                    }
                    if (newInfo.TaxID != oldInfo.TaxID)
                    {
                        commonDao.InsertLogDetail(logId, "TaxID", "TaxID", oldInfo.TaxID, newInfo.TaxID);
                        isUpdated = true;
                    }
                    if (newInfo.TaxIssueDate != oldInfo.TaxIssueDate)
                    {
                        commonDao.InsertLogDetail(logId, "TaxIssueDate", "Tax Issue Date", oldInfo.TaxIssueDate.HasValue?oldInfo.TaxIssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.TaxIssueDate.HasValue?newInfo.TaxIssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"");
                        isUpdated = true;
                    }
                    if (newInfo.SocialInsuranceNo != oldInfo.SocialInsuranceNo)
                    {
                        commonDao.InsertLogDetail(logId, "SocialInsuranceNo", "Insurance Book No", oldInfo.SocialInsuranceNo, newInfo.SocialInsuranceNo);
                        isUpdated = true;
                    }
                    if (newInfo.InsuranceHospitalID != oldInfo.InsuranceHospitalID)
                    {
                        commonDao.InsertLogDetail(logId, "InsuranceHospitalID", "Insurance Hospital", oldInfo.InsuranceHospitalID, newInfo.InsuranceHospitalID);
                        isUpdated = true;
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]";
                        commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null);
                    }
                    else
                    {
                        commonDao.DeleteMasterLog(logId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        //private StringBuilder GetStringBuilder(IEnumerable list, string DataTextFiled, string DataValueField, string selectedValue)
        //{
        //    StringBuilder strBuilder = new StringBuilder();
        //    if (((IList)list).Count == 0)
        //        return strBuilder;
        //    strBuilder.Append("[");
        //    foreach (Object item in list)
        //    {
        //        strBuilder.Append("{");
        //        strBuilder.Append("\"Name\":\"" + item.GetType().GetProperty(DataTextFiled).GetValue(item, null) + "\",");
        //        //strBuilder.Append("\"ID\":\"" + item.GetType().GetProperty(DataValueField).GetValue(item, null) + "\"");
        //        string id = item.GetType().GetProperty(DataValueField).GetValue(item, null).ToString();
        //        if (id.Equals("0"))
        //            id = "";
        //        strBuilder.Append("\"ID\":\"" + id + "\"");
        //        if(id.Equals(selectedValue))
        //            strBuilder.Append("\"Selected\":\"" + true + "\"");
        //        strBuilder.Append("},");
        //    }
        //    strBuilder.Remove(strBuilder.Length - 1, 1);
        //    strBuilder.Append("]");
        //    return strBuilder;
        //}
        public void ProcessRequest(HttpContext context)
        {
            string ID = context.Request.QueryString["ID"];
            string pageName = context.Request.QueryString["Page"];
            StringBuilder strBuilder = new StringBuilder();
            bool toGroup = false;
            switch (pageName)
            {
                case "JRAdmin":
                    List<WFRole> list = null;
                    if (string.IsNullOrEmpty(ID))
                    {
                        list = roleDao.GetList(true);
                    }
                    else
                    {
                        list = roleDao.GetListByWorkflow(int.Parse(ID));
                    }
                    strBuilder = GetStringBuilder(list, "Name", "ID");

                    break;
                case "JobRequest":
                    List<JobTitleLevel> posList = posDao.GetListByLevelId(int.Parse(ID));
                    strBuilder = GetStringBuilder(posList, "DisplayName", "ID");

                    break;
                //Tuc 13-12-11
                //Change name of method
                case "Department":
                    IList<JobTitleLevel> jobTitleList = null;
                    if (!string.IsNullOrEmpty(ID))
                    {
                        // triet.dinh 27-12-2011
                        int rootDeptId = deptDao.GetDepartmentRoot(ConvertUtil.ConvertToInt(ID));
                        jobTitleList = commDao.GetJobTitleList(rootDeptId);
                        //jobTitleList = commDao.GetJobTitleList(int.Parse(ID));
                    }
                    else
                    {
                        jobTitleList = commDao.GetJobTitleLevelList();
                    }
                    strBuilder = GetStringBuilder(jobTitleList, "DisplayName", "ID");

                    break;

                //Show list of Job Title which are fixed with Department when Create or Edit
                case "NewDepartment":
                    IList<JobTitle> jobTitleParentList = null;
                    if (!string.IsNullOrEmpty(ID))
                    {
                        // triet.dinh 27-12-2011
                        int rootDeptId = deptDao.GetDepartmentRoot(ConvertUtil.ConvertToInt(ID));
                        jobTitleParentList = commDao.GetJobTitleListByDepartmentId(rootDeptId);
                        //jobTitleParentList = commDao.GetJobTitleListByDepartmentId(int.Parse(ID));
                    }
                    else
                    {
                        jobTitleParentList = commDao.GetJobTitleList();
                    }
                    strBuilder = GetStringBuilder(jobTitleParentList, "JobTitleName", "JobTitleId");

                    break;

                //Tuc 13-12-11
                case "JobTitleParent":
                    IList<JobTitleLevel> jobTitleLevelList = null;
                    if (!string.IsNullOrEmpty(ID))
                    {
                        jobTitleLevelList = commDao.GetJobTitleLevelListByJobTitleId(int.Parse(ID));
                    }
                    else
                    {
                        jobTitleLevelList = commDao.GetJobTitleLevelList();
                    }
                    strBuilder = GetStringBuilder(jobTitleLevelList, "DisplayName", "ID");

                    break;

                case "SubDepartment":
                    DepartmentDao departmentDao = new DepartmentDao();
                    IList<Department> subDepartmentList = null;
                    if (!string.IsNullOrEmpty(ID))
                    {
                        subDepartmentList = departmentDao.GetSubListByParent(int.Parse(ID));
                    }
                    else
                    {
                        subDepartmentList = departmentDao.GetSubList();
                    }
                    strBuilder = GetStringBuilder(subDepartmentList, "DepartmentName", "DepartmentId");

                    break;

                case "Assign":
                    List<sp_GetListAssignByResolutionIdResult> assignList = jrDao.GetListAssign(int.Parse(ID));
                    strBuilder = GetStringBuilder(assignList, "DisplayName", "UserAdminRole");

                    break;

                case "PReviewAssign":
                    List<sp_GetListAssignByResolutionIdResult> assignPrList = prDao.GetListAssign(int.Parse(ID));
                    strBuilder = GetStringBuilder(assignPrList, "DisplayName", "UserAdminRole");

                    break;
                case "Status":
                    List<WFStatus> staList = new List<WFStatus> ();
                    //staList.Add(new WFStatus() { Name = Constants.PURCHASE_REQUEST_STATUS_FIRST_ITEM});
                    staList.AddRange(staDao.GetListStatusByResolution(int.Parse(ID)));
                    strBuilder = GetStringBuilder(staList, "Name", "ID");

                    break;

                case "Employee":
                    JobTitleLevelDao levelDao = new JobTitleLevelDao();
                    List<JobTitleLevel> titleList = null;
                    if (string.IsNullOrEmpty(ID))
                    {
                        titleList = levelDao.GetList();
                    }
                    else
                    {
                        titleList = levelDao.GetJobTitleListByDepId(int.Parse(ID));
                    }
                    strBuilder = GetStringBuilder(titleList, "DisplayName", "ID");

                    break;
                case "PurChaseAssign":
                    toGroup = false;
                    bool isUsPurchasing = context.Request.QueryString.AllKeys.Contains("isus") ?
                        bool.Parse(context.Request.QueryString["isus"]) : false;
                    if(context.Request.QueryString.AllKeys.Contains("toGroup"))
                        toGroup = bool.Parse(context.Request.QueryString["toGroup"]);
                    if (toGroup)
                    {
                        int roleId = int.Parse(context.Request.QueryString["roleId"]);
                        List<ListItem> prList = new List<ListItem>();
                        prList.Add(new ListItem(Constants.PURCHASE_REQUEST_APPROVAL_MAN, ""));
                        prList.AddRange(userAdminDao.GetListWithRole(roleId));
                        strBuilder = GetStringBuilder(prList, "Text", "Value");
                    }
                    else
                    {
                        List<sp_GetListAssignByResolutionIdResult> pruchaseAssignList = new List<sp_GetListAssignByResolutionIdResult>();
                        pruchaseAssignList.Add(new sp_GetListAssignByResolutionIdResult()
                        {
                            DisplayName = Constants.PURCHASE_REQUEST_APPROVAL_MAN,
                            UserAdminRole = ""
                        });
                        if(isUsPurchasing)
                            pruchaseAssignList.AddRange(purchaseDao.GetListAssign(int.Parse(ID), Constants.WORK_FLOW_PURCHASE_REQUEST_US));
                        else
                            pruchaseAssignList.AddRange(purchaseDao.GetListAssign(int.Parse(ID), Constants.WORK_FLOW_PURCHASE_REQUEST));
                        strBuilder = GetStringBuilder(pruchaseAssignList, "DisplayName", "UserAdminRole");
                    }
                    break;
                case "PurChaseAssignUS":
                    toGroup = false;
                    if (context.Request.QueryString.AllKeys.Contains("toGroup"))
                        toGroup = bool.Parse(context.Request.QueryString["toGroup"]);
                    if (toGroup)
                    {
                        int roleId = int.Parse(context.Request.QueryString["roleId"]);
                        List<ListItem> prList = new List<ListItem>();
                        prList.Add(new ListItem(Constants.PURCHASE_REQUEST_APPROVAL_MAN, ""));
                        prList.AddRange(userAdminDao.GetListWithRole(roleId));
                        strBuilder = GetStringBuilder(prList, "Text", "Value");
                    }
                    else
                    {
                        List<sp_GetListAssignByResolutionIdResult> pruchaseAssignList = new List<sp_GetListAssignByResolutionIdResult>();
                        pruchaseAssignList.Add(new sp_GetListAssignByResolutionIdResult()
                        {
                            DisplayName = Constants.PURCHASE_REQUEST_APPROVAL_MAN,
                            UserAdminRole = ""
                        });
                        pruchaseAssignList.AddRange(purchaseDao.GetListAssign(int.Parse(ID), Constants.WORK_FLOW_PURCHASE_REQUEST_US));
                        strBuilder = GetStringBuilder(pruchaseAssignList, "DisplayName", "UserAdminRole");
                    }
                    break;
                case "AssignListByRole":
                    List<UserAdmin> adminList = commDao.GetUserAdminByRole(int.Parse(ID));
                    strBuilder = GetStringBuilder(adminList, "UserName", "UserAdminId");
                    break;
                case "WFRole":
                    List<WFRole> wfRoleList = new List<WFRole>();
                    if (string.IsNullOrEmpty(ID))
                    {
                       wfRoleList= roleDao.GetList();
                    }
                    else
                    {
                        wfRoleList = roleDao.GetListByWorkflow(int.Parse(ID));
                    }
                    strBuilder = GetStringBuilder(wfRoleList, "Name", "ID");
                    break;
                case "WFResolution":
                    List<WFResolution> wfResolutionList = new List<WFResolution>();
                    if (string.IsNullOrEmpty(ID))
                    {
                       wfResolutionList= resolutionDao.GetList();
                    }
                    else
                    {
                        wfResolutionList = resolutionDao.GetResolutionByWorkFlow(int.Parse(ID));
                    }
                    strBuilder = GetStringBuilder(wfResolutionList, "Name", "ID");
                    break;
                case "PTOType":
                    List<PTO_Type> ptoTypeList = new PTOTypeDao().GetTypeListByParentID(int.Parse(ID));
                    strBuilder = GetStringBuilder(ptoTypeList, "Name","ID" );
                    break;

                case "Category":
                    List<sp_GetSRCategoryResult> catList = new SRCategoryDao().GetList( null, int.Parse(ID), true);
                    strBuilder = GetStringBuilder(catList, "Name", "ID");
                    break;
                case "USAccouting":
                    List<sp_GetListAssignByResolutionIdResult> usAccountingAssignList = new List<sp_GetListAssignByResolutionIdResult>();
                    usAccountingAssignList.Add(new sp_GetListAssignByResolutionIdResult()
                        {
                            DisplayName = Constants.PURCHASE_REQUEST_APPROVAL_MAN,
                            UserAdminRole = ""
                        });
                    usAccountingAssignList.AddRange(purchaseDao.GetListAssign(int.Parse(ID), Constants.WORK_FLOW_PURCHASE_REQUEST));
                    strBuilder = GetStringBuilder(usAccountingAssignList, "DisplayName", "UserAdminRole");
                    break;
            }
            context.Response.ContentType = "application/json";
            context.Response.Write(strBuilder.ToString());
            context.Response.End();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Write Update Log For Employee
        /// </summary>
        /// <param name="newInfo"></param>
        /// <param name="logId"></param>
        /// <returns></returns>
        private bool WriteUpdateLogForEmployee(Employee newInfo, string logId)
        {
            bool isUpdated = false;
            try
            {
                // Get old info
                Employee oldInfo = new EmployeeDao().GetById(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.IDNumber != oldInfo.IDNumber)
                    {
                        commonDao.InsertLogDetail(logId, "IDNumber", "ID Number", oldInfo.IDNumber, newInfo.IDNumber);
                        isUpdated = true;
                    }
                    if (newInfo.LastName != oldInfo.LastName)
                    {
                        commonDao.InsertLogDetail(logId, "LastName", "Last Name", oldInfo.LastName, newInfo.LastName);
                        isUpdated = true;
                    }
                    if (newInfo.Major != oldInfo.Major)
                    {
                        commonDao.InsertLogDetail(logId, "LastName", "Last Name", oldInfo.Major, newInfo.Major);
                        isUpdated = true;
                    }
                    if (newInfo.MiddleName != oldInfo.MiddleName)
                    {
                        commonDao.InsertLogDetail(logId, "MiddleName", "Middle Name", oldInfo.MiddleName, newInfo.MiddleName);
                        isUpdated = true;
                    }
                    if (newInfo.OtherDegree != oldInfo.OtherDegree)
                    {
                        commonDao.InsertLogDetail(logId, "OtherDegree", "Other Degree", oldInfo.OtherDegree, newInfo.OtherDegree);
                        isUpdated = true;
                    }
                    if (newInfo.FirstName != oldInfo.FirstName)
                    {
                        commonDao.InsertLogDetail(logId, "FirstName", "First Name", oldInfo.FirstName, newInfo.FirstName);
                        isUpdated = true;
                    }
                    if (newInfo.VnFirstName != oldInfo.VnFirstName)
                    {
                        commonDao.InsertLogDetail(logId, "VnFirstName", "Vn First Name", oldInfo.VnFirstName, newInfo.VnFirstName);
                        isUpdated = true;
                    }
                    if (newInfo.VnMiddleName != oldInfo.VnMiddleName)
                    {
                        commonDao.InsertLogDetail(logId, "MiddleName", "Vn Middle Name", oldInfo.VnMiddleName, newInfo.VnMiddleName);
                        isUpdated = true;
                    }
                    if (newInfo.VnLastName != oldInfo.VnLastName)
                    {
                        commonDao.InsertLogDetail(logId, "VnLastName", "Vn Last Name", oldInfo.VnLastName, newInfo.VnLastName);
                        isUpdated = true;
                    }
                    if (newInfo.VnPOB != oldInfo.VnPOB)
                    {
                        commonDao.InsertLogDetail(logId, "VnPOB", "Vn Place Of Birth", oldInfo.VnPOB, newInfo.VnPOB);
                        isUpdated = true;
                    }
                    if (newInfo.VnPlaceOfOrigin != oldInfo.VnPlaceOfOrigin)
                    {
                        commonDao.InsertLogDetail(logId, "VnPlaceOfOrigin", "Vn Place Of Origin", oldInfo.VnPlaceOfOrigin, newInfo.VnPlaceOfOrigin);
                        isUpdated = true;
                    }
                    if (newInfo.Degree != oldInfo.Degree)
                    {
                        commonDao.InsertLogDetail(logId, "Degree", "Degree", oldInfo.Degree, newInfo.Degree);
                        isUpdated = true;
                    }
                    if (newInfo.Race != oldInfo.Race)
                    {
                        commonDao.InsertLogDetail(logId, "Race", "Race", oldInfo.Race, newInfo.Race);
                        isUpdated = true;
                    }
                    if (newInfo.IDIssueLocation != oldInfo.IDIssueLocation)
                    {
                        commonDao.InsertLogDetail(logId, "IDIssueLocation", "Issue Location", oldInfo.IDIssueLocation, newInfo.IDIssueLocation);
                        isUpdated = true;
                    }
                    if (newInfo.VnIDIssueLocation != oldInfo.VnIDIssueLocation)
                    {
                        commonDao.InsertLogDetail(logId, "VnIDIssueLocation", "Vn Issue Location", oldInfo.VnIDIssueLocation, newInfo.VnIDIssueLocation);
                        isUpdated = true;
                    }
                    if (newInfo.TaxID != oldInfo.TaxID)
                    {
                        commonDao.InsertLogDetail(logId, "TaxID", "TaxID", oldInfo.TaxID, newInfo.TaxID);
                        isUpdated = true;
                    }
                    if (newInfo.TaxIssueDate != oldInfo.TaxIssueDate)
                    {
                        commonDao.InsertLogDetail(logId, "TaxIssueDate", "Tax Issue Date", oldInfo.TaxIssueDate.HasValue ? oldInfo.TaxIssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW) : "", newInfo.TaxIssueDate.HasValue ? newInfo.TaxIssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW) : "");
                        isUpdated = true;
                    }
                    if (newInfo.SocialInsuranceNo != oldInfo.SocialInsuranceNo)
                    {
                        commonDao.InsertLogDetail(logId, "SocialInsuranceNo", "Social Insurance Book No", oldInfo.SocialInsuranceNo, newInfo.SocialInsuranceNo);
                        isUpdated = true;
                    }
                    if (newInfo.InsuranceHospitalID != oldInfo.InsuranceHospitalID)
                    {
                            commonDao.InsertLogDetail(logId, "InsuranceHospitalID", "Health Insurance Hospital", !string.IsNullOrEmpty(oldInfo.InsuranceHospitalID)?oldInfo.InsuranceHospital.Name:"",string.IsNullOrEmpty(newInfo.InsuranceHospitalID)?"":new InsuranceHospitalDao().GetById(newInfo.InsuranceHospitalID).Name);
                            isUpdated = true;
                    }
                    if (newInfo.VnPermanentAddress != oldInfo.VnPermanentAddress)
                    {
                        commonDao.InsertLogDetail(logId, "VnPermanentAddress", "Vn Permanent Address", oldInfo.VnPermanentAddress, newInfo.VnPermanentAddress);
                        isUpdated = true;
                    }
                    if (newInfo.VnPermanentArea != oldInfo.VnPermanentArea)
                    {
                        commonDao.InsertLogDetail(logId, "VnPermanentArea", "Vn Permanent Area", oldInfo.VnPermanentArea, newInfo.VnPermanentArea);
                        isUpdated = true;
                    }
                    if (newInfo.VnPermanentDistrict != oldInfo.VnPermanentDistrict)
                    {
                        commonDao.InsertLogDetail(logId, "VnPermanentDistrict", "Vn Permanent District", oldInfo.VnPermanentDistrict, newInfo.VnPermanentDistrict);
                        isUpdated = true;
                    }
                    if (newInfo.VnPermanentCityProvince != oldInfo.VnPermanentCityProvince)
                    {
                        commonDao.InsertLogDetail(logId, "VnPermanentCityProvince", "Vn Permanent City Province", oldInfo.VnPermanentCityProvince, newInfo.VnPermanentCityProvince);
                        isUpdated = true;
                    }
                    if (newInfo.VnPermanentCountry != oldInfo.VnPermanentCountry)
                    {
                        commonDao.InsertLogDetail(logId, "VnPermanentCountry", "Vn Permanent Country", oldInfo.VnPermanentCountry, newInfo.VnPermanentCountry);
                        isUpdated = true;
                    }
                    if (newInfo.VnTempAddress != oldInfo.VnTempAddress)
                    {
                        commonDao.InsertLogDetail(logId, "VnTempAddress", "Vn Temp Address", oldInfo.VnTempAddress, newInfo.VnTempAddress);
                        isUpdated = true;
                    }
                    if (newInfo.VnTempArea != oldInfo.VnTempArea)
                    {
                        commonDao.InsertLogDetail(logId, "VnTempArea", "Vn Temp Area", oldInfo.VnTempArea, newInfo.VnTempArea);
                        isUpdated = true;
                    }
                    if (newInfo.VnTempCityProvince != oldInfo.VnTempCityProvince)
                    {
                        commonDao.InsertLogDetail(logId, "VnTempCityProvince", "Vn Temp City Province", oldInfo.VnTempCityProvince, newInfo.VnTempCityProvince);
                        isUpdated = true;
                    }
                    if (newInfo.VnTempCountry != oldInfo.VnTempCountry)
                    {
                        commonDao.InsertLogDetail(logId, "VnTempCountry", "Vn Temp Country", oldInfo.VnTempCountry, newInfo.VnTempCountry);
                        isUpdated = true;
                    }
                    if (newInfo.Gender != oldInfo.Gender)
                    {
                        commonDao.InsertLogDetail(logId, "Gender", "Gender",oldInfo.Gender.HasValue?(oldInfo.Gender == Constants.MALE ? "Male" : "Famale"):"", newInfo.Gender.HasValue?(newInfo.Gender == Constants.MALE ? "Male" : "Famale"):"");
                        isUpdated = true;
                    }
                    if (newInfo.StartDate != oldInfo.StartDate)
                    {
                        commonDao.InsertLogDetail(logId, "StartDate", "Start Date", oldInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW));
                        isUpdated = true;
                    }
                    if (newInfo.ContractedDate != oldInfo.ContractedDate)
                    {
                        commonDao.InsertLogDetail(logId, "ContractedDate", "Contracted Date",oldInfo.ContractedDate.HasValue?oldInfo.ContractedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.ContractedDate.HasValue?newInfo.ContractedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"");
                        isUpdated = true;
                    }
                    if (newInfo.Photograph != oldInfo.Photograph)
                    {
                        commonDao.InsertLogDetail(logId, "Photograph", "Photograph", oldInfo.Photograph, newInfo.Photograph);
                        isUpdated = true;
                    }
                    if (newInfo.JR != oldInfo.JR)
                    {
                        commonDao.InsertLogDetail(logId, "JobRequest", "Job Request", oldInfo.JR, newInfo.JR);
                        isUpdated = true;
                    }
                    if (newInfo.JRApproval != oldInfo.JRApproval)
                    {
                        commonDao.InsertLogDetail(logId, "JobRequestApproval", "Job Request Approval", oldInfo.JRApproval, newInfo.JRApproval);
                        isUpdated = true;
                    }
                    if (newInfo.TempAddress != oldInfo.TempAddress)
                    {
                        commonDao.InsertLogDetail(logId, "TempAddress", "Temp Address", oldInfo.TempAddress, newInfo.TempAddress);
                        isUpdated = true;
                    }
                    if (newInfo.TempArea != oldInfo.TempArea)
                    {
                        commonDao.InsertLogDetail(logId, "TempArea", "Temp Area", oldInfo.TempArea, newInfo.TempArea);
                        isUpdated = true;
                    }
                    if (newInfo.TempDistrict != oldInfo.TempDistrict)
                    {
                        commonDao.InsertLogDetail(logId, "TempDistrict", "Temp District", oldInfo.TempDistrict, newInfo.TempDistrict);
                        isUpdated = true;
                    }
                    if (newInfo.TempCityProvince != oldInfo.TempCityProvince)
                    {
                        commonDao.InsertLogDetail(logId, "TempCityProvince", "Temp City Province", oldInfo.TempCityProvince, newInfo.TempCityProvince);
                        isUpdated = true;
                    }
                    if (newInfo.TempCountry != oldInfo.TempCountry)
                    {
                        commonDao.InsertLogDetail(logId, "TempCountry", "Temp Country", oldInfo.TempCountry, newInfo.TempCountry);
                        isUpdated = true;
                    }
                    if (newInfo.PermanentAddress != oldInfo.PermanentAddress)
                    {
                        commonDao.InsertLogDetail(logId, "PermanentAddress", "Permanent Address", oldInfo.PermanentAddress, newInfo.PermanentAddress);
                        isUpdated = true;
                    }
                    if (newInfo.PermanentArea != oldInfo.PermanentArea)
                    {
                        commonDao.InsertLogDetail(logId, "PermanentArea", "Permanent Ward", oldInfo.PermanentArea, newInfo.PermanentArea);
                        isUpdated = true;
                    }
                    if (newInfo.PermanentDistrict != oldInfo.PermanentDistrict)
                    {
                        commonDao.InsertLogDetail(logId, "PermanentDistrict", "Permanent District", oldInfo.PermanentDistrict, newInfo.PermanentDistrict);
                        isUpdated = true;
                    }
                    if (newInfo.PermanentCityProvince != oldInfo.PermanentCityProvince)
                    {
                        commonDao.InsertLogDetail(logId, "PermanentCityProvince", "Permanent City Province", oldInfo.PermanentCityProvince, newInfo.PermanentCityProvince);
                        isUpdated = true;
                    }
                    if (newInfo.PermanentCountry != oldInfo.PermanentCountry)
                    {
                        commonDao.InsertLogDetail(logId, "PermanentCountry", "PermanentCountry ", oldInfo.PermanentCountry, newInfo.PermanentCountry);
                        isUpdated = true;
                    }
                    if (newInfo.HomePhone != oldInfo.HomePhone)
                    {
                        commonDao.InsertLogDetail(logId, "HomePhone", "Home Phone", oldInfo.HomePhone, newInfo.HomePhone);
                        isUpdated = true;
                    }
                    if ( newInfo.CellPhone != oldInfo.CellPhone)
                    {
                        commonDao.InsertLogDetail(logId, "CellPhone", "Cell Phone", oldInfo.CellPhone, newInfo.CellPhone);
                        isUpdated = true;
                    }
                    if (newInfo.PersonalEmail != oldInfo.PersonalEmail)
                    {
                        commonDao.InsertLogDetail(logId, "PersonalEmail", "Personal Email", oldInfo.PersonalEmail, newInfo.PersonalEmail);
                        isUpdated = true;
                    }
                    if (newInfo.OfficeEmail != oldInfo.OfficeEmail)
                    {
                        commonDao.InsertLogDetail(logId, "OfficeEmail", "Office Email", oldInfo.OfficeEmail, newInfo.OfficeEmail);
                        isUpdated = true;
                    }
                    if (newInfo.ExtensionNumber != oldInfo.ExtensionNumber)
                    {
                        commonDao.InsertLogDetail(logId, "ExtensionNumber", "Extension Number", oldInfo.ExtensionNumber, newInfo.ExtensionNumber);
                        isUpdated = true;
                    }
                    if (newInfo.DOB != oldInfo.DOB)
                    {
                        commonDao.InsertLogDetail(logId, "DOB", "Date Of Birth",oldInfo.DOB.HasValue?oldInfo.DOB.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.DOB.HasValue?newInfo.DOB.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"");
                        isUpdated = true;
                    }
                    if (newInfo.POB != oldInfo.POB)
                    {
                        commonDao.InsertLogDetail(logId, "POB", "Place Of Birth", oldInfo.POB, newInfo.POB);
                        isUpdated = true;
                    }
                    if (newInfo.Nationality != oldInfo.Nationality)
                    {
                        commonDao.InsertLogDetail(logId, "Nationality", "Nationality", oldInfo.Nationality, newInfo.Nationality);
                        isUpdated = true;
                    }
                    if (newInfo.PlaceOfOrigin != oldInfo.PlaceOfOrigin)
                    {
                        commonDao.InsertLogDetail(logId, "PlaceOfOrigin", "Place Of Origin", oldInfo.PlaceOfOrigin, newInfo.PlaceOfOrigin);
                        isUpdated = true;
                    }
                    if (newInfo.IssueDate != oldInfo.IssueDate)
                    {
                        commonDao.InsertLogDetail(logId, "IssueDate", "Issue Date",oldInfo.IssueDate.HasValue?oldInfo.IssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.IssueDate.HasValue? newInfo.IssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"");
                        isUpdated = true;
                    }
                    if (newInfo.BankAccount != oldInfo.BankAccount)
                    {
                        commonDao.InsertLogDetail(logId, "BankAccount", "Bank Account", oldInfo.BankAccount, newInfo.BankAccount);
                        isUpdated = true;
                    }
                    if (newInfo.BankName != oldInfo.BankName)
                    {
                        commonDao.InsertLogDetail(logId, "BankName", "Bank Name", oldInfo.BankName, newInfo.BankName);
                        isUpdated = true;
                    }
                    if (newInfo.ResignedDate != oldInfo.ResignedDate)
                    {
                        commonDao.InsertLogDetail(logId, "ResignedDate", "Resigned Date", oldInfo.ResignedDate.HasValue?oldInfo.ResignedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.ResignedDate.HasValue?newInfo.ResignedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"");
                        isUpdated = true;
                    }
                    if (newInfo.ResignedReason != oldInfo.ResignedReason)
                    {
                        commonDao.InsertLogDetail(logId, "ResignedReason", "Resigned Reason", oldInfo.ResignedReason, newInfo.ResignedReason);
                        isUpdated = true;
                    }
                    if (newInfo.ResignedAllowance != oldInfo.ResignedAllowance)
                    {
                        commonDao.InsertLogDetail(logId, "ResignedAllowance", "Resigned Allowance", oldInfo.ResignedAllowance.HasValue?oldInfo.ResignedAllowance.ToString():"", newInfo.ResignedAllowance.HasValue?newInfo.ResignedAllowance.ToString():"");
                        isUpdated = true;
                    }
                    if (newInfo.LaborUnion != oldInfo.LaborUnion)
                    {
                        commonDao.InsertLogDetail(logId, "LaborUnion", "Labor Union",oldInfo.LaborUnion.HasValue?(oldInfo.LaborUnion.Value == Constants.LABOR_UNION_FALSE ? "No" : "Yes"):"",newInfo.LaborUnion.HasValue?(newInfo.LaborUnion.Value == Constants.LABOR_UNION_FALSE ? "No" : "Yes"):"");
                        isUpdated = true;
                    }
                    if (newInfo.LaborUnionDate != oldInfo.LaborUnionDate)
                    {
                        commonDao.InsertLogDetail(logId, "LaborUnionDate", "Labor Union Date", oldInfo.LaborUnionDate.HasValue ? oldInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW) : "",newInfo.LaborUnionDate.HasValue?newInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"");
                        isUpdated = true;
                    }
                    if (newInfo.Remarks != oldInfo.Remarks)
                    {
                        commonDao.InsertLogDetail(logId, "Remarks", "Remarks", oldInfo.Remarks, newInfo.Remarks);
                        isUpdated = true;
                    }
                    if (newInfo.MarriedStatus != oldInfo.MarriedStatus)
                    {
                        commonDao.InsertLogDetail(logId, "Married Status", "Married Status",oldInfo.MarriedStatus.HasValue?(oldInfo.MarriedStatus == Constants.SINGLE ? "Single" : "Married"):"",newInfo.MarriedStatus.HasValue?(newInfo.MarriedStatus == Constants.SINGLE ? "Single" : "Married"):"");
                        isUpdated = true;
                    }
                    if (newInfo.Religion != oldInfo.Religion)
                    {
                        commonDao.InsertLogDetail(logId, "Religion", "Religion", oldInfo.Religion, newInfo.Religion);
                        isUpdated = true;
                    }
                    if (newInfo.EmergencyContactName != oldInfo.EmergencyContactName)
                    {
                        commonDao.InsertLogDetail(logId, "EmergencyContactName", "Emergency Contact Name", oldInfo.EmergencyContactName, newInfo.EmergencyContactName);
                        isUpdated = true;
                    }
                    if (newInfo.EmergencyContactPhone != oldInfo.EmergencyContactPhone)
                    {
                        commonDao.InsertLogDetail(logId, "EmergencyContactPhone", "Emergency Contact Phone", oldInfo.EmergencyContactPhone, newInfo.EmergencyContactPhone);
                        isUpdated = true;
                    }
                    if (newInfo.EmergencyContactRelationship != oldInfo.EmergencyContactRelationship)
                    {
                        commonDao.InsertLogDetail(logId, "EmergencyContactRelationship", "Emergency Contact Relationship", oldInfo.EmergencyContactRelationship, newInfo.EmergencyContactRelationship);
                        isUpdated = true;
                    }
                    if (newInfo.TitleId != oldInfo.TitleId)
                    {
                        JobTitleLevelDao titleDao = new JobTitleLevelDao();
                        JobTitleLevel objTitle = titleDao.GetById(newInfo.TitleId);
                        if (objTitle != null)
                        {
                            commonDao.InsertLogDetail(logId, "TitleId", "Job Title", oldInfo.JobTitleLevel.DisplayName, objTitle.DisplayName);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.DepartmentId != oldInfo.DepartmentId)
                    {
                        DepartmentDao departDao = new DepartmentDao();
                        Department objDepart = departDao.GetById(newInfo.DepartmentId);
                        if (objDepart != null)
                        {
                            commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", oldInfo.Department.DepartmentName, objDepart.DepartmentName);
                            commonDao.InsertLogDetail(logId, "Department", "Department", new DepartmentDao().GetDepartmentNameBySub(oldInfo.DepartmentId), new DepartmentDao().GetDepartmentNameBySub(newInfo.DepartmentId));
                            isUpdated = true;
                        }
                    }
                    if (newInfo.SkypeId != oldInfo.SkypeId)
                    {
                        commonDao.InsertLogDetail(logId, "SkypeId", "SkypeId", oldInfo.SkypeId, newInfo.SkypeId);
                        isUpdated = true;
                    }
                    if (newInfo.YahooId != oldInfo.YahooId)
                    {
                        commonDao.InsertLogDetail(logId, "YahooId", "YahooId", oldInfo.YahooId, newInfo.YahooId);
                        isUpdated = true;
                    }
                    if (newInfo.LocationCode != oldInfo.LocationCode)
                    {
                        commonDao.InsertLogDetail(logId, "LocationCode", "LocationCode", CommonFunc.GenerateStringOfLocation(oldInfo.LocationCode), CommonFunc.GenerateStringOfLocation(newInfo.LocationCode));
                        isUpdated = true;
                    }
                    if (newInfo.CVFile != oldInfo.CVFile)
                    {
                        commonDao.InsertLogDetail(logId, "CVFile", "CVFile", oldInfo.CVFile, newInfo.CVFile);
                        isUpdated = true;
                    }
                    if (newInfo.EmpStatusId != oldInfo.EmpStatusId)
                    {
                        commonDao.InsertLogDetail(logId, "EmpStatusId", "Employee Status",oldInfo.EmpStatusId.HasValue?oldInfo.EmployeeStatus.StatusName:"",newInfo.EmpStatusId.HasValue?new EmployeeStatusDao().GetById(newInfo.EmpStatusId.Value).StatusName:"");
                        isUpdated = true;
                    }
                    if (newInfo.Project != oldInfo.Project)
                    {
                        commonDao.InsertLogDetail(logId, "Project", "Project", oldInfo.Project, newInfo.Project);
                        isUpdated = true;
                    }
                    if (newInfo.ManagerId != oldInfo.ManagerId)
                    {
                        commonDao.InsertLogDetail(logId, "Manager", "Manager", oldInfo.ManagerId, newInfo.ManagerId);
                        isUpdated = true;
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]";
                        commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return isUpdated;
        }
Ejemplo n.º 4
0
 public List<Employee> Sort(List<Employee> empList, string sortColumn, string sortOrder)
 {
     int order;
     DepartmentDao depDao=new DepartmentDao ();
     if (sortOrder == "desc")
     {
         order = -1;
     }
     else
     {
         order = 1;
     }
     switch (sortColumn)
     {
         case "ID":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  { return m1.ID.CompareTo(m2.ID) * order; });
             break;
         case "DisplayName":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  {
                      return CommonFunc.GetEmployeeFullName(m1, Constants.FullNameFormat.FirstMiddleLast).
                      CompareTo(CommonFunc.GetEmployeeFullName(m2, Constants.FullNameFormat.FirstMiddleLast))
                      * order;
                  });
             break;
         case "DirectManager":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  {
                      string displayname1 = "";
                      string displayname2 = "";
                      if (!string.IsNullOrEmpty(m1.ManagerId))
                      {
                          //Employee emp1 = GetById(m1.ManagerId);
                          //if (emp1 != null)
                          //{
                          displayname1 = dbContext.GetEmployeeFullName(m1.ManagerId, (int)Constants.FullNameFormat.FirstMiddleLast);
                          //}
                      }
                      if (!string.IsNullOrEmpty(m2.ManagerId))
                      {
                          //Employee emp2 = GetById(m2.ManagerId);
                          //if (emp2 != null)
                          //{
                          displayname2 = dbContext.GetEmployeeFullName(m2.ManagerId, (int)Constants.FullNameFormat.FirstMiddleLast);
                          //}
                      }
                      return displayname1.CompareTo(displayname2) * order;
                  });
             break;
         case "Project":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  {
                      string project1 = string.IsNullOrEmpty(m1.Project) ? "" : m1.Project;
                      string project2 = string.IsNullOrEmpty(m2.Project) ? "" : m2.Project;
                      return project1.CompareTo(project2) * order;
                  });
             break;
         case "SeatCode":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  {
                      string st1 = string.IsNullOrEmpty(m1.SeatCode) ? "" : m1.SeatCode;
                      string st2 = string.IsNullOrEmpty(m2.SeatCode) ? "" : m2.SeatCode;
                      return st1.CompareTo(st2) * order;
                  });
             break;
         case "Floor":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  {
                      string f1 = string.IsNullOrEmpty(m1.Floor) ? "" : m1.Floor;
                      string f2 = string.IsNullOrEmpty(m2.Floor) ? "" : m2.Floor;
                      return f1.CompareTo(f2) * order;
                  });
             break;
         case "NextReviewDate":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  {
                      DateTime? date1 = GetNextReviewDate(m1.ID);
                      DateTime? date2 = GetNextReviewDate(m2.ID);
                      if (!date1.HasValue)
                          date1 = DateTime.MinValue;
                      if (!date2.HasValue)
                          date2 = DateTime.MinValue;
                      return date1.Value.CompareTo(date2.Value) * order;
                  });
             break;
         case "Department":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  {
                      string d1 = depDao.GetById(m1.Department.ParentId.Value).DepartmentName;
                      string d2 = depDao.GetById(m2.Department.ParentId.Value).DepartmentName;
                      return d1.CompareTo(d2) * order;
                  });
             break;
         case "LoginName":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  {
                      string s1 = CommonFunc.GetLoginNameByEmail(m1.OfficeEmail);
                      string s2 = CommonFunc.GetLoginNameByEmail(m2.OfficeEmail);
                      return s1.CompareTo(s2) * order;
                  });
             break;
         case "ManagerLoginName":
             empList.Sort(
                  delegate(Employee m1, Employee m2)
                  {
                      string s1 = CommonFunc.GetLoginNameByEmail(m1.Employee1.OfficeEmail);
                      string s2 = CommonFunc.GetLoginNameByEmail(m2.Employee1.OfficeEmail);
                      return s1.CompareTo(s2) * order;
                  });
             break;
     }
     return empList;
 }
Ejemplo n.º 5
0
        // Hung.bui 10-01-2012
        public IQueryable<Employee> GetQueryListEnglishCourseAttendees(string text, int titleId, int departmentId, int managerId)
        {
            if (text.Equals(Constants.TRAINING_EEI_TXT_KEYWORD_LABEL))
                text = string.Empty;

            var sql = from e in dbContext.Employees
                      select e;
            text = text.Trim();
            text = CommonFunc.GetFilterText(text);

            if (text != string.Empty)
                sql = sql.Where(e => SqlMethods.Like((e.FirstName + (e.MiddleName != null ? "%" + e.MiddleName + "%" : "%") + e.LastName), text)
                    || SqlMethods.Like(e.ID, text)
                    || SqlMethods.Like(e.OfficeEmail, "%" + text + "%@%"));
            if (titleId > 0)
                sql = sql.Where(e => e.TitleId == ConvertUtil.ConvertToInt(titleId));
            if (managerId > 0)
                sql = sql.Where(e => e.ManagerId == managerId.ToString());
            sql = sql.Where(e => e.DeleteFlag == false);

            if (departmentId > 0)
            {
                DepartmentDao depDao = new DepartmentDao();
                List<sp_GetDepartmentRootResult> subDepartmentList = dbContext.sp_GetDepartmentRoot(departmentId).ToList();
                if (subDepartmentList.Count > 0)
                {
                    List<int> subDepartmentIds = new List<int>();
                    foreach (sp_GetDepartmentRootResult d in subDepartmentList)
                        subDepartmentIds.Add(d.DepartmentId);

                    sql = sql.Where(e => subDepartmentIds.Contains(e.DepartmentId));
                }
                else
                {
                    sql = sql.Where(e => e.DepartmentId == departmentId);
                }
            }

            return sql;
        }
Ejemplo n.º 6
0
        public List<sp_GetPositionResult> Sort(List<sp_GetPositionResult> empList, string sortColumn, string sortOrder)
        {
            int order;
            DepartmentDao depDao = new DepartmentDao();
            JobTitleLevelDao levelDao = new JobTitleLevelDao();
            if (sortOrder == "desc")
            {
                order = -1;
            }
            else
            {
                order = 1;
            }
            switch (sortColumn)
            {
                case "ID":
                    empList.Sort(
                         delegate(sp_GetPositionResult m1, sp_GetPositionResult m2)
                         { return m1.ID.CompareTo(m2.ID) * order; });
                    break;
                case "DisplayName":
                    empList.Sort(
                         delegate(sp_GetPositionResult m1, sp_GetPositionResult m2)
                         {
                             return m1.FullName.CompareTo(m2.FullName)
                             * order;
                         });
                    break;
                case "JobTitle":
                    empList.Sort(
                         delegate(sp_GetPositionResult m1, sp_GetPositionResult m2)
                         {
                             string sTitle1 = m1.TitleId.HasValue ? levelDao.GetById(m1.TitleId.Value).DisplayName : "";
                             string sTitle2 = m2.TitleId.HasValue ? levelDao.GetById(m2.TitleId.Value).DisplayName : "";
                             return sTitle1.CompareTo(sTitle2) * order;
                         });
                    break;
                case "DirectManager":
                    empList.Sort(
                         delegate(sp_GetPositionResult m1, sp_GetPositionResult m2)
                         {
                             string displayname1 = "";
                             string displayname2 = "";
                             if (!string.IsNullOrEmpty(m1.ManagerId))
                             {
                                 //Employee emp1 = GetById(m1.ManagerId);
                                 //if (emp1 != null)
                                 //{
                                 displayname1 = dbContext.GetEmployeeFullName(m1.ManagerId, (int)Constants.FullNameFormat.FirstMiddleLast);
                                 //}
                             }
                             if (!string.IsNullOrEmpty(m2.ManagerId))
                             {
                                 //Employee emp2 = GetById(m2.ManagerId);
                                 //if (emp2 != null)
                                 //{
                                 displayname2 = dbContext.GetEmployeeFullName(m2.ManagerId, (int)Constants.FullNameFormat.FirstMiddleLast);
                                 //}
                             }
                             return displayname1.CompareTo(displayname2) * order;
                         });
                    break;
                case "Project":
                    empList.Sort(
                         delegate(sp_GetPositionResult m1, sp_GetPositionResult m2)
                         {
                             string project1 = string.IsNullOrEmpty(m1.Project) ? "" : m1.Project;
                             string project2 = string.IsNullOrEmpty(m2.Project) ? "" : m2.Project;
                             return project1.CompareTo(project2) * order;
                         });
                    break;

                case "NextReviewDate":
                    empList.Sort(
                         delegate(sp_GetPositionResult m1, sp_GetPositionResult m2)
                         {
                             DateTime? date1 = GetNextReviewDate(m1.ID);
                             DateTime? date2 = GetNextReviewDate(m2.ID);
                             if (!date1.HasValue)
                                 date1 = DateTime.MinValue;
                             if (!date2.HasValue)
                                 date2 = DateTime.MinValue;
                             return date1.Value.CompareTo(date2.Value) * order;
                         });
                    break;
            }
            return empList;
        }
Ejemplo n.º 7
0
 public List<sp_GetEmployeesForPRResult> Sort(List<sp_GetEmployeesForPRResult> empList, string sortColumn, string sortOrder)
 {
     int order;
     DepartmentDao depDao = new DepartmentDao();
     if (sortOrder == "desc")
     {
         order = -1;
     }
     else
     {
         order = 1;
     }
     switch (sortColumn)
     {
         case "ID":
             empList.Sort(
                  delegate(sp_GetEmployeesForPRResult m1, sp_GetEmployeesForPRResult m2)
                  { return m1.ID.CompareTo(m2.ID) * order; });
             break;
         case "NextReviewDate":
             empList.Sort(
                  delegate(sp_GetEmployeesForPRResult m1, sp_GetEmployeesForPRResult m2)
                  {
                      DateTime? date1 = GetNextReviewDate(m1.ID);
                      DateTime? date2 = GetNextReviewDate(m2.ID);
                      if (!date1.HasValue)
                          date1 = DateTime.MinValue;
                      if (!date2.HasValue)
                          date2 = DateTime.MinValue;
                      return date1.Value.CompareTo(date2.Value) * order;
                  });
             break;
         case "Department":
             empList.Sort(
                  delegate(sp_GetEmployeesForPRResult m1, sp_GetEmployeesForPRResult m2)
                  {
                      string d1 = depDao.GetDepartmentNameBySub(m1.DepartmentId);
                      string d2 = depDao.GetDepartmentNameBySub(m2.DepartmentId);
                      return d1.CompareTo(d2) * order;
                  });
             break;
         case "LoginName":
             empList.Sort(
                  delegate(sp_GetEmployeesForPRResult m1, sp_GetEmployeesForPRResult m2)
                  {
                      string s1 = FullName(m1.ID, Constants.FullNameFormat.FirstMiddleLast);
                      string s2 = FullName(m2.ID, Constants.FullNameFormat.FirstMiddleLast);
                      return s1.CompareTo(s2) * order;
                  });
             break;
         case "ManagerLoginName":
             empList.Sort(
                  delegate(sp_GetEmployeesForPRResult m1, sp_GetEmployeesForPRResult m2)
                  {
                      string s1 = string.IsNullOrEmpty(m1.ManagerId) ?
                          "" : FullName(m1.ManagerId, Constants.FullNameFormat.FirstMiddleLast);
                      string s2 = string.IsNullOrEmpty(m2.ManagerId) ?
                          "" : FullName(m2.ManagerId, Constants.FullNameFormat.FirstMiddleLast);
                      return s1.CompareTo(s2) * order;
                  });
             break;
     }
     return empList;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Write Update Log For Job Request
        /// </summary>
        /// <param name="newInfo"></param>
        /// <param name="logId"></param>
        /// <returns></returns>
        private bool WriteUpdateLogForJobRequest(JobRequest newInfo, string logId)
        {
            bool isUpdated = false;
            try
            {
                // Get old info
                JobRequest oldInfo = new JobRequestDao().GetById(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.WFStatusID != oldInfo.WFStatusID)
                    {
                        if (newInfo.WFStatusID != 0)
                        {
                            commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new WFStatusDao().GetByID(newInfo.WFStatusID).Name);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.CCList != oldInfo.CCList)
                    {
                        commonDao.InsertLogDetail(logId, "CCList", "CC List", oldInfo.CCList, newInfo.CCList);
                        isUpdated = true;
                    }
                    if (newInfo.RequestTypeId != oldInfo.RequestTypeId)
                    {
                        commonDao.InsertLogDetail(logId, "CCList", "CC List", oldInfo.RequestTypeId == Constants.JR_REQUEST_TYPE_NEW ? "New":"Replace", newInfo.RequestTypeId == Constants.JR_REQUEST_TYPE_NEW ? "New":"Replace");
                        isUpdated = true;
                    }
                    if (newInfo.WFResolutionID != oldInfo.WFResolutionID)
                    {
                        if (newInfo.WFResolutionID != 0)
                        {
                            WFResolution objRes = new ResolutionDao().GetByID(newInfo.WFResolutionID);
                            if (objRes != null)
                            {
                                commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, objRes.Name);
                                isUpdated = true;
                            }
                        }
                    }
                    if (newInfo.RequestDate != oldInfo.RequestDate)
                    {
                        commonDao.InsertLogDetail(logId, "RequestDate", "Request Date", oldInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW));
                        isUpdated = true;
                    }
                    if (newInfo.DepartmentId != oldInfo.DepartmentId)
                    {
                        Department objDepart = new DepartmentDao().GetById(newInfo.DepartmentId);
                        if (objDepart != null)
                        {
                            commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", oldInfo.Department.DepartmentName, objDepart.DepartmentName);
                            commonDao.InsertLogDetail(logId, "Department", "Department", deptDao.GetDepartmentNameBySub(oldInfo.DepartmentId), deptDao.GetDepartmentNameBySub(newInfo.DepartmentId));
                            isUpdated = true;
                        }
                    }
                    //if (newInfo.PositionFrom != oldInfo.PositionFrom)
                    //{
                    //    JobTitleLevel objJobFrom = new JobTitleLevelDao().GetById(newInfo.PositionFrom);
                    //    if (objJobFrom != null)
                    //    {
                    //        commonDao.InsertLogDetail(logId, "PositionFrom", "Position From", oldInfo.JobTitleLevel.DisplayName, objJobFrom.DisplayName);
                    //        isUpdated = true;
                    //    }
                    //}
                    //if (newInfo.PositionTo != oldInfo.PositionTo)
                    //{
                    //    if (newInfo.PositionTo.HasValue)
                    //    {
                    //        JobTitleLevel objJobTo = new JobTitleLevelDao().GetById(newInfo.PositionTo.Value);
                    //        if (objJobTo != null)
                    //        {
                    //            commonDao.InsertLogDetail(logId, "PositionTo", "Position To", oldInfo.PositionTo.HasValue?oldInfo.JobTitleLevel1.DisplayName:"", objJobTo.DisplayName);
                    //            isUpdated = true;
                    //        }
                    //    }
                    //}
                    string oldSalarySuggestionValue = string.IsNullOrEmpty(oldInfo.SalarySuggestion) ? null : EncryptUtil.Decrypt(oldInfo.SalarySuggestion);
                    if (newInfo.SalarySuggestion != oldSalarySuggestionValue)
                    {
                        if (!string.IsNullOrEmpty(newInfo.SalarySuggestion))
                        {
                            commonDao.InsertLogDetail(logId, "SalarySuggestion", "Salary Suggestion", oldInfo.SalarySuggestion, EncryptUtil.Encrypt(newInfo.SalarySuggestion));
                            isUpdated = true;
                        }
                        else
                        {
                            commonDao.InsertLogDetail(logId, "SalarySuggestion", "Salary Suggestion", oldInfo.SalarySuggestion,newInfo.SalarySuggestion);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.AssignRole != oldInfo.AssignRole || newInfo.AssignID != oldInfo.AssignID)
                    {
                        if (newInfo.AssignRole.HasValue)
                        {
                            WFRole obj = new RoleDao().GetByID(newInfo.AssignRole.Value);
                            if (obj != null)
                            {
                                UserAdmin objUserAdmin = new UserAdminDao().GetById(newInfo.AssignID.Value);
                                if (objUserAdmin != null)
                                {
                                    commonDao.InsertLogDetail(logId, "AssignID", "Forward to", oldInfo.UserAdmin1.UserName + " ( " + oldInfo.WFRole.Name + " )", objUserAdmin.UserName + " ( " + obj.Name + " )");
                                    isUpdated = true;
                                }
                            }
                        }
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = Constants.JOB_REQUEST_PREFIX + oldInfo.ID.ToString();
                        commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Update", key, null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return isUpdated;
        }
Ejemplo n.º 9
0
        public ActionResult ListJRInterview(string page, string isOnPopup)
        {
            //// triet.dinh 26-12-2011
            ViewData["SubDepartment"] = new DepartmentDao().GetDepartmentByHierarchy();
            //ViewData["Department"] = new SelectList(new DepartmentDao().GetList(), "DepartmentId", "DepartmentName");
            //ViewData["SubDepartment"] = new SelectList(new DepartmentDao().GetSubList(), "DepartmentId", "DepartmentName");

            ViewData["positionId"] = new SelectList(new JobTitleLevelDao().GetList(), "ID", "DisplayName");
            ViewData["Func"] = page;
            ViewData["RequestType"] = new SelectList(Constants.JR_REQUEST_TYPE, "Value", "Text", string.Empty);
            ViewData["IsOnPopup"] = isOnPopup;
            return View();
        }
Ejemplo n.º 10
0
        public void WriteLogForUpdateCompany(STT newInfo, ELogAction action)
        {
            try
            {
                bool isUpdated = false;
                if (newInfo == null)
                {
                    return;
                }
                MasterLog objMasterLog = new MasterLog();
                string logId = commonDao.UniqueId;
                commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.STT.ToString(), action.ToString());
                STT oldInfo = new STTDao().GetById(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.JR != oldInfo.JR)
                    {
                        commonDao.InsertLogDetail(logId, "JR", "Job Request", oldInfo.JR, newInfo.JR);
                        isUpdated = true;
                    }
                    if (newInfo.Project != oldInfo.Project)
                    {
                        commonDao.InsertLogDetail(logId, "Project", "Project", oldInfo.Project, newInfo.Project);
                        isUpdated = true;
                    }
                    if (newInfo.ManagerId != oldInfo.ManagerId)
                    {
                        commonDao.InsertLogDetail(logId, "Manager", "Manager", oldInfo.ManagerId, newInfo.ManagerId);
                        isUpdated = true;
                    }
                    if (newInfo.JRApproval != oldInfo.JRApproval)
                    {
                        commonDao.InsertLogDetail(logId, "JRApproval", "Job Request Approval", oldInfo.JRApproval, newInfo.JRApproval);
                        isUpdated = true;
                    }
                    if (newInfo.StartDate != oldInfo.StartDate)
                    {
                        commonDao.InsertLogDetail(logId, "StartDate", "Start Date", oldInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW));
                        isUpdated = true;
                    }
                    if (newInfo.ExpectedEndDate != oldInfo.ExpectedEndDate)
                    {
                        commonDao.InsertLogDetail(logId, "ContractedDate", "Contracted Date",oldInfo.ExpectedEndDate.HasValue? oldInfo.ExpectedEndDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.ExpectedEndDate.HasValue? newInfo.ExpectedEndDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"");
                        isUpdated = true;
                    }
                    if (newInfo.DepartmentId != oldInfo.DepartmentId)
                    {
                        Department sub = new DepartmentDao().GetById(newInfo.DepartmentId);
                        commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", oldInfo.Department.DepartmentName, sub.DepartmentName);
                        isUpdated = true;
                    }
                    if (newInfo.LaborUnion != oldInfo.LaborUnion)
                    {
                        commonDao.InsertLogDetail(logId, "LaborUnion", "Labor Union",oldInfo.LaborUnion.HasValue? oldInfo.LaborUnion == true ? "Yes" : "No":"",oldInfo.LaborUnion.HasValue? newInfo.LaborUnion == true ? "Yes" : "No":"");
                        isUpdated = true;
                    }
                    if (newInfo.LaborUnionDate != oldInfo.LaborUnionDate)
                    {
                        commonDao.InsertLogDetail(logId, "LaborUnionDate", "Labor Union date", oldInfo.LaborUnionDate.HasValue ? oldInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW) : "", newInfo.LaborUnionDate.HasValue ? newInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW) : "");
                        isUpdated = true;
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]";
                        commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null);
                    }
                    else
                    {
                        commonDao.DeleteMasterLog(logId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }