|
|
@@ -217,40 +217,43 @@ namespace UAS_MES.SystemSetting
|
|
|
//如果有改变的行才传递到后台
|
|
|
if (dt.GetChanges() != null)
|
|
|
{
|
|
|
- //如果是新增的默认加上Radio当前选中的打印软件
|
|
|
+
|
|
|
for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
|
|
|
{
|
|
|
-
|
|
|
+ //如果是新增的默认加上Radio当前选中的打印软件
|
|
|
if (LabelDataGridView.Rows[i].Cells["pl_labelsoft"].Value.ToString() == "")
|
|
|
{
|
|
|
LabelDataGridView.Rows[i].Cells["pl_labelsoft"].Value = LabelSoft;
|
|
|
}
|
|
|
+ //从表格判断一个产品以及对应的打印模板是否存在默认选项
|
|
|
if (!dic.ContainsKey(LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() + LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()))
|
|
|
{
|
|
|
dic.Add(LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() + LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString(), LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString());
|
|
|
}
|
|
|
- else {
|
|
|
- string outvalue = dic[LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() + LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()];
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string outvalue = dic[LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() + LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()];
|
|
|
if (outvalue == "0")
|
|
|
{
|
|
|
dic[LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() + LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()] = LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString();
|
|
|
}
|
|
|
- else if (LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString() == "1"&&(LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() == LabelDataGridView.Rows[i-1].Cells["pl_prodcode"].Value.ToString()) &&(LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString() == LabelDataGridView.Rows[i-1].Cells["pl_labeltype"].Value.ToString())){
|
|
|
- MessageBox.Show("保存的模板之前具有默认模板");
|
|
|
+ else if (LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString() == "1" && (LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString() == LabelDataGridView.Rows[i - 1].Cells["pl_prodcode"].Value.ToString()) && (LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString() == LabelDataGridView.Rows[i - 1].Cells["pl_labeltype"].Value.ToString()))
|
|
|
+ {
|
|
|
+ MessageBox.Show("产品"+LabelDataGridView.Rows[i].Cells["pr_detail1"].Value.ToString() +" "+ LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()+ " 保存的模板之前具有默认模板");
|
|
|
LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value = "0";
|
|
|
}
|
|
|
}
|
|
|
+ //从数据库核对是否同时存在一个产品以及对应打印模板是否存在默认选项
|
|
|
DataTable table = (DataTable)dh.ExecuteSql("select pl_isdefault from productlabel where pl_id = '" + LabelDataGridView.Rows[i].Cells["pl_id"].Value.ToString() + " '", "select");
|
|
|
if (LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString() == "1" && table.Rows[0][0].ToString() == "0")
|
|
|
{
|
|
|
int is_defualt = isdefault(LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString(), LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString());
|
|
|
if (is_defualt == 0)
|
|
|
{
|
|
|
- MessageBox.Show("保存的模板之前具有默认模板");
|
|
|
+ MessageBox.Show("产品" + LabelDataGridView.Rows[i].Cells["pr_detail1"].Value.ToString()+" "+ LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString()+ " 保存的模板之前具有默认模板");
|
|
|
LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value = is_defualt;
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
string sql = "Insert into productlabel (PL_ID,PL_PRODCODE,PL_LABELTYPE,PL_LABELCODE,PL_LABELURL,PL_DETNO,PL_LABELSOFT,PL_ISDEFAULT) values( ProductLabel_seq.nextval,'" + pr_code.Text + "',:PL_LABELTYPE,:PL_LABELCODE,:PL_LABELURL,:PL_DETNO,:PL_LABELSOFT,:PL_ISDEFAULT )";
|
|
|
dh.SaveDataTable(dt.GetChanges(), "productlabel", "pl_id", sql.ToLower());
|
|
|
@@ -341,9 +344,31 @@ namespace UAS_MES.SystemSetting
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //判断与标签保存时是否已经有同类型标签存在
|
|
|
+ private Boolean isSameLabel(string pl_prodcode, string pl_labeltype, string pl_labelname)
|
|
|
+ {
|
|
|
+ LogStringBuilder sql2 = new LogStringBuilder();
|
|
|
+ sql2.Append("select la_id,pl_labelname,pl_labelurl,pl_labeltype,pl_isdefault,pl_prodcode,pl_id,pl_labelcode,pl_detno,pl_labelsoft,pr_detail,pr_spec,");
|
|
|
+ sql2.Append("pr_code from productlabel left join product on pl_prodcode=pr_code left join label on pl_labelcode=la_code");
|
|
|
+ sql2.Append(" where pl_prodcode = '" + pl_prodcode + "' and pl_labeltype = '" + pl_labeltype + "' and pl_labelname = '" + pl_labelname + "'");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql2.GetString(), "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ sql2.Clear();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sql2.Clear();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void LoadData()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
//如果没有任何筛选条件直接选取productlabel的数据
|
|
|
if (sql.GetString().Length == 0)
|
|
|
{
|
|
|
@@ -389,17 +414,37 @@ namespace UAS_MES.SystemSetting
|
|
|
ftp.UpLoadFile(FolderPath.Text, la_name.Text);
|
|
|
if (pl_id2 != "")
|
|
|
{
|
|
|
- sql.Clear();
|
|
|
- sql.Append("update productlabel set pl_labelcode=:pl_labelcode,pl_labeltype=:pl_labeltype,pl_labelname=:pl_labelname,");
|
|
|
- sql.Append("pl_prodcode=:pl_prodcode,pl_indate=sysdate where pl_id='" + pl_id2 + "'");
|
|
|
- dh.ExecuteSql(sql.GetString(), "update", la_code.Text, la_type.Text, la_name.Text, pr_code.Text);
|
|
|
+ if (!isSameLabel(pr_code.Text, la_type.Text, la_name.Text))
|
|
|
+ {
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("update productlabel set pl_labelcode=:pl_labelcode,pl_labeltype=:pl_labeltype,pl_labelname=:pl_labelname,");
|
|
|
+ sql.Append("pl_prodcode=:pl_prodcode,pl_indate=sysdate where pl_id='" + pl_id2 + "'");
|
|
|
+ dh.ExecuteSql(sql.GetString(), "update", la_code.Text, la_type.Text, la_name.Text, pr_code.Text);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("编号" + pr_code.Text + "商品已有相同标签");
|
|
|
+ sql.Clear();
|
|
|
+ LoadData();
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- sql.Clear();
|
|
|
- sql.Append("insert into productlabel (pl_id,pl_labelcode,pl_labeltype,pl_isdefault,pl_labelurl,pl_labelsoft,pl_labelname,pl_prodcode,pl_indate) values( productlabel_seq.nextval, ");
|
|
|
- sql.Append("'" + la_code.Text + "','" + la_type.Text + "','" + isdefault(pr_code.Text, la_type.Text) + "','" + ftpOperater.FTPAddress + la_name.Text + "','" + SoftWare + "','" + la_name.Text + "','" + pr_code.Text + "',sysdate)");
|
|
|
- dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
+ if (!isSameLabel(pr_code.Text, la_type.Text, la_name.Text))
|
|
|
+ {
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("insert into productlabel (pl_id,pl_labelcode,pl_labeltype,pl_isdefault,pl_labelurl,pl_labelsoft,pl_labelname,pl_prodcode,pl_indate) values( productlabel_seq.nextval, ");
|
|
|
+ sql.Append("'" + la_code.Text + "','" + la_type.Text + "','" + isdefault(pr_code.Text, la_type.Text) + "','" + ftpOperater.FTPAddress + la_name.Text + "','" + SoftWare + "','" + la_name.Text + "','" + pr_code.Text + "',sysdate)");
|
|
|
+ dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("编号" + pr_code.Text + "商品已有相同标签");
|
|
|
+ sql.Clear();
|
|
|
+ LoadData();
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
pl_id2 = "";
|
|
|
MessageBox.Show("保存成功!");
|