|
|
@@ -27,10 +27,7 @@ namespace UAS_LabelMachine
|
|
|
DataHelper dh;
|
|
|
|
|
|
DataTable dt;
|
|
|
- /// <summary>
|
|
|
- /// 已经打印过的Vivo外箱号
|
|
|
- /// </summary>
|
|
|
- List<string> PrintedVivoOutboxCode = new List<string>();
|
|
|
+
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
/// <summary>
|
|
|
/// CodeSoft新建打印机引擎
|
|
|
@@ -92,8 +89,7 @@ namespace UAS_LabelMachine
|
|
|
DataTable OutLabelParam;
|
|
|
|
|
|
Dictionary<string, string> CollectData;
|
|
|
- //缓存单盘数据数据的DataTable
|
|
|
- DataTable SingleBoxCacheData;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 存放单盘的ID
|
|
|
/// </summary>
|
|
|
@@ -103,10 +99,6 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
List<string> SingleBoxArgument = new List<string>();
|
|
|
/// <summary>
|
|
|
- /// 中盒缓存数据
|
|
|
- /// </summary>
|
|
|
- DataTable MidBoxCacheData;
|
|
|
- /// <summary>
|
|
|
/// 存放中盒的ID和盒号
|
|
|
/// </summary>
|
|
|
Dictionary<string, string> MidIDAndOutboxcode = new Dictionary<string, string>();
|
|
|
@@ -176,11 +168,6 @@ namespace UAS_LabelMachine
|
|
|
CheckForIllegalCrossThreadCalls = false;
|
|
|
CloumnCount = LabelInf.Columns.Count;
|
|
|
pi_inoutno.Focus();
|
|
|
- //将本地读取的打印机设置进Combox,并选中默认打印机
|
|
|
- if (User.UserAccountType == "admin")
|
|
|
- PowerSetting.Visible = true;
|
|
|
- MidBoxCacheData = new DataTable();
|
|
|
- SingleBoxCacheData = new DataTable();
|
|
|
sg_code.FormName = Name;
|
|
|
sg_code.SetValueField = new string[] { "sg_code" };
|
|
|
sg_code.SelectField = "sg_code # 策略编号 ,sg_name # 策略名称,sg_brand # 品牌,sg_separator # 分隔符";
|
|
|
@@ -513,8 +500,6 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
}
|
|
|
- string cl_labelname = SingleLabelCombox.Text;
|
|
|
- string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() == LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value.ToString())
|
|
|
@@ -539,13 +524,7 @@ namespace UAS_LabelMachine
|
|
|
CurrentRowIndex = i;
|
|
|
if (SingleLabelAutoPrint.Checked)
|
|
|
{
|
|
|
- if (la_id != "")
|
|
|
- AutoPrintSingleLabel(la_id, LabelUrl);
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show("未维护单盘标签");
|
|
|
- return;
|
|
|
- }
|
|
|
+ AutoPrintSingleLabel();
|
|
|
}
|
|
|
if (MidLabelAutoPrint.Checked)
|
|
|
AutoPrintMidLabel();
|
|
|
@@ -586,10 +565,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (SingleLabelCombox.SelectedValue != null)
|
|
|
{
|
|
|
- string la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- string cl_labelname = SingleLabelCombox.Text;
|
|
|
- string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
|
|
|
- AutoPrintSingleLabel(la_id, LabelUrl);
|
|
|
+ AutoPrintSingleLabel();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -662,36 +638,32 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void AutoPrintSingleLabel(string la_id, string LabelUrl)
|
|
|
+ private void AutoPrintSingleLabel()
|
|
|
{
|
|
|
//用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
- string[] arg = SingleBoxArgument.ToArray();
|
|
|
+ string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
|
|
|
StringBuilder ParamLog = new StringBuilder();
|
|
|
- for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select * from ");
|
|
|
+ for (int i = 0; i < SingleLabelParam.Rows.Count; i++)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
+ if (i != SingleLabelParam.Rows.Count - 1)
|
|
|
+ sql.Append("(" + SingleLabelParam.Rows[i]["lp_sql"].ToString() + "),");
|
|
|
+ else
|
|
|
+ sql.Append("(" + SingleLabelParam.Rows[i]["lp_sql"].ToString() + ")");
|
|
|
+ }
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id), "select");
|
|
|
+ for (int i = 0; i < SingleDoc.Variables.FreeVariables.Count; i++)
|
|
|
+ {
|
|
|
+ if (dt.Columns.Contains(SingleDoc.Variables.FreeVariables.Item(i + 1).Name))
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][SingleDoc.Variables.FreeVariables.Item(i + 1).Name].ToString();
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(i + 1).Value == "")
|
|
|
{
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == SingleLabelParam.Rows[k]["lp_name"].ToString().ToLower())
|
|
|
- {
|
|
|
- string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
|
|
|
- DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
|
|
|
- if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- ParamLog.AppendLine("pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
+ DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(i + 1).Name + "'");
|
|
|
+ if (dr1.Length > 0)
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
}
|
|
|
}
|
|
|
- LogManager.DoLog(ParamLog.ToString());
|
|
|
SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
SingleDoc.PrintDocument();
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
|
|
|
@@ -830,35 +802,12 @@ namespace UAS_LabelMachine
|
|
|
//MPN和QTY只做比较不需要赋值
|
|
|
if (cell.Value.ToString() == "" || cell.Value.ToString() != Matchstr)
|
|
|
{
|
|
|
- string MatchResult = "";
|
|
|
if (kind != "MPN" && kind != "QTY" && kind != "品牌")
|
|
|
{
|
|
|
DataTable dt = (DataTable)MidSource.DataSource;
|
|
|
cell.Value = Matchstr;
|
|
|
- MatchResult = "成功";
|
|
|
- }
|
|
|
- else
|
|
|
- MatchResult = "失败";
|
|
|
- switch (SiItem[kind]["si_kind"])
|
|
|
- {
|
|
|
- case "索引字符":
|
|
|
- LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",使用字符" + SiItem[kind]["si_indexstring"] + ",匹配后字符串" + Matchstr);
|
|
|
- break;
|
|
|
- case "起始位置":
|
|
|
- LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",从第" + SiItem[kind]["si_index"] + "位开始匹配,匹配后字符串" + Matchstr);
|
|
|
- break;
|
|
|
- case "二次解析":
|
|
|
- LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",匹配后字符串" + Matchstr);
|
|
|
- break;
|
|
|
- case "全部":
|
|
|
- LogManager.DoLog("采集项" + kind + ",匹配结果:【" + MatchResult + "】,匹配方式:" + SiItem[kind]["si_kind"] + ",匹配后字符串" + Matchstr);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- LogManager.DoLog("采集项" + kind + ",匹配结果:【成功】,匹配方式:" + SiItem[kind]["si_kind"] + ",,匹配后字符串" + Matchstr);
|
|
|
}
|
|
|
}
|
|
|
//添加外箱号,如果外箱号的箱内容量不为0并且已经采集完成
|
|
|
@@ -1109,8 +1058,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//缓存外箱参数
|
|
|
ComBoxClickChangeLabelDoc = true;
|
|
|
- GetSingleBoxData();
|
|
|
- GetMidBoxData();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -1138,27 +1085,11 @@ namespace UAS_LabelMachine
|
|
|
LoadGridData(sender, e);
|
|
|
//重新输入单号后清除缓存
|
|
|
MidBoxArgument.Clear();
|
|
|
- MidBoxCacheData.Clear();
|
|
|
- BaseUtil.CleanDataTable(MidBoxCacheData);
|
|
|
SingleBoxArgument.Clear();
|
|
|
- SingleBoxCacheData.Clear();
|
|
|
- BaseUtil.CleanDataTable(SingleBoxCacheData);
|
|
|
MidIDAndOutboxcode.Clear();
|
|
|
SingleID.Clear();
|
|
|
//刷新采集进度
|
|
|
RefreshProcessData();
|
|
|
- //设置当前的最大箱号
|
|
|
- for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
- {
|
|
|
- string outboxcode = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
- //如果包含有-,则需要解析
|
|
|
- if (outboxcode.Contains("-"))
|
|
|
- if (int.Parse(outboxcode.Split('-')[0] == "" ? "1" : outboxcode.Split('-')[0]) > MaxOutBoxCode)
|
|
|
- MaxOutBoxCode = int.Parse(outboxcode.Split('-')[0]);
|
|
|
- //else
|
|
|
- //if (int.Parse(outboxcode == "" ? "1" : outboxcode) > MaxOutBoxCode)
|
|
|
- // MaxOutBoxCode = int.Parse(outboxcode);
|
|
|
- }
|
|
|
thread = new Thread(GetInOutInfAndLabelFile);
|
|
|
stw = new SetLoadingWindow(thread, "正在获取打印标签");
|
|
|
BaseUtil.SetFormCenter(stw);
|
|
|
@@ -1193,11 +1124,6 @@ namespace UAS_LabelMachine
|
|
|
MessageBox.Show("中盘标签未维护参数");
|
|
|
}
|
|
|
}
|
|
|
- string la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- string cl_labelname = SingleLabelCombox.Text;
|
|
|
- string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
|
|
|
- //查询该模板维护的所有参数
|
|
|
- dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
|
|
|
if (SingleLabelParam.Rows.Count > 0 && LabelInf.Rows.Count > 0)
|
|
|
{
|
|
|
//每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
|
|
|
@@ -1225,11 +1151,6 @@ namespace UAS_LabelMachine
|
|
|
MessageBox.Show("选择的行未勾选采集或者已打印");
|
|
|
return;
|
|
|
}
|
|
|
- //打印的时候如果不存在数据开始缓存
|
|
|
- if (SingleBoxCacheData.Rows.Count == 0)
|
|
|
- GetSingleBoxData();
|
|
|
- if (MidBoxCacheData.Rows.Count == 0)
|
|
|
- GetMidBoxData();
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
if (i + 1 < LabelInf.RowCount)
|
|
|
@@ -1250,7 +1171,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//用于判断用户是否勾选了行
|
|
|
int CheckedRowCount = 0;
|
|
|
- string[] arg = SingleBoxArgument.ToArray();
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
//勾选了并且未打印
|
|
|
@@ -1262,23 +1182,29 @@ namespace UAS_LabelMachine
|
|
|
try
|
|
|
{
|
|
|
string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
|
|
|
- DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
|
|
|
- StringBuilder ParamLog = new StringBuilder();
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select * from ");
|
|
|
+ for (int j = 0; j < SingleLabelParam.Rows.Count; j++)
|
|
|
+ {
|
|
|
+ if (j != SingleLabelParam.Rows.Count - 1)
|
|
|
+ sql.Append("(" + SingleLabelParam.Rows[j]["lp_sql"].ToString() + "),");
|
|
|
+ else
|
|
|
+ sql.Append("(" + SingleLabelParam.Rows[j]["lp_sql"].ToString() + ")");
|
|
|
+ }
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id), "select");
|
|
|
for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
- if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
+ if (dt.Columns.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
+ {
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
+ }
|
|
|
if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
{
|
|
|
DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
if (dr1.Length > 0)
|
|
|
- {
|
|
|
SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
}
|
|
|
- ParamLog.AppendLine("pib_id:" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
}
|
|
|
- LogManager.DoLog(ParamLog.ToString());
|
|
|
SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
SingleDoc.PrintDocument();
|
|
|
if (MidLabelAutoPrint.Checked)
|
|
|
@@ -1290,8 +1216,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (MidLabelCombox.SelectedValue != null)
|
|
|
{
|
|
|
- string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- MidBoxCodePrint(la_id_mid, CurrentRowIndex);
|
|
|
+ MidBoxCodePrint(CurrentRowIndex);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1303,8 +1228,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
|
|
|
- MidBoxCacheData.Clear();
|
|
|
- BaseUtil.CleanDataTable(MidBoxCacheData);
|
|
|
if (CheckedRowCount == 0)
|
|
|
MessageBox.Show("未勾选打印明细!");
|
|
|
else if (CurrentRowIndex + 1 < LabelInf.Rows.Count)
|
|
|
@@ -1318,168 +1241,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 缓存单盘的数据
|
|
|
- /// </summary>
|
|
|
- private void GetSingleBoxData()
|
|
|
- {
|
|
|
- if (SingleDoc == null)
|
|
|
- return;
|
|
|
- for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
- {
|
|
|
- if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
|
|
|
- SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
|
|
|
- //如果不存在中盒号则进行添加
|
|
|
- if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
- MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
- }
|
|
|
- //id数组
|
|
|
- string[] pib_id_arr = SingleID.ToArray();
|
|
|
- //将所有的列存在在这里
|
|
|
- List<DataTable> AllSingleBoxCacheData = new List<DataTable>();
|
|
|
- //每五百条拼接一次条件
|
|
|
- //手动添加ID列
|
|
|
- DataColumn datacolumn = new DataColumn("pib_id");
|
|
|
- if (!SingleBoxCacheData.Columns.Contains("pib_id"))
|
|
|
- SingleBoxCacheData.Columns.Add(datacolumn);
|
|
|
- //获取打印的SQL
|
|
|
- try
|
|
|
- {
|
|
|
- for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
- {
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == SingleLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- DataColumn dc = new DataColumn(SingleDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
- SingleBoxCacheData.Columns.Add(dc);
|
|
|
- SingleBoxArgument.Add(SingleDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
- string sql = SingleLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("="));
|
|
|
- DataTable temp = dh.getFieldsDatasByCondition(sql.Replace(" from ", " ,pib_id PIBID from ") + " in (select pib_id from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "') ORDER by pib_id");
|
|
|
- temp.Columns[0].ColumnName = SingleDoc.Variables.FreeVariables.Item(j + 1).Name;
|
|
|
- AllSingleBoxCacheData.Add(temp);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- DataTable[] Temp = AllSingleBoxCacheData.ToArray();
|
|
|
- //将所有数据写入到CacheData中
|
|
|
- if (Temp.Length > 0)
|
|
|
- for (int i = 0; i < Temp[0].Rows.Count; i++)
|
|
|
- {
|
|
|
- DataRow dr = SingleBoxCacheData.NewRow();
|
|
|
- dr["pib_id"] = pib_id_arr[i];
|
|
|
- //由于之前加了一个ID列,导致j从1开始
|
|
|
- for (int j = 1; j < SingleBoxCacheData.Columns.Count; j++)
|
|
|
- {
|
|
|
- dr[Temp[j - 1].Columns[0].ColumnName] = (Temp[j - 1].Select("PIBID=" + pib_id_arr[i]))[0][0];
|
|
|
- }
|
|
|
- SingleBoxCacheData.Rows.Add(dr);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
-
|
|
|
- SingleBoxArgument.Clear();
|
|
|
- SingleBoxCacheData.Clear();
|
|
|
- BaseUtil.CleanDataTable(SingleBoxCacheData);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 缓存中盒的数据
|
|
|
- /// </summary>
|
|
|
- private void GetMidBoxData()
|
|
|
- {
|
|
|
- if (MidDoc == null)
|
|
|
- return;
|
|
|
- StringBuilder pib_condition_string = new StringBuilder();
|
|
|
- StringBuilder pib_qtycondition_string = new StringBuilder();
|
|
|
- for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
- {
|
|
|
- //如果不存在中盒号则进行添加
|
|
|
- if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
- {
|
|
|
- MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
- }
|
|
|
- }
|
|
|
- //id数组
|
|
|
- string[] pib_id_arr = MidIDAndOutboxcode.Keys.ToArray();
|
|
|
- string[] pib_outbox_arr = MidIDAndOutboxcode.Values.ToArray();
|
|
|
- if (pib_id_arr.Length == 0)
|
|
|
- {
|
|
|
- MessageBox.Show("未勾选打印明细");
|
|
|
- return;
|
|
|
- }
|
|
|
- //记录一个ID用来取中盒的数量
|
|
|
- string pib_id = pib_id_arr[0];
|
|
|
- //id个数
|
|
|
- //将所有的列存在在这里
|
|
|
- List<DataTable> AllMidBoxCacheData = new List<DataTable>();
|
|
|
- //每五百条拼接一次条件
|
|
|
- //手动添加ID列
|
|
|
- DataColumn IDColumn = new DataColumn("pib_id");
|
|
|
- DataColumn OutBoxColumn = new DataColumn("pib_outboxcode1");
|
|
|
- if (!MidBoxCacheData.Columns.Contains("pib_id"))
|
|
|
- MidBoxCacheData.Columns.Add(IDColumn);
|
|
|
- if (!MidBoxCacheData.Columns.Contains("pib_outboxcode1"))
|
|
|
- MidBoxCacheData.Columns.Add(OutBoxColumn);
|
|
|
- if (MidLabelCombox.SelectedValue == null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
- {
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- DataColumn dc = new DataColumn(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
- MidBoxCacheData.Columns.Add(dc);
|
|
|
- MidBoxArgument.Add(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
- string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- //如果打印的含有数量
|
|
|
- if (sql.ToLower().Contains("pib_qty"))
|
|
|
- {
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("=")) + " in (select distinct pib_outboxcode1 from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "')" + sql.Substring(sql.LastIndexOf("}") + 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("="));
|
|
|
- sql = sql + " in (select distinct pib_outboxcode1 from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "')" + " and pib_inoutno='" + pi_inoutno.Text + "' order by to_number(pib_outboxcode1)";
|
|
|
- }
|
|
|
- DataTable temp = dh.getFieldsDatasByCondition(sql);
|
|
|
- temp.Columns[0].ColumnName = MidDoc.Variables.FreeVariables.Item(j + 1).Name;
|
|
|
- AllMidBoxCacheData.Add(temp);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- DataTable[] Temp = AllMidBoxCacheData.ToArray();
|
|
|
- //将所有数据写入到CacheData中
|
|
|
- if (Temp.Length > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < pib_id_arr.Length; i++)
|
|
|
- {
|
|
|
- DataRow dr = MidBoxCacheData.NewRow();
|
|
|
- dr["pib_id"] = pib_id_arr[i];
|
|
|
- dr["pib_outboxcode1"] = pib_outbox_arr[i];
|
|
|
- //由于之前加了一个ID列和箱号,导致j从2开始
|
|
|
- for (int j = 2; j < MidBoxCacheData.Columns.Count; j++)
|
|
|
- {
|
|
|
- //选出勾选的中盒号
|
|
|
- dr[Temp[j - 2].Columns[0].ColumnName] = Temp[j - 2].Select("PIB_OUTBOXCODE1='" + pib_outbox_arr[i] + "'")[0][0];
|
|
|
- }
|
|
|
- MidBoxCacheData.Rows.Add(dr);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void SingleLabelPrint_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (SingleLabelCombox.Text != "")
|
|
|
@@ -1563,8 +1324,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
MidBoxArgument.Clear();
|
|
|
- MidBoxCacheData.Clear();
|
|
|
- BaseUtil.CleanDataTable(MidBoxCacheData);
|
|
|
List<int> MidOutBoxCode = new List<int>();
|
|
|
List<int> MidOutBoxCodeIndex = new List<int>();
|
|
|
string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
@@ -1578,26 +1337,18 @@ namespace UAS_LabelMachine
|
|
|
MidOutBoxCodeIndex.Add(i);
|
|
|
}
|
|
|
}
|
|
|
- GetMidBoxData();
|
|
|
for (int i = 0; i < MidOutBoxCodeIndex.Count; i++)
|
|
|
{
|
|
|
- MidBoxCodePrint(la_id, MidOutBoxCodeIndex[i]);
|
|
|
+ MidBoxCodePrint(MidOutBoxCodeIndex[i]);
|
|
|
}
|
|
|
MidBoxArgument.Clear();
|
|
|
- MidBoxCacheData.Clear();
|
|
|
- BaseUtil.CleanDataTable(MidBoxCacheData);
|
|
|
return;
|
|
|
}
|
|
|
bool FindMidLabel = false;
|
|
|
if (MidLabelCombox.SelectedValue != null)
|
|
|
{
|
|
|
- string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- string cl_labelname = MidLabelCombox.Text;
|
|
|
- string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
|
|
|
//中盒号所在的行
|
|
|
int MidLabelRowIndex = 0;
|
|
|
- //查找是否存在该中盒号
|
|
|
- List<int> MidRowIndex = new List<int>();
|
|
|
//缓存中盒数据
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
@@ -1606,12 +1357,11 @@ namespace UAS_LabelMachine
|
|
|
//找到了输入的中盒号停止循环
|
|
|
FindMidLabel = true;
|
|
|
MidLabelRowIndex = i;
|
|
|
- MidRowIndex.Add(i);
|
|
|
}
|
|
|
}
|
|
|
//找到了指定的盒号
|
|
|
if (FindMidLabel)
|
|
|
- MidBoxCodePrint(la_id, MidLabelRowIndex, MidRowIndex.ToArray());
|
|
|
+ MidBoxCodePrint(MidLabelRowIndex);
|
|
|
else
|
|
|
MessageBox.Show("该出入库单未找到该中盒号!");
|
|
|
}
|
|
|
@@ -1636,9 +1386,6 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
List<string> Outboxcode = new List<string>();
|
|
|
//如果未勾选箱号则对勾选的数据的箱号进行整合
|
|
|
- string la_id = OutBoxCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- string cl_labelname = OutBoxCombox.Text;
|
|
|
- string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
|
|
|
if (OutBoxNum.Text == "")
|
|
|
{
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
@@ -1664,7 +1411,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (LabelInf.Rows[h].Cells["pib_outboxcode2"].Value.ToString() == Outboxcode.ToArray()[i])
|
|
|
{
|
|
|
- OutBoxCodePrint(la_id, h);
|
|
|
+ OutBoxCodePrint(h);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -1696,7 +1443,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//找到了指定的盒号
|
|
|
if (FindMidLabel)
|
|
|
- OutBoxCodePrint(la_id, OutBoxLabelRowIndex);
|
|
|
+ OutBoxCodePrint(OutBoxLabelRowIndex);
|
|
|
else
|
|
|
MessageBox.Show("该出入库单未找到该外箱号!");
|
|
|
}
|
|
|
@@ -1705,14 +1452,8 @@ namespace UAS_LabelMachine
|
|
|
Outboxcode.Clear();
|
|
|
}
|
|
|
|
|
|
- private void MidBoxCodePrint(string la_id, int rowindex)
|
|
|
+ private void MidBoxCodePrint(int rowindex)
|
|
|
{
|
|
|
- if (MidBoxCacheData.Rows.Count == 0)
|
|
|
- {
|
|
|
- MidIDAndOutboxcode.Add(LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
- GetMidBoxData();
|
|
|
- }
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
|
|
|
string[] arg = MidBoxArgument.ToArray();
|
|
|
for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
@@ -1725,102 +1466,27 @@ namespace UAS_LabelMachine
|
|
|
//获取对应行的pib_id
|
|
|
string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- try
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select * from ");
|
|
|
+ for (int i = 0; i < MidLabelParam.Rows.Count; i++)
|
|
|
{
|
|
|
- //获取打印执行的SQL
|
|
|
- if (sql.IndexOf("{") == 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
+ if (i != MidLabelParam.Rows.Count - 1)
|
|
|
+ sql.Append("(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + "),");
|
|
|
else
|
|
|
- {
|
|
|
- DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
|
|
|
- if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
- {
|
|
|
- if (dr.Length > 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][MidDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
+ sql.Append("(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + ")");
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id).Replace("{pib_outboxcode1}", pib_outboxcode1), "select");
|
|
|
+ for (int i = 0; i < MidDoc.Variables.FreeVariables.Count; i++)
|
|
|
{
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
- MidDoc.PrintDocument();
|
|
|
- }
|
|
|
-
|
|
|
- private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
|
|
|
- {
|
|
|
- for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
- {
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- //获取对应行的pib_id
|
|
|
- string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
- string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- try
|
|
|
- {
|
|
|
- //获取打印执行的SQL
|
|
|
- if (sql.IndexOf("{") == 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- else
|
|
|
+ if (dt.Columns.Contains(MidDoc.Variables.FreeVariables.Item(i + 1).Name))
|
|
|
+ MidDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][MidDoc.Variables.FreeVariables.Item(i + 1).Name].ToString();
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
{
|
|
|
- if (sql.ToLower().Contains("pib_qty"))
|
|
|
- {
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("=")) + "='" + pib_outboxcode1 + "' group by pib_outboxcode1";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("="));
|
|
|
- sql = sql + " in (select distinct pib_outboxcode1 from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "')" + " and pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1='" + pib_outboxcode1 + "'";
|
|
|
- }
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
+ DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
+ if (dr1.Length > 0)
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
- return;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1831,55 +1497,34 @@ namespace UAS_LabelMachine
|
|
|
/// <summary>
|
|
|
/// 执行打印外箱号
|
|
|
/// </summary>
|
|
|
- private void OutBoxCodePrint(string la_id, int rowindex)
|
|
|
+ private void OutBoxCodePrint(int rowindex)
|
|
|
{
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
|
|
|
- try
|
|
|
+ //获取对应行的pib_id
|
|
|
+ string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
+ string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select * from ");
|
|
|
+ for (int i = 0; i < OutLabelParam.Rows.Count; i++)
|
|
|
{
|
|
|
- for (int j = 0; j < OutBoxDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ if (i != OutLabelParam.Rows.Count - 1)
|
|
|
+ sql.Append("(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + "),");
|
|
|
+ else
|
|
|
+ sql.Append("(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + ")");
|
|
|
+ }
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString().ToLower().Replace("{pib_id}", pib_id).Replace("{pib_outboxcode2}", pib_outboxcode2), "select");
|
|
|
+ for (int i = 0; i < OutBoxDoc.Variables.FreeVariables.Count; i++)
|
|
|
+ {
|
|
|
+ if (dt.Columns.Contains(OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name))
|
|
|
+ OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value = dt.Rows[0][OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name].ToString();
|
|
|
+ if (OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value == "")
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name == OutLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- //获取对应行的pib_id
|
|
|
- string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
- string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = OutLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- //select * from productiobarcode where pib_id={pib_id} and pib_outboxcode1={pib_outboxcode1}
|
|
|
- try
|
|
|
- {
|
|
|
- string ExeSQL = "";
|
|
|
- ExeSQL = sql.ToLower().Replace("{pib_id}", "'" + pib_id + "'");
|
|
|
- ExeSQL = ExeSQL.Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'");
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(ExeSQL).ToString();
|
|
|
- if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句" + sql);
|
|
|
- MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ DataRow[] dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "'");
|
|
|
+ if (dr1.Length > 0)
|
|
|
+ OutBoxDoc.Variables.FreeVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
}
|
|
|
- OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
|
|
|
- OutBoxDoc.PrintDocument();
|
|
|
- LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
|
|
|
}
|
|
|
- catch (Exception ex) { MessageBox.Show(ex.Message); }
|
|
|
+ OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
|
|
|
+ OutBoxDoc.PrintDocument();
|
|
|
}
|
|
|
|
|
|
private void CleanDetail_Click(object sender, EventArgs e)
|
|
|
@@ -1967,29 +1612,12 @@ namespace UAS_LabelMachine
|
|
|
private void LoadGridData(object sender, EventArgs e)
|
|
|
{
|
|
|
AllCollect = false;
|
|
|
- PrintedVivoOutboxCode.Clear();
|
|
|
- //如果是富为则使用特殊的查询语句
|
|
|
- if (DataHelper.DBConnectionString.Contains("richwell") || DataHelper.DBConnectionString.Contains("192.168.0.88"))
|
|
|
- {
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select pd_custprodcode,pd_pocode,pd_inoutno,pib_custbarcode,pib_brand,pib_cusbarcode,pib_cusoutboxcode,pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,");
|
|
|
- sql.Append("pr_brand,pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pib_barcode,pib_outboxcode1,pib_outboxcode2,pib_ifpick,pib_ifprint,");
|
|
|
- sql.Append("pr_spec,pd_prodcode,pd_pocode,pr_code from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno ");
|
|
|
- sql.Append("and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join (select pd_prodcode ");
|
|
|
- sql.Append("prcode,pd_pocode pocode,max(pd_detno) pd_detno from prodinout left join packing on packing.pi_code=prodinout.pi_packingcode ");
|
|
|
- sql.Append("left join packingdetail on packing.pi_id=pd_piid where prodinout.pi_id='" + PI_ID + "' group by pd_prodcode,pd_pocode");
|
|
|
- sql.Append(")A on pd_pocode=A.pocode and pd_prodcode=A.PRCODE where pd_piid='" + PI_ID + "' order by pr_code,a.pd_detno,pib_id");
|
|
|
- GetOutBoxCode.Visible = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select pd_custprodcode,pd_custprodspec,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
|
|
|
- sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
|
|
|
- sql.Append(" from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
|
|
|
- sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
|
|
|
- sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode1),pib_id,pd_prodcode");
|
|
|
- }
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select pd_custprodcode,pd_custprodspec,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
|
|
|
+ sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
|
|
|
+ sql.Append(" from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
|
|
|
+ sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
|
|
|
+ sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode1),pib_id,pd_prodcode");
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
MidSource.DataSource = dt;
|
|
|
BaseUtil.FillDgvWithDataTable(LabelInf, (DataTable)MidSource.DataSource);
|
|
|
@@ -2097,16 +1725,6 @@ namespace UAS_LabelMachine
|
|
|
CusOutBoxCode.Add(i);
|
|
|
}
|
|
|
}
|
|
|
- //打印外箱号
|
|
|
- string la_id = OutBoxCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- for (int i = 0; i < CusOutBoxCode.Count; i++)
|
|
|
- {
|
|
|
- if (!PrintedVivoOutboxCode.Contains(CusOutBoxCode[i].ToString()))
|
|
|
- {
|
|
|
- OutBoxCodePrint(la_id, CusOutBoxCode[i]);
|
|
|
- PrintedVivoOutboxCode.Add(CusOutBoxCode[i].ToString());
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
private void pr_code_UserControlTextChanged(object sender, EventArgs e)
|
|
|
@@ -2175,8 +1793,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (MidLabelCombox.SelectedValue != null)
|
|
|
{
|
|
|
- string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- MidBoxCodePrint(la_id, CurrentRowIndex);
|
|
|
+ MidBoxCodePrint(CurrentRowIndex);
|
|
|
}
|
|
|
else
|
|
|
MessageBox.Show("未维护中盒模板");
|
|
|
@@ -2223,24 +1840,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void PowerSetting_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- PowerSetting pw = new PowerSetting();
|
|
|
- BaseUtil.SetFormCenter(pw);
|
|
|
- pw.ShowDialog();
|
|
|
- }
|
|
|
-
|
|
|
- private void GetOutBoxCode_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select top 1000 pib_madein,pib_inoutno,pib_id,pib_pdid,pib_piid,pib_indate,pib_pdno,pib_prodcode,pib_brand,");
|
|
|
- sql.Append("pib_lotno,pib_datecode,pib_qty,pib_barcode,pib_outboxcode1,pib_outboxcode2,pib_ifpick,pib_ifprint ");
|
|
|
- sql.Append("from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_id ");
|
|
|
- (MidSource.DataSource as DataTable).Merge((DataTable)adh.ExecuteSql(sql.ToString(), "select"));
|
|
|
- Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
|
|
- }
|
|
|
-
|
|
|
private void LogingOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
{
|
|
|
string close = MessageBox.Show(this.ParentForm, "是否注销", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
|
|
|
@@ -2329,91 +1928,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
AccessDBHelper adh = new AccessDBHelper("LabelPrint.accdb");
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 获取ViVo的料盘信息
|
|
|
- /// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
- private void ViVoPlate_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select top 500 pib_madein,pib_inoutno,pib_id,pib_pdid,pib_piid,pib_indate,pib_pdno,pib_prodcode,pib_brand,");
|
|
|
- sql.Append("pib_lotno,pib_datecode,pib_qty,pib_barcode,pib_outboxcode1,pib_outboxcode2,pib_ifpick,pib_ifprint ");
|
|
|
- sql.Append("from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_id ");
|
|
|
- MidSource.DataSource = (DataTable)adh.ExecuteSql(sql.ToString(), "select");
|
|
|
-
|
|
|
- LabelInf.DataSource = MidSource;
|
|
|
-
|
|
|
- //Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
|
|
- //adh.SaveDataTable(dt, "prodiobarcode");
|
|
|
- //Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
|
|
- //adh.DeleleFile("LabelPrint.accdb");
|
|
|
- //Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
|
|
- }
|
|
|
-
|
|
|
- private void GetVivoInf()
|
|
|
- {
|
|
|
- if (LabelInf.Rows.Count > 0)
|
|
|
- {
|
|
|
- if (LabelInf.Rows[0].Cells["pib_outboxcode2"].Value != null)
|
|
|
- {
|
|
|
- Vivo_GetPlateID.Service1SoapClient getPlateID = new Vivo_GetPlateID.Service1SoapClient();
|
|
|
- Vivo_BoxReelRelation.Service1SoapClient getOutBox = new Vivo_BoxReelRelation.Service1SoapClient();
|
|
|
- string VenderCode = dh.GetConfig("VivoCode", "ProdInOut!Sale").ToString();
|
|
|
- string CurrentTime = System.DateTime.Now.ToString("yyyyMM");
|
|
|
- string Createcode = VenderCode + CurrentTime;
|
|
|
- string outboxcode = "";
|
|
|
- //装入箱内的数量统计,用于判断是否达到容量
|
|
|
- decimal InBoxCount = OutboxCapacity.Value;
|
|
|
- for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
- {
|
|
|
- //勾选了的内容才进行料盘的获取和箱号的维护
|
|
|
- if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
|
|
|
- {
|
|
|
- int amount = int.Parse(LabelInf.Rows[i].Cells["pib_qty"].Value.ToString());
|
|
|
- string DateCode = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
|
|
|
- string LotNo = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
|
|
|
- string OrderCode = LabelInf.Rows[i].Cells["pr_vendprodcode"].Value.ToString();
|
|
|
- string custprodcode = LabelInf.Rows[i].Cells["pd_custprodcode"].Value.ToString();
|
|
|
- //通过接口获取Vivo料盘号
|
|
|
- string custbarcode = getPlateID.getCompID(Createcode, "", custprodcode, VenderCode, LotNo, DateCode, amount, OrderCode, "", "").Replace("T-", "");
|
|
|
- LabelInf.Rows[i].Cells["pib_cusbarcode"].Value = custbarcode;
|
|
|
- //如果下一行的外箱号和当前行不一致
|
|
|
- bool NextBoxDiff = false;
|
|
|
- //通过接口维护料盘和外箱关系,需要根据箱内容量计算
|
|
|
- //判断下一行箱号不一样重新取一个客户外箱号
|
|
|
- if (i - 1 > 0)
|
|
|
- {
|
|
|
- string CurrentOutBoxCode = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
- string NextOutBoxCode = LabelInf.Rows[i - 1].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
- if (CurrentOutBoxCode != NextOutBoxCode)
|
|
|
- {
|
|
|
- NextBoxDiff = true;
|
|
|
- InBoxCount = OutboxCapacity.Value - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- if (InBoxCount == OutboxCapacity.Value || NextBoxDiff)
|
|
|
- {
|
|
|
- outboxcode = VenderCode + "-" + CurrentTime + "-" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
|
|
|
- InBoxCount = 1;
|
|
|
- NextBoxDiff = false;
|
|
|
- }
|
|
|
- else
|
|
|
- InBoxCount = InBoxCount + 1;
|
|
|
- //获取信息为T-表示成功获取了信息
|
|
|
- string Message = getOutBox.insertBoxReelRelation(Createcode, VenderCode, outboxcode, custbarcode, "", "");
|
|
|
- if (Message.Substring(0, 1) == "T")
|
|
|
- LabelInf.Rows[i].Cells["pib_cusoutboxcode"].Value = outboxcode;
|
|
|
- else
|
|
|
- LabelInf.Rows[i].Cells["pib_cusoutboxcode"].Value = Message;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- MessageBox.Show("请先维护外箱号");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void ChooseAll_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (AllChecked)
|
|
|
@@ -2498,16 +2012,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void AttachInfo_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (pi_cardcode.Text != "")
|
|
|
- {
|
|
|
- 附件内容打印 att = new 附件内容打印(pi_cardcode.Text);
|
|
|
- att.ShowDialog();
|
|
|
- }
|
|
|
- else MessageBox.Show("请先获取出库单信息");
|
|
|
- }
|
|
|
-
|
|
|
private void MidBoxCapacity_Leave(object sender, EventArgs e)
|
|
|
{
|
|
|
NumericUpDown nup = (NumericUpDown)sender;
|
|
|
@@ -2528,7 +2032,7 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void RefreshDBConnect_Tick(object sender, EventArgs e)
|
|
|
{
|
|
|
- dh.ExecuteSql("select sysdate from dual", "select");
|
|
|
+ dh.getRowCount("employee", "1=1");
|
|
|
}
|
|
|
|
|
|
private void CleanBarCode_Click(object sender, EventArgs e)
|