Ejemplo n.º 1
0
 private void saveCriticalARInfo(List <string> xlsFilePathList)
 {
     //先清除所有记录。
     AR_Temp.deleteTheARTemp();
     for (int i = 0; i <= xlsFilePathList.Count - 1; i++)
     {
         string excelPath = xlsFilePathList[i];
         //打开文档
         MyExcel myExcel = new MyExcel(excelPath);
         myExcel.openWithoutAlerts();
         Worksheet firstWS = myExcel.getFirstWorkSheetAfterOpen();
         //删除  时间后立即为空的行。
         AttendanceRHelper.clearSheet(firstWS);
         Usual_Excel_Helper uEHelper  = new Usual_Excel_Helper(firstWS);
         string             excelName = Usual_Excel_Helper.getExcelName(excelPath);
         //先获取第4行的最大行列数目。
         int rowMaxIndex = firstWS.UsedRange.Rows.Count;
         int pbMaximum   = rowMaxIndex - 4;
         int pbValue     = 0;
         //0: 表示 lblResult.Visible
         checkNameBGWorker.ReportProgress(0, "lblResult.Visible");
         checkNameBGWorker.ReportProgress(pbMaximum, "pb.Maximum");
         checkNameBGWorker.ReportProgress(pbValue, "pb.Value");
         //lblPrompt.Text = excelName + ": 基本信息采集中...";
         checkNameBGWorker.ReportProgress(0, string.Format(@"lblPrompt.Text={0}: 姓名采集中...", excelName));
         for (int rowIndex = 5; rowIndex <= rowMaxIndex; rowIndex++)
         {
             //偶数行为 时间。
             if (0 == rowIndex % 2)
             {
                 checkNameBGWorker.ReportProgress(pbValue++, "pb.Value");
                 continue;
             }
             //姓名 存于第11列。
             string  name    = uEHelper.getCellContentByRowAndColIndex(rowIndex, 11);
             AR_Temp ar_Temp = new AR_Temp();
             ar_Temp.Attendance_machine_flag = int.Parse(excelName.Substring(excelName.Length - 1, 1));
             ar_Temp.Row_Index  = rowIndex;
             ar_Temp.Job_number = uEHelper.getCellContentByRowAndColIndex(rowIndex, 3);
             ar_Temp.Name       = name;
             /// <summary>
             /// 保存 ATTENDANCE_MACHINE_FLAG,
             ///     row_index,
             ///     job_number,
             ///     name
             /// 至AR_Temp中
             ar_Temp.saveRecord();
             checkNameBGWorker.ReportProgress(pbValue++, "pb.Value");
         }
         myExcel.close();
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private MSG checkExistSameStaffsButDifferentAttendanceMachine(List <String> excelPathList)
        {
            MSG msg = new MSG();
            List <SimpleARInfo> simpleARInfoList = new List <SimpleARInfo>();

            foreach (string excelPath in excelPathList)
            {
                //打开文档
                MyExcel myExcel = new MyExcel(excelPath);
                myExcel.open();
                Worksheet firstWS = myExcel.getFirstWorkSheetAfterOpen();
                //删除  时间为空 的行。
                AttendanceRHelper.clearSheet(firstWS);
                Usual_Excel_Helper uEHelper = new Usual_Excel_Helper(firstWS);

                SimpleARInfo simpleARInfo    = null;
                string       fileNameWithout = DirectoryHelper.getFileNameWithoutSuffix(excelPath);

                int rowMaxIndex = firstWS.UsedRange.Rows.Count;
                for (int rowIndex = 5; rowIndex <= rowMaxIndex; rowIndex++)
                {
                    if (0 == rowIndex % 2)
                    {
                        continue;
                    }
                    //姓名 存于第11列。
                    string name = uEHelper.getCellContentByRowAndColIndex(rowIndex, 11);
                    simpleARInfo = new SimpleARInfo();
                    simpleARInfo.AttendanceMachineFlag = int.Parse(fileNameWithout.Substring(fileNameWithout.Length - 1, 1));
                    simpleARInfo.Name     = name;
                    simpleARInfo.RowIndex = rowIndex;
                    SimpleARInfo sARInfo = simpleARInfoList.Find(x => x.Name == simpleARInfo.Name);
                    if (sARInfo != null)
                    {
                        //存在重复的员工.
                        msg.Msg = string.Format(@"{0} 与 {1} 同名;同一人请汇总为一行,不同人,请姓名相异。", sARInfo.toString(), simpleARInfo.toString());
                        myExcel.close();
                        return(msg);
                    }
                    simpleARInfoList.Add(simpleARInfo);
                }
                myExcel.save();
                myExcel.close();
            }
            msg.Flag = true;
            msg.Msg  = "未发现同名用户";
            return(msg);
        }
Ejemplo n.º 3
0
 private void saveCriticalARInfo(List <String> excelPathList)
 {
     //先清除所有记录。
     AR_Temp.deleteTheARTemp();
     foreach (string excelPath in excelPathList)
     {
         //打开文档
         MyExcel myExcel = new MyExcel(excelPath);
         myExcel.open();
         Worksheet firstWS = myExcel.getFirstWorkSheetAfterOpen();
         //删除  时间后立即为空的行。
         AttendanceRHelper.clearSheet(firstWS);
         Usual_Excel_Helper uEHelper = new Usual_Excel_Helper(firstWS);
         string             fileNameWithoutSuffix = DirectoryHelper.getFileNameWithoutSuffix(excelPath);
         //先获取第4行的最大行列数目。
         int rowMaxIndex = firstWS.UsedRange.Rows.Count;
         pb.Value          = 0;
         pb.Maximum        = rowMaxIndex - 4;
         pb.Visible        = true;
         lblPrompt.Visible = true;
         lblResult.Visible = false;
         lblPrompt.Text    = fileNameWithoutSuffix + ": 基本信息采集中...";
         for (int rowIndex = 5; rowIndex <= rowMaxIndex; rowIndex++)
         {
             if (0 == rowIndex % 2)
             {
                 pb.Value++;
                 continue;
             }
             //姓名 存于第11列。
             string  name    = uEHelper.getCellContentByRowAndColIndex(rowIndex, 11);
             AR_Temp ar_Temp = new AR_Temp();
             ar_Temp.Attendance_machine_flag = int.Parse(fileNameWithoutSuffix.Substring(fileNameWithoutSuffix.Length - 1, 1));
             ar_Temp.Row_Index  = rowIndex;
             ar_Temp.Job_number = uEHelper.getCellContentByRowAndColIndex(rowIndex, 3);
             ar_Temp.Name       = name;
             ar_Temp.saveRecord();
             pb.Value++;
         }
         lblPrompt.Visible = false;
         pb.Visible        = false;
         myExcel.save();
         myExcel.close();
     }
 }