//swipe card private void txtStuCardNo_KeyDown(object sender, KeyEventArgs e) { Student objStu = objStuService.GetStudentByCardNo(this.txtStuCardNo.Text.Trim()); if (objStu == null) { MessageBox.Show("The card no is incorrect", "Warning"); this.lblInfo.Text = "Fail"; this.txtStuCardNo.SelectAll(); this.lblStuName.Text = ""; this.lblStuClass.Text = ""; this.lblStuId.Text = ""; this.pbStu.Image = null; } else { this.lblStuName.Text = objStu.StudentName; this.lblStuId.Text = objStu.StudentId.ToString(); this.lblStuClass.Text = objStu.ClassName; // image if (objStu.StuImage != null && objStu.StuImage.Length != 0) { this.pbStu.Image = (Image) new SerializeObjectToString().DeserializeObject(objStu.StuImage); } else { this.pbStu.Image = Image.FromFile("default.png"); } string result = objAttendanceService.AddCardNo(this.txtStuCardNo.Text.Trim()); if (result != "success") { this.lblInfo.Text = "Fail"; MessageBox.Show(result, "Warning"); } else { this.lblInfo.Text = "Success"; ShowStat(); // save signed student to list objStu.SignedTime = DateTime.Now; signedStudent.Add(objStu); this.dgvStudentList.DataSource = null; this.dgvStudentList.DataSource = this.signedStudent; // wait next student to swipe card this.txtStuCardNo.Text = ""; this.txtStuCardNo.Focus(); } } }