📄 dynamicczkem.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using zkemkeeper;
namespace DynamicCZKEM
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class DynamicCZKEMForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblIp;
private System.Windows.Forms.Label lblPort;
private System.Windows.Forms.Button btnConnect;
private System.Windows.Forms.TextBox textIP;
private System.Windows.Forms.TextBox textPort;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.ListBox listResult;
private System.Windows.Forms.Button btnGetUserInfo;
private CZKEMClass testCZKEM = null;
private System.Windows.Forms.Label lblSDKVersion;
private System.Windows.Forms.Label lblFirmware;
private bool connected = false;
public DynamicCZKEMForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnConnect = new System.Windows.Forms.Button();
this.lblIp = new System.Windows.Forms.Label();
this.lblPort = new System.Windows.Forms.Label();
this.textIP = new System.Windows.Forms.TextBox();
this.textPort = new System.Windows.Forms.TextBox();
this.listResult = new System.Windows.Forms.ListBox();
this.btnGetUserInfo = new System.Windows.Forms.Button();
this.lblSDKVersion = new System.Windows.Forms.Label();
this.lblFirmware = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// btnConnect
//
this.btnConnect.Location = new System.Drawing.Point(264, 8);
this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(112, 23);
this.btnConnect.TabIndex = 0;
this.btnConnect.Text = "Connect";
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
//
// lblIp
//
this.lblIp.Location = new System.Drawing.Point(16, 8);
this.lblIp.Name = "lblIp";
this.lblIp.TabIndex = 1;
this.lblIp.Text = "IP";
//
// lblPort
//
this.lblPort.Location = new System.Drawing.Point(16, 40);
this.lblPort.Name = "lblPort";
this.lblPort.TabIndex = 2;
this.lblPort.Text = "Port";
//
// textIP
//
this.textIP.Location = new System.Drawing.Point(136, 8);
this.textIP.Name = "textIP";
this.textIP.TabIndex = 3;
this.textIP.Text = "192.168.1.233";
//
// textPort
//
this.textPort.Location = new System.Drawing.Point(136, 40);
this.textPort.Name = "textPort";
this.textPort.TabIndex = 4;
this.textPort.Text = "4370";
//
// listResult
//
this.listResult.ItemHeight = 12;
this.listResult.Location = new System.Drawing.Point(16, 120);
this.listResult.Name = "listResult";
this.listResult.Size = new System.Drawing.Size(384, 136);
this.listResult.TabIndex = 5;
//
// btnGetUserInfo
//
this.btnGetUserInfo.Enabled = false;
this.btnGetUserInfo.Location = new System.Drawing.Point(264, 32);
this.btnGetUserInfo.Name = "btnGetUserInfo";
this.btnGetUserInfo.Size = new System.Drawing.Size(112, 23);
this.btnGetUserInfo.TabIndex = 6;
this.btnGetUserInfo.Text = "Get Users Info";
this.btnGetUserInfo.Click += new System.EventHandler(this.btnGetUserInfo_Click);
//
// lblSDKVersion
//
this.lblSDKVersion.Location = new System.Drawing.Point(16, 72);
this.lblSDKVersion.Name = "lblSDKVersion";
this.lblSDKVersion.Size = new System.Drawing.Size(208, 23);
this.lblSDKVersion.TabIndex = 7;
//
// lblFirmware
//
this.lblFirmware.Location = new System.Drawing.Point(240, 72);
this.lblFirmware.Name = "lblFirmware";
this.lblFirmware.Size = new System.Drawing.Size(152, 23);
this.lblFirmware.TabIndex = 8;
//
// DynamicCZKEMForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(408, 273);
this.Controls.Add(this.lblFirmware);
this.Controls.Add(this.lblSDKVersion);
this.Controls.Add(this.btnGetUserInfo);
this.Controls.Add(this.listResult);
this.Controls.Add(this.textPort);
this.Controls.Add(this.textIP);
this.Controls.Add(this.lblPort);
this.Controls.Add(this.lblIp);
this.Controls.Add(this.btnConnect);
this.Name = "DynamicCZKEMForm";
this.Text = "Dynamic CZKEM";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new DynamicCZKEMForm());
}
private void btnConnect_Click(object sender, System.EventArgs e)
{
string strSDKVer = "";
string strVer = "";
if(testCZKEM == null)
{
testCZKEM = new CZKEMClass();
}
if (connected)
{
testCZKEM.Disconnect();
btnConnect.Text = "Connect";
btnGetUserInfo.Enabled = !btnGetUserInfo.Enabled;
connected = false;
}
else
{
connected = testCZKEM.Connect_Net(textIP.Text, Convert.ToInt32(textPort.Text));
if(connected)
{
testCZKEM.GetSDKVersion(ref strSDKVer);
lblSDKVersion.Text = "SDK Version:"+strSDKVer;
testCZKEM.GetFirmwareVersion(1, ref strVer);
lblFirmware.Text = strVer;
btnConnect.Text = "Disconnect";
btnGetUserInfo.Enabled = !btnGetUserInfo.Enabled;
}
}
}
private void btnGetUserInfo_Click(object sender, System.EventArgs e)
{
int dwEnrollNumber = 0;
int iPrivilege = 0;
string sName = "";
string sPassword = "";
bool bEnabled = false;
StringBuilder theUser;
if (connected)
{
while(testCZKEM.GetAllUserInfo(1,ref dwEnrollNumber,ref sName,ref sPassword, ref iPrivilege, ref bEnabled))
{
theUser = new StringBuilder();
theUser.AppendFormat("UserNo:{0},Name:{1}, Password:{2}, Privilege:{3}, Enable:{4}",dwEnrollNumber,sName, sPassword, iPrivilege, bEnabled);
listResult.Items.Add(theUser);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -