基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
using Lskj.Control;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using ZXing;
|
||||
using ZXing.QrCode;
|
||||
|
||||
namespace Lskj.PubInvoiceOut
|
||||
{
|
||||
public partial class FrmQrCode : BaseForm
|
||||
{
|
||||
public EventHandler<ResultEventArgs> OnAttestationCallback;
|
||||
public EventHandler<ResultEventArgs> OnVerifyQrCodeCallback;
|
||||
public System.Threading.Thread thread;
|
||||
public FrmQrCode()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Load += OnFrmQrCodeLoad;
|
||||
}
|
||||
|
||||
private void OnFrmQrCodeLoad(object sender, EventArgs e)
|
||||
{
|
||||
ResultEventArgs resultEventArgs = new ResultEventArgs();
|
||||
if (OnAttestationCallback != null)
|
||||
{
|
||||
OnAttestationCallback(null, resultEventArgs);
|
||||
if (resultEventArgs.Code.Equals("0000"))
|
||||
{
|
||||
string qrId = resultEventArgs.Result;
|
||||
var options = new QrCodeEncodingOptions
|
||||
{
|
||||
Width = 180,
|
||||
Height = 180,
|
||||
Margin = 1
|
||||
};
|
||||
var writer = new BarcodeWriter();
|
||||
writer.Format = BarcodeFormat.QR_CODE;
|
||||
writer.Options = options;
|
||||
var bitmap = writer.Write(qrId);
|
||||
this.qrCodeImage.Image = bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show(resultEventArgs.Message);
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
this.Dispose();
|
||||
return;
|
||||
}
|
||||
thread = new System.Threading.Thread(() =>
|
||||
{
|
||||
bool isContain = true;
|
||||
while (isContain)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (OnVerifyQrCodeCallback != null)
|
||||
{
|
||||
OnVerifyQrCodeCallback(null, resultEventArgs);
|
||||
}
|
||||
if (resultEventArgs.Code.Equals("0000"))
|
||||
{
|
||||
if (resultEventArgs.Result.Equals("2"))//完成
|
||||
{
|
||||
if (this.InvokeRequired && this.IsHandleCreated)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
this.Dispose();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
this.Dispose();
|
||||
}
|
||||
}
|
||||
else if (resultEventArgs.Result.Equals("3"))//过期
|
||||
{
|
||||
resultEventArgs = new ResultEventArgs();
|
||||
if (OnAttestationCallback != null)
|
||||
{
|
||||
OnAttestationCallback(null, resultEventArgs);
|
||||
if (resultEventArgs.Code.Equals("0000"))
|
||||
{
|
||||
string qrId = resultEventArgs.Result;
|
||||
var options = new QrCodeEncodingOptions
|
||||
{
|
||||
Width = 180,
|
||||
Height = 180,
|
||||
Margin = 1
|
||||
};
|
||||
var writer = new BarcodeWriter();
|
||||
writer.Format = BarcodeFormat.QR_CODE;
|
||||
writer.Options = options;
|
||||
var bitmap = writer.Write(qrId);
|
||||
if (this.InvokeRequired && this.IsHandleCreated)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.qrCodeImage.Image = bitmap;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.qrCodeImage.Image = bitmap;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.InvokeRequired && this.IsHandleCreated)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
MessageUtil.Show(resultEventArgs.Message);
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
this.Dispose();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show(resultEventArgs.Message);
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
this.Dispose();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowTips(resultEventArgs.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
System.Threading.Thread.Sleep(5000);
|
||||
}
|
||||
});
|
||||
thread.Start();
|
||||
}
|
||||
}
|
||||
public void ShowTips(string msg)
|
||||
{
|
||||
if (this.InvokeRequired && this.IsHandleCreated)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.tipsLabel.Text = msg;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tipsLabel.Text = msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user