📄 set_port.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace D_Equipment_Mis
{
public partial class set_port : Form
{
public set_port()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (cbo_port.Text == "")
{
MessageBox.Show("请选择端口号!");
cbo_port.Focus();
return;
}
string del_str = "delete from zd_port";
OleDbConnection myconn = new OleDbConnection(data.connstr);
OleDbCommand del_cmd = new OleDbCommand(del_str, myconn);
try
{
myconn.Open();
del_cmd.ExecuteNonQuery();
}
catch (Exception t)
{
MessageBox.Show(t.ToString());
}
myconn.Close();
string ins_str = "insert into zd_port (com) values (@icom)";
OleDbCommand ins_cmd = new OleDbCommand(ins_str, myconn);
ins_cmd.Parameters.Add("icom", OleDbType.VarChar).Value = cbo_port.Text;
try
{
myconn.Open();
if ((int)ins_cmd.ExecuteNonQuery() == 1)
MessageBox.Show("保存成功");
}
catch (Exception t)
{
MessageBox.Show(t.ToString());
}
myconn.Close();
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -