C# 生成条形码

时间:2017-01-23 12:20:39
【文件属性】:

文件名称:C# 生成条形码

文件大小:580KB

文件格式:RAR

更新时间:2017-01-23 12:20:39

C# 条形码

///

/// 生成条码 /// private void btnEncode_Click(object sender, EventArgs e) { errorProvider1.Clear(); int W = Convert.ToInt32(this.txtWidth.Text.Trim()); int H = Convert.ToInt32(this.txtHeight.Text.Trim()); int AddNum = Convert.ToInt32(this.tbAddNum.Text.Trim()); int SerialNo = Convert.ToInt32(this.tbSerialNO.Text.Trim()); CodeLib.AlignmentPositions Align = CodeLib.AlignmentPositions.CENTER; switch (cbBarcodeAlign.SelectedItem.ToString().Trim().ToLower()) { case "left": Align = CodeLib.AlignmentPositions.LEFT; break; case "right": Align = CodeLib.AlignmentPositions.RIGHT; break; default: Align = CodeLib.AlignmentPositions.CENTER; break; } CodeLib.TYPE type = CodeLib.TYPE.UNSPECIFIED; switch (cbEncodeType.SelectedItem.ToString().Trim()) { case "Code 128": type = CodeLib.TYPE.CODE128; break; case "Code 128-A": type = CodeLib.TYPE.CODE128A; break; case "Code 128-B": type = CodeLib.TYPE.CODE128B; break; default: MessageBox.Show("请指定编码类型。"); break; } try { if (type != CodeLib.TYPE.UNSPECIFIED) { b.IncludeLabel = this.chkGenerateLabel.Checked; b.Alignment = Align; switch (this.cbLabelLocation.SelectedItem.ToString().Trim().ToUpper()) { case "BOTTOMLEFT": b.LabelPosition = CodeLib.LabelPositions.BOTTOMLEFT; break; case "BOTTOMRIGHT": b.LabelPosition = CodeLib.LabelPositions.BOTTOMRIGHT; break; case "TOPCENTER": b.LabelPosition = CodeLib.LabelPositions.TOPCENTER; break; case "TOPLEFT": b.LabelPosition = CodeLib.LabelPositions.TOPLEFT; break; case "TOPRIGHT": b.LabelPosition = CodeLib.LabelPositions.TOPRIGHT; break; default: b.LabelPosition = CodeLib.LabelPositions.BOTTOMCENTER; break; } int SerialLen = this.tbSerialNO.Text.Trim().Length; string Barcodedata = ""; int i = 0; do { int zeroNum = SerialLen - SerialNo.ToString().Trim().Length; switch (zeroNum) { case 0: Barcodedata = this.txtData.Text.Trim() + SerialNo.ToString(); break; case 1: Barcodedata = this.txtData.Text.Trim() + SerialNo.ToString().Insert(0, "0"); break; case 2: Barcodedata = this.txtData.Text.Trim() + SerialNo.ToString().Insert(0, "00"); break; case 3: Barcodedata = this.txtData.Text.Trim() + SerialNo.ToString().Insert(0, "000"); break; default : Barcodedata = this.txtData.Text.Trim() + SerialNo.ToString().Insert(0, "0000"); break; } barcode.Image = b.Encode(type, Barcodedata.ToString(), W, H); i++; SerialNo++; this.Refresh(); Thread.Sleep(1000); //Printer(); //打印 //Thread.Sleep(500); } while (i< AddNum); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }


【文件预览】:
C# 生成条形码
----CodeLib()
--------bin()
--------CodeLib.csproj.user(451B)
--------Sysbase()
--------obj()
--------BarcodeXML.xss(853B)
--------BarcodeXML.designer.cs(68KB)
--------BarcodeXML.xsd(7KB)
--------BarcodeXML.xsc(361B)
--------BarcodeCommon.cs(1KB)
--------BarcodeLib.cs(15KB)
--------IBarcode.cs(340B)
--------BarcodeXML.cs(192B)
--------CodeLib.csproj(4KB)
--------Properties()
----UpgradeLog.XML(2KB)
----_UpgradeReport_Files()
--------UpgradeReport.xslt(12KB)
--------UpgradeReport_Minus.gif(69B)
--------UpgradeReport.css(3KB)
--------UpgradeReport_Plus.gif(71B)
----BarCodeTest()
--------bin()
--------Program.cs(476B)
--------obj()
--------MainTest.cs(7KB)
--------BarCodeTest.csproj.user(498B)
--------MainTest.Designer.cs(17KB)
--------MainTest.resx(6KB)
--------app.config(144B)
--------BarCodeTest.csproj(5KB)
--------ommoo_purple.ico(100KB)
--------Properties()
----BarCode_2D.sln(1KB)
----BarCode_2D.suo(50KB)

网友评论