Browse Source

产品标签维护插入新模板会判断是否具有相同类型模板从而正确选择默认值

Hcsy 8 years ago
parent
commit
b6086af098
1 changed files with 26 additions and 2 deletions
  1. 26 2
      UAS-MES/FunctionCode/SystemSetting/SystemSetting_LabelMaintain.cs

+ 26 - 2
UAS-MES/FunctionCode/SystemSetting/SystemSetting_LabelMaintain.cs

@@ -222,6 +222,10 @@ namespace UAS_MES.SystemSetting
                     {
                         LabelDataGridView.Rows[i].Cells["pl_labelsoft"].Value = LabelSoft;
                     }
+                    
+                    //if (LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value.ToString() == "1") {
+                    //    LabelDataGridView.Rows[i].Cells["pl_isdefault"].Value = isdefault(LabelDataGridView.Rows[i].Cells["pl_prodcode"].Value.ToString(), LabelDataGridView.Rows[i].Cells["pl_labeltype"].Value.ToString());
+                    //}
                 }
                 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());
@@ -292,6 +296,26 @@ namespace UAS_MES.SystemSetting
             //覆盖参数错误的事件,使得不会报错    
         }
 
+        //判断与维护标签相同ID是否具有默认模板
+        private int isdefault(string pl_prodcode,string pl_labeltype)
+        {
+            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_isdefault = '1' and pl_prodcode = '" + pl_prodcode+ "'  and pl_labeltype = '"+pl_labeltype+"'");
+            dt = (DataTable)dh.ExecuteSql(sql2.GetString(), "select");
+            if (dt.Rows.Count > 0)
+            {
+                sql2.Clear();
+                return 0;
+            }
+            else
+            {
+                sql2.Clear();
+                return 1;
+            }
+        } 
+
         private void LoadData()
         {
        
@@ -348,8 +372,8 @@ namespace UAS_MES.SystemSetting
                     else
                     {
                         sql.Clear();
-                        sql.Append("insert into productlabel (pl_id,pl_labelcode,pl_labeltype,pl_labelurl,pl_labelsoft,pl_labelname,pl_prodcode) values( productlabel_seq.nextval, ");
-                        sql.Append("'" + la_code.Text + "','" + la_type.Text + "','" + ftpOperater.FTPAddress + la_name.Text + "','" + SoftWare + "','" + la_name.Text + "','" + pr_code.Text + "')");
+                        sql.Append("insert into productlabel (pl_id,pl_labelcode,pl_labeltype,pl_isdefault,pl_labelurl,pl_labelsoft,pl_labelname,pl_prodcode) 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 + "')");
                         dh.ExecuteSql(sql.GetString(), "insert");
                     }
                     pl_id2 = "";