|
|
@@ -73,7 +73,7 @@ namespace UAS_PRINT
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void vendorZplPrint( string str)
|
|
|
+ public static void vendorZplPrint(string str)
|
|
|
{
|
|
|
Report Report = new Report();
|
|
|
string chooseprintername;
|
|
|
@@ -148,47 +148,47 @@ namespace UAS_PRINT
|
|
|
|
|
|
foreach (var item in barcode)
|
|
|
{
|
|
|
- foreach (var itemc in item)
|
|
|
+ foreach (var itemc in item)
|
|
|
+ {
|
|
|
+ Dictionary<string, object> Sidc = parameter.Find(p => p["LP_NAME"].ToString().Replace(" ", "").Replace("\"", "").ToUpper() == itemc.Key.ToUpper());
|
|
|
+ if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "text")
|
|
|
{
|
|
|
- Dictionary<string, object> Sidc = parameter.Find(p => p["LP_NAME"].ToString().Replace(" ", "").Replace("\"", "").ToUpper() == itemc.Key.ToUpper());
|
|
|
- if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "text")
|
|
|
+ string itemstr = "";
|
|
|
+ if (itemc.Value != null)
|
|
|
{
|
|
|
- string itemstr = "";
|
|
|
- if (itemc.Value != null)
|
|
|
+ itemstr = itemc.Value.ToString();
|
|
|
+ while (itemstr.StartsWith("\f") || itemstr.StartsWith("\v") || itemstr.StartsWith("\t") || itemstr.StartsWith("\r") || itemstr.StartsWith("\n"))
|
|
|
{
|
|
|
- itemstr = itemc.Value.ToString();
|
|
|
- while (itemstr.StartsWith("\f") || itemstr.StartsWith("\v") || itemstr.StartsWith("\t") || itemstr.StartsWith("\r") || itemstr.StartsWith("\n"))
|
|
|
- {
|
|
|
- itemstr = itemstr.Remove(0, 2);
|
|
|
- }
|
|
|
- if (itemstr.StartsWith("\""))
|
|
|
- {
|
|
|
- itemstr = itemstr.Remove(0, 1);
|
|
|
- }
|
|
|
- while (itemstr.EndsWith("\f") || itemstr.EndsWith("\v") || itemstr.EndsWith("\t") || itemstr.EndsWith("\r") || itemstr.EndsWith("\n"))
|
|
|
- {
|
|
|
- itemstr = itemstr.Remove(itemstr.Length - 2);
|
|
|
- }
|
|
|
- if (itemstr.EndsWith("\""))
|
|
|
- {
|
|
|
- itemstr = itemstr.Remove(itemstr.Length - 1);
|
|
|
- }
|
|
|
- if (itemstr.Contains("\\\""))
|
|
|
- {
|
|
|
- itemstr = itemstr.Replace("\\\"", "\"");
|
|
|
- }
|
|
|
+ itemstr = itemstr.Remove(0, 2);
|
|
|
+ }
|
|
|
+ if (itemstr.StartsWith("\""))
|
|
|
+ {
|
|
|
+ itemstr = itemstr.Remove(0, 1);
|
|
|
+ }
|
|
|
+ while (itemstr.EndsWith("\f") || itemstr.EndsWith("\v") || itemstr.EndsWith("\t") || itemstr.EndsWith("\r") || itemstr.EndsWith("\n"))
|
|
|
+ {
|
|
|
+ itemstr = itemstr.Remove(itemstr.Length - 2);
|
|
|
+ }
|
|
|
+ if (itemstr.EndsWith("\""))
|
|
|
+ {
|
|
|
+ itemstr = itemstr.Remove(itemstr.Length - 1);
|
|
|
+ }
|
|
|
+ if (itemstr.Contains("\\\""))
|
|
|
+ {
|
|
|
+ itemstr = itemstr.Replace("\\\"", "\"");
|
|
|
}
|
|
|
- DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
|
|
|
- if (!dt.Columns.Contains(itemc.Key))
|
|
|
- dt.Columns.Add(DC);
|
|
|
- }
|
|
|
- else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
|
|
|
- {
|
|
|
- DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
|
|
|
- if (!dt.Columns.Contains(itemc.Key))
|
|
|
- dt.Columns.Add(DC);
|
|
|
}
|
|
|
- }
|
|
|
+ DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
|
|
|
+ if (!dt.Columns.Contains(itemc.Key))
|
|
|
+ dt.Columns.Add(DC);
|
|
|
+ }
|
|
|
+ else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
|
|
|
+ {
|
|
|
+ DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
|
|
|
+ if (!dt.Columns.Contains(itemc.Key))
|
|
|
+ dt.Columns.Add(DC);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
code = 0;
|
|
|
first = "";
|
|
|
@@ -235,9 +235,9 @@ namespace UAS_PRINT
|
|
|
{
|
|
|
dr[itemc.Key] = itemc.Value.ToString().Replace("\"", "");
|
|
|
if (code == 0)
|
|
|
- first = itemc.Value.ToString().Replace("\"", "");
|
|
|
- if(code == barcode.Count -1)
|
|
|
- last = itemc.Value.ToString().Replace("\"", "");
|
|
|
+ first = itemc.Value.ToString().Replace("\"", "");
|
|
|
+ if (code == barcode.Count - 1)
|
|
|
+ last = itemc.Value.ToString().Replace("\"", "");
|
|
|
}
|
|
|
}
|
|
|
dt.Rows.Add(dr);
|
|
|
@@ -250,10 +250,10 @@ namespace UAS_PRINT
|
|
|
////string logout_confirm = MessageBox.Show("打印" + dt.Rows.Count + "张条码,"+first+"到"+last+",是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly).ToString();
|
|
|
if (logout_confirm == "Yes")
|
|
|
{
|
|
|
- Report.PrintSettings.ShowDialog = false;
|
|
|
- byte[] buffer = Encoding.GetEncoding("GB2312").GetBytes(chooseprintername);
|
|
|
- chooseprintername = Encoding.UTF8.GetString(buffer);
|
|
|
- Report.PrintSettings.Printer = chooseprintername.Replace("\\\\", "\\");
|
|
|
+ Report.PrintSettings.ShowDialog = false;
|
|
|
+ byte[] buffer = Encoding.GetEncoding("GB2312").GetBytes(chooseprintername);
|
|
|
+ chooseprintername = Encoding.UTF8.GetString(buffer);
|
|
|
+ Report.PrintSettings.Printer = chooseprintername.Replace("\\\\", "\\");
|
|
|
//foreach (DataRow dr in dt.Rows)
|
|
|
//{
|
|
|
// DataTable dta = dt.Clone();
|
|
|
@@ -262,15 +262,15 @@ namespace UAS_PRINT
|
|
|
// Report.GetDataSource(label_type).Enabled = true;
|
|
|
// Report.Print();
|
|
|
//}
|
|
|
- Report.RegisterData(dt, label_type);
|
|
|
- Report.GetDataSource(label_type).Enabled = true;
|
|
|
- Report.Print();
|
|
|
+ Report.RegisterData(dt, label_type);
|
|
|
+ Report.GetDataSource(label_type).Enabled = true;
|
|
|
+ Report.Print();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- MessageBox.Show("打印出现错误,请检查标签文件选择是否正确"+ex.Message);
|
|
|
+ MessageBox.Show("打印出现错误,请检查标签文件选择是否正确" + ex.Message);
|
|
|
}
|
|
|
dt.Clear();
|
|
|
}
|