//private void btnStaffStatistic_Click(object sender, EventArgs e) //{ // // Turn off screen updating and displaying alerts // Globals.ThisAddIn.Application.ScreenUpdating = false; // Globals.ThisAddIn.Application.DisplayAlerts = false; // Globals.ThisAddIn.Application.AskToUpdateLinks = false; // try // { // // Person Repository // Excel.Workbook personBook = Globals.ThisAddIn.Application.Workbooks.Open("C:\\data\\外包人员台账.xlsx"); // PersonInfoRepo.GenerateInfoMapByName(personBook); // personBook.Close(); // // filter out person // List<PersonInfo> outsourceList = PersonInfoRepo.GetOnsiteOutsourceList(); // // // this.WriteOutsourceInfo(outsourceList, Globals.ThisAddIn.Application.ActiveSheet); // } // catch (Exception exp) // { // MessageBox.Show(exp.ToString()); // throw; // } // // Turn on screen updating and displaying alerts again // Globals.ThisAddIn.Application.ScreenUpdating = true; // Globals.ThisAddIn.Application.DisplayAlerts = true; // Globals.ThisAddIn.Application.AskToUpdateLinks = true; //} //private void WriteOutsourceInfo(List<PersonInfo> infoList, Excel.Worksheet sheet) //{ // int rowIndex = 1; // int colIndex = 1; // Excel.Range objRange = sheet.Cells[rowIndex, colIndex++]; // objRange.Value = "姓名"; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // objRange.Value = "所属公司"; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // objRange.Value = "项目组"; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // objRange.Value = "所属系统"; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // objRange.Value = "主管项目经理"; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // objRange.Value = "外包形式"; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // objRange.Value = "所属中心"; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // objRange.Value = "备注"; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // foreach (var nextInfo in infoList) // { // rowIndex++; // from row #2 // colIndex = 1; // objRange = sheet.Cells[rowIndex, colIndex++]; // //objRange.Value = "姓名"; // objRange.Value = nextInfo.Name; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // //objRange.Value = "所属公司"; // objRange.Value = nextInfo != null ? nextInfo.Company : string.Empty; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // //objRange.Value = "项目组"; // objRange.Value = nextInfo != null ? nextInfo.Project : string.Empty; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // //objRange.Value = "所属系统"; // objRange.Value = nextInfo != null ? nextInfo.System : string.Empty; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // //objRange.Value = "主管项目经理"; // objRange.Value = nextInfo != null ? nextInfo.Manager : string.Empty; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // //objRange.Value = "外包形式"; // objRange.Value = nextInfo != null ? nextInfo.WorkType : string.Empty; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // //objRange.Value = "所属中心"; // objRange.Value = nextInfo != null ? nextInfo.Department : string.Empty; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // objRange = sheet.Cells[rowIndex, colIndex++]; // //objRange.Value = "备注"; // objRange.Value = string.Empty; // objRange.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; // } //} private void btnWorkLoad_Click(object sender, EventArgs e) { // Turn off screen updating and displaying alerts Globals.ThisAddIn.Application.ScreenUpdating = false; Globals.ThisAddIn.Application.DisplayAlerts = false; Globals.ThisAddIn.Application.AskToUpdateLinks = false; try { // get attendance info OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "请选择考勤数据文件"; dlg.Filter = "excel文件|*.xlsx;*.xls"; dlg.RestoreDirectory = true; if (dlg.ShowDialog() != DialogResult.OK) { return; } Excel.Workbook attendanceBook = Globals.ThisAddIn.Application.Workbooks.Open(dlg.FileName); List <AttendanceInfo> attendanceInfoList = AttendanceUtil.GetAttendanceInfoList(attendanceBook.Worksheets[1]); attendanceBook.Close(); // Person Repository dlg = new OpenFileDialog { Title = "请选择外包人员台账文件", Filter = "excel文件|*.xlsx;*.xls", RestoreDirectory = true }; if (dlg.ShowDialog() != DialogResult.OK) { return; } Excel.Workbook personBook = Globals.ThisAddIn.Application.Workbooks.Open(dlg.FileName); PersonInfoRepo.GenerateInfoMapByName(personBook); personBook.Close(); // filter out dissmissed person AttendanceUtil.FilteroutDissmissedPerson(attendanceInfoList); // get unsual info // invoke this method to set the attendance state List <AttendanceInfo> unsualInfoList = AttendanceUtil.GetUnusalAttendance(attendanceInfoList); // get workload list List <WorkloadInfo> workloadListPerMonth = WorkloadUtil.GetWorklaodListPerMonth(attendanceInfoList); // write to sheet - per month object sheet = Globals.ThisAddIn.Application.Worksheets.Add(); Globals.ThisAddIn.Application.ActiveSheet.Name = "月度统计"; this.WriteWorkLoadPerMonth(workloadListPerMonth, Globals.ThisAddIn.Application.ActiveSheet); // write to sheet - total sheet = Globals.ThisAddIn.Application.Worksheets.Add(); Globals.ThisAddIn.Application.ActiveSheet.Name = "汇总统计"; List <WorkloadInfo> workloadListTotally = WorkloadUtil.GetWorkloadListTotally(workloadListPerMonth); this.WriteWorkLoadTotally(workloadListTotally, Globals.ThisAddIn.Application.ActiveSheet); } catch (Exception exp) { MessageBox.Show(exp.ToString()); throw; } finally { // Turn on screen updating and displaying alerts again Globals.ThisAddIn.Application.ScreenUpdating = true; Globals.ThisAddIn.Application.DisplayAlerts = true; Globals.ThisAddIn.Application.AskToUpdateLinks = true; } }
private void btnAttendanceException_Click(object sender, EventArgs e) { // Turn off screen updating and displaying alerts Globals.ThisAddIn.Application.ScreenUpdating = false; Globals.ThisAddIn.Application.DisplayAlerts = false; Globals.ThisAddIn.Application.AskToUpdateLinks = false; try { Excel.Worksheet activeSheet = Globals.ThisAddIn.Application.ActiveSheet; activeSheet.Name = "考勤异常"; this.DrawUnsualHeader(activeSheet); // select attendance file OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "请选择考勤数据文件"; dlg.Filter = "excel文件|*.xlsx;*.xls"; dlg.RestoreDirectory = true; if (dlg.ShowDialog() != DialogResult.OK) { return; } // get attendance info Excel.Workbook attendanceBook = Globals.ThisAddIn.Application.Workbooks.Open(dlg.FileName); List <AttendanceInfo> attendanceInfoList = AttendanceUtil.GetAttendanceInfoList(attendanceBook.Worksheets[1]); // close files attendanceBook.Close(); // Person Repository // select attendance file dlg = new OpenFileDialog(); dlg.Title = "请选择外包人员台账文件"; dlg.Filter = "excel文件|*.xlsx;*.xls"; dlg.RestoreDirectory = true; if (dlg.ShowDialog() != DialogResult.OK) { return; } Excel.Workbook personBook = Globals.ThisAddIn.Application.Workbooks.Open(dlg.FileName); PersonInfoRepo.GenerateInfoMapByName(personBook); personBook.Close(); // filter out dissmissed person AttendanceUtil.FilteroutDissmissedPerson(attendanceInfoList); // get unsual info List <AttendanceInfo> unsualInfoList = AttendanceUtil.GetUnusalAttendance(attendanceInfoList); // get no show list List <PersonInfo> outsourceList = PersonInfoRepo.GetOnsiteOutsourceList(); List <PersonInfo> noShowList = AttendanceUtil.GetNoShowPersonList(outsourceList, attendanceInfoList); // write unsual record this.WriteUnsualInfo(unsualInfoList, noShowList, activeSheet); } catch (Exception exp) { MessageBox.Show(exp.ToString()); } finally { // Turn on screen updating and displaying alerts again Globals.ThisAddIn.Application.ScreenUpdating = true; Globals.ThisAddIn.Application.DisplayAlerts = true; Globals.ThisAddIn.Application.AskToUpdateLinks = true; } }