You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.3 KiB
53 lines
2.3 KiB
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 System.Data.SqlClient;
|
|
|
|
namespace _01调度窗口
|
|
{
|
|
public partial class addmenu : Form
|
|
{
|
|
public addmenu()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
//子窗口实现添加行操作
|
|
private void btsave_Click(object sender, EventArgs e)
|
|
{
|
|
string constr = @"Server=DESKTOP-PE4T4D8;Database=Test;Trusted_Connection=true;";
|
|
SqlConnection con = new SqlConnection(constr);
|
|
con.Open();
|
|
|
|
string a = addtextBox1.Text.ToString(); //将输入的条码值取出来 tostring()
|
|
bool b = a.Skip(1).All(char.IsDigit); //判断除第一个字符后面的五位是不是数字
|
|
if (addtextBox1.Text.Length == 6 && a[0] == 'T'&& b) //char.IsLetter(char.Parse(addtextBox1.Text))
|
|
{
|
|
MessageBox.Show("输入成功!");
|
|
string addsql = $"insert into Table_1(条码, 调度任务索引, 关联任务索引, 任务类型," +
|
|
$"作业类型, 起点, 起点货位, 终点, 终点货位, 任务状态, 开始时间, 故障信息) " +
|
|
$"values ('" + addtextBox1.Text.ToString() + "', '" + addtextBox2.Text.ToString() + "', '" + addtextBox3.Text.ToString() + "', " +
|
|
"'" + addtextBox4.Text.ToString() + "', '" + addtextBox5.Text.ToString() + "', '" + addtextBox6.Text.ToString() + "', " +
|
|
"'" + addtextBox7.Text.ToString() + "', '" + addtextBox8.Text.ToString() + "', '" + addtextBox9.Text.ToString() + "'," +
|
|
"'" + addtextBox10.Text.ToString() + "', '" + addtextBox11.Text.ToString() + "', '" + addtextBox12.Text.ToString() + "' )";
|
|
SqlDataAdapter da = new SqlDataAdapter(addsql, con);
|
|
|
|
DataTable dt = new DataTable();
|
|
dataGridView1.DataSource = dt;
|
|
da.Fill(dt);
|
|
MessageBox.Show("新增成功,请刷新界面!");
|
|
con.Close();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("输入有误!");
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|