コード例 #1
0
ファイル: EmployeeLogDao.cs プロジェクト: vuchannguyen/lg-py
        /// <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;
        }
コード例 #2
0
ファイル: EmployeeDao.cs プロジェクト: vuchannguyen/lg-py
 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;
 }