Beispiel #1
0
        private void WriteUnsualInfo(List <AttendanceInfo> unsualInfoList, List <PersonInfo> noShowList, Excel.Worksheet sheet)
        {
            int rowIndex = 1;
            int colIndex = 1;

            // unsual attendance
            foreach (var nextInfo in unsualInfoList)
            {
                PersonInfo personInfo = PersonInfoRepo.GetPersonInfo(nextInfo.Name);
                if (personInfo == null)
                {
                    Trace.WriteLine("cannot find " + nextInfo.Name);
                    continue;
                }

                // check if the person has left
                //if (!string.IsNullOrWhiteSpace(personInfo.LeaveDate)
                //    && (personInfo.LeaveDate != "长期"))
                //{
                //    Trace.WriteLine(personInfo.Name + " has left at " + personInfo.LeaveDate);
                //    continue;
                //}

                rowIndex++; // from row #2
                colIndex = 1;

                this.WriteUnsualAttendanceRow(sheet, rowIndex, colIndex, nextInfo, personInfo);
            } // foreach (var nextInfo in unsualInfoList)

            // no show list
            foreach (var nextInfo in noShowList)
            {
                rowIndex++;
                colIndex = 1;

                AttendanceInfo attendanceInfo = new AttendanceInfo(nextInfo.Name, string.Empty, string.Empty, string.Empty, string.Empty);
                attendanceInfo.State = AttendanceState.NoShow;

                this.WriteUnsualAttendanceRow(sheet, rowIndex, colIndex, attendanceInfo, nextInfo);
            } // foreach (var nextInfo in noShowList)
        }
Beispiel #2
0
        private void WriteUnsualAttendanceRow(Excel.Worksheet sheet, int rowIndex, int colIndex,
                                              AttendanceInfo attendanceInfo, PersonInfo personInfo)
        {
            Excel.Range objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "姓名";
            objRange.Value             = attendanceInfo.Name;
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "所属公司";
            objRange.Value             = personInfo != null ? personInfo.Company : string.Empty;
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "项目组";
            objRange.Value             = personInfo != null ? personInfo.BizProject : string.Empty;
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "主管项目经理";
            objRange.Value             = personInfo != null ? personInfo.Manager : string.Empty;
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "所属中心";
            objRange.Value             = personInfo != null ? personInfo.Department : string.Empty;
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "日期";
            objRange.Value             = attendanceInfo.Date.ToShortDateString();
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "上班打卡时间";
            if (attendanceInfo.ArriveTime != DateTime.MinValue)
            {
                objRange.Value = attendanceInfo.ArriveTime.ToShortTimeString();
            }
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "下班打卡时间";
            if (attendanceInfo.LeaveTime != DateTime.MinValue)
            {
                objRange.Value = attendanceInfo.LeaveTime.ToShortTimeString();
            }
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "结算人天";
            objRange.Value             = attendanceInfo.WorkDay.ToString();
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "备注";
            switch (attendanceInfo.State)
            {
            case AttendanceState.Late:
                objRange.Value = "迟到";
                break;

            case AttendanceState.Absent:
                objRange.Value = "旷工";
                break;

            case AttendanceState.Leave:
                objRange.Value = "请假";
                break;

            case AttendanceState.AdditionalRecord:
                objRange.Value = "补录";
                break;

            case AttendanceState.Dimission:
                if (string.IsNullOrWhiteSpace(personInfo.DimissionDate))
                {
                    objRange.Value = "未办理离场手续";     // did not update the status
                }
                else
                {
                    objRange.Value = "已离场";
                }
                break;

            case AttendanceState.NotOnboard:
                objRange.Value = "未入场";
                break;

            case AttendanceState.NoShow:
                objRange.Value = "无考勤记录";
                break;

            default:
                break;
            }
            objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;

            objRange = sheet.Cells[rowIndex, colIndex++];
            //objRange.Value = "Debug";
            //objRange.Value = attendanceInfo.State.ToString();
            //objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
        }