//材料库位保存 private void simpleButton1_Click(object sender, EventArgs e) { if (CheckDataIntegrity() == true) { Model.CLKW ck = new Model.CLKW(); ck.Id = Guid.NewGuid().ToString(); ck.Cpkw = textBox1.Text; ck.CPKWName = textBox2.Text; //检测库位代码和库位名称时候重复 if (CheckLocationCodeRepeat(textBox1.Text)) { MessageBox.Show("库位代码重复", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (CheckLocationNameRepeat(textBox2.Text)) { MessageBox.Show("库位名称重复", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (SQL.SqlExecute.CLKWInsert(ck) == 0) { MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("保存失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("所填数据必须为非空", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static int CLKWInsert(Model.CLKW ck) { SqlHelper.connectionStr = GetSQLConnect(); string sqlstr = "INSERT INTO WMS_M_CLKW (ID,CLKW,CLKWName) VALUES ('" + ck.Id + "','" + ck.Cpkw + "','" + ck.CPKWName + "')"; try { SqlHelper.ExecCommand(sqlstr); return(0); } catch { return(-1); } }