QR code is now more and more popular, you can use the phone or other mobile terminals on the QR code scanner software to scan the QR code, you can get relevant information. In the Internet site, you can find a lot of QR code tools, and even a lot of online generation, parsing QR code of the site. In the business system, such as the file management system, previously generally through the barcode (one-dimensional code) to store the basic information of staff, but the storage capacity is limited. You can now use the QR code to store more capacity information.
We use the ThoughtWorks.QRCode.dll class library, which is referenced in an ASP. NET project, and can be developed using the relevant API.
For example, we encapsulate one of the most streamlined classes:
Help class:
[CSharp]/// <summary> ///Search QR Code helper class/// /// </summary> ///Public class Qrcodeop {/// <summary> ///generate two-dimensional code/// </summary> /// <param name= "Qrcodecontent" >the content to encode</param> //<returns> return QR code bitmap </returns> Public StaticBitmap Qrcodeencoderutil (stringqrcodecontent) {Qrcodeencoder Qrcodeencoder=NewQrcodeencoder (); Qrcodeencoder.qrcodeversion=0; Bitmap img= Qrcodeencoder.encode (qrcodecontent, Encoding.UTF8);//Specify UTF-8 encoding, support Chinese returnimg; } /// <summary> ///parsing two-dimensional code/// </summary> /// <param name= "Bitmap" >Two-dimensional code bitmap to parse</param> /// <returns>parsed String</returns> Public Static stringQrcodedecoderutil (Bitmap Bitmap) {Qrcodedecoder decoder=NewQrcodedecoder (); stringDecodedString = Decoder.decode (NewQrcodebitmapimage (bitmap), Encoding.UTF8);//Specify UTF-8 encoding, support Chinese returndecodedstring; }
View Code
Test:
[CSharp]protected voidEncodeclick (Objectsender, Directeventargs e) {StringBuilder SB=NewStringBuilder (); Sb. Append (Tf6_personidnum. Text.trim () +";");//personal ID Card numberSb. Append (Tf_daid. Text.trim () +";"); Sb. Append (Tf_daname. Text.trim () +";"); Sb. Append (Cb_dabuskind. Text.trim ()+";"); Sb. Append (Cb_dakind. Text.trim () +";"); Sb. Append (Cb_dalevelcode. Text.trim ()+";"); Sb. Append (Df_dabuildtime. Text.trim () +";"); Sb. Append (tf_daorg. Text.trim ()+";"); Sb. Append (Cb_dastatus. Text.trim () +";"); Sb. Append (Tf_dabuilder. Text.trim ()+";"); Sb. Append (tf_dabuildorg. Text.trim () +";"); Bitmap Bitmap= Qrcodeop.qrcodeencoderutil (sb. ToString (). Trim ()));//call QR Code encoding method to generate bitmap stringFileName = Server.MapPath ("~") +"images\\qrimages\\"+ Tf6_personidnum. Text.trim () +". jpg"; Bitmap. Save (FileName);//save Bitmap, file name is personal ID number This. Qrcodeimage.imageurl ="~/images/qrimages/"+ Tf6_personidnum. Text.trim () +". jpg";//Show PicturesX.msg.alert ("Two-dimensional code information", Qrcodeop.qrcodedecoderutil (bitmap)). Show ();//Call the QR code decoding method to eject the information before the encoding } //Here I am using the Ext.net component in the project. X.msg.alert and Qrcodeimage.imageurl and Dicrecteventargs are not very important and interested readers can visit the Ext.net website for ext.net knowledge.
View Code