bug
lu
5 天以前 2e44301eda2efb4b61e6dc53d4fff668229f7321
DevApp/Gs.DevApp/XtraForm1.cs
@@ -1,7 +1,9 @@
using DevExpress.XtraEditors;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NModbus;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
@@ -23,7 +25,6 @@
        public XtraForm1()
        {
            InitializeComponent();
        }
        private void simpleButton2_Click(object sender, EventArgs e)
@@ -172,7 +173,9 @@
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            DataTable dataTable1 = this.GetDataTable($"select MIG004,MIG005 from BASMIG(nolock) where MIG001='ShuiJianZhanWei01' and MIG003='{((BaseEdit)this.txtGWM).EditValue.ToString()}'", "tmpBASMIG2");
            System.Text.StringBuilder sbSql1 = new StringBuilder();
            sbSql1.Append($"select MIG004,MIG005 from BASMIG(nolock) where MIG001='ShuiJianZhanWei01' and MIG003='{((BaseEdit)this.txtGWM).EditValue.ToString()}'");
            DataTable dataTable1 = this.GetDataTable(sbSql1.ToString(), "tmpBASMIG2");
            if (dataTable1 == null || dataTable1.Rows.Count <= 0)
            {
                MessageBox.Show("该水检站位码不存在,请确认!");
@@ -183,7 +186,9 @@
                ModbusFactory modbusFactory = new ModbusFactory();
                byte num1 = byte.Parse("1");
                ushort num2 = ushort.Parse("1");
                DataTable dataTable2 = GetDataTable(string.Format($"select case when MIG006='D' then MIG003+{dataTable1.Rows[0][0]} else MIG003+{dataTable1.Rows[0][1]} end MIG003,MIG004 from BASMIG(nolock) where MIG001 = 'ShuiJianAddress01' order by MIG005"), "tmpBASMIG3");
                System.Text.StringBuilder sbSql2 = new StringBuilder();
                sbSql2.Append(string.Format($"select case when MIG006='D' then MIG003+{dataTable1.Rows[0][0]} else MIG003+{dataTable1.Rows[0][1]} end MIG003,MIG004 from BASMIG(nolock) where MIG001 = 'ShuiJianAddress01' order by MIG005"));
                DataTable dataTable2 = GetDataTable(sbSql2.ToString(), "tmpBASMIG3");
                if (dataTable2 == null || dataTable2.Rows.Count <= 0)
                {
                    MessageBox.Show("水检地址不存在,请确认!");
@@ -251,10 +256,73 @@
                {
                    throw new Exception(ex.Message);
                }
                return ds.Tables[0];
            }
        }
        private void btnEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            MessageBox.Show("d");
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string json = @"{
            ""100℃"": {
                ""temp"": ""94"",
                ""150ml"": ""143"",
                ""250ml"": ""241"",
                ""500ml"": ""482"",
                ""750ml"": ""732""
            },
            ""85℃"": {
                ""temp"": ""86"",
                ""150ml"": ""146"",
                ""250ml"": ""238"",
                ""500ml"": ""495"",
                ""750ml"": ""739""
            },
            ""60℃"": {
                ""temp"": ""62"",
                ""150ml"": ""152"",
                ""250ml"": ""244"",
                ""500ml"": ""499"",
                ""750ml"": ""745""
            },
            ""45℃"": {
                ""temp"": ""48"",
                ""150ml"": ""158"",
                ""250ml"": ""246"",
                ""500ml"": ""506"",
                ""750ml"": ""778""
            },
            ""常温水"": {
                ""temp"": ""29"",
                ""150ml"": ""161"",
                ""250ml"": ""249"",
                ""500ml"": ""504"",
                ""750ml"": ""781""
            }
        }";
            System.Text.StringBuilder sbLine = new StringBuilder();
            var data = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(json);
            List<string> resultLines = new List<string>();
            foreach (var entry in data)
            {
                string key = entry.Key;
                var values = entry.Value;
                string temp = values["temp"];
                sbLine.Append(key + "/" + temp + ":");
                System.Text.StringBuilder dbdb = new StringBuilder();
                foreach (var dddddd in values)
                {
                    if (dddddd.Key == "temp")
                        continue;
                    dbdb.Append(dddddd.Key+"-"+ dddddd.Value + "、");
                }
                sbLine.Append(dbdb.ToString()+"\n");
            }
            richTextBox1.Text = sbLine.ToString();
        }
    }
}