001.
using
System;
002.
using
System.Drawing;
003.
using
System.IO;
004.
using
ZXing.Common;
005.
using
ZXing;
006.
using
ZXing.QrCode;
007.
using
System.Web.UI.WebControls;
008.
using
System.Web.UI.HtmlControls;
009.
010.
namespace
CheckLoopQR
011.
{
012.
public
partial
class
Default : System.Web.UI.Page
013.
{
014.
protected
void
Page_Load(
object
sender, EventArgs e)
015.
{
016.
this
.checkTextAll.Text =
" Check All"
;
017.
}
018.
protected
void
btnSelect_Click(
object
sender, EventArgs e)
019.
{
020.
string
code = txtQRCode.Text;
021.
long
num = Convert.ToInt64(code);
022.
023.
int
i;
024.
025.
for
(i = 1; i < 4; i++)
026.
{
027.
num += i;
028.
CheckBox1.Items.Add(
new
ListItem(
" "
+ num));
029.
}
030.
}
031.
protected
void
btnGenerate_Click(
object
sender, EventArgs e)
032.
{
033.
if
(CheckBox1.SelectedItem ==
null
)
034.
{
035.
Response.Redirect(
"Default.aspx"
);
036.
}
037.
038.
string
[] texture = {
"Selected Item Text1 : "
,
"Selected Item Text2 : "
,
"Selected Item Text3 : "
};
039.
int
a = 0;
040.
041.
foreach
(ListItem listItem
in
CheckBox1.Items)
042.
{
043.
if
(listItem.Selected)
044.
{
045.
a++;
046.
047.
string
code = listItem.Text;
048.
049.
CheckBox1.Visible =
false
;
050.
checkAll.Visible =
false
;
051.
checkTextAll.Visible =
false
;
052.
053.
QrCodeEncodingOptions options =
new
QrCodeEncodingOptions();
054.
055.
options =
new
QrCodeEncodingOptions
056.
{
057.
DisableECI =
true
,
058.
CharacterSet =
"UTF-8"
,
059.
Width = 150,
060.
Height = 150,
061.
Margin = 0,
062.
};
063.
064.
var barcodeWriter =
new
BarcodeWriter();
065.
barcodeWriter.Format = BarcodeFormat.QR_CODE;
066.
barcodeWriter.Options = options;
067.
068.
System.Web.UI.WebControls.Image imgBarCode =
new
System.Web.UI.WebControls.Image();
069.
imgBarCode.Height = 150;
070.
imgBarCode.Width = 150;
071.
072.
Label lblvalues =
new
Label();
073.
lblvalues.Text += texture[a-1] + listItem.Text;
074.
lblvalues.Font.Size = FontUnit.Large;
075.
Label lblvalues2 =
new
Label();
076.
lblvalues2.Text += texture[a-1] + listItem.Text;
077.
lblvalues2.Font.Size = FontUnit.Large;
078.
Label lblvalues3 =
new
Label();
079.
lblvalues3.Text += texture[a-1] + listItem.Text;
080.
lblvalues3.Font.Size = FontUnit.Large;
081.
082.
using
(Bitmap bitMap = barcodeWriter.Write(code))
083.
{
084.
using
(MemoryStream ms =
new
MemoryStream())
085.
{
086.
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
087.
byte
[] byteImage = ms.ToArray();
088.
imgBarCode.ImageUrl =
"data:image/png;base64,"
+ Convert.ToBase64String(byteImage);
089.
}
090.
PlaceHolder1.Controls.Add(imgBarCode);
091.
PlaceHolder1.Controls.Add(
new
HtmlGenericControl(
"br"
));
092.
PlaceHolder1.Controls.Add(lblvalues);
093.
PlaceHolder1.Controls.Add(
new
HtmlGenericControl(
"br"
));
094.
PlaceHolder1.Controls.Add(lblvalues2);
095.
PlaceHolder1.Controls.Add(
new
HtmlGenericControl(
"br"
));
096.
PlaceHolder1.Controls.Add(lblvalues3);
097.
PlaceHolder1.Controls.Add(
new
HtmlGenericControl(
"br"
));
098.
}
099.
}
100.
else
101.
{
102.
103.
}
104.
}
105.
}
106.
}
107.
}