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