|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using CNAS_SerialPort;
- using CnasSynchronusClient;
- using CnasSynchrousModel;
- using System;
- using System.Windows.Forms;
-
- namespace CNAS_BalanceClient
- {
- public partial class frmConfigPort : Form
- {
- public SerialPortConfigInfo serialPortConfig;
-
- public frmConfigPort(SerialPortConfigInfo serialPortConfig)
- {
- InitializeComponent();
-
- this.serialPortConfig = serialPortConfig;
- }
-
- private void frmConfigPort_Load(object sender, EventArgs e)
- {
- if (serialPortConfig != null)
- {
- cbxPortName.Text=serialPortConfig.PortName;
- cbxBaudRate.Text = serialPortConfig.BaudRate.ToString();
- cbxDataBits.Text = serialPortConfig.DataBits.ToString();
- cbxParity.Text = serialPortConfig.Parity;
- cbxStopBits.Text = serialPortConfig.StopBits;
- cbxHandshake.Text = serialPortConfig.Handshake;
-
- //if (serialPortConfig.IfAutoWrap)
- // cbIfAutoWrap.Checked = true;
- //if (serialPortConfig.IfMuffleFurnace)
- // cbIfMuffleFurnace.Checked = true;
- //if (serialPortConfig.IfPeelingWeighing)
- // cbIfPeelingWeighing.Checked = true;
- }
-
- //cbxPortName.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames());
- }
-
- private void btnOK_Click(object sender, EventArgs e)
- {
- if (serialPortConfig == null) serialPortConfig = new SerialPortConfigInfo();
-
- serialPortConfig.PortName = cbxPortName.Text;
- serialPortConfig.BaudRate = Convert.ToInt32(cbxBaudRate.Text);
- serialPortConfig.DataBits = Convert.ToInt32(cbxDataBits.Text);
- serialPortConfig.Parity = cbxParity.Text;
- serialPortConfig.StopBits = cbxStopBits.Text;
- serialPortConfig.Handshake = cbxHandshake.Text;
- //if (cbIfAutoWrap.Checked)
- // serialPortConfig.IfAutoWrap = true;
- //if (cbIfMuffleFurnace.Checked)
- // serialPortConfig.IfMuffleFurnace = true;
- //if (cbIfPeelingWeighing.Checked)
- // serialPortConfig.IfPeelingWeighing = true;
-
- this.DialogResult = DialogResult.OK;
-
- int iReturn=new SericalPortConfigBLL().SaveSerialPortConfigInfo(serialPortConfig);
- if (iReturn > 0)
- {
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- MessageBox.Show("保存时发生异常,无法正常保存!", "提示");
- }
- }
-
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
-
- private void frmConfigPort_Shown(object sender, EventArgs e)
- {
- this.cbxPortName.Select(0, 0);
- }
- }
- }
|