CFieldDB.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using OTSModelSharp.DTLBase;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data.Common;
  5. using System.Data.SQLite;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace OTSModelSharp
  10. {
  11. public class CFieldDB : CSQLiteDB
  12. {
  13. public CFieldDB(IDBStoreBase _conStr, CSQLiteTable _table) : base(_conStr, _table)
  14. {
  15. }
  16. public void SaveAField(int fieldId,System.Drawing.Point fldPos,System.Drawing.Point OTSPos)
  17. {
  18. var tableInfoPtr = GetTableInfo();
  19. if (tableInfoPtr == null)
  20. {
  21. return ;
  22. }
  23. var datastorePtr = GetDatastore();
  24. string sInsertFormat = tableInfoPtr.GetInsertCommandFormatString(true);
  25. string sSQLCommand;
  26. sSQLCommand = string.Format(sInsertFormat, fieldId, fldPos.X, fldPos.Y,OTSPos.X,OTSPos.Y);
  27. if (!datastorePtr.RunCommand(sSQLCommand))
  28. {
  29. return ;
  30. }
  31. return ;
  32. }
  33. public string GetSavingAFieldcmd(int fieldId, System.Drawing.Point OTSPos,System.Drawing.Point SemPos)
  34. {
  35. var tableInfoPtr = GetTableInfo();
  36. if (tableInfoPtr == null)
  37. {
  38. return "";
  39. }
  40. var datastorePtr = GetDatastore();
  41. string sInsertFormat = tableInfoPtr.GetInsertCommandFormatString(true);
  42. string sSQLCommand;
  43. sSQLCommand = string.Format(sInsertFormat, fieldId, OTSPos.X, OTSPos.Y,SemPos.X,SemPos.Y);
  44. return sSQLCommand;
  45. }
  46. public KeyValuePair<string, SQLiteParameter[]> GetSavingAFieldcmdObj(int fieldId, System.Drawing.PointF OTSPos, System.Drawing.PointF SemPos)
  47. {
  48. var tableInfoPtr = GetTableInfo();
  49. var datastorePtr = GetDatastore();
  50. var sInsertCmd = tableInfoPtr.GetInsertCommand(true);
  51. var paras = sInsertCmd.Value;
  52. paras[0].Value= fieldId;
  53. paras[1].Value= OTSPos.X;
  54. paras[2].Value= OTSPos.Y;
  55. paras[3].Value= SemPos.X;
  56. paras[4].Value= SemPos.Y;
  57. return new KeyValuePair<string,SQLiteParameter[]>(sInsertCmd.Key, paras.ToArray());
  58. }
  59. }
  60. }