基本信息
源码名称:C#连接指纹机 实例源码下载
源码大小:3.59KB
文件格式:.txt
开发语言:C#
更新时间:2014-05-29
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
namespace 将指纹数据存入数据库中
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool isConnected=false;//判断是否已经连接
private void button1_Click(object sender, EventArgs e)
{
if (axZKFPEngX1.InitEngine() == 0)//初始化指纹仪
{
toolStripStatusLabel1.Text= "指纹仪连接成功";//显示指纹仪连接成功
this.Text ="注册码:" axZKFPEngX1.SensorSN;//获取指纹仪的注册码
isConnected = true;//标识,指纹仪连接成功
}
else
{
toolStripStatusLabel1.Text = "指纹仪连接失败";//显示指纹仪连接失败
isConnected = false;//标识,指纹仪连接失败
}
}
private void timer1_Tick(object sender, EventArgs e)
{
label2.Text = DateTime.Now.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
label2.Text = DateTime.Now.ToString();
}
private void axZKFPEngX1_OnCapture(object sender, AxZKFPEngXControl.IZKFPEngXEvents_OnCaptureEvent e)
{
if (isConnected)
{
if (e.actionResult)//如果成功取到指纹模板
{
string dtt = "";
Graphics g = panel1.CreateGraphics();//获取panel1控件的Graphics类
string tp = "";//记录是对比成功还是对比失败
string Ntemp = axZKFPEngX1.GetTemplateAsString();//获取当前指纹图片的字符串
SqlConnection conn = new SqlConnection("server=.;database=db_Finger;uid=sa;pwd=");//设置要连接数据库
conn.Open();//连接数据库
dtt = DateTime.Now.ToString();
//向数据表中插入当有员工的信息
SqlCommand cmd1 = new SqlCommand("insert into tb_finger(Ufinger,dt) values('" Ntemp "','" dtt "')", conn);
int i = cmd1.ExecuteNonQuery();//获取SQL影响的行数
if (i > 0)//插入成功
{
tp = "指纹录入成功!";
}
conn.Close();//断开数据库的连接
toolStripStatusLabel1.Text = tp;
richTextBox1.Clear();
richTextBox1.AppendText(tp);
richTextBox1.AppendText("指纹模板:" Ntemp);
richTextBox1.AppendText("考勤日期:" dtt);
//在panel1控件的指定位置显示是否考勤成功
g.DrawString(tp, new Font("黑体",20, FontStyle.Bold), new SolidBrush(Color.Red), new PointF(18, 120));
}
}
}
[DllImport("kernel32")]
public static extern int Beep(int dwFreg, int dwDuration);
private void axZKFPEngX1_OnImageReceived(object sender, AxZKFPEngXControl.IZKFPEngXEvents_OnImageReceivedEvent e)
{
Graphics canvas = panel1.CreateGraphics();//获取panel1控件的Graphics类
axZKFPEngX1.PrintImageAt(canvas.GetHdc().ToInt32(), 0, 0, panel1.Width, panel1.Height);//在panel1控件上绘制指纹图片
canvas.Dispose();//释放
axZKFPEngX1.SaveBitmap("c:\\ls_lb.bmp");//存储指纹图片
Beep(3000, 100);//发出声音
}
}
}