|
|
@@ -11,7 +11,6 @@ using LabelManager2;
|
|
|
using UAS_LabelMachine.PublicMethod;
|
|
|
using UAS_LabelMachine.Entity;
|
|
|
using UAS_特殊解析规则;
|
|
|
-using System.Globalization;
|
|
|
using UAS_LabelMachine.CustomControl.GroupBoxWithBorder;
|
|
|
using UAS_LabelMachine.PublicForm;
|
|
|
using System.Threading;
|
|
|
@@ -36,7 +35,6 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
List<string> PrintedVivoOutboxCode = new List<string>();
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// CodeSoft新建打印机引擎
|
|
|
/// </summary>
|
|
|
@@ -93,21 +91,51 @@ namespace UAS_LabelMachine
|
|
|
object[] ItemData;
|
|
|
|
|
|
Dictionary<string, string> CollectData;
|
|
|
-
|
|
|
+ //缓存单盘数据数据的DataTable
|
|
|
+ DataTable SingleBoxCacheData;
|
|
|
+ /// <summary>
|
|
|
+ /// 存放单盘的ID
|
|
|
+ /// </summary>
|
|
|
+ List<string> SingleID = new List<string>();
|
|
|
+ /// <summary>
|
|
|
+ /// 单盘的打印参数
|
|
|
+ /// </summary>
|
|
|
+ List<string> SingleBoxArgument = new List<string>();
|
|
|
+ /// <summary>
|
|
|
+ /// 中盒缓存数据
|
|
|
+ /// </summary>
|
|
|
+ DataTable MidBoxCacheData;
|
|
|
+ /// <summary>
|
|
|
+ /// 存放中盒的ID和盒号
|
|
|
+ /// </summary>
|
|
|
+ Dictionary<string, string> MidIDAndOutboxcode = new Dictionary<string, string>();
|
|
|
+ /// <summary>
|
|
|
+ /// 中盒的打印参数
|
|
|
+ /// </summary>
|
|
|
+ List<string> MidBoxArgument = new List<string>();
|
|
|
+ /// <summary>
|
|
|
+ /// 全部采集
|
|
|
+ /// </summary>
|
|
|
bool AllCollect = false;
|
|
|
/// <summary>
|
|
|
+ /// 是否全选
|
|
|
+ /// </summary>
|
|
|
+ bool AllChecked = false;
|
|
|
+ /// <summary>
|
|
|
/// 是否获取过箱号
|
|
|
/// </summary>
|
|
|
bool GetPackingCode = false;
|
|
|
/*用于存放采集项目的Grid信息*/
|
|
|
Dictionary<string, Dictionary<string, string>> SiItem;
|
|
|
-
|
|
|
+ int CloumnCount = 0;
|
|
|
/*需要重绘的Cell*/
|
|
|
Dictionary<DataGridViewCell, bool> PaintCell = new Dictionary<DataGridViewCell, bool>();
|
|
|
//使用二维数组进行排序
|
|
|
ArrayList<ArrayList<string>> ScanData;
|
|
|
ArrayList<string> GetData;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public UAS_出货标签打印()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
@@ -139,13 +167,15 @@ namespace UAS_LabelMachine
|
|
|
LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
|
|
|
dh = new DataHelper();
|
|
|
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 # 分隔符";
|
|
|
@@ -156,7 +186,6 @@ namespace UAS_LabelMachine
|
|
|
pr_code.TableName = "prodiodetail";
|
|
|
pr_code.SelectField = "pd_pdno # 行号,pd_prodcode # 物料编号";
|
|
|
|
|
|
- ChooseAll.ChooseAll(LabelInf);
|
|
|
CollectionUnit.Text = "盘";
|
|
|
Point pt = new Point();
|
|
|
int ScreenWidth = Screen.GetWorkingArea(pt).Width;
|
|
|
@@ -1054,6 +1083,13 @@ namespace UAS_LabelMachine
|
|
|
pi_cardcode.Text = dt.Rows[0]["pi_cardcode"].ToString();
|
|
|
PI_ID = dt.Rows[0]["pi_id"].ToString();
|
|
|
LoadGridData(sender, e);
|
|
|
+ //重新输入单号后清除缓存
|
|
|
+ MidBoxArgument.Clear();
|
|
|
+ MidBoxCacheData.Clear();
|
|
|
+ BaseUtil.CleanDataTable(MidBoxCacheData);
|
|
|
+ SingleBoxArgument.Clear();
|
|
|
+ SingleBoxCacheData.Clear();
|
|
|
+ BaseUtil.CleanDataTable(SingleBoxCacheData);
|
|
|
//刷新采集进度
|
|
|
RefreshProcessData();
|
|
|
//设置当前的最大箱号
|
|
|
@@ -1062,19 +1098,11 @@ namespace UAS_LabelMachine
|
|
|
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
|
|
|
- {
|
|
|
+ else
|
|
|
if (int.Parse(outboxcode == "" ? "1" : outboxcode) > MaxOutBoxCode)
|
|
|
- {
|
|
|
MaxOutBoxCode = int.Parse(outboxcode);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
thread = new Thread(GetInOutInfAndLabelFile);
|
|
|
stw = new SetLoadingWindow(thread, "正在获取打印标签");
|
|
|
@@ -1098,10 +1126,33 @@ namespace UAS_LabelMachine
|
|
|
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 (dt.Rows.Count > 0)
|
|
|
{
|
|
|
+ //每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
|
|
|
+ MidIDAndOutboxcode.Clear();
|
|
|
+ SingleID.Clear();
|
|
|
//获取全部的中盒号
|
|
|
Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
|
|
|
//判断所有盒号为该盒的是否勾选已采集
|
|
|
outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
|
|
|
+ for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
|
|
|
+ {
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (SingleID.ToArray().Length == 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show("选择的行未勾选采集或者已打印");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //打印的时候如果不存在数据开始缓存
|
|
|
+ if (MidBoxCacheData.Rows.Count == 0)
|
|
|
+ GetMidBoxData();
|
|
|
+ if (SingleBoxCacheData.Rows.Count == 0)
|
|
|
+ GetSingleBoxData();
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
if (i + 1 < LabelInf.RowCount)
|
|
|
@@ -1122,6 +1173,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//用于判断用户是否勾选了行
|
|
|
int CheckedRowCount = 0;
|
|
|
+ string[] arg = SingleBoxArgument.ToArray();
|
|
|
//打印所有的选中行
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
@@ -1133,57 +1185,39 @@ 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();
|
|
|
for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode1"))
|
|
|
{
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == dt.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = dt.Rows[k]["lp_sql"].ToString();
|
|
|
- if (sql.IndexOf("{") == 0)
|
|
|
- {
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- LogManager.DoLog("打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
- //获取对应行的pib_id
|
|
|
- string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
|
|
|
- if (sql.ToLower().Contains("pib_lotno"))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
|
|
|
- else if (sql.ToLower().Contains("pib_datecode"))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
|
|
|
- else if (sql.ToLower().Contains("pib_cusbarcode"))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_cusbarcode"].Value.ToString();
|
|
|
- else if (sql.ToLower().Contains("pib_cusoutboxcode"))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_cusoutboxcode"].Value.ToString();
|
|
|
- else
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql + pib_id).ToString();
|
|
|
- LogManager.DoLog("打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + pib_id + ",取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
|
|
|
- {
|
|
|
- if (LabelInf.Rows[i].Cells["DateCode1"].Value != null)
|
|
|
- {
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["DateCode1"].Value.ToString();
|
|
|
- }
|
|
|
- }
|
|
|
+ if (LabelInf.Rows[i].Cells["DateCode1"].Value != null)
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["DateCode1"].Value.ToString();
|
|
|
+ }
|
|
|
+ else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("lotno"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[i].Cells["pib_lotno"].Value != null)
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
|
|
|
}
|
|
|
+ else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[i].Cells["pib_datecode"].Value != null)
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
|
|
|
+ }
|
|
|
+ else 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();
|
|
|
+ ParamLog.AppendLine("打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
}
|
|
|
+ LogManager.DoLog(ParamLog.ToString());
|
|
|
//保存参数打印
|
|
|
SingleDoc.Save();
|
|
|
SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
SingleDoc.PrintDocument();
|
|
|
- LogManager.DoLog("执行打印单盘,pib_id:" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",标签地址" + LabelUrl);
|
|
|
//勾选为已打印
|
|
|
LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
|
|
|
}
|
|
|
- catch (Exception ex) { MessageBox.Show(ex.Message); }
|
|
|
+ catch (Exception ex) { LogManager.DoLog(ex.Message); }
|
|
|
}
|
|
|
if (MidLabelAutoPrint.Checked && LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
|
|
|
{
|
|
|
@@ -1214,6 +1248,184 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 缓存单盘的数据
|
|
|
+ /// </summary>
|
|
|
+ private void GetSingleBoxData()
|
|
|
+ {
|
|
|
+ StringBuilder pib_id_string = new StringBuilder();
|
|
|
+ //id数组
|
|
|
+ string[] pib_id_arr = SingleID.ToArray();
|
|
|
+ //id个数
|
|
|
+ int pib_id_length = pib_id_arr.Length;
|
|
|
+ //将所有的列存在在这里
|
|
|
+ List<DataTable> AllSingleBoxCacheData = new List<DataTable>();
|
|
|
+
|
|
|
+ //每五百条拼接一次条件
|
|
|
+ int fivehundred_count = pib_id_length / 500 + 1;
|
|
|
+ //当前打印的索引
|
|
|
+ int CurrentCount = 0;
|
|
|
+ for (int i = 0; i < fivehundred_count; i++)
|
|
|
+ {
|
|
|
+ //本次循环的数量
|
|
|
+ int count = 0;
|
|
|
+ pib_id_string.Append("(");
|
|
|
+ if (i + 1 == fivehundred_count)
|
|
|
+ count = pib_id_length - i * 500;
|
|
|
+ else
|
|
|
+ count = 500;
|
|
|
+ //当前执行的索引
|
|
|
+ int LastCount = CurrentCount;
|
|
|
+ for (int j = CurrentCount; j < LastCount + count - 1; j++)
|
|
|
+ {
|
|
|
+ pib_id_string.Append(pib_id_arr[j] + ",");
|
|
|
+ CurrentCount = CurrentCount + 1;
|
|
|
+ }
|
|
|
+ pib_id_string.Append(pib_id_arr[CurrentCount]);
|
|
|
+ pib_id_string.Append(")");
|
|
|
+ if (i + 1 != fivehundred_count)
|
|
|
+ pib_id_string.Append(" or pib_id in ");
|
|
|
+ }
|
|
|
+
|
|
|
+ //手动添加ID列
|
|
|
+ DataColumn datacolumn = new DataColumn("pib_id");
|
|
|
+ SingleBoxCacheData.Columns.Add(datacolumn);
|
|
|
+ //获取打印的SQL
|
|
|
+ for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ {
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ {
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == dt.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 = dt.Rows[k]["lp_sql"].ToString();
|
|
|
+ sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
+ sql = sql.Substring(0, sql.LastIndexOf("="));
|
|
|
+ DataTable temp = dh.getFieldsDatasByCondition(sql + " in " + pib_id_string.ToString());
|
|
|
+ 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].Rows[i][0].ToString();
|
|
|
+ }
|
|
|
+ SingleBoxCacheData.Rows.Add(dr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 缓存中盒的数据
|
|
|
+ /// </summary>
|
|
|
+ private void GetMidBoxData()
|
|
|
+ {
|
|
|
+ StringBuilder pib_condition_string = new StringBuilder();
|
|
|
+ StringBuilder pib_qtycondition_string = new StringBuilder();
|
|
|
+ //id数组
|
|
|
+ string[] pib_id_arr = MidIDAndOutboxcode.Keys.ToArray();
|
|
|
+ string[] pib_outbox_arr = MidIDAndOutboxcode.Values.ToArray();
|
|
|
+ //记录一个ID用来取中盒的数量
|
|
|
+ string pib_id = pib_id_arr[0];
|
|
|
+ //id个数
|
|
|
+ int pib_id_length = pib_id_arr.Length;
|
|
|
+ //将所有的列存在在这里
|
|
|
+ List<DataTable> AllMidBoxCacheData = new List<DataTable>();
|
|
|
+ //每五百条拼接一次条件
|
|
|
+ int fivehundred_count = pib_id_length / 900 + 1;
|
|
|
+ //当前打印的索引
|
|
|
+ int CurrentCount = 0;
|
|
|
+ for (int i = 0; i < fivehundred_count; i++)
|
|
|
+ {
|
|
|
+ //本次循环的数量
|
|
|
+ int count = 0;
|
|
|
+ pib_condition_string.Append("(");
|
|
|
+ pib_qtycondition_string.Append("(");
|
|
|
+ if (i + 1 == fivehundred_count)
|
|
|
+ count = pib_id_length - i * 900;
|
|
|
+ else
|
|
|
+ count = 900;
|
|
|
+ //当前执行的索引
|
|
|
+ int LastCount = CurrentCount;
|
|
|
+ for (int j = LastCount; j < LastCount + count - 1; j++)
|
|
|
+ {
|
|
|
+ pib_condition_string.Append(pib_id_arr[j] + ",");
|
|
|
+ pib_qtycondition_string.Append(pib_outbox_arr[j] + ",");
|
|
|
+ CurrentCount = CurrentCount + 1;
|
|
|
+ }
|
|
|
+ pib_condition_string.Append(pib_id_arr[CurrentCount]);
|
|
|
+ pib_qtycondition_string.Append(pib_outbox_arr[CurrentCount]);
|
|
|
+ pib_condition_string.Append(")");
|
|
|
+ pib_qtycondition_string.Append(")");
|
|
|
+ if (i + 1 != fivehundred_count)
|
|
|
+ pib_condition_string.Append(" or pib_id in ");
|
|
|
+ }
|
|
|
+ //手动添加ID列
|
|
|
+ DataColumn IDColumn = new DataColumn("pib_id");
|
|
|
+ DataColumn OutBoxColumn = new DataColumn("pib_outboxcode1");
|
|
|
+ MidBoxCacheData.Columns.Add(IDColumn);
|
|
|
+ MidBoxCacheData.Columns.Add(OutBoxColumn);
|
|
|
+ string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
+ 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");
|
|
|
+ for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ {
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ {
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == dt.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 = dt.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 " + pib_qtycondition_string.ToString() + sql.Substring(sql.LastIndexOf("}") + 1);
|
|
|
+ Console.WriteLine(sql);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
+ sql = sql.Substring(0, sql.LastIndexOf("="));
|
|
|
+ sql = sql + " in " + pib_condition_string.ToString();
|
|
|
+ }
|
|
|
+ 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 < Temp[0].Rows.Count; 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].Rows[i][0].ToString();
|
|
|
+ }
|
|
|
+ MidBoxCacheData.Rows.Add(dr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void SingleLabelPrint_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (SingleLabelCombox.Text != "")
|
|
|
@@ -1273,9 +1485,7 @@ namespace UAS_LabelMachine
|
|
|
stw.ShowDialog();
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
MessageBox.Show("未维护中盒标签");
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
private void OutBoxPrint()
|
|
|
@@ -1352,6 +1562,7 @@ namespace UAS_LabelMachine
|
|
|
private void MidBoxCodePrint(string la_id, int rowindex)
|
|
|
{
|
|
|
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++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
@@ -1365,7 +1576,6 @@ namespace UAS_LabelMachine
|
|
|
string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
|
|
|
//获取打印执行的SQL
|
|
|
string sql = dt.Rows[k]["lp_sql"].ToString();
|
|
|
- //select * from productiobarcode where pib_id={pib_id} and pib_outboxcode1={pib_outboxcode1}
|
|
|
try
|
|
|
{
|
|
|
//获取打印执行的SQL
|
|
|
@@ -1376,33 +1586,34 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- string ExeSQL = "";
|
|
|
- if (sql.ToLower().Contains("pib_lotno"))
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
|
|
|
- else if (sql.ToLower().Contains("pib_datecode"))
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
|
|
|
- else
|
|
|
+ DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
|
|
|
+ Console.WriteLine(pib_outboxcode1);
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode1"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[rowindex].Cells["DateCode1"].Value != null)
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["DateCode1"].Value.ToString();
|
|
|
+ }
|
|
|
+ else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("lotno"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[rowindex].Cells["pib_lotno"].Value != null)
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
|
|
|
+ }
|
|
|
+ else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode"))
|
|
|
{
|
|
|
- ExeSQL = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
|
|
|
- ExeSQL = ExeSQL.Substring(0, ExeSQL.IndexOf("{")) + pib_outboxcode1;
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(ExeSQL).ToString();
|
|
|
+ if (LabelInf.Rows[rowindex].Cells["pib_datecode"].Value != null)
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
|
|
|
}
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
+ else if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][MidDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
+ LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
- MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
+ LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
|
|
|
- {
|
|
|
- if (LabelInf.Rows[rowindex].Cells["DateCode1"].Value != null)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["DateCode1"].Value.ToString();
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
//保存参数打印
|
|
|
@@ -1563,6 +1774,11 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void LoadGridData()
|
|
|
+ {
|
|
|
+ LoadGridData(new object(), new EventArgs());
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 自定义函数 加载明细行的数据,多处使用添加进函数
|
|
|
/// </summary>
|
|
|
@@ -1793,41 +2009,35 @@ namespace UAS_LabelMachine
|
|
|
/// <param name="e"></param>
|
|
|
private void LabelInf_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
|
|
{
|
|
|
- if (LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode")
|
|
|
- {
|
|
|
- string datecode = LabelInf.Rows[e.RowIndex].Cells["pib_datecode"].Value.ToString();
|
|
|
- try
|
|
|
- {
|
|
|
- System.DateTime dt = System.DateTime.ParseExact(datecode, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
|
|
|
- GregorianCalendar gc = new GregorianCalendar();
|
|
|
- int weekOfYear = gc.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
|
|
|
- if (weekOfYear < 10)
|
|
|
- LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + "0" + weekOfYear;
|
|
|
- else
|
|
|
- LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + weekOfYear;
|
|
|
- }
|
|
|
- catch (Exception) { }
|
|
|
- }
|
|
|
+ //if (LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode")
|
|
|
+ //{
|
|
|
+ // string datecode = LabelInf.Rows[e.RowIndex].Cells["pib_datecode"].Value.ToString();
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+ // System.DateTime dt = System.DateTime.ParseExact(datecode, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
|
|
|
+ // GregorianCalendar gc = new GregorianCalendar();
|
|
|
+ // int weekOfYear = gc.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
|
|
|
+ // if (weekOfYear < 10)
|
|
|
+ // LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + "0" + weekOfYear;
|
|
|
+ // else
|
|
|
+ // LabelInf.Rows[e.RowIndex].Cells["DateCode1"].Value = dt.Year.ToString().Substring(2, 2) + weekOfYear;
|
|
|
+ // }
|
|
|
+ // catch (Exception) { }
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
private void AllCollected_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (AllCollect == false)
|
|
|
{
|
|
|
- for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
- {
|
|
|
- if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "False")
|
|
|
- LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
|
|
|
- }
|
|
|
+ foreach (DataGridViewRow dr in LabelInf.Rows)
|
|
|
+ dr.Cells[CloumnCount - 2].Value = true;
|
|
|
AllCollect = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
- {
|
|
|
- if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
|
|
|
- LabelInf.Rows[i].Cells["pib_ifpick"].Value = false;
|
|
|
- }
|
|
|
+ foreach (DataGridViewRow dr in LabelInf.Rows)
|
|
|
+ dr.Cells[CloumnCount - 2].Value = false;
|
|
|
AllCollect = false;
|
|
|
}
|
|
|
}
|
|
|
@@ -2019,5 +2229,21 @@ namespace UAS_LabelMachine
|
|
|
MessageBox.Show("请先维护外箱号");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void ChooseAll_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (AllChecked)
|
|
|
+ {
|
|
|
+ foreach (DataGridViewRow dr in LabelInf.Rows)
|
|
|
+ dr.Cells[0].Value = false;
|
|
|
+ AllChecked = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach (DataGridViewRow dr in LabelInf.Rows)
|
|
|
+ dr.Cells[0].Value = true;
|
|
|
+ AllChecked = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|