Update 20250117 12:30
This commit is contained in:
@@ -38,6 +38,7 @@ namespace BarcodeLib.UI
|
||||
{
|
||||
this.cbxreportname.Items.Add(file.Name);
|
||||
}
|
||||
this.cbxreportname.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
@@ -45,13 +46,15 @@ namespace BarcodeLib.UI
|
||||
DataTable dt = new DataTable();
|
||||
DataSet dataSet = new DataSet();
|
||||
dt.Columns.Add("barcode");
|
||||
dt.Columns.Add("barcodetext");
|
||||
for (int i = 0; i < Convert.ToInt32(textBox1.Text); i++)
|
||||
{
|
||||
DataRow dr = dt.NewRow();
|
||||
string s;
|
||||
s = i.ToString();
|
||||
while (s.Length < 8) { s = "0" + s; };
|
||||
dr[0] = "" + s;
|
||||
dr[0] = Bar25I(s);
|
||||
dr[1] = s;
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
dataSet.Tables.Add(dt);
|
||||
@@ -75,6 +78,7 @@ namespace BarcodeLib.UI
|
||||
DataTable dt = new DataTable();
|
||||
DataSet dataSet = new DataSet();
|
||||
dt.Columns.Add("barcode");
|
||||
dt.Columns.Add("barcodetext");
|
||||
for (int i = 0; i < Convert.ToInt32(textBox1.Text); i++)
|
||||
{
|
||||
DataRow dr = dt.NewRow();
|
||||
@@ -87,7 +91,8 @@ namespace BarcodeLib.UI
|
||||
while (s.Length < 5) { s = "0" + s; };
|
||||
s = DateTime.Now.Year.ToString()+s;
|
||||
s = s+Helper.DivFnkt.modulo10(s).ToString();
|
||||
dr[0] = s;
|
||||
dr[0] = Bar25I(s);
|
||||
dr[1] = s;
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
dataSet.Tables.Add(dt);
|
||||
@@ -107,5 +112,60 @@ namespace BarcodeLib.UI
|
||||
|
||||
|
||||
}
|
||||
public bool IsNumeric(string value)
|
||||
{
|
||||
return value.All(char.IsNumber);
|
||||
}
|
||||
public string Bar25I(string BarTextIn)
|
||||
{
|
||||
string Bar25IRet = default;
|
||||
string BarTextOut = "";
|
||||
string TempString = "";
|
||||
long CharValue = 0;
|
||||
string barcodeout = "";
|
||||
// Initialize input and output strings
|
||||
BarTextOut = "";
|
||||
BarTextIn = BarTextIn.Trim();
|
||||
|
||||
// Throw away non-numeric data
|
||||
TempString = "";
|
||||
for (int II = 1, loopTo = BarTextIn.Length; II <= loopTo; II++)
|
||||
{
|
||||
if (IsNumeric(BarTextIn.Substring(II - 1, 1)))
|
||||
{
|
||||
TempString = TempString + BarTextIn.Substring(II - 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// If not an even number of digits, add a leading 0
|
||||
if (TempString.Length % 2 == 1)
|
||||
{
|
||||
TempString = "0" + TempString;
|
||||
}
|
||||
|
||||
// Break digit pairs up and convert to characters- build output string
|
||||
for (int II = 1, loopTo1 = TempString.Length; II <= loopTo1; II += 2)
|
||||
{
|
||||
// Break string into pairs of digits and get value
|
||||
CharValue = Convert.ToInt32(TempString.Substring(II - 1, 2));
|
||||
// translate value to ASCII and save in BarTextOut
|
||||
if (CharValue < 90)
|
||||
{
|
||||
BarTextOut = BarTextOut + (char)(CharValue + 33);
|
||||
}
|
||||
else
|
||||
{
|
||||
BarTextOut = BarTextOut + (char)(CharValue + 71);
|
||||
}
|
||||
}
|
||||
|
||||
// Build ouput string, trailing space for Windows rasterization bug
|
||||
barcodeout = "{" + BarTextOut + "} ";
|
||||
|
||||
// Return the string
|
||||
Bar25IRet = barcodeout;
|
||||
return Bar25IRet;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user