/// <summary> /// 是否存在该记录 /// </summary> public bool Exists(string mobStr, string cmobStr, string NameStr) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from [BPMGen]"); strSql.Append(" where mobStr=@mobStr and cmobStr=@cmobStr and NameStr=@NameStr"); OleDbParameter[] parameters = { new OleDbParameter("@mobStr", OleDbType.VarWChar, 255), new OleDbParameter("@NameStr", OleDbType.VarWChar, 255), new OleDbParameter("@cmobStr", OleDbType.VarWChar, 255) }; parameters[0].Value = mobStr; parameters[1].Value = cmobStr; parameters[2].Value = NameStr; return(DbHelperOleDb.Exists(strSql.ToString(), parameters)); }
/// <summary> /// 是否存在该记录 /// </summary> public bool Exists(string 测试时间, string 二维码, string 正螺丝1马头结果, string 正螺丝1马头扭矩, string 正螺丝1马头角度, string 正螺丝2马头结果, string 正螺丝2马头扭矩, string 正螺丝2马头角度, string 反螺丝1马头结果, string 反螺丝1马头扭矩, string 反螺丝1马头角度, string 反螺丝2马头结果, string 反螺丝2马头扭矩, string 反螺丝2马头角度) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from db1"); strSql.Append(" where 测试时间=@测试时间 and 二维码=@二维码 and 正螺丝1马头结果=@正螺丝1马头结果 and 正螺丝1马头扭矩=@正螺丝1马头扭矩 and 正螺丝1马头角度=@正螺丝1马头角度 and 正螺丝2马头结果=@正螺丝2马头结果 and 正螺丝2马头扭矩=@正螺丝2马头扭矩 and 正螺丝2马头角度=@正螺丝2马头角度 and 反螺丝1马头结果=@反螺丝1马头结果 and 反螺丝1马头扭矩=@反螺丝1马头扭矩 and 反螺丝1马头角度=@反螺丝1马头角度 and 反螺丝2马头结果=@反螺丝2马头结果 and 反螺丝2马头扭矩=@反螺丝2马头扭矩 and 反螺丝2马头角度=@反螺丝2马头角度 "); OleDbParameter[] parameters = { new OleDbParameter("@测试时间", OleDbType.VarChar, 255), new OleDbParameter("@二维码", OleDbType.VarChar, 255), new OleDbParameter("@正螺丝1马头结果", OleDbType.VarChar, 255), new OleDbParameter("@正螺丝1马头扭矩", OleDbType.VarChar, 255), new OleDbParameter("@正螺丝1马头角度", OleDbType.VarChar, 255), new OleDbParameter("@正螺丝2马头结果", OleDbType.VarChar, 255), new OleDbParameter("@正螺丝2马头扭矩", OleDbType.VarChar, 255), new OleDbParameter("@正螺丝2马头角度", OleDbType.VarChar, 255), new OleDbParameter("@反螺丝1马头结果", OleDbType.VarChar, 255), new OleDbParameter("@反螺丝1马头扭矩", OleDbType.VarChar, 255), new OleDbParameter("@反螺丝1马头角度", OleDbType.VarChar, 255), new OleDbParameter("@反螺丝2马头结果", OleDbType.VarChar, 255), new OleDbParameter("@反螺丝2马头扭矩", OleDbType.VarChar, 255), new OleDbParameter("@反螺丝2马头角度", OleDbType.VarChar, 255) }; parameters[0].Value = 测试时间; parameters[1].Value = 二维码; parameters[2].Value = 正螺丝1马头结果; parameters[3].Value = 正螺丝1马头扭矩; parameters[4].Value = 正螺丝1马头角度; parameters[5].Value = 正螺丝2马头结果; parameters[6].Value = 正螺丝2马头扭矩; parameters[7].Value = 正螺丝2马头角度; parameters[8].Value = 反螺丝1马头结果; parameters[9].Value = 反螺丝1马头扭矩; parameters[10].Value = 反螺丝1马头角度; parameters[11].Value = 反螺丝2马头结果; parameters[12].Value = 反螺丝2马头扭矩; parameters[13].Value = 反螺丝2马头角度; return(DbHelperOleDb.Exists(strSql.ToString(), parameters)); }
public bool Exists(string sql) { return(DbHelperOleDb.Exists(sql)); }
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, "数据合并完成"); }