• 大小: 229KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-09
  • 语言: C#
  • 标签: RFID  

资源简介

门禁考勤模拟软件,添加用户信息,实现考勤记录管理。

资源截图

代码片段和文件信息

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.IO.Ports;
using System.Threading;
using System.Data.OleDb;

namespace Attendance
{
    public partial class Form1 : Form
    {
        private string[] arryPorts; /*系统可用串口号列表*/
        private string exePath; /*当前程序运行路径*/
        public OleDbConnection connAttendance;  /*attendance.mdb链接对象*/
        private OleDbConnection connLog;    /*log.mdb链接对象*/
        private Form2 form2;    /*添加用户窗口对象*/
        private byte[] dataBuf; /*串口数据接收buffer*/
        private int readCnt = 0;/*串口数据字节长度*/

        public Form1()
        {
            InitializeComponent();
        }
        /*窗体加载回调函数*/
        private void Form1_Load(object sender EventArgs e)
        {
            /*获取系统可用串口*/
            arryPorts = SerialPort.GetPortNames();
            cbxPort.Items.Clear();
            for (int i = 0; i < arryPorts.Length; i++)
            {
                cbxPort.Items.Add(arryPorts[i]);
            }
            cbxPort.SelectedIndex = 0;
            /*注册串口控件数据接收回调函数*/
            sPort.DataReceived += commDataReceived;
            /*创建数据库链接*/
            exePath = System.Environment.CurrentDirectory;
            connAttendance = new OleDbConnection(“provider=Microsoft.Jet.OLEDB.4.0;data source=“ + exePath + @“\attendance.mdb“);
            connLog = new OleDbConnection(“provider=Microsoft.Jet.OLEDB.4.0;data source=“ + exePath + @“\log.mdb“);
            /*将数据库中的数据显示在界面DataGridView控件上*/
            string cmdStr = “select * from attendance“;
            queryDatabase(connAttendance cmdStr dgvUsrMng);
            cmdStr = “select * from log“;
            queryDatabase(connLog cmdStr dgvLogInfo);
            form2 = new Form2();
            dataBuf = new byte[29];
        }
        /*查询,刷新数据库*/
        public void queryDatabase(OleDbConnection conn string str DataGridView dgv)
        {
            if ((null == conn) || (null == str) || (null == dgv))
                return;
            conn.Open();
            OleDbDataAdapter da = new OleDbDataAdapter(str conn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            dgv.DataSource = dt;
            conn.Close();
        }
        /*修改数据库*/
        public void modifyDatabase(OleDbConnection conn string cmdStr)
        {
            if ((null == conn) || (null == cmdStr))
                return;
            conn.Open();
            OleDbCommand comm = new OleDbCommand(cmdStr conn);
            comm.ExecuteNonQuery();
            conn.Close();
        }
        /*串口接收回调函数*/
        private void commDataReceived(object sender SerialDataReceivedEventArgs e)
        {
            byte[] readBuf = new byte[29];
            byte[] blk1Buf = new byte[4];

            int count = sPort.Read(readBuf 0 29);

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     47616  2017-03-27 07:35  Attendance\.vs\Attendance\v14\.suo

    ..A..H.     79872  2017-03-27 10:09  Attendance\Attendance\App1\.vs\App1\v14\.suo

     文件        249  2017-03-27 10:04  Attendance\Attendance\App1\App1\App.xaml

     文件       3983  2017-03-27 10:04  Attendance\Attendance\App1\App1\App.xaml.cs

     文件       6559  2017-03-27 10:04  Attendance\Attendance\App1\App1\App1.csproj

     文件        355  2017-03-27 10:09  Attendance\Attendance\App1\App1\App1.csproj.user

     文件       2520  2017-03-27 10:05  Attendance\Attendance\App1\App1\App1_TemporaryKey.pfx

     文件       1430  2015-09-20 17:22  Attendance\Attendance\App1\App1\Assets\LockScreenLogo.scale-200.png

     文件       7700  2015-09-20 17:22  Attendance\Attendance\App1\App1\Assets\SplashScreen.scale-200.png

     文件       2937  2015-09-20 17:22  Attendance\Attendance\App1\App1\Assets\Square150x150Logo.scale-200.png

     文件       1647  2015-09-20 17:22  Attendance\Attendance\App1\App1\Assets\Square44x44Logo.scale-200.png

     文件       1255  2015-09-20 17:22  Attendance\Attendance\App1\App1\Assets\Square44x44Logo.targetsize-24_altform-unplated.png

     文件       1451  2015-09-20 17:22  Attendance\Attendance\App1\App1\Assets\StoreLogo.png

     文件       3204  2015-09-20 17:22  Attendance\Attendance\App1\App1\Assets\Wide310x150Logo.scale-200.png

     文件        468  2017-03-27 10:04  Attendance\Attendance\App1\App1\MainPage.xaml

     文件        821  2017-03-27 10:04  Attendance\Attendance\App1\App1\MainPage.xaml.cs

     文件          0  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\ARM\Debug\App.g.cs

     文件       7676  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\ARM\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\ARM\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\ARM\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\ARM\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件          0  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\x86\Debug\App.g.cs

     文件       2253  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\x86\Debug\App.g.i.cs

     文件      40912  2017-03-27 10:06  Attendance\Attendance\App1\App1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\x86\Debug\MainPage.g.cs

     文件       1563  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\x86\Debug\MainPage.g.i.cs

     文件          0  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\x86\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\x86\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2017-03-27 10:05  Attendance\Attendance\App1\App1\obj\x86\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件        791  2017-03-27 10:06  Attendance\Attendance\App1\App1\obj\x86\Debug\XamlSaveStateFile.xml

............此处省略97个文件信息

评论

共有 条评论