private void button1_Click(object sender, EventArgs e) { SetMachineTime set = new SetMachineTime(this.portData); set.ShowDialog(); //if (portData == null) //{ // MessageBox.Show("还没有打开串口,请先打开串口!"); // return; //} //try //{ // decimal data = this.numericUpDown_date.Value; // string DataStr = data.ToString(); // if (data.ToString().Length == 1) // DataStr = "0" + data.ToString(); // string command = "F" + this.comboBox_SetdateType.SelectedIndex.ToString() + DataStr.ToString() + "00"; // byte[] receiveData=new byte[2]; // portData.SendCommand(command,ref receiveData,1000); // string receiveString=Lib.byteToHexStr(receiveData); // if (receiveString == command.Substring(0, 4)) // MessageBox.Show("设置成功"); // else // MessageBox.Show("设置失败,串口未返回正确数据,请连接正确的下位机!"); //} //catch (Exception ex) //{ // MessageBox.Show("设置失败" + Environment.NewLine + "错误信息:" + ex.Message); //} }
private void 校时ToolStripMenuItem_Click(object sender, EventArgs e) { if (portData == null) { MessageBox.Show("串口还未打开,请先打开!"); return; } SetMachineTime set = new SetMachineTime(this.portData); set.ShowDialog(); }