1 Star 0 Fork 0

毛雄斌/WindowsFormsApp2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Form2.cs 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
毛雄斌 提交于 2019-07-02 21:37 . 完成基本的操作
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using S7.Net;
namespace WindowsFormsApp2
{
public partial class Form2 : Form
{
public Form1 ParentForm1 { get; set; }
public Form2()
{
InitializeComponent();
this.S7PLCType.Items.Clear();
this.S7PLCType.Items.AddRange(Enum.GetNames(typeof(CpuType)));
this.S7PLCType.SelectedItem = CpuType.S71200.ToString();
}
private void PlcAddCheck_Click(object sender, EventArgs e)
{
int tmp1,tmp2;
if ((!int.TryParse(plcRack.Text, out tmp1 )) | (!int.TryParse(plcRack.Text, out tmp2)))
{
MessageBox.Show("请正确输入数字");
return;
}
if (checkParaOk())
{
MessageBox.Show("plc名称重复!");
return;
}
CpuType cputype = (CpuType)Enum.Parse(typeof(CpuType), S7PLCType.Text);
s7Plc newplc = new s7Plc(plcName.Text, cputype, plcAddr.Text, (short)tmp1, (short)tmp2);
newplc.Node.ContextMenuStrip = ParentForm1.plcContextStrip;
this.ParentForm1.Pmg.add(newplc);
this.DialogResult = DialogResult.OK;
}
private void PlcAddCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void S7PLCType_SelectedIndexChanged(object sender, EventArgs e)
{
}
private bool checkParaOk()
{
if (ParentForm1.Pmg.FindPLCByName(plcName.Text) == null) return false;
return true;
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/mao_qin_bin/WindowsFormsApp2.git
git@gitee.com:mao_qin_bin/WindowsFormsApp2.git
mao_qin_bin
WindowsFormsApp2
WindowsFormsApp2
master

搜索帮助