Example #1
0
 //单条记录设置隐藏
 void miHidden_Click(object sender, RoutedEventArgs e)
 {
     Model.TB_AthleteInfo selectedAth = dgAthlete.SelectedValue as Model.TB_AthleteInfo;
     try
     {
         if (BLL.TB_Setting.OldPwd == "")
         {
             AddHiddenPwdWindow pwdWindow = new AddHiddenPwdWindow();
             pwdWindow.Owner = Application.Current.MainWindow;
             if (pwdWindow.ShowDialog() == true)
             {
                 athleteBLL.HiddenData(selectedAth.ID.ToString(), true);
                 RefrenshAthleteList();
             }
         }
         else
         {
             athleteBLL.HiddenData(selectedAth.ID.ToString(), true);
             RefrenshAthleteList();
         }
     }
     catch (Exception ee)
     {
         MessageBox.Show("隐藏出错!\r\n" + ee.Message, "系统错误");
     }
 }
Example #2
0
 //显示测试信息
 void miShowTestInfo_Click(object sender, RoutedEventArgs e)
 {
     Model.TB_AthleteInfo selectedAth = dgAthlete.SelectedValue as Model.TB_AthleteInfo;
     DSJL.Modules.Test.ShowTestInfoWindow stiWindow = new Test.ShowTestInfoWindow();
     stiWindow.Owner       = Application.Current.MainWindow;
     stiWindow.AthleteInfo = selectedAth;
     stiWindow.TestManager = testManager.SelectedItem;
     stiWindow.ShowDialog();
 }
Example #3
0
 private void dgAthlete_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (dgAthlete.SelectedIndex >= 0)
     {
         foreach (Model.TB_AthleteInfo athInfo in athleteList)
         {
             athInfo.IsChecked = false;
         }
         Model.TB_AthleteInfo selectedAth = dgAthlete.SelectedItem as Model.TB_AthleteInfo;
         selectedAth.IsChecked = true;
     }
 }
Example #4
0
        /// <summary>
        /// 从数据库里查找测试者信息
        /// </summary>
        /// <param name="athModel"></param>
        /// <returns></returns>
        private Model.TB_AthleteInfo FindAthInfoFromDataBase(Model.TB_AthleteInfo athModel)
        {
            Model.TB_AthleteInfo ath = null;

            DateTime birthday = (DateTime)athModel.Ath_Birthday;
            List <Model.TB_AthleteInfo> athList = athleteInfoBLL.GetModelList("ath_pinyin='" + athModel.Ath_PinYin + "' and ath_sex='" + athModel.Ath_Sex + "' and ath_testdate=#" + athModel.Ath_TestDate.ToString("yyyy-MM-dd") + "# and (format(ath_birthday,'yyyy-MM-dd')='" + birthday.ToString("yyyy-MM-dd") + "' or format(ath_birthday,'yyyy-MM')='" + birthday.ToString("yyyy-MM") + "')");

            if (athList.Count > 0)
            {
                ath = athList[0];
            }

            return(ath);
        }
Example #5
0
 private Model.TB_AthleteInfo CheckAthInfoFromNoCheckedInfoList(List <string> baseData)
 {
     Model.TB_AthleteInfo ath = null;
     for (int i = 0; i < noCheckedAthInfoDict.Count; i++)
     {
         List <string> key = noCheckedAthInfoDict.Keys.ElementAt(i);
         if (key[0] == baseData[0] && key[1] == baseData[1] && key[2] == baseData[2] && key[3] == baseData[3] && key[4] == baseData[4] && key[5] == baseData[5])
         {
             ath = noCheckedAthInfoDict.Values.ElementAt(i);
             break;
         }
     }
     return(ath);
 }
Example #6
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            List <Model.TB_AthleteInfo> selectedAthleteList = athleteList.FindAll(model => model.IsChecked == true);

            if (selectedAthleteList.Count > 0)
            {
                checkedAth        = selectedAthleteList[0];
                this.DialogResult = true;
                this.Close();
            }
            else
            {
                this.DialogResult = false;
                this.Close();
            }
        }
Example #7
0
        //导出人员信息
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            List <Model.TB_AthleteInfo> selectedAthleteList = athleteList.FindAll(model => model.IsChecked == true);

            if (selectedAthleteList.Count == 0)
            {
                MessageBox.Show("请选择要导出的受试者信息!");
                return;
            }
            string fileName;
            string excelName = testManager.SelectedItem.TestName + "的受试者信息";

            if (ShowFileDialogTool.ShowSaveFileDialog(out fileName, ShowFileDialogTool.excelFilter, ShowFileDialogTool.excelExt, excelName))
            {
                string tempFileName = AppDomain.CurrentDomain.BaseDirectory + "\\AppTemplate\\listofnames.xls";
                string[,] contents = new string[selectedAthleteList.Count, 15];
                for (int i = 0; i < selectedAthleteList.Count; i++)
                {
                    Model.TB_AthleteInfo item = selectedAthleteList[i];
                    contents[i, 0]  = item.Ath_TestDate.ToString("yyyy年MM月dd日");
                    contents[i, 1]  = item.Ath_Name;
                    contents[i, 2]  = item.Ath_Sex;
                    contents[i, 3]  = ((DateTime)item.Ath_Birthday).ToString("yyyy年MM月dd日");
                    contents[i, 4]  = item.Ath_Height;
                    contents[i, 5]  = item.Ath_Weight;
                    contents[i, 6]  = item.Ath_Project;
                    contents[i, 7]  = item.Ath_MainProject;
                    contents[i, 8]  = item.Ath_TrainYears;
                    contents[i, 9]  = item.Ath_Level;
                    contents[i, 10] = item.Ath_Team;
                    contents[i, 11] = item.Ath_TestAddress;
                    contents[i, 12] = item.Ath_TestMachine;
                    contents[i, 13] = item.Ath_TestState;
                    contents[i, 14] = item.Ath_Remark;
                }
                try
                {
                    ExcelDao.ExcelUtil.SaveExcelFile(fileName, tempFileName, contents, 1, 3);
                    MessageBox.Show("导出成功!", "系统信息", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ee)
                {
                    MessageBox.Show("导出受试者信息出错!\r\n" + ee.Message, "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Example #8
0
        //单条记录编辑
        void miEdit_Click(object sender, RoutedEventArgs e)
        {
            Model.TB_AthleteInfo selectedAth = dgAthlete.SelectedValue as Model.TB_AthleteInfo;
            if (selectedAth.Hidden != "0")
            {
                MessageBox.Show("该人员信息已被设置为隐藏,请在设置中选择“显示所有数据”后进行编辑", "系统信息");
                return;
            }
            AddOrEditAthlete window = new AddOrEditAthlete();

            window.Athlete = selectedAth;
            window.Owner   = Application.Current.MainWindow;
            if (window.ShowDialog() == true)
            {
                RefrenshAthleteList();
            }
        }
Example #9
0
 //单条记录删除
 void miDelete_Click(object sender, RoutedEventArgs e)
 {
     Model.TB_AthleteInfo selectedAth = dgAthlete.SelectedValue as Model.TB_AthleteInfo;
     if (MessageBox.Show("删除信息将会删除该运动员的测试数据,改变应用该受试者测试数据建立的测试参考值。\r\n删除的信息将不能恢复,请确认要删除选择的信息吗?", "删除受试者信息确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         List <Model.TB_TestInfo> testInfoList = testInfoBLL.GetModelList("ath_id=" + selectedAth.ID);
         DeleteDataFile(testInfoList);
         if (athleteBLL.Delete(selectedAth.ID))
         {
             RefrenshAthleteList();
         }
         else
         {
             MessageBox.Show("删除出错!", "系统错误");
         }
     }
 }
Example #10
0
        /// <summary>
        /// 手动选择人员信息
        /// </summary>
        /// <param name="athModel"></param>
        /// <returns></returns>
        private Model.TB_AthleteInfo FindAthInfoHM(Model.TB_AthleteInfo athModel)
        {
            Model.TB_AthleteInfo ath = null;

            CheckAthWindow checkAthWindow = new CheckAthWindow();

            checkAthWindow.SelectedTestItem = SelectedTestItem;
            checkAthWindow.CurrentAthInfo   = athModel;
            checkAthWindow.Owner            = Application.Current.MainWindow;

            if (checkAthWindow.ShowDialog() == true)
            {
                ath = checkAthWindow.CheckedAth;
            }

            return(ath);
        }
Example #11
0
        private Model.TB_AthleteInfo CheckAthInfo(Model.TB_AthleteInfo athModel)
        {
            Model.TB_AthleteInfo findedAthInfoModel = null;

            bool isExists = false;

            //先从本地查找
            foreach (List <Model.TB_AthleteInfo> aths in localAthInfoList)
            {
                Model.TB_AthleteInfo ath = aths[0];
                if (athModel.Ath_Name == ath.Ath_Name && athModel.Ath_Sex == ath.Ath_Sex && athModel.Ath_Height == ath.Ath_Height && athModel.Ath_Weight == ath.Ath_Weight && athModel.Ath_Birthday == ath.Ath_Birthday && athModel.Ath_TestDate.ToString("yyyyMMdd") == ath.Ath_TestDate.ToString("yyyyMMdd"))
                {
                    isExists           = true;
                    findedAthInfoModel = aths[1];
                    break;
                }
            }
            //本地没有查找到
            if (!isExists)
            {
                if (athModel.Ath_Birthday != null)//根据拼音,性别,测试日期,生日从数据库查找
                {
                    findedAthInfoModel = FindAthInfoFromDataBase(athModel);
                }
                if (findedAthInfoModel == null)   //进入手动模式选择人员
                {
                    if (MessageBox.Show("未找到测试人员信息,是否手动选择受测者?", "系统信息", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        findedAthInfoModel = FindAthInfoHM(athModel);

                        if (MessageBox.Show("是否将同姓名、同出生、同测试日期的其余测试数据全部对应到该受试者?", "系统信息", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                        {
                            List <Model.TB_AthleteInfo> athL = new List <Model.TB_AthleteInfo>()
                            {
                                athModel, findedAthInfoModel
                            };
                            localAthInfoList.Add(athL);
                        }
                    }
                }
            }

            return(findedAthInfoModel);
        }
Example #12
0
        //添加人员信息
        private int AddAthInfo(Model.TB_AthleteInfo athModel)
        {
            int athID = 0;

            bool isExists = false;

            foreach (Model.TB_AthleteInfo ath in athInfoList)
            {
                if (athModel.Ath_Name == ath.Ath_Name && athModel.Ath_Sex == ath.Ath_Sex && athModel.Ath_Height == ath.Ath_Height && athModel.Ath_Weight == ath.Ath_Weight && athModel.Ath_Birthday == ath.Ath_Birthday && athModel.Ath_TestDate.ToString("yyyyMMdd") == ath.Ath_TestDate.ToString("yyyyMMdd"))
                {
                    isExists = true;
                    athID    = ath.ID;
                    break;
                }
            }
            //在本地没有对应的信息,则添加
            if (!isExists)
            {
                string idStr = "";
                try
                {
                    athBLL.Add(athModel, out idStr);
                }
                catch
                {
                    athID = -1;
                }
                if (idStr != "")
                {
                    athID = int.Parse(idStr);
                }
                else
                {
                    athID = athBLL.GetMaxId();
                }
                athModel.ID = athID;
                athInfoList.Add(athModel);
            }

            return(athID);
        }
 private void dgAthlete_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (dgAthlete.SelectedIndex >= 0)
     {
         foreach (Model.TB_AthleteInfo bi in athleteList)
         {
             bi.IsChecked = false;
         }
         if (dgAthlete.SelectedItems.Count > 1)
         {
             foreach (var selectedItem in dgAthlete.SelectedItems)
             {
                 Model.TB_AthleteInfo selectedAth = selectedItem as Model.TB_AthleteInfo;
                 selectedAth.IsChecked = true;
             }
         }
         else
         {
             Model.TB_AthleteInfo selectedAth = dgAthlete.SelectedItem as Model.TB_AthleteInfo;
             selectedAth.IsChecked = true;
         }
     }
 }
Example #14
0
        //编辑
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            List <Model.TB_AthleteInfo> selectedAthleteList = athleteList.FindAll(model => model.IsChecked == true);

            if (selectedAthleteList.Count == 0 || selectedAthleteList.Count > 1)
            {
                MessageBox.Show("请选择一个测试者信息编辑!");
                return;
            }
            Model.TB_AthleteInfo selectedAth = selectedAthleteList[0];
            if (selectedAth.Hidden != "0")
            {
                MessageBox.Show("该人员信息已被设置为隐藏,请在设置中选择“显示所有数据”后进行编辑", "系统信息");
                return;
            }
            AddOrEditAthlete window = new AddOrEditAthlete();

            window.Athlete = selectedAth;
            window.Owner   = Application.Current.MainWindow;
            if (window.ShowDialog() == true)
            {
                RefrenshAthleteList();
            }
        }
Example #15
0
        private void Merge()
        {
            DbHelperOleDb.SetDBPath(tempExtrctorPath + "DSJLDB.mdb");

            DSJL.BLL.TB_AthleteInfo   athBLL         = new BLL.TB_AthleteInfo();
            DSJL.BLL.TB_StandardInfo  standBLL       = new BLL.TB_StandardInfo();
            DSJL.BLL.TB_StandTestRefe refeBLL        = new BLL.TB_StandTestRefe();
            DSJL.BLL.TB_TestInfo      testInfoBLL    = new BLL.TB_TestInfo();
            DSJL.BLL.TB_TestManager   testManagerBLL = new BLL.TB_TestManager();

            List <Model.TB_AthleteInfo>   athList         = athBLL.GetModelList("");
            List <Model.TB_StandardInfo>  standList       = standBLL.GetModelList("");
            List <Model.TB_StandTestRefe> refeList        = refeBLL.GetModelList("");
            List <Model.TB_TestInfo>      testInfoList    = testInfoBLL.GetModelList("");
            List <Model.TB_TestManager>   testManagerList = testManagerBLL.GetModelList("");

            DbHelperOleDb.SetDefaultDBPath();

            Dictionary <int, int> testManagerDict = new Dictionary <int, int>();
            Dictionary <int, int> testInfoDict    = new Dictionary <int, int>();
            Dictionary <int, int> standDict       = new Dictionary <int, int>();
            Dictionary <int, int> athDict         = new Dictionary <int, int>();

            for (int i = 0; i < testManagerList.Count; i++)
            {
                Model.TB_TestManager managerModel = testManagerList[i];
                if (DbHelperOleDb.Exists("TB_TestManager", "TestName", managerModel.TestName))
                {
                    managerModel.TestName = managerModel.TestName + "(1)";
                }
                testManagerBLL.Add(managerModel);
                int newID = testManagerBLL.GetMaxId();
                testManagerDict.Add(managerModel.ID, newID);
                UpdateMergeState(Percent(i + 1, testManagerList.Count), "正在导入测试项目信息...");
            }

            for (int i = 0; i < standList.Count; i++)
            {
                Model.TB_StandardInfo standModel = standList[i];
                if (DbHelperOleDb.Exists("Tb_StandardInfo", "Stand_Name", standModel.Stand_Name))
                {
                    standModel.Stand_Name = standModel.Stand_Name + "(1)";
                }
                standBLL.Add(standModel);
                int newID = standBLL.GetMaxId();
                standDict.Add(standModel.ID, newID);
                UpdateMergeState(Percent(i + 1, standList.Count), "正在导入测试参考值信息...");
            }

            for (int i = 0; i < athList.Count; i++)
            {
                Model.TB_AthleteInfo athModel = athList[i];
                athModel.Ath_TestID = testManagerDict[athModel.Ath_TestID];
                string existID = "";

                int addResult = athBLL.Add(athModel, out existID);
                int newID     = 0;
                switch (addResult)
                {
                case BLL.TB_AthleteInfo.RepeatAdd:
                    newID = int.Parse(existID);
                    break;

                case BLL.TB_AthleteInfo.Success:
                    newID = athBLL.GetMaxId();
                    break;
                }
                athDict.Add(athModel.ID, newID);
                UpdateMergeState(Percent(i + 1, athList.Count), "正在导入受测者信息...");
            }

            for (int i = 0; i < testInfoList.Count; i++)
            {
                Model.TB_TestInfo testInfoModel = testInfoList[i];
                testInfoModel.Ath_ID = athDict[testInfoModel.Ath_ID];
                testInfoBLL.Add(testInfoModel);
                int newID = testInfoBLL.GetMaxId();

                string dataFileFullName = AppPath.XmlDataDirPath + testInfoModel.DataFileName;
                string oldFileName      = testInfoModel.DataFileName;
                if (File.Exists(dataFileFullName))
                {
                    testInfoModel.DataFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".xml";
                }
                File.Copy(tempExtrctorPath + oldFileName, AppPath.XmlDataDirPath + testInfoModel.DataFileName);

                testInfoDict.Add(testInfoModel.ID, newID);
                UpdateMergeState(Percent(i + 1, testInfoList.Count), "正在导入测试信息...");
            }

            for (int i = 0; i < refeList.Count; i++)
            {
                Model.TB_StandTestRefe refeModel = refeList[i];
                refeModel.StandID = standDict[refeModel.StandID];
                refeModel.TestID  = testInfoDict[refeModel.TestID];
                refeBLL.Add(refeModel);
                UpdateMergeState(Percent(i + 1, refeList.Count), "正在重设数据关系...");
            }

            Directory.Delete(tempExtrctorPath, true);

            UpdateMergeState(-2, "数据合并完成");
        }
Example #16
0
        //后台导入
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Model.ImportDataErrorModel errorModel;        //错误模型

            int currentManagerID = AddTestManagerModel(); //添加测试项目

            for (int i = 0; i < choosedFileNames.Length; i++)
            {
                if (importFlag == 1)
                {
                    break;
                }
                if (importFlag == 2)
                {
                    i--;
                    continue;
                }

                string   fileName = choosedFileNames[i];
                string[] contents = File.ReadAllLines(fileName);

                //检查数据文件是否是测试数据文件
                if (!CheckFile(fileName, contents))
                {
                    worker.ReportProgress(i + 1, null);
                    continue;
                }
                else
                {
                    worker.ReportProgress(i + 1, contents);
                }

                string   testDate     = GetLineValue(contents[2]);
                string   testTime     = GetLineValue(contents[3]);
                DateTime testDateTime = DateTime.Now;
                if (testDate != "" && testTime != "")
                {
                    try
                    {
                        testDateTime = Convert.ToDateTime(testDate + " " + testTime, dtPointFormat);
                    }
                    catch {
                        testDateTime = DateTime.Now;
                    }
                }

                //添加人员信息
                Model.TB_AthleteInfo athModel = new Model.TB_AthleteInfo();
                athModel.Ath_PinYin   = athModel.Ath_Name = GetLineValue(contents[4]);
                athModel.Ath_TestID   = currentManagerID;
                athModel.Ath_Sex      = DataUtil.AthleteSexUtil.GetSex(GetLineValue(contents[29]));
                athModel.Ath_TestDate = testDateTime;
                string birthdayStr = GetLineValue(contents[27]);
                if (birthdayStr != "")
                {
                    try
                    {
                        athModel.Ath_Birthday = Convert.ToDateTime(birthdayStr, dtLineFormat);
                    }
                    catch {
                        athModel.Ath_Birthday = DateTime.Now;
                    }
                }
                athModel.Ath_Height = GetLineValue(contents[26]);
                athModel.Ath_Weight = GetLineValue(contents[25]);

                int athID = AddAthInfo(athModel);
                if (athID == -1)
                {//添加失败,继续
                    errorModel             = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "添加人员信息出错";
                    errorModel.FileName    = fileName;
                    errorModelList.Add(errorModel);
                    continue;
                }


                string Gravitycomp  = GetLineValue(contents[31]);
                string dataFileName = "";
                //处理数据文件
                try
                {
                    BaseDataUtil dataUtil = new BaseDataUtil();
                    dataUtil.SmoothValue = (int)smoothValue;
                    dataUtil.Weight      = athModel.Ath_Weight;
                    if (Gravitycomp != "")
                    {
                        dataUtil.Gravitycomp = Gravitycomp;
                    }
                    dataFileName = dataUtil.WriteBaseData(contents);
                }
                catch
                {
                    errorModel             = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "计算出错";
                    errorModel.FileName    = fileName;
                    errorModelList.Add(errorModel);
                    continue;
                }
                //添加到数据库
                try
                {
                    Model.TB_TestInfo testInfoModel = new Model.TB_TestInfo();
                    testInfoModel.Gravitycomp  = Gravitycomp;
                    testInfoModel.DataFileName = dataFileName;
                    testInfoModel.BaseFileName = contents[0].Trim();
                    testInfoModel.Ath_ID       = athID;

                    testInfoModel.TestDate = testInfoModel.TestTime = testDateTime;

                    testInfoModel.Joint_Side      = GetLineValue(contents[5]);
                    testInfoModel.Test_Mode       = GetLineValue(contents[6]);
                    testInfoModel.Joint           = GetLineValue(contents[7]);
                    testInfoModel.Plane           = GetLineValue(contents[8]);
                    testInfoModel.Motion_Start    = GetLineValue(contents[10]);
                    testInfoModel.Motion_End      = GetLineValue(contents[11]);
                    testInfoModel.Speed1          = GetLineValue(contents[12]);
                    testInfoModel.Speed2          = GetLineValue(contents[13]);
                    testInfoModel.Acceleration1   = GetLineValue(contents[14]);
                    testInfoModel.Acceleration2   = GetLineValue(contents[15]);
                    testInfoModel.Break           = GetLineValue(contents[18]);
                    testInfoModel.NOOfSets        = GetLineValue(contents[22]);
                    testInfoModel.NOOfRepetitions = GetLineValue(contents[23]);
                    testInfoModel.InsuredSide     = GetLineValue(contents[28]);
                    testInfoModel.Therapist       = GetLineValue(contents[30]);

                    testInfoBLL.Add(testInfoModel);
                }
                catch
                {
                    errorModel             = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "保存测试信息出错";
                    errorModel.FileName    = fileName;
                    errorModelList.Add(errorModel);
                    continue;
                }
            }
        }
Example #17
0
 private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     List<Model.TB_AthleteInfo> selectedAthleteList = athleteList.FindAll(model => model.IsChecked == true);
     if (selectedAthleteList.Count > 0)
     {
         checkedAth = selectedAthleteList[0];
         this.DialogResult = true;
         this.Close();
     }
     else {
         this.DialogResult = false;
         this.Close();
     }
 }
Example #18
0
        //导入方法
        private void Import(string [] fileNames, bool ischeckRepeate)
        {
            importProgress.Maximum = fileNames.Count();
            importProgress.Minimum = 0;
            importProgress.Value   = 0;
            double value = 0;
            UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(importProgress.SetValue);

            for (int i = 0; i < fileNames.Count(); i++)
            {
                if (importFlag == 1)
                {
                    break;
                }
                if (importFlag == 2)
                {
                    i--;
                    continue;
                }
                value += 1;
                Dispatcher.Invoke(updatePbDelegate,
                                  System.Windows.Threading.DispatcherPriority.Background,
                                  new object[] { ProgressBar.ValueProperty, value });

                Model.ImportDataErrorModel errorModel = null;

                string baseFileName = fileNames[i];

                #region 写入进度
                tbFileName.Text = "文件名:" + baseFileName.Substring(baseFileName.LastIndexOf("\\") + 1);
                tbContent1.Text = "";
                tbContent2.Text = "";
                tbContent3.Text = "";
                tbProgress.Text = (i + 1) + "/" + fileNames.Count();
                #endregion

                #region 读取数据文件信息
                string[] contents = File.ReadAllLines(baseFileName);

                if (!CheckFile(baseFileName, contents))
                {
                    continue;
                }
                for (int a = 0; a < 11; a++)
                {
                    tbContent1.Text += contents[a] + "\r\n";
                    tbContent2.Text += contents[11 + a] + "\r\n";
                    tbContent3.Text += contents[22 + a] + "\r\n";
                }

                string   testDate     = GetLineValue(contents[2]);
                string   testTime     = GetLineValue(contents[3]);
                DateTime testDateTime = DateTime.Now;
                if (testDate != "" && testTime != "")
                {
                    try
                    {
                        testDateTime = Convert.ToDateTime(testDate + " " + testTime, dtPointFormat);
                    }
                    catch {
                        testDateTime = DateTime.Now;
                    }
                }

                Model.TB_AthleteInfo athModel = new Model.TB_AthleteInfo();
                athModel.Ath_PinYin   = athModel.Ath_Name = GetLineValue(contents[4]);
                athModel.Ath_Sex      = DataUtil.AthleteSexUtil.GetSex(GetLineValue(contents[29]));
                athModel.Ath_TestDate = testDateTime;
                string birthdayStr = GetLineValue(contents[27]);
                if (birthdayStr != "")
                {
                    try
                    {
                        athModel.Ath_Birthday = Convert.ToDateTime(birthdayStr, dtLineFormat);
                    }
                    catch {
                        athModel.Ath_Birthday = DateTime.Now;
                    }
                }
                else
                {
                    athModel.Ath_Birthday = null;
                }
                athModel.Ath_Height = GetLineValue(contents[26]);
                athModel.Ath_Weight = GetLineValue(contents[25]);

                Model.TB_AthleteInfo testAthInfoModel = CheckAthInfo(athModel);
                if (testAthInfoModel == null)
                {
                    continue;
                }

                Model.TB_TestInfo testInfo = new Model.TB_TestInfo();
                testInfo.BaseFileName    = contents[0].Trim();
                testInfo.TestTime        = testInfo.TestDate = testDateTime;
                testInfo.Joint_Side      = GetLineValue(contents[5]);
                testInfo.Test_Mode       = GetLineValue(contents[6]);
                testInfo.Joint           = GetLineValue(contents[7]);
                testInfo.Plane           = GetLineValue(contents[8]);
                testInfo.Motion_Start    = GetLineValue(contents[10]);
                testInfo.Motion_End      = GetLineValue(contents[11]);
                testInfo.Speed1          = GetLineValue(contents[12]);
                testInfo.Speed2          = GetLineValue(contents[13]);
                testInfo.Acceleration1   = GetLineValue(contents[14]);
                testInfo.Acceleration2   = GetLineValue(contents[15]);
                testInfo.Break           = GetLineValue(contents[18]);
                testInfo.NOOfSets        = GetLineValue(contents[22]);
                testInfo.NOOfRepetitions = GetLineValue(contents[23]);
                testInfo.InsuredSide     = GetLineValue(contents[28]);
                testInfo.Therapist       = GetLineValue(contents[30]);
                testInfo.Gravitycomp     = GetLineValue(contents[31]);

                testInfo.DataFileName = "";

                testInfo.Ath_ID = testAthInfoModel.ID;
                #endregion

                #region 检查是否重复导入
                if (ischeckRepeate)
                {
                    //检测是否有相同时间的数据导入
                    try
                    {
                        //判断该测试信息是否导入,判断条件 用户ID 测试日期,数据文件名
                        List <Model.TB_TestInfo> existsTestInfoList = testInfoBLL.GetModelList("ath_id=" + testInfo.Ath_ID + " and testdate=#" + testInfo.TestDate + "# and BaseFileName='" + testInfo.BaseFileName + "'");
                        if (existsTestInfoList.Count > 0)//有重复数据
                        {
                            existsIDs += existsTestInfoList[0].ID + ",";
                            Model.ExistsFileModel exFileModel = new Model.ExistsFileModel();
                            exFileModel.FileName = baseFileName;
                            exFileModel.RealName = baseFileName.Substring(baseFileName.LastIndexOf("\\") + 1);
                            existsFiles.Add(exFileModel);
                            continue;
                        }
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show("检查此文件是否导入时出错!\r\n" + ee.Message, "系统错误");
                        errorModel             = new Model.ImportDataErrorModel();
                        errorModel.ErrorString = "3";
                        errorModel.FileName    = baseFileName;
                        errorModelList.Add(errorModel);
                        continue;
                    }
                }
                #endregion

                //导入
                try
                {
                    BaseDataUtil dataUtil = new BaseDataUtil();
                    dataUtil.SmoothValue = (int)smoothValue;
                    dataUtil.Weight      = testAthInfoModel.Ath_Weight;
                    if (testInfo.Gravitycomp.Trim() != "")
                    {
                        dataUtil.Gravitycomp = testInfo.Gravitycomp;
                    }
                    string fileName = dataUtil.WriteBaseData(contents);

                    testInfo.DataFileName = fileName;
                }
                catch (Exception ee)
                {
                    MessageBox.Show("计算出错!\r\n" + ee.Message, "系统错误");
                    errorModel             = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "4";
                    errorModel.FileName    = baseFileName;
                    errorModelList.Add(errorModel);
                    continue;
                }
                //添加到数据库
                try
                {
                    testInfoBLL.Add(testInfo);
                }
                catch (Exception ee)
                {
                    MessageBox.Show("添加测试信息出错,请稍候重试!\r\n" + ee.Message, "系统错误");
                    errorModel             = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "5";
                    errorModel.FileName    = baseFileName;
                    errorModelList.Add(errorModel);
                    continue;
                }
            }

            if (errorModelList.Count > 0)
            {
                tbErrorCount.Text     = errorModelList.Count + "个文件导入错误";
                ErrorPanel.Visibility = Visibility.Visible;
            }

            if (ischeckRepeate)
            {//如果检查重复并且存在重复数据就刷新数据列表
                if (existsFiles.Count > 0)
                {
                    btnReImport.IsEnabled = true;
                    RefrenshDataGridSource();
                }
                else
                {
                    btnReImport.IsEnabled = false;
                }
            }
        }
        //后台导入
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Model.ImportDataErrorModel errorModel;//错误模型

            int currentManagerID = AddTestManagerModel();//添加测试项目

            for (int i = 0; i < choosedFileNames.Length; i++)
            {
                if (importFlag == 1) {
                    break;

                }
                if (importFlag == 2) {
                    i--;
                    continue;
                }

                string fileName = choosedFileNames[i];
                string[] contents = File.ReadAllLines(fileName);

                //检查数据文件是否是测试数据文件
                if (!CheckFile(fileName, contents))
                {
                    worker.ReportProgress(i + 1, null);
                    continue;
                }
                else {
                    worker.ReportProgress(i + 1, contents);
                }

                string testDate = GetLineValue(contents[2]);
                string testTime = GetLineValue(contents[3]);
                DateTime testDateTime = DateTime.Now;
                if (testDate != "" && testTime != "")
                {
                    try
                    {
                        testDateTime = Convert.ToDateTime(testDate + " " + testTime, dtPointFormat);
                    }
                    catch {
                        testDateTime = DateTime.Now;
                    }
                }

                //添加人员信息
                Model.TB_AthleteInfo athModel = new Model.TB_AthleteInfo();
                athModel.Ath_PinYin = athModel.Ath_Name = GetLineValue(contents[4]);
                athModel.Ath_TestID = currentManagerID;
                athModel.Ath_Sex = DataUtil.AthleteSexUtil.GetSex(GetLineValue(contents[29]));
                athModel.Ath_TestDate = testDateTime;
                string birthdayStr = GetLineValue(contents[27]);
                if (birthdayStr != "")
                {
                    try
                    {
                        athModel.Ath_Birthday = Convert.ToDateTime(birthdayStr, dtLineFormat);
                    }
                    catch {
                        athModel.Ath_Birthday = DateTime.Now;
                    }
                }
                athModel.Ath_Height = GetLineValue(contents[26]);
                athModel.Ath_Weight = GetLineValue(contents[25]);

                int athID = AddAthInfo(athModel);
                if (athID == -1)
                {//添加失败,继续
                    errorModel = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "添加人员信息出错";
                    errorModel.FileName = fileName;
                    errorModelList.Add(errorModel);
                    continue;
                }

                string Gravitycomp = GetLineValue(contents[31]);
                string dataFileName = "";
                //处理数据文件
                try
                {
                    BaseDataUtil dataUtil = new BaseDataUtil();
                    dataUtil.SmoothValue = (int)smoothValue;
                    dataUtil.Weight = athModel.Ath_Weight;
                    if (Gravitycomp != "")
                    {
                        dataUtil.Gravitycomp = Gravitycomp;
                    }
                    dataFileName = dataUtil.WriteBaseData(contents);
                }
                catch
                {
                    errorModel = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "计算出错";
                    errorModel.FileName = fileName;
                    errorModelList.Add(errorModel);
                    continue;
                }
                //添加到数据库
                try
                {
                    Model.TB_TestInfo testInfoModel = new Model.TB_TestInfo();
                    testInfoModel.Gravitycomp = Gravitycomp;
                    testInfoModel.DataFileName = dataFileName;
                    testInfoModel.BaseFileName = contents[0].Trim();
                    testInfoModel.Ath_ID = athID;

                    testInfoModel.TestDate = testInfoModel.TestTime = testDateTime;

                    testInfoModel.Joint_Side = GetLineValue(contents[5]);
                    testInfoModel.Test_Mode = GetLineValue(contents[6]);
                    testInfoModel.Joint = GetLineValue(contents[7]);
                    testInfoModel.Plane = GetLineValue(contents[8]);
                    testInfoModel.Motion_Start = GetLineValue(contents[10]);
                    testInfoModel.Motion_End = GetLineValue(contents[11]);
                    testInfoModel.Speed1 = GetLineValue(contents[12]);
                    testInfoModel.Speed2 = GetLineValue(contents[13]);
                    testInfoModel.Acceleration1 = GetLineValue(contents[14]);
                    testInfoModel.Acceleration2 = GetLineValue(contents[15]);
                    testInfoModel.Break = GetLineValue(contents[18]);
                    testInfoModel.NOOfSets = GetLineValue(contents[22]);
                    testInfoModel.NOOfRepetitions = GetLineValue(contents[23]);
                    testInfoModel.InsuredSide = GetLineValue(contents[28]);
                    testInfoModel.Therapist = GetLineValue(contents[30]);

                    testInfoBLL.Add(testInfoModel);
                }
                catch
                {
                    errorModel = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "保存测试信息出错";
                    errorModel.FileName = fileName;
                    errorModelList.Add(errorModel);
                    continue;
                }
            }
        }
Example #20
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text.Trim() == "")
            {
                MessageBox.Show("姓名不能为空!", "系统信息");
                return;
            }
            if (cbTestItems.SelectedIndex < 0)
            {
                MessageBox.Show("请选择测试项目!", "系统信息");
                return;
            }
            if (isEdit)
            {
                try {
                    int updateResult = -1;

                    athlete.Ath_PinYin = DataUtil.PersonNamePinYinUtil.GetNamePinyin(athlete.Ath_Name);
                    if (oldAthInfo.Ath_Name != athlete.Ath_Name || oldAthInfo.Ath_Sex != athlete.Ath_Sex || ((DateTime)oldAthInfo.Ath_Birthday).ToString("yyyy-MM-dd") != ((DateTime)athlete.Ath_Birthday).ToString("yyyy-MM-dd") || ((DateTime)oldAthInfo.Ath_TestDate).ToString("yyyy-MM-dd") != ((DateTime)athlete.Ath_TestDate).ToString("yyyy-MM-dd"))
                    {
                        updateResult = athleteBLL.Update(athlete, true);
                    }
                    else
                    {
                        updateResult = athleteBLL.Update(athlete);
                    }
                    switch (updateResult)
                    {
                    case BLL.TB_AthleteInfo.Success:
                        this.DialogResult = true;
                        this.Close();
                        break;

                    case BLL.TB_AthleteInfo.RepeatAdd:
                        MessageBox.Show("因已存在相同的人员信息,编辑失败,请确认!", "系统错误");
                        break;

                    case BLL.TB_AthleteInfo.Error:
                        MessageBox.Show("修改信息时出错,请重试!\r\n如果问题一直存在,或联系软件制作者。", "系统错误");
                        break;
                    }
                }
                catch (Exception ee) {
                    MessageBox.Show("编辑失败\r\n" + ee.Message, "系统错误");
                }
            }
            else
            {
                try
                {
                    athlete.Ath_PinYin = DataUtil.PersonNamePinYinUtil.GetNamePinyin(athlete.Ath_Name);
                    string existID   = "";
                    int    addResult = athleteBLL.Add(athlete, out existID);
                    switch (addResult)
                    {
                    case BLL.TB_AthleteInfo.Success:
                        athlete = new Model.TB_AthleteInfo();
                        SetBind();
                        this.DialogResult = true;
                        break;

                    case BLL.TB_AthleteInfo.RepeatAdd:
                        MessageBox.Show("已存在相同的人员信息,请确认!", "系统错误");
                        break;
                    }
                }
                catch (Exception ee) {
                    MessageBox.Show("添加失败\r\n" + ee.Message, "系统错误");
                }
            }
        }
Example #21
0
        private void btnImport_Click(object sender, RoutedEventArgs e)
        {
            dgAthlete.ItemsSource = null;
            tbAllCount.Text = "";
            tbSuccessCount.Text = "";
            tbFaildCount.Text = "";

            if (tbFilePath.Text == ""||excelContentList.Count==0) {
                MessageBox.Show("请选择受测者名单!", "系统信息");
                return;
            }
            if (cbTestItems.SelectedIndex < 0) {
                MessageBox.Show("请选择测试项目!", "系统信息");
                return;
            }

            double value = 0;
            UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(importProgress.SetValue);

            List<Model.TB_AthleteInfo> existsAthNameList = new List<Model.TB_AthleteInfo>();
            int errorCount = 0;
            int successCount = 0;
            bool cancleImport = false;
            for (int i = 0; i < excelContentList.Count; i++) {
                 List<string> columnList = excelContentList[i];

                    tbProgress.Text = (i + 1) + "/" + excelContentList.Count;

                    try
                    {
                        Model.TB_AthleteInfo newAthInfo = new Model.TB_AthleteInfo();
                        newAthInfo.Ath_TestDate = columnList[0] == "" ? DateTime.Now : DateTime.Parse(columnList[0]);
                        newAthInfo.Ath_Name = columnList[1];
                        newAthInfo.Ath_PinYin = DataUtil.PersonNamePinYinUtil.GetNamePinyin(newAthInfo.Ath_Name);
                        newAthInfo.Ath_Sex = DataUtil.AthleteSexUtil.GetSex(columnList[2]);
                        newAthInfo.Ath_Birthday = columnList[3] == "" ? DateTime.Now : DateTime.Parse(columnList[3]);
                        newAthInfo.Ath_Height = columnList[4];
                        newAthInfo.Ath_Weight = columnList[5];
                        newAthInfo.Ath_Project = columnList[6];
                        newAthInfo.Ath_MainProject = columnList[7];
                        newAthInfo.Ath_TrainYears = columnList[8];
                        newAthInfo.Ath_Level = columnList[9];
                        newAthInfo.Ath_Team = columnList[10];
                        newAthInfo.Ath_TestAddress = columnList[11];
                        newAthInfo.Ath_TestMachine = columnList[12];
                        newAthInfo.Ath_TestState = columnList[13];
                        newAthInfo.Ath_Remark = columnList[14];
                        newAthInfo.Ath_TestID = testList[cbTestItems.SelectedIndex].ID;
                        string existID = "";
                        int result = athInfoBLL.Add(newAthInfo, out existID);
                        if (result == BLL.TB_AthleteInfo.RepeatAdd)
                        {
                            existsAthNameList.Add(newAthInfo);
                        }
                        else {
                            successCount++;
                        }
                    }
                    catch
                    {
                        errorCount++;
                        if (MessageBox.Show("第" + (i + 2) + "行 " + columnList[0] + "的信息导入错误,请检查!\r\n是否继续导入?", "系统信息", MessageBoxButton.YesNo) == MessageBoxResult.No)
                        {
                            value = 0;
                            Dispatcher.Invoke(updatePbDelegate,
                     System.Windows.Threading.DispatcherPriority.Background,
                     new object[] { ProgressBar.ValueProperty, value });
                            cancleImport = true;
                            break;
                        }
                    }
                    value += 1;
                    Dispatcher.Invoke(updatePbDelegate,
                        System.Windows.Threading.DispatcherPriority.Background,
                        new object[] { ProgressBar.ValueProperty, value });

            }

            for (int i = 0; i < existsAthNameList.Count; i++) {
                existsAthNameList[i].Index = i + 1;
            }

            dgAthlete.ItemsSource = existsAthNameList;
            tbAllCount.Text = "总共" + excelContentList.Count + "条信息";
            tbSuccessCount.Text = "成功导入" + successCount + "条信息";
            tbFaildCount.Text = "未导入" + (existsAthNameList.Count + errorCount) + "条信息";
            if (!cancleImport)
            {
                MessageBox.Show("导入完成!", "系统信息");
            }

            tbFilePath.Text = "";
        }
Example #22
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text.Trim() == "") {
                MessageBox.Show("姓名不能为空!","系统信息");
                return;
            }
            if (cbTestItems.SelectedIndex < 0) {
                MessageBox.Show("请选择测试项目!", "系统信息");
                return;
            }
            if (isEdit)
            {
                try {
                    int updateResult = -1;

                    athlete.Ath_PinYin = DataUtil.PersonNamePinYinUtil.GetNamePinyin(athlete.Ath_Name);
                    if (oldAthInfo.Ath_Name != athlete.Ath_Name || oldAthInfo.Ath_Sex != athlete.Ath_Sex || ((DateTime)oldAthInfo.Ath_Birthday).ToString("yyyy-MM-dd") != ((DateTime)athlete.Ath_Birthday).ToString("yyyy-MM-dd")||((DateTime)oldAthInfo.Ath_TestDate).ToString("yyyy-MM-dd")!=((DateTime)athlete.Ath_TestDate).ToString("yyyy-MM-dd"))
                    {
                        updateResult= athleteBLL.Update(athlete, true);
                    }
                    else {
                        updateResult= athleteBLL.Update(athlete);
                    }
                    switch (updateResult)
                    {
                        case BLL.TB_AthleteInfo.Success:
                             this.DialogResult = true;
                             this.Close();
                            break;
                        case BLL.TB_AthleteInfo.RepeatAdd:
                            MessageBox.Show("因已存在相同的人员信息,编辑失败,请确认!", "系统错误");
                            break;
                        case BLL.TB_AthleteInfo.Error:
                            MessageBox.Show("修改信息时出错,请重试!\r\n如果问题一直存在,或联系软件制作者。", "系统错误");
                            break;
                    }

                }
                catch (Exception ee) {
                    MessageBox.Show("编辑失败\r\n" + ee.Message, "系统错误");
                }
            }
            else {
                try
                {
                    athlete.Ath_PinYin = DataUtil.PersonNamePinYinUtil.GetNamePinyin(athlete.Ath_Name);
                    string existID = "";
                    int addResult = athleteBLL.Add(athlete,out existID);
                    switch (addResult) {
                        case BLL.TB_AthleteInfo.Success:
                             athlete = new Model.TB_AthleteInfo();
                             SetBind();
                             this.DialogResult = true;
                             break;
                        case BLL.TB_AthleteInfo.RepeatAdd:
                             MessageBox.Show("已存在相同的人员信息,请确认!", "系统错误");
                             break;
                    }
                }
                catch (Exception ee) {
                    MessageBox.Show("添加失败\r\n" + ee.Message, "系统错误");
                }
            }
        }
Example #23
0
        private void btnImport_Click(object sender, RoutedEventArgs e)
        {
            dgAthlete.ItemsSource = null;
            tbAllCount.Text       = "";
            tbSuccessCount.Text   = "";
            tbFaildCount.Text     = "";

            if (tbFilePath.Text == "" || excelContentList.Count == 0)
            {
                MessageBox.Show("请选择受测者名单!", "系统信息");
                return;
            }
            if (cbTestItems.SelectedIndex < 0)
            {
                MessageBox.Show("请选择测试项目!", "系统信息");
                return;
            }

            double value = 0;
            UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(importProgress.SetValue);

            List <Model.TB_AthleteInfo> existsAthNameList = new List <Model.TB_AthleteInfo>();
            int  errorCount   = 0;
            int  successCount = 0;
            bool cancleImport = false;

            for (int i = 0; i < excelContentList.Count; i++)
            {
                List <string> columnList = excelContentList[i];

                tbProgress.Text = (i + 1) + "/" + excelContentList.Count;

                try
                {
                    Model.TB_AthleteInfo newAthInfo = new Model.TB_AthleteInfo();
                    newAthInfo.Ath_TestDate    = columnList[0] == "" ? DateTime.Now : DateTime.Parse(columnList[0]);
                    newAthInfo.Ath_Name        = columnList[1];
                    newAthInfo.Ath_PinYin      = DataUtil.PersonNamePinYinUtil.GetNamePinyin(newAthInfo.Ath_Name);
                    newAthInfo.Ath_Sex         = DataUtil.AthleteSexUtil.GetSex(columnList[2]);
                    newAthInfo.Ath_Birthday    = columnList[3] == "" ? DateTime.Now : DateTime.Parse(columnList[3]);
                    newAthInfo.Ath_Height      = columnList[4];
                    newAthInfo.Ath_Weight      = columnList[5];
                    newAthInfo.Ath_Project     = columnList[6];
                    newAthInfo.Ath_MainProject = columnList[7];
                    newAthInfo.Ath_TrainYears  = columnList[8];
                    newAthInfo.Ath_Level       = columnList[9];
                    newAthInfo.Ath_Team        = columnList[10];
                    newAthInfo.Ath_TestAddress = columnList[11];
                    newAthInfo.Ath_TestMachine = columnList[12];
                    newAthInfo.Ath_TestState   = columnList[13];
                    newAthInfo.Ath_Remark      = columnList[14];
                    newAthInfo.Ath_TestID      = testList[cbTestItems.SelectedIndex].ID;
                    string existID = "";
                    int    result  = athInfoBLL.Add(newAthInfo, out existID);
                    if (result == BLL.TB_AthleteInfo.RepeatAdd)
                    {
                        existsAthNameList.Add(newAthInfo);
                    }
                    else
                    {
                        successCount++;
                    }
                }
                catch
                {
                    errorCount++;
                    if (MessageBox.Show("第" + (i + 2) + "行 " + columnList[0] + "的信息导入错误,请检查!\r\n是否继续导入?", "系统信息", MessageBoxButton.YesNo) == MessageBoxResult.No)
                    {
                        value = 0;
                        Dispatcher.Invoke(updatePbDelegate,
                                          System.Windows.Threading.DispatcherPriority.Background,
                                          new object[] { ProgressBar.ValueProperty, value });
                        cancleImport = true;
                        break;
                    }
                }
                value += 1;
                Dispatcher.Invoke(updatePbDelegate,
                                  System.Windows.Threading.DispatcherPriority.Background,
                                  new object[] { ProgressBar.ValueProperty, value });
            }

            for (int i = 0; i < existsAthNameList.Count; i++)
            {
                existsAthNameList[i].Index = i + 1;
            }

            dgAthlete.ItemsSource = existsAthNameList;
            tbAllCount.Text       = "总共" + excelContentList.Count + "条信息";
            tbSuccessCount.Text   = "成功导入" + successCount + "条信息";
            tbFaildCount.Text     = "未导入" + (existsAthNameList.Count + errorCount) + "条信息";
            if (!cancleImport)
            {
                MessageBox.Show("导入完成!", "系统信息");
            }

            tbFilePath.Text = "";
        }
        //导入方法
        private void Import(string [] fileNames,bool ischeckRepeate)
        {
            importProgress.Maximum = fileNames.Count();
            importProgress.Minimum = 0;
            importProgress.Value = 0;
            double value = 0;
            UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(importProgress.SetValue);
            for (int i = 0; i < fileNames.Count(); i++) {
                if (importFlag == 1) {
                    break;
                }
                if (importFlag == 2) {
                    i--;
                    continue;
                }
                value += 1;
                Dispatcher.Invoke(updatePbDelegate,
                    System.Windows.Threading.DispatcherPriority.Background,
                    new object[] { ProgressBar.ValueProperty, value });

                Model.ImportDataErrorModel errorModel=null;

                string baseFileName=fileNames[i];

                #region 写入进度
                tbFileName.Text = "文件名:" + baseFileName.Substring(baseFileName.LastIndexOf("\\") + 1);
                tbContent1.Text = "";
                tbContent2.Text = "";
                tbContent3.Text = "";
                tbProgress.Text = (i + 1) + "/" + fileNames.Count();
                #endregion

                #region 读取数据文件信息
                string[] contents = File.ReadAllLines(baseFileName);

                if (!CheckFile(baseFileName, contents))
                {
                    continue;
                }
                for (int a = 0; a < 11; a++)
                {
                    tbContent1.Text += contents[a] + "\r\n";
                    tbContent2.Text += contents[11 + a] + "\r\n";
                    tbContent3.Text += contents[22 + a] + "\r\n";
                }

                string testDate = GetLineValue(contents[2]);
                string testTime = GetLineValue(contents[3]);
                DateTime testDateTime = DateTime.Now;
                if (testDate != "" && testTime != "")
                {
                    try
                    {
                        testDateTime = Convert.ToDateTime(testDate + " " + testTime, dtPointFormat);
                    }
                    catch {
                        testDateTime = DateTime.Now;
                    }
                }

                Model.TB_AthleteInfo athModel = new Model.TB_AthleteInfo();
                athModel.Ath_PinYin = athModel.Ath_Name = GetLineValue(contents[4]);
                athModel.Ath_Sex = DataUtil.AthleteSexUtil.GetSex(GetLineValue(contents[29]));
                athModel.Ath_TestDate = testDateTime;
                string birthdayStr = GetLineValue(contents[27]);
                if (birthdayStr != "")
                {
                    try
                    {
                        athModel.Ath_Birthday = Convert.ToDateTime(birthdayStr, dtLineFormat);
                    }
                    catch {
                        athModel.Ath_Birthday = DateTime.Now;
                    }
                }
                else {
                    athModel.Ath_Birthday = null;
                }
                athModel.Ath_Height = GetLineValue(contents[26]);
                athModel.Ath_Weight = GetLineValue(contents[25]);

                Model.TB_AthleteInfo testAthInfoModel = CheckAthInfo(athModel);
                if (testAthInfoModel == null) {
                    continue;
                }

                Model.TB_TestInfo testInfo = new Model.TB_TestInfo();
                testInfo.BaseFileName = contents[0].Trim();
                testInfo.TestTime = testInfo.TestDate = testDateTime;
                testInfo.Joint_Side = GetLineValue(contents[5]);
                testInfo.Test_Mode = GetLineValue(contents[6]);
                testInfo.Joint = GetLineValue(contents[7]);
                testInfo.Plane = GetLineValue(contents[8]);
                testInfo.Motion_Start = GetLineValue(contents[10]);
                testInfo.Motion_End = GetLineValue(contents[11]);
                testInfo.Speed1 = GetLineValue(contents[12]);
                testInfo.Speed2 = GetLineValue(contents[13]);
                testInfo.Acceleration1 = GetLineValue(contents[14]);
                testInfo.Acceleration2 = GetLineValue(contents[15]);
                testInfo.Break = GetLineValue(contents[18]);
                testInfo.NOOfSets = GetLineValue(contents[22]);
                testInfo.NOOfRepetitions = GetLineValue(contents[23]);
                testInfo.InsuredSide = GetLineValue(contents[28]);
                testInfo.Therapist = GetLineValue(contents[30]);
                testInfo.Gravitycomp = GetLineValue(contents[31]);

                testInfo.DataFileName = "";

                testInfo.Ath_ID = testAthInfoModel.ID;
                #endregion

                #region 检查是否重复导入
                if (ischeckRepeate) {
                    //检测是否有相同时间的数据导入
                    try
                    {
                        //判断该测试信息是否导入,判断条件 用户ID 测试日期,数据文件名
                        List<Model.TB_TestInfo> existsTestInfoList = testInfoBLL.GetModelList("ath_id=" + testInfo.Ath_ID + " and testdate=#" + testInfo.TestDate + "# and BaseFileName='" + testInfo.BaseFileName + "'");
                        if (existsTestInfoList.Count > 0)//有重复数据
                        {
                            existsIDs += existsTestInfoList[0].ID + ",";
                            Model.ExistsFileModel exFileModel = new Model.ExistsFileModel();
                            exFileModel.FileName = baseFileName;
                            exFileModel.RealName = baseFileName.Substring(baseFileName.LastIndexOf("\\") + 1);
                            existsFiles.Add(exFileModel);
                            continue;
                        }
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show("检查此文件是否导入时出错!\r\n" + ee.Message, "系统错误");
                        errorModel = new Model.ImportDataErrorModel();
                        errorModel.ErrorString = "3";
                        errorModel.FileName = baseFileName;
                        errorModelList.Add(errorModel);
                        continue;
                    }
                }
                #endregion

                //导入
                try
                {
                    BaseDataUtil dataUtil = new BaseDataUtil();
                    dataUtil.SmoothValue = (int)smoothValue;
                    dataUtil.Weight = testAthInfoModel.Ath_Weight;
                    if (testInfo.Gravitycomp.Trim() != "") {
                        dataUtil.Gravitycomp = testInfo.Gravitycomp;
                    }
                    string fileName = dataUtil.WriteBaseData(contents);

                    testInfo.DataFileName = fileName;
                }
                catch (Exception ee)
                {
                    MessageBox.Show("计算出错!\r\n" + ee.Message, "系统错误");
                    errorModel = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "4";
                    errorModel.FileName = baseFileName;
                    errorModelList.Add(errorModel);
                    continue;
                }
                //添加到数据库
                try
                {
                    testInfoBLL.Add(testInfo);
                }
                catch (Exception ee)
                {
                    MessageBox.Show("添加测试信息出错,请稍候重试!\r\n" + ee.Message, "系统错误");
                    errorModel = new Model.ImportDataErrorModel();
                    errorModel.ErrorString = "5";
                    errorModel.FileName = baseFileName;
                    errorModelList.Add(errorModel);
                    continue;
                }

            }

            if (errorModelList.Count > 0) {
                tbErrorCount.Text = errorModelList.Count + "个文件导入错误";
                ErrorPanel.Visibility = Visibility.Visible;
            }

            if (ischeckRepeate)
            {//如果检查重复并且存在重复数据就刷新数据列表
                if (existsFiles.Count > 0)
                {
                    btnReImport.IsEnabled = true;
                    RefrenshDataGridSource();
                }
                else {
                    btnReImport.IsEnabled = false;
                }
            }
        }