private void btnChangePort_Click(object sender, EventArgs e) { try { if (lvPort.SelectedItems.Count == 0) { MessageBox.Show("选项为空"); return; } string IP = lvServer.SelectedItems[0].SubItems[2].Text; int port = Convert.ToInt32(lvPort.SelectedItems[0].SubItems[0].Text); string MOXANo = lvServer.SelectedItems[0].SubItems[0].Text; string DeskNo = lvPort.SelectedItems[0].SubItems[1].Text; string DeskDesc = lvPort.SelectedItems[0].SubItems[2].Text; string PLC = lvPort.SelectedItems[0].SubItems[3].Text; string Red = lvPort.SelectedItems[0].SubItems[4].Text; string Green = lvPort.SelectedItems[0].SubItems[5].Text; string ScreenIP = lvPort.SelectedItems[0].SubItems[6].Text; string MoxaIP = lvServer.SelectedItems[0].SubItems[2].Text; SetPort s = new SetPort(IP, port.ToString(), DeskNo, DeskDesc, PLC, Red, Green, ScreenIP, cbxMoxaGroup.Text); if (s.ShowDialog() == DialogResult.OK) { ModifyMCCPortConfig(MoxaIP, MOXANo, port, s.DeskNo, s.DeskDes, s.PLCAddress, s.RedAddress, s.GreenAddress, s.ScreenIP);; LoadMCCConfig(); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void btnAddPort_Click(object sender, EventArgs e) { try { if (lvServer.SelectedItems.Count == 0) { MessageBox.Show("选择则一个摩莎"); return; } int port = GetNewPortNo(); string MOXANo = lvServer.SelectedItems[0].SubItems[0].Text; string IP = lvServer.SelectedItems[0].SubItems[2].Text; string Model = lvServer.SelectedItems[0].SubItems[1].Text; SetPort s = new SetPort(IP, port.ToString(), cbxMoxaGroup.Text); if (s.ShowDialog() == DialogResult.OK) { port = Convert.ToInt32(s.PortNo); InsertMCCPortConfig(IP, Model, MOXANo, port, s.DeskNo, s.DeskDes, s.PLCAddress, s.RedAddress, s.GreenAddress, s.ScreenIP, s.Group); string SQL = "INSERT INTO LightModel ([DeskNo],[SRemind],[SLong],[STwinkle],[STimes],[FRemind],[FLong],[Ftwinkle],[FTimes],[BRemind],[BLong]" + ",[BTwinkle],[BTimes],[Lremind],[LLong],[LTwinkle],[LTimes],[SerialName],[Rate])" + "SELECT '" + s.DeskNo + "',[SRemind],[SLong],[STwinkle],[STimes],[FRemind],[FLong],[Ftwinkle],[FTimes],[BRemind] ,[BLong]" + ",[BTwinkle],[BTimes],[Lremind],[LLong],[LTwinkle],[LTimes],[SerialName],[Rate] FROM LightModel where DeskNo = '默认设置' "; DB.SetPIVAsDB(SQL); LoadMCCConfig(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }