/*************************************************************************************************************************************************** * Before you refer to this demo,we strongly suggest you read the development manual deeply first. * * This part is for demonstrating the operations of Udisk data management.Including getting data from Udisk & writing data to files to be uploaded.* * No need to connect the device,just need to plug in the usb disk. * ****************************************************************************************************************************************************/ #region SSR_User //To read the user information of the TFT screen devices,Filename:user.dat private void btnSSR_UserRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength; int iCount;//count of users int iPIN = 0; int iPrivilege = 0; string sName = ""; string sPassword = ""; int iCard = 0; int iGroup = 0; string sTimeZones = ""; string sPIN2 = ""; lvSSRUser.Items.Clear(); openFileDialog1.Filter = "user(*.dat)|*.dat"; openFileDialog1.FileName = "user.dat"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read); byDataBuf = File.ReadAllBytes(openFileDialog1.FileName); iLength = Convert.ToInt32(stream.Length); if (iLength % 72 != 0) { MessageBox.Show("Data Error!Please check whether you have chosen the right file!", "Error", MessageBoxButtons.OK); return; } iCount = iLength / 72; for (int j = 0; j < iCount; j++)//loop to manage all the users { byte[] byUserInfo = new byte[72]; for (int i = 0; i < 72; i++)//loop to manage every user's information { byUserInfo[i] = byDataBuf[j * 72 + i]; } udisk.GetSSRUserInfoFromDat(byUserInfo, out iPIN, out iPrivilege, out sPassword, out sName, out iCard, out iGroup, out sTimeZones, out sPIN2); ListViewItem list = new ListViewItem(); list.Text = sPIN2; list.SubItems.Add(sName); list.SubItems.Add(iCard.ToString()); list.SubItems.Add(iPrivilege.ToString()); list.SubItems.Add(sPassword); list.SubItems.Add(iGroup.ToString()); list.SubItems.Add(sTimeZones); list.SubItems.Add(iPIN.ToString()); lvSSRUser.Items.Add(list); byUserInfo = null; } stream.Close(); } }
private void btnSSR_UserRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength; int iCount;//count of users int iPIN = 0; int iPrivilege = 0; string sName = ""; string sPassword = ""; int iCard = 0; int iGroup = 0; string sTimeZones = ""; string sPIN2 = ""; lvSSRUser.Items.Clear(); openFileDialog1.Filter = "user(*.dat)|*.dat"; openFileDialog1.FileName = "user.dat"; try { if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read); byDataBuf = File.ReadAllBytes(openFileDialog1.FileName); iLength = Convert.ToInt32(stream.Length); if (iLength % 72 != 0) { MessageBox.Show("Data Error!Please check whether you have chosen the right file!", "Error", MessageBoxButtons.OK); return; } iCount = iLength / 72; for (int j = 0; j < iCount; j++)//loop to deal with all the users { byte[] byUserInfo = new byte[72]; for (int i = 0; i < 72; i++)//loop to deal with every user's information { byUserInfo[i] = byDataBuf[j * 72 + i]; } udisk.GetSSRUserInfoFromDat(byUserInfo, out iPIN, out iPrivilege, out sPassword, out sName, out iCard, out iGroup, out sTimeZones, out sPIN2); ListViewItem list = new ListViewItem() { Text = sPIN2 }; list.SubItems.Add(sName); list.SubItems.Add(iCard.ToString()); list.SubItems.Add(iPrivilege.ToString()); list.SubItems.Add(sPassword); list.SubItems.Add(iGroup.ToString()); list.SubItems.Add(sTimeZones); list.SubItems.Add(iPIN.ToString()); lvSSRUser.Items.Add(list); //SAVE DATA TO DATABASE DBEngine.exec("sp_UserSave", CommonConst.A_LoginID, UserID, "@Name", sName, "@Privilige", iPrivilege, "@BadgeNumber", iPIN, "@Password", sPassword, "@CardNo", iCard); byUserInfo = null; } stream.Close(); } UIMessage.ShowMessage(CommonConst.DATASAVED_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { HPA.Common.Helper.ShowException(ex, this.Name, "btnUserRead_Click"); } }
//To read the user information of the TFT screen devices,Filename:user.dat private void btnSSR_UserRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength; int iCount;//count of users int iPIN = 0; int iPrivilege = 0; string sName = ""; string sPassword = ""; int iCard = 0; int iGroup = 0; string sTimeZones = ""; string sPIN2 = ""; lvSSRUser.Items.Clear(); openFileDialog1.Filter = "user(*.dat)|*.dat"; openFileDialog1.FileName = "user.dat"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read); byDataBuf = File.ReadAllBytes(openFileDialog1.FileName); iLength = Convert.ToInt32(stream.Length); if (iLength % 72 != 0) { MessageBox.Show("Data Error!Please check whether you have chosen the right file!", "Error", MessageBoxButtons.OK); return; } iCount = iLength / 72; for (int j = 0; j < iCount; j++)//loop to deal with all the users { byte[] byUserInfo = new byte[72]; for (int i = 0; i < 72; i++)//loop to deal with every user's information { byUserInfo[i] = byDataBuf[j * 72 + i]; } udisk.GetSSRUserInfoFromDat(byUserInfo, out iPIN, out iPrivilege, out sPassword, out sName, out iCard, out iGroup, out sTimeZones, out sPIN2); ListViewItem list = new ListViewItem(); list.Text = sPIN2; list.SubItems.Add(sName); list.SubItems.Add(iCard.ToString()); list.SubItems.Add(iPrivilege.ToString()); list.SubItems.Add(sPassword); list.SubItems.Add(iGroup.ToString()); list.SubItems.Add(sTimeZones); list.SubItems.Add(iPIN.ToString()); lvSSRUser.Items.Add(list); byUserInfo = null; } stream.Close(); } }