DH_WorkAttend attend = new DH_WorkAttend();
protected void btnGetData_Click(object sender, EventArgs e)
{
string sdwEnrollNumber = "";
int idwTMachineNumber = 0;
int idwEMachineNumber = 0;
int idwVerifyMode = 0;
int idwInOutMode = 0;
int idwYear = 0;
int idwMonth = 0;
int idwDay = 0;
int idwHour = 0;
int idwMinute = 0;
int idwSecond = 0;
int idwWorkcode = 0;
int idwErrorCode = 0;
int iGLCount = 0;
int iIndex = 0;
int iMachineNumber = int.Parse(txtiMachineNumber.Text.Trim());
bool bIsConnected = axCZKEM1.Connect_Net(txtIP.Text, Convert.ToInt32(txtPort.Text));
if (bIsConnected == true)
{
axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device
if (axCZKEM1.ReadGeneralLogData(iMachineNumber))//read all the attendance records to the memory
{
while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out sdwEnrollNumber, out idwVerifyMode,
out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))//get records from the memory
{
decimal UserID = decimal.Parse(sdwEnrollNumber);
iMachineNumber = int.Parse(txtiMachineNumber.Text.Trim());
string IPAdd = txtIP.Text.Trim();
string workDates = idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + " " + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString();
DateTime workDate = DateTime.Parse(workDates);
DateTime InputDate = DateTime.Now;
attend.DH_AttendanceEmpOriginalInsert(UserID, workDate, iMachineNumber, IPAdd, InputDate);
}
}
else
{
axCZKEM1.GetLastError(ref idwErrorCode);
if (idwErrorCode != 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Reading data from terminal failed')", true);
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('No data from terminal returns!')", true);
}
}
if (axCZKEM1.ClearGLog(iMachineNumber))
{
axCZKEM1.RefreshData(iMachineNumber);
}
axCZKEM1.EnableDevice(iMachineNumber, true);
axCZKEM1.Disconnect();
BindGridView(pageSize, 1, SearchTerms);
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('设备连接失败!')", true);
}
}