日期:2014-05-17  浏览次数:21106 次

C# 清理串口返回数据缓冲区数据问题(急!)
本帖最后由 z525416460 于 2013-01-25 16:56:56 编辑
[size=14px]MainForm.cs
  private void SendCommand(string ls_CmdType,string ls_CmdTypeStr,int i)
        {
            DataTable dt = null;
            string terstr = null;//临时数据表存储“H_Termina”
            string ls_teradds = null;//变量TerAdds
            string ls_str = null;//组合参数
            //string ls_wk = null;//临时TerminalID
            string ls_TerRemark = null;//该设备所属com口
            try
            {
            if (ltvEmp.Items.Count > 0)
            {
               
                if (i == -1)
                {
                    terstr = ltvEmp.SelectedItems[0].SubItems[1].Text;
                    
                }
                else
                {
                    terstr = ltvEmp.Items[i].SubItems[1].Text;
                }
                    isml = terstr;
                    Reclb = 1;
                    dt = dbr.getTable("select TerAdds,TerRemark from H_Termina where TerminalID = '" + isml + "'");
                    ls_teradds = dt.Rows[0][0].ToString();
                    ls_TerRemark = dt.Rows[0][1].ToString();
                    //ls_str = "I" + ls_teradds.Substring(ls_teradds.Length - 4, 4);
             &nbs