コード例 #1
0
ファイル: TestManager.xaml.cs プロジェクト: dewade2003/DSJL
        //删除
        private void imgDelete_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (testItmesListBox.SelectedIndex >= 0)
            {
                if (MessageBox.Show("删除测试项目将会删除该项目下所有受试者信息和测试数据,改变应用该项目中测试数据建立的测试参考值。\r\n删除的信息将不能恢复,请确认要删除选择的测试项目吗?", "删除测试项目确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    testInfoBLL = new BLL.TB_TestInfo();
                    List <Model.TB_TestInfo> testInfoList = testInfoBLL.GetModelList("ath_id in (select id from tb_athleteinfo where ath_testid=" + testList[testItmesListBox.SelectedIndex].ID + ")");

                    foreach (Model.TB_TestInfo testInfo in testInfoList)
                    {
                        string dataFileName = Model.AppPath.XmlDataDirPath + testInfo.DataFileName;
                        if (File.Exists(dataFileName))
                        {
                            File.Delete(dataFileName);
                        }
                    }
                    int selectTestID = testList[testItmesListBox.SelectedIndex].ID;
                    testManagerBLL.Delete(selectTestID);

                    //删除测试信息缓存
                    DSJL.Caches.TestInfoModelCache.DeleteCache(selectTestID);

                    RefrenshList();
                }
            }
            else
            {
                MessageBox.Show("请选择一项删除!");
            }
        }
コード例 #2
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("删除出错!", "系统错误");
         }
     }
 }
コード例 #3
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;
                }
            }
        }
コード例 #4
0
ファイル: AddDataWindow.xaml.cs プロジェクト: dewade2003/DSJL
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            List <int> athIDs = new List <int>();

            foreach (var item in athInfoListDict.Values)
            {
                foreach (var item1 in item)
                {
                    if (item1.IsChecked)
                    {
                        athIDs.Add(item1.ID);
                    }
                }
            }
            StringBuilder caseStringBuilder = new StringBuilder();

            caseStringBuilder.Append("ath_id in(" + string.Join(",", athIDs.ToArray()) + ")");
            if (standParam != null)
            {
                if (standParam?.Joint.Equals("-1") == false)
                {
                    caseStringBuilder.Append(" and joint='" + standParam.Joint + "'");
                }
                if (standParam?.Joint_Side.Equals("-1") == false)
                {
                    caseStringBuilder.Append(" and joint_side='" + standParam.Joint_Side + "'");
                }
                if (standParam?.Plane.Equals("-1") == false)
                {
                    caseStringBuilder.Append(" and plane='" + standParam.Plane + "'");
                }
                if (standParam?.Test_Mode.Equals("-1") == false)
                {
                    caseStringBuilder.Append(" and test_mode='" + standParam.Test_Mode + "'");
                }
                if (standParam?.Speed1 != "-1" && standParam?.Speed2 != "-1")
                {
                    caseStringBuilder.Append(" and CInt(speed1)>=" + standParam.Speed1 + " and CInt(speed2)<=" + standParam.Speed2);
                }
            }
            List <Model.TB_TestInfo> testInfoList = testInfoBLL.GetModelList(caseStringBuilder.ToString());
            //List<Model.TB_TestInfo> willAddedTestInfoList = new List<Model.TB_TestInfo>();
            int count = 0;

            foreach (var item in testInfoList)
            {
                if (!standTestRefeBLL.Exists(item.ID, StandInfo.ID))
                {
                    Model.TB_StandTestRefe refe = new Model.TB_StandTestRefe();
                    refe.StandID = StandInfo.ID;
                    refe.TestID  = item.ID;
                    standTestRefeBLL.Add(refe);
                    count++;
                }
            }
            if (count == 0)
            {
                MessageBox.Show("没有找到测试数据!", "系统信息", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                DialogResult = true;
                MessageBox.Show("添加了" + count + "条测试数据!", "系统信息", MessageBoxButton.OK, MessageBoxImage.Information);
                this.Close();
            }
        }
コード例 #5
0
ファイル: TestManager.xaml.cs プロジェクト: dewade2003/DSJL
        //删除
        private void imgDelete_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (testItmesListBox.SelectedIndex >= 0)
            {
                if (MessageBox.Show("删除测试项目将会删除该项目下所有受试者信息和测试数据,改变应用该项目中测试数据建立的测试参考值。\r\n删除的信息将不能恢复,请确认要删除选择的测试项目吗?", "删除测试项目确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    testInfoBLL = new BLL.TB_TestInfo();
                    List<Model.TB_TestInfo> testInfoList = testInfoBLL.GetModelList("ath_id in (select id from tb_athleteinfo where ath_testid=" + testList[testItmesListBox.SelectedIndex].ID + ")");

                    foreach (Model.TB_TestInfo testInfo in testInfoList)
                    {
                        string dataFileName = Model.AppPath.XmlDataDirPath + testInfo.DataFileName;
                        if (File.Exists(dataFileName))
                        {
                            File.Delete(dataFileName);
                        }
                    }
                    int selectTestID=testList[testItmesListBox.SelectedIndex].ID;
                    testManagerBLL.Delete(selectTestID);

                    //删除测试信息缓存
                    DSJL.Caches.TestInfoModelCache.DeleteCache(selectTestID);

                    RefrenshList();
                }
            }
            else {
                MessageBox.Show("请选择一项删除!");
            }
        }
コード例 #6
0
ファイル: MergeDB.xaml.cs プロジェクト: dewade2003/DSJL
        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, "数据合并完成");
        }
コード例 #7
0
ファイル: MergeDB.xaml.cs プロジェクト: dewade2003/DSJL
        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, "数据合并完成");
        }