Form2.cs
2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HaierExe04
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
LinkSqlDB SqlDbItem = new LinkSqlDB();
private void button1_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text!= "" && textBox6.Text != "" && textBox7.Text != "")
{
if (textBox2.Text.Length == 9)
{
MessageBox.Show("条码录入的长度必须为9");
textBox2.Focus();
}
else
{
string strInsert = "Insert into T_BarcodeRules(Brand,Code,[Type],ExternalSerial,Serial,[Platform],ProductType,SaleTo)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";
string strSql = string.Format(strInsert, textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, textBox7.Text, comboBox1.Text);
if (SqlDbItem.Exists("T_BarcodeRules", "Code", textBox2.Text) != 0)
{
if (SqlDbItem.Insert(strSql) == true)
{
label17.Text = "导入成功!!!";
label17.ForeColor = Color.Green;
}
else
{
label17.Text = "导入失败!!!";
label17.ForeColor = Color.Red;
}
}
else
{
MessageBox.Show("条码的前9位信息已经存在!!!,请核对");
}
}
}
else
{
MessageBox.Show("录入信息项目不允许出现为空!!!,请核对项目");
}
}
catch (Exception ex)
{
LogExecute.WriteExceptionLog("手工导入", ex);
}
}
}
}