|
|
@@ -1,5 +1,6 @@
|
|
|
using LabelManager2;
|
|
|
using System;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
using System.Text;
|
|
|
@@ -19,6 +20,7 @@ namespace UAS_MES.SystemSetting
|
|
|
//设置Grid中Combox的静态数据,这个格式是必须的,#前面是展示值,#后面是实际值
|
|
|
string[] labeltype = { "机身标#机身标", "彩盒标#彩盒标", "卡通箱标#卡通箱标", "大箱标#大箱标", "栈板标#栈板标" };
|
|
|
string[] defaultype = { "是#1", "否#0" };
|
|
|
+ Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
//用于拼接条件查询
|
|
|
StringBuilder condition = new StringBuilder();
|
|
|
LogStringBuilder sql = new LogStringBuilder();
|
|
|
@@ -218,14 +220,42 @@ namespace UAS_MES.SystemSetting
|
|
|
//如果是新增的默认加上Radio当前选中的打印软件
|
|
|
for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
|
|
|
{
|
|
|
+
|
|
|
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()];
|
|
|
+ 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("保存的模板之前具有默认模板");
|
|
|
+ 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("保存的模板之前具有默认模板");
|
|
|
+ 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());
|
|
|
LoadData();
|
|
|
+ dic.Clear();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -291,6 +321,25 @@ 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 +397,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,pl_indate) values( productlabel_seq.nextval, ");
|
|
|
- sql.Append("'" + la_code.Text + "','" + la_type.Text + "','" + ftpOperater.FTPAddress + la_name.Text + "','" + SoftWare + "','" + la_name.Text + "','" + pr_code.Text + "',sysdate)");
|
|
|
+ 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");
|
|
|
}
|
|
|
pl_id2 = "";
|
|
|
@@ -378,7 +427,13 @@ namespace UAS_MES.SystemSetting
|
|
|
string[] deleteid = new string[LabelDataGridView.RowCount];
|
|
|
for (int i = 0; i < LabelDataGridView.RowCount; i++)
|
|
|
{
|
|
|
- deleteid[i] = LabelDataGridView.Rows[i].Cells["pl_id"].Value.ToString();
|
|
|
+ if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
|
|
|
+ {
|
|
|
+ if ((bool)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
|
|
|
+ {
|
|
|
+ deleteid[i] = LabelDataGridView.Rows[i].Cells["pl_id"].Value.ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
dh.DeleteDataByID("productlabel", "pl_id", deleteid);
|
|
|
LoadData();
|