CNAS取数仪器端升级
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UpLoadRecordDAL.cs 1.6KB

4 mesi fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using CnasLocalIDAL;
  2. using CnasSynchronousCommon;
  3. using CnasSynchrousModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data.SQLite;
  7. using System.Linq;
  8. using System.Text;
  9. namespace SyncLocalDAL
  10. {
  11. public class UpLoadRecordDAL : LocalDBbase, IUpLoadRecord
  12. {
  13. /// <summary>
  14. /// 插入一条记录数据
  15. /// </summary>
  16. /// <param name="record"></param>
  17. /// <returns></returns>
  18. public int InsertUpLoadRecord(UpLoadRecord record)
  19. {
  20. int iReturn = 0;
  21. string strSql = @"INSERT INTO UpLoadRecord (GUID,LaboratoryTestGUID,UpLoadUser,UploadTime)
  22. VALUES(@GUID,@LaboratoryTestGUID,@UpLoadUser,@UploadTime)";
  23. try
  24. {
  25. //构建数据库连接
  26. SQLiteHelper.SetConnectionString(ConnectString);
  27. int index = 0;
  28. SQLiteParameter[] parameters = new SQLiteParameter[record.GetType().GetProperties().Count()];
  29. for (int i = 0; i < record.GetType().GetProperties().Count(); i++)
  30. {
  31. parameters[index] = new SQLiteParameter(record.GetType().GetProperties()[i].Name, record.GetType().GetProperties()[i].GetValue(record, null));
  32. index++;
  33. }
  34. //执行SQL语句
  35. iReturn += SQLiteHelper.ExecuteNonQuery(strSql, parameters);
  36. }
  37. catch (Exception ex)
  38. {
  39. AppLog.Error(ex.Message);
  40. throw ex;
  41. }
  42. return iReturn;
  43. }
  44. }
  45. }