private void button1_Click(object sender, EventArgs e) { SysSetModel m = new SysSetModel(); m.Com = comboBox_Port.Text; m.Rate = cbBtl.Text; ConfigManager.MyConfig = m; this.DialogResult = DialogResult.OK; }
private void Config_Load(object sender, EventArgs e) { SysSetModel m = ConfigManager.MyConfig; if (m != null) { comboBox_Port.Text = m.Com; cbBtl.Text = m.Rate; } }
private void OrderScan_Load(object sender, EventArgs e) { ddlSerLength.SelectedIndex = 0; cbCount.SelectedIndex = 0; var a = from t in db.OrderWeights where Convert.ToDateTime(t.ScanTime) < DateTime.Now select t; var b = a.ToList(); p.SoundLocation = Application.StartupPath + "//1.wav"; p.Load(); //byte[] bts = HexStrTobyte("0A 77 6E 30 30 30 30 2E 31 32 6B 67 0D"); SysSetModel config = ConfigManager.MyConfig; if (config == null) { MessageBox.Show("未检测到串口设置信息,请先设置串口信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); // this.Close(); } else { //设置串口相关属性 ComDevice.PortName = config.Com; ComDevice.BaudRate = int.Parse(config.Rate); ComDevice.Parity = (Parity)0; ComDevice.DataBits = 8; ComDevice.StopBits = (StopBits)1; try { //开启串口 ComDevice.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message, "未能成功开启串口", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // MessageBox.Show(data); }