我正在做一场噩梦,想弄清楚如何阻止“0瓶”标签打印......
示例:
Line one - 3 Cases 0 Bottles
Line two - 1 Cases 6 Bottles
Line three - 0 Cases 5 Bottles
Line four - 1 case 0 Bottles
需要为每个案例打印标签:
for Line one = L1- 1 case, L2- 1 case, L3- 1 case.
for Line two = L1- 1 case, L2- 6 Bottles.
for Line three = L1- 5 Bottles.
for Line four = L1- 1 case.
但是我为每行“0瓶”打印了一个额外的标签...
for Line one = L1- 1 case, L2- 1 case, L3- 1 case, L4- 0 Bottles.
for Line two = L1- 1 case, L2- 6 Bottles.
for Line three = L1- 5 Bottles.
for Line four = L1- 1 case, L2- 0 Bottles.
我的代码
foreach (DataRow dr in dtaGI.Rows)
{
Label = ARchivos.Clone().ToString();
Label= Label.Replace("[&PRODUCTDESCR]", dr["Description"].ToString())
.Replace("[&PRODUCTCODE]", dr["ProductCode"].ToString())
.Replace("[&PACKDESC]", dr["PAckDescr"].ToString())
.Replace("[&ROTATION]", dr["rotationNum"].ToString())
.Replace("[&SIZE]", dr["CaseLOL"].ToString() + "L")
.Replace("[&BPC]", dr["CasesPerPallet"].ToString());
TotalLabel = " Total " +dr["cases"].ToString() + "c " + dr["Bottles"] +"b";
for(int i = 0 ;i<Convert.ToInt32( dr["cases"]);i++)
{
Labels.Append(Label.Replace("[&TOTALS]", "1 Case " + TotalLabel )).Append(Environment.NewLine );
}
Labels.Append(Label.Replace("[&TOTALS]", dr["Bottles"].ToString() + " Bottles" + TotalLabel)).Append(Environment.NewLine);
}
请让我知道你的想法。
非常感谢提前
答案 0 :(得分:0)
请尝试使用此代码:
foreach (DataRow dr in dtaGI.Rows)
{
Label = ARchivos.Clone().ToString();
Label= Label.Replace("[&PRODUCTDESCR]", dr["Description"].ToString())
.Replace("[&PRODUCTCODE]", dr["ProductCode"].ToString())
.Replace("[&PACKDESC]", dr["PAckDescr"].ToString())
.Replace("[&ROTATION]", dr["rotationNum"].ToString())
.Replace("[&SIZE]", dr["CaseLOL"].ToString() + "L")
.Replace("[&BPC]", dr["CasesPerPallet"].ToString());
TotalLabel = " Total " +dr["cases"].ToString() + "c " + dr["Bottles"] +"b";
for(int i = 0 ;i<Convert.ToInt32( dr["cases"]);i++)
{
Labels.Append(Label.Replace("[&TOTALS]", "1 Case " + TotalLabel )).Append(Environment.NewLine );
}
if (dr["Bottles"].ToString() != "0") {
Labels.Append(Label.Replace("[&TOTALS]", dr["Bottles"].ToString() + " Bottles" + TotalLabel)).Append(Environment.NewLine);
}
}