门禁管理系统源码
功能包括:
1、有简单部门;
2、有简单人事;
3、有设备管理,增,删功能,对设备设置时间 ,取回时间,删除管理员等。
4、备份与恢复数据库功能;
该源码是用C#.net4.0简单三层写成;有需要可下载学习一下;代码比较简单。该系统源码还可改成用于饭堂计次系统;只要你自己写一个汇总功能即可。
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 ZKAccess.BLL;
using ZKAccess.Model;
namespace ZKAccess
{
public partial class FormDeviceInfo : Form
{
public FormDeviceInfo()
{
InitializeComponent();
}
private MachineManage mm = new MachineManage();
private MachinesInfo mi = new MachinesInfo();
private zkemkeeper.CZKEMClass zk = new zkemkeeper.CZKEMClass();
private void button1_Click(object sender, EventArgs e)
{
SetTextBoxTrue();
}
private void SetTextBoxFalse()
{
cbbConnectionType.Enabled = false;
txtMachineNumber.Enabled = false;
txtMachineName.Enabled = false;
txtIPAddress.Enabled = false;
txtMachineNumber.Clear();
txtMachineName.Clear();
txtIPAddress.Clear();
}
private void SetTextBoxTrue()
{
cbbConnectionType.Enabled = true;
txtMachineNumber.Enabled = true;
txtMachineName.Enabled = true;
txtIPAddress.Enabled = true;
txtMachineNumber.Clear();
txtMachineName.Clear();
txtIPAddress.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
//MessageBox.Show(dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[0].Value.ToString());
mi.MachinesNumber = dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[0].Value.ToString();
if (MessageBox.Show("是否删除当前设备信息!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
mm.DelMachine(mi);
MessageBox.Show("删除设备成功!");
dgvMachinesInfo.DataSource = mm.dgvReadMachines();
}
}
private void btnTest_Click(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
if (txtMachineNumber.Text == "" || txtMachineName.Text == "" || txtIPAddress.Text == "")
{
MessageBox.Show("设备信息不完整!请重新输入...", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (zk.Connect_Net(txtIPAddress.Text.Trim(), 4370) == true)
{
MessageBox.Show("测试设备连接成功!可以保存...");
}
else
{
MessageBox.Show("测试设备连接失败!请检查...");
}
Cursor = Cursors.Default;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (txtMachineNumber.Text == "" || txtMachineName.Text == "" || txtIPAddress.Text == "" || cbbConnectionType.Text == "")
{
MessageBox.Show("设备信息输入不完整!请重新输入...", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
mi.MachinesNumber = txtMachineNumber.Text.Trim();
mi.MachinesName = txtMachineName.Text.Trim();
mi.MachinesIPAddress = txtIPAddress.Text.Trim();
mi.MachinesConnectionType = cbbConnectionType.Text.Trim();
mi.MachinesPort = "4370";
mi.MachinesRemark = "";
mm.AddMachine(mi);
MessageBox.Show("设备添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
SetTextBoxFalse();
}
dgvMachinesInfo.DataSource = mm.dgvReadMachines();
}
private void FormDeviceInfo_Load(object sender, EventArgs e)
{
dgvMachinesInfo.DataSource = mm.dgvReadMachines();
}
private void btnSetMachineTime_Click(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
string ip = dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[3].Value.ToString();
int machineNumber = Convert.ToInt16(dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[0].Value.ToString());
//MessageBox.Show(ip machineNumber);
if (zk.Connect_Net(ip.Trim(), 4370))
{
zk.SetDeviceTime(machineNumber);
MessageBox.Show("设置设备时间成功!");
}
zk.Disconnect();
Cursor = Cursors.Default;
}
private void btnReadMachineTime_Click(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
int idwYear =0;
int idwMonth=0;
int idwDay=0;
int idwHour=0;
int idwMinute=0;
int idwSecond=0;
string ip = dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[3].Value.ToString();
int machineNumber = Convert.ToInt16(dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[0].Value.ToString());
if (zk.Connect_Net(ip.Trim(), 4370))
{
zk.GetDeviceTime(machineNumber, ref idwYear, ref idwMonth, ref idwDay, ref idwHour, ref idwMinute, ref idwSecond);
MessageBox.Show(Convert.ToString(idwYear) "-" Convert.ToString(idwMonth) "-" Convert.ToString(idwDay) " " Convert.ToString(idwHour).PadLeft(2,'0') ":" Convert.ToString(idwMinute).PadLeft(2,'0') ":" Convert.ToString(idwSecond).PadLeft(2,'0'));
}
zk.Disconnect();
Cursor = Cursors.Default;
}
private void btnClearMachineManage_Click(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
string ip = dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[3].Value.ToString();
int machineNumber = Convert.ToInt16(dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[0].Value.ToString());
//MessageBox.Show(ip machineNumber);
if (zk.Connect_Net(ip.Trim(), 4370))
{
zk.ClearAdministrators(machineNumber);
MessageBox.Show("清除设备管理员成功!");
}
zk.Disconnect();
Cursor = Cursors.Default;
}
private void btnClearData_Click(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
string ip = dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[3].Value.ToString();
int machineNumber = Convert.ToInt16(dgvMachinesInfo.Rows[dgvMachinesInfo.CurrentCell.RowIndex].Cells[0].Value.ToString());
//MessageBox.Show(ip machineNumber);
if (zk.Connect_Net(ip.Trim(), 4370))
{
zk.ClearKeeperData(machineNumber);
zk.Disconnect();
MessageBox.Show("清除设备数据成功!");
}
Cursor = Cursors.Default;
}
}
}
评论