|
@@ -61,14 +61,9 @@ namespace UAS_LabelMachine
|
|
|
/// 当前扫描的所在行
|
|
|
/// </summary>
|
|
|
int CurrentRowIndex = 0;
|
|
|
- /// <summary>
|
|
|
- /// 正则表达式用于项目匹配
|
|
|
- /// </summary>
|
|
|
- Regex reg;
|
|
|
|
|
|
bool logout = false;
|
|
|
|
|
|
-
|
|
|
DataTable SingleLabelParam;
|
|
|
DataTable MidLabelParam;
|
|
|
DataTable OutLabelParam;
|
|
@@ -99,17 +94,10 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
List<string> MidBoxArgument = new List<string>();
|
|
|
/// <summary>
|
|
|
- /// 全部采集
|
|
|
- /// </summary>
|
|
|
- bool AllCollect = false;
|
|
|
- /// <summary>
|
|
|
/// 是否全选
|
|
|
/// </summary>
|
|
|
bool AllChecked = false;
|
|
|
|
|
|
- int CloumnCount = 0;
|
|
|
- /*需要重绘的Cell*/
|
|
|
- Dictionary<DataGridViewCell, bool> PaintCell = new Dictionary<DataGridViewCell, bool>();
|
|
|
/// <summary>
|
|
|
/// 是否通过选择Combox来改变打开的文件
|
|
|
/// </summary>
|
|
@@ -120,12 +108,30 @@ namespace UAS_LabelMachine
|
|
|
List<string> MidParam = new List<string>();
|
|
|
|
|
|
List<string> OutParam = new List<string>();
|
|
|
-
|
|
|
+ //当前采集的物料编号
|
|
|
string CurrentPrCode = "";
|
|
|
-
|
|
|
+ //当前采集的最小包装
|
|
|
string CurrentZXBZ = "";
|
|
|
-
|
|
|
+ //当前采集的单位
|
|
|
string CurrentUnit = "";
|
|
|
+ //当前采集的总数
|
|
|
+ string CurrentPrCount = "";
|
|
|
+ //当前明细序号
|
|
|
+ string CurrentPDNO = "";
|
|
|
+ //当前的物料品牌
|
|
|
+ string CurrentBrand = "";
|
|
|
+
|
|
|
+ string SinglePrefix = "";
|
|
|
+ string SingleSuffix = "";
|
|
|
+ int SingleMaxNum = 0;
|
|
|
+ int SingleNumLength = 0;
|
|
|
+ int SingleRadix = 0;
|
|
|
+
|
|
|
+ string OutPrefix = "";
|
|
|
+ string OutSuffix = "";
|
|
|
+ int OutMaxNum = 0;
|
|
|
+ int OutNumLength = 0;
|
|
|
+ int OutRadix = 0;
|
|
|
|
|
|
public UAS_出货标签打印(string Master)
|
|
|
{
|
|
@@ -154,7 +160,6 @@ namespace UAS_LabelMachine
|
|
|
LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
|
|
|
dh = SystemInf.dh;
|
|
|
CheckForIllegalCrossThreadCalls = false;
|
|
|
- CloumnCount = LabelInf.Columns.Count;
|
|
|
pi_inoutno.Focus();
|
|
|
//将本地读取的打印机设置进Combox,并选中默认打印机
|
|
|
MidBoxCacheData = new DataTable();
|
|
@@ -294,9 +299,24 @@ namespace UAS_LabelMachine
|
|
|
int CodeCount = 0;
|
|
|
//如果单位是KPCS则需要除1000
|
|
|
if (CurrentUnit == "KPCS")
|
|
|
+ {
|
|
|
+ if (int.Parse(Data["QTY"]) / 1000 % int.Parse(CurrentZXBZ) != 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show("采集数量无法按照最小包装数拆分");
|
|
|
+ return;
|
|
|
+ }
|
|
|
CodeCount = int.Parse(Data["QTY"]) / 1000 / int.Parse(CurrentZXBZ);
|
|
|
+ }
|
|
|
else
|
|
|
+ {
|
|
|
+ if (int.Parse(Data["QTY"]) % int.Parse(CurrentZXBZ) != 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show("采集数量无法按照最小包装数拆分");
|
|
|
+ return;
|
|
|
+ }
|
|
|
CodeCount = int.Parse(Data["QTY"]) / int.Parse(CurrentZXBZ);
|
|
|
+ }
|
|
|
+
|
|
|
string pib_barcode = Data.ContainsKey("SERIAL") ? Data["SERIAL"] : "";
|
|
|
//获取ID
|
|
|
string[] PIBID = dh.GetSEQ("prodiobarcode_seq", CodeCount);
|
|
@@ -314,14 +334,38 @@ namespace UAS_LabelMachine
|
|
|
pib_outboxcode2 = (int.Parse(maxoutbox) + 1).ToString();
|
|
|
}
|
|
|
}
|
|
|
- else pib_outboxcode2 = OutBoxNum.Text;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pib_outboxcode2 = OutBoxNum.Text;
|
|
|
+ }
|
|
|
+ List<string> CustBarCode = new List<string>();
|
|
|
+ List<string> CustOutBarCode = new List<string>();
|
|
|
+ for (int i = 0; i < CodeCount; i++)
|
|
|
+ {
|
|
|
+ string serialcode = BaseUtil.DToAny(SingleMaxNum, SingleRadix);
|
|
|
+ for (int j = serialcode.ToString().Length; j < SingleNumLength; j++)
|
|
|
+ {
|
|
|
+ serialcode = "0" + serialcode;
|
|
|
+ }
|
|
|
+ CustBarCode.Add(SinglePrefix + serialcode + SingleSuffix);
|
|
|
+ serialcode = BaseUtil.DToAny(OutMaxNum, OutRadix);
|
|
|
+ for (int j = serialcode.ToString().Length; j < OutNumLength; j++)
|
|
|
+ {
|
|
|
+ serialcode = "0" + serialcode;
|
|
|
+ }
|
|
|
+ CustOutBarCode.Add(OutPrefix + serialcode + OutSuffix);
|
|
|
+ SingleMaxNum = SingleMaxNum + 1;
|
|
|
+ OutMaxNum = OutMaxNum + 1;
|
|
|
+ }
|
|
|
sql.Clear();
|
|
|
sql.Append("insert into prodiobarcode(PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_PDNO, PIB_PDID,PIB_PICLASS,");
|
|
|
sql.Append("PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,PIB_OUTBOXCODE1,PIB_OUTBOXCODE2,pib_custoutboxcode,PIB_IFPRINT,PIB_ORDERCODE,PIB_CUSTPO) ");
|
|
|
sql.Append("select :PIB_ID,pd_prodcode,sysdate,pi_inoutno,pi_id,pd_pdno,pd_id,pi_class,");
|
|
|
- sql.Append("'" + pib_barcode + "','','','','" + pib_outboxcode2 + "','',0,pd_ordercode,pd_pocode ");
|
|
|
+ sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','','" + pib_outboxcode2 + "',:pib_custoutboxcode,0,pd_ordercode,pd_pocode ");
|
|
|
sql.Append("from prodinout left join prodiodetail on pi_id=pd_piid where pi_id='" + PI_ID + "' and pd_prodcode='" + CurrentPrCode + "'");
|
|
|
- dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID" }, PIBID);
|
|
|
+ dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID", "PIB_CUSTBARCODE", "pib_custoutboxcode" }, PIBID, CustBarCode.ToArray(), CustOutBarCode.ToArray());
|
|
|
+ dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (SingleMaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Single' and rmn_prefix='" + SinglePrefix + "'");
|
|
|
+ dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (OutMaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Out' and rmn_prefix='" + OutPrefix + "'");
|
|
|
LoadGridData(new object(), new EventArgs());
|
|
|
//加载完数据之后进行容量的判断
|
|
|
if (LabelInfDataTable.Select("pib_outboxcode2='" + OutBoxNum.Text + "'").Length > OutboxCapacity.Value)
|
|
@@ -532,6 +576,9 @@ namespace UAS_LabelMachine
|
|
|
pi_date.Text = dt.Rows[0]["pi_date"].ToString();
|
|
|
PI_ID = dt.Rows[0]["pi_id"].ToString();
|
|
|
LoadGridData(sender, e);
|
|
|
+ //获取条码规则
|
|
|
+ GetBarCodeRule("Single", out SinglePrefix, out SingleSuffix, out SingleMaxNum, out SingleNumLength, out SingleRadix);
|
|
|
+ GetBarCodeRule("Out", out OutPrefix, out OutSuffix, out OutMaxNum, out OutNumLength, out OutRadix);
|
|
|
//重新输入单号后清除缓存
|
|
|
MidBoxArgument.Clear();
|
|
|
MidBoxCacheData.Clear();
|
|
@@ -1408,7 +1455,6 @@ namespace UAS_LabelMachine
|
|
|
/// <param name="e"></param>
|
|
|
private void LoadGridData(object sender, EventArgs e)
|
|
|
{
|
|
|
- AllCollect = false;
|
|
|
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_ifprint,0)pib_ifprint");
|
|
@@ -1505,22 +1551,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void AllCollected_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (AllCollect == false)
|
|
|
- {
|
|
|
- foreach (DataGridViewRow dr in LabelInf.Rows)
|
|
|
- dr.Cells[1].Value = true;
|
|
|
- AllCollect = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- foreach (DataGridViewRow dr in LabelInf.Rows)
|
|
|
- dr.Cells[1].Value = false;
|
|
|
- AllCollect = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void LogingOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
{
|
|
|
string close = MessageBox.Show(this.ParentForm, "是否注销", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
|
|
@@ -1705,12 +1735,15 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void LoadPrcodeData()
|
|
|
{
|
|
|
- GridPrcode.DataSource = (DataTable)dh.ExecuteSql("select pd_prodcode,pd_brand,pjd_zxbzs_user,pr_unit from prodiodetail left join prodinout on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode left join product on pd_prodcode=pr_code where pi_id='" + PI_ID + "' order by pjd_prodcode", "select");
|
|
|
+ GridPrcode.DataSource = (DataTable)dh.ExecuteSql("select pd_prodcode,pd_brand,pjd_zxbzs_user,pd_outqty,pd_pdno,pr_unit,pjd_id from prodiodetail left join prodinout on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode left join product on pd_prodcode=pr_code where pi_id='" + PI_ID + "' order by pd_pdno", "select");
|
|
|
if (GridPrcode.Rows.Count > 0)
|
|
|
{
|
|
|
CurrentPrCode = GridPrcode.Rows[0].Cells["pd_prodcode"].Value.ToString();
|
|
|
CurrentZXBZ = GridPrcode.Rows[0].Cells["pjd_zxbzs_user"].Value.ToString();
|
|
|
CurrentUnit = GridPrcode.Rows[0].Cells["pr_unit"].Value.ToString();
|
|
|
+ CurrentPDNO = GridPrcode.Rows[0].Cells["pd_pdno"].Value.ToString();
|
|
|
+ CurrentPrCount = GridPrcode.Rows[0].Cells["pd_outqty"].Value.ToString();
|
|
|
+ CurrentBrand = GridPrcode.Rows[0].Cells["pd_brand"].Value.ToString();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1719,9 +1752,12 @@ namespace UAS_LabelMachine
|
|
|
//用户在重新勾选后重置采集项目的索引
|
|
|
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
|
|
|
{
|
|
|
- CurrentPrCode = GridPrcode.Rows[e.RowIndex].Cells["pd_prodcode"].ToString();
|
|
|
- CurrentZXBZ = GridPrcode.Rows[e.RowIndex].Cells["pjd_zxbzs_user"].ToString();
|
|
|
- CurrentUnit = GridPrcode.Rows[e.RowIndex].Cells["pr_unit"].ToString();
|
|
|
+ CurrentPrCode = GridPrcode.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString();
|
|
|
+ CurrentZXBZ = GridPrcode.Rows[e.RowIndex].Cells["pjd_zxbzs_user"].Value.ToString();
|
|
|
+ CurrentUnit = GridPrcode.Rows[e.RowIndex].Cells["pr_unit"].Value.ToString();
|
|
|
+ CurrentPDNO = GridPrcode.Rows[e.RowIndex].Cells["pd_pdno"].Value.ToString();
|
|
|
+ CurrentPrCount = GridPrcode.Rows[e.RowIndex].Cells["pd_outqty"].Value.ToString();
|
|
|
+ CurrentBrand = GridPrcode.Rows[e.RowIndex].Cells["pd_brand"].Value.ToString();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1756,5 +1792,100 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
OutBoxNum.SelectedIndex = OutBoxNum.Items.Count - 1;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取条码规则
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="Type"></param>
|
|
|
+ /// <param name="Prefix"></param>
|
|
|
+ /// <param name="Suffix"></param>
|
|
|
+ /// <param name="CurrentMaxNum"></param>
|
|
|
+ /// <param name="SerialNumLength"></param>
|
|
|
+ /// <param name="Radix"></param>
|
|
|
+ private void GetBarCodeRule(string Type, out string Prefix, out string Suffix, out int CurrentMaxNum, out int SerialNumLength, out int Radix)
|
|
|
+ {
|
|
|
+ //获取编码规则
|
|
|
+ Prefix = "";
|
|
|
+ Suffix = "";
|
|
|
+ CurrentMaxNum = 0;
|
|
|
+ SerialNumLength = 0;
|
|
|
+ Radix = 0;
|
|
|
+ DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode='" + pi_cardcode.Text + "' and nr_type='" + Type + "' order by nrd_detno", "select");
|
|
|
+ //如果没有则取公共规则
|
|
|
+ if (Nr.Rows.Count == 0)
|
|
|
+ Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_type='" + Type + "' and nr_isdefault <> 0 order by nrd_detno", "select");
|
|
|
+ //用于过滤参数的正则表达式
|
|
|
+ Regex match = new Regex("{\\w+}");
|
|
|
+ //用于存放每一项的明细的数据
|
|
|
+ string[] NrData = new string[Nr.Rows.Count];
|
|
|
+ //流水长度
|
|
|
+ Dictionary<int, string> NrDic = new Dictionary<int, string>();
|
|
|
+ Prefix = "";
|
|
|
+ for (int m = 0; m < Nr.Rows.Count; m++)
|
|
|
+ {
|
|
|
+ switch (Nr.Rows[m]["nrd_type"].ToString())
|
|
|
+ {
|
|
|
+ //常量直接进行拼接
|
|
|
+ case "常量":
|
|
|
+ Prefix += Nr.Rows[m]["nrd_sql"].ToString();
|
|
|
+ Suffix += Nr.Rows[m]["nrd_sql"].ToString();
|
|
|
+ break;
|
|
|
+ case "SQL":
|
|
|
+ string SQL = Nr.Rows[m]["nrd_sql"].ToString();
|
|
|
+ DataTable Temp;
|
|
|
+ //如果不包含参数替换
|
|
|
+ if (SQL.IndexOf("{") == 0)
|
|
|
+ {
|
|
|
+ Temp = (DataTable)dh.ExecuteSql(SQL, "select");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //替换参数后重新执行SQL
|
|
|
+ foreach (Match mch in match.Matches(SQL))
|
|
|
+ {
|
|
|
+ SQL = SQL.Replace(mch.Value.Trim(), "'" + pi_inoutno.Text + "'");
|
|
|
+ }
|
|
|
+ Temp = (DataTable)dh.ExecuteSql(SQL, "select");
|
|
|
+ }
|
|
|
+ if (Temp.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ Prefix += Temp.Rows[0][0].ToString();
|
|
|
+ Suffix += Temp.Rows[0][0].ToString();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //流水需要通过MaxNumber去取
|
|
|
+ case "流水":
|
|
|
+ string maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_prefix='" + Prefix + "' and rmn_type='" + Type + "'").ToString();
|
|
|
+ //设置当前流水
|
|
|
+ if (maxnum == "")
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber,rmn_type) values(RuleMaxNum_seq.nextval,'" + pi_cardcode.Text + "','" + Prefix + "','1','" + Type + "')", "insert");
|
|
|
+ CurrentMaxNum = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CurrentMaxNum = int.Parse(maxnum);
|
|
|
+ }
|
|
|
+ SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
|
|
|
+ Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
|
|
|
+ Suffix = "";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GridPrcode_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
|
|
+ {
|
|
|
+ string Value = GridPrcode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
|
|
|
+ string ID = GridPrcode.Rows[e.RowIndex].Cells["pjd_id"].Value.ToString();
|
|
|
+ dh.UpdateByCondition("PRODJOINVENDDETAIL", "pjd_zxbzs_user='" + Value + "'", "pjd_id='" + ID + "'");
|
|
|
+ //删除对应物料的明细
|
|
|
+ string CurrentPrCode = GridPrcode.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString();
|
|
|
+ string CurrentPDNO = GridPrcode.Rows[e.RowIndex].Cells["pd_pdno"].Value.ToString();
|
|
|
+ dh.ExecuteSql("delete from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno='" + CurrentPDNO + "' and pib_prodcode='" + CurrentPrCode + "'", "delete");
|
|
|
+ LoadGridData(sender, new EventArgs());
|
|
|
+ }
|
|
|
}
|
|
|
}
|