int ppr2 = Convert.ToInt32(cmd2.ExecuteScalar());
string sq4 = "insert into kehu values('" + comboBox1.Text.Trim() + "','" + ppr + "','" + comboBox2.Text.Trim() + "','" + ppr1 + "','" + textBox1.Text.Trim() + "','" + ppr2 + "','" + textBox4.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox7.Text.Trim() + "','" + textBox8.Text.Trim() + "','" + textBox9.Text.Trim() + "','" + textBox10.Text.Trim() + "','" + textBox11.Text.Trim() + "')";
SqlCommand cmd3 = new SqlCommand(sq4, conn);
cmd3.ExecuteNonQuery();
sqlClose();
MessageBox.Show("添加成功");
button3.Enabled = true;
}
图 3.8添加联系人
添加的联系人与之前添加的客户相对应,当然,也可以不用现在添加,可以从模块导航界面直接进入到添加联系人界面。
输入正确的联系人信息,按下“确认”键后,保存信息,若输入不完整,也会出现错误提示,并无法保存信息。
实现代码如下:
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox6.Text == "" || textBox9.Text == "")
{
MessageBox.Show("信息输入不完整,请检查");
return;
}
else
{
sqlConnect();
string sq = "select max(custormid) from kehu";
SqlCommand cmd = new SqlCommand(sq, conn);
int ppr = Convert.ToInt32(cmd.ExecuteScalar());
string sq1 = "select max(lianxirenid)+1 from lianxiren";
SqlCommand cmd1 = new SqlCommand(sq1, conn);
int ppr1 = Convert.ToInt32(cmd1.ExecuteScalar());
string sq2 = "insert into lianxiren values('" + ppr + "','" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + textBox5.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox7.Text.Trim() + "','" + textBox8.Text.Trim() + "','" + textBox9.Text.Trim() + "','" +ppr1 + "','" + textBox10.Text.Trim() + "','" + textBox11.Text.Trim() + "')"; ASP.NET客户信息管理系统的开发(10):http://www.751com.cn/jisuanji/lunwen_460.html