资源简介

使用sqlserver数据库,VS2013,生成的二维码支持中文,内有说明文档...................................................................

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ThoughtWorks.QRCode.Codec;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnWrite_Click(object sender EventArgs e)
        {
            string strConn = ““;
            strConn = “server = .; database = Test; uid = sa; pwd = 123456; “; //数据库的链接字符串
            SqlConnection cnn;//定义数据库的链接
            SqlCommand cmd;//定义操作

            string strSql = ““;
            string strQRCodeContent = ““;//要生成二维码的内容的汇总
            string orderNo orderInfo;

            orderNo = TextBox1.Text;
            orderInfo = TextBox2.Text;

            strQRCodeContent = orderNo + ““ + orderInfo;
            strSql = @“insert into AcceptOrder(OrderNoOrderInfoQRCode) values(@OrderNo@OrderInfo@PhotoBinary)“;

            byte[] QRCodeByte = setQRCode(strQRCodeContent.Trim() 2 PictureBox1);

            cnn = new SqlConnection(strConn); //创建链接
            cmd = new SqlCommand(strSql cnn);

            cmd.Parameters.Add(“@OrderNo“ SqlDbType.VarChar);
            cmd.Parameters[“@OrderNo“].Value = orderNo;
            cmd.Parameters.Add(“@OrderInfo“ SqlDbType.VarChar);
            cmd.Parameters[“@OrderInfo“].Value = orderInfo;
            cmd.Parameters.Add(“@PhotoBinary“ SqlDbType.Binary QRCodeByte.Length);
            cmd.Parameters[“@PhotoBinary“].Value = QRCodeByte;

            cmd.Connection.Open();
            cmd.ExecuteNonQuery();
            cmd.Connection.Close();
        }

        /// 
        /// 创建生成二维码图片得到二维码保存路径的字节
        /// 

        /// 生成二维码的内容
        /// 生成二维码图片的大小
        /// 用来加载显示二维码图片的控件
        /// 返回保存二维码图片的路径的字节
        /// 创建生成二维码图片得到二维码保存路径的字节
        public byte[] setQRCode(string strData int scale PictureBox pictureImage)
        {
            string[] str;
            Image mying;
            QRCodeEncoder qRCodeEncoder = new QRCodeEncoder();
            string path = Application.StartupPath;//相对存储图片路径
            FileStream fs = null;
            qRCodeEncoder.QRCodeScale = Convert.ToInt16(scale);//指定生成的二维码 图片的大小
            mying = qRCodeEncoder.Encode(strData System.Text.Encoding.UTF8);//将指定内容生成二维码图片,编译格式为utf8 可以编译中文
            str = strData.Split(‘‘);

            string paths = path + @“\QRCode\“;
            if (!Directory.Exists(paths))
            {
                Directory.CreateDirectory(paths);
            }

            string filePath = paths + str[0] + “.Bmp“;
            mying

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-01-20 09:41  水晶报表打印二维码\
     目录           0  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\
     目录           0  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\
     文件         187  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\App.config
     目录           0  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\
     目录           0  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\
     目录           0  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\QRCode\
     文件       33178  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\QRCode\阿斯达.Bmp
     文件     6209536  2011-09-29 05:20  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\ThoughtWorks.QRCode.dll
     文件       11264  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
     文件         187  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config
     文件       22016  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
     文件       24224  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
     文件         187  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.config
     文件         490  2013-03-19 08:00  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
     文件        3749  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs
     文件        4773  2016-01-20 09:25  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs
     文件        5817  2016-01-20 09:25  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx
     目录           0  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\
     目录           0  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\
     文件        7172  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件           0  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     目录           0  2016-01-20 09:24  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TempPE\
     文件        1059  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt
     文件         977  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache
     文件        6554  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache
     文件       11264  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
     文件         180  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources
     文件       22016  2016-01-20 09:27  水晶报表打印二维码\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
............此处省略12个文件信息

评论

共有 条评论