MachineSetting.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using UAS_LabelMachine.Entity;
  10. namespace UAS_LabelMachine
  11. {
  12. public partial class MachineSetting : Form
  13. {
  14. SqliteDBHelper sdh = SystemInf.sdh;
  15. public MachineSetting()
  16. {
  17. InitializeComponent();
  18. }
  19. private void MachineSetting_Load(object sender, EventArgs e)
  20. {
  21. DataTable dt = (DataTable)sdh.ExecuteSql("select * from ParamSetting", "select");
  22. if (dt.Rows.Count > 0)
  23. {
  24. ps_ip.Text = dt.Rows[0]["ps_ip"].ToString();
  25. ps_receiveport.Text = dt.Rows[0]["ps_receiveport"].ToString();
  26. ps_sendport.Text = dt.Rows[0]["ps_sendport"].ToString();
  27. ps_resetport.Text = dt.Rows[0]["ps_resetport"].ToString();
  28. ps_dataindex.Text = dt.Rows[0]["ps_dataindex"].ToString();
  29. ps_split.Text = dt.Rows[0]["ps_split"].ToString();
  30. }
  31. }
  32. private void SaveSetting_Click(object sender, EventArgs e)
  33. {
  34. string sql = "";
  35. if (sdh.getRowCount("ParamSetting") > 0)
  36. {
  37. sql = "update ParamSetting set ps_ip='" + ps_ip.Text + "',ps_receiveport='" + ps_receiveport.Text + "',ps_sendport='" + ps_sendport.Text + "',ps_resetport='" + ps_resetport.Text + "',ps_dataindex='" + ps_dataindex.Text + "',ps_split='" + ps_split.Text + "' where ps_id=1";
  38. sdh.ExecuteSql(sql, "update");
  39. }
  40. else
  41. {
  42. sql = "insert into ParamSetting(ps_id,ps_ip,ps_receiveport,ps_sendport,ps_resetport,ps_dataindex,ps_split)";
  43. sql += "values(1,'" + ps_ip.Text + "','" + ps_receiveport.Text + "','" + ps_sendport.Text + "','" + ps_resetport.Text + "','" + ps_dataindex.Text + "','" + ps_split.Text + "')";
  44. sdh.ExecuteSql(sql, "insert");
  45. }
  46. MessageBox.Show("保存成功");
  47. Close();
  48. }
  49. }
  50. }