Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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, "系统错误");
                }
            }
        }
Ejemplo n.º 3
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 = "";
        }
Ejemplo n.º 4
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, "数据合并完成");
        }
Ejemplo n.º 5
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, "数据合并完成");
        }