void form_FormClosed(object sender, FormClosedEventArgs e)
 {
     try
     {
         HardDeviceManaging.rec = this;
     }
     catch (Exception ex)
     {
         DBO.Err(ex);
         MessageBox.Show(ex.Message, "警告!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void MainWithGrid_Load(object sender, EventArgs e)
 {
     try
     {
         HardDeviceManaging.rec = this;
     }
     catch (Exception ex)
     {
         DBO.Err(ex);
         MessageBox.Show(ex.Message, "警告!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void AddToLog(String ucard)
        {
            if (timer1.Enabled)
            {
                return;
            }
            try
            {
                Entities.Students stu  = DBO.getStudentKH(ucard);
                String            dt   = DateTime.Now.ToString();
                String            evnt = "禁止进门.";
                if (stu != null)
                {
                    if (stu.ENABLE)
                    {
                        HardDeviceManaging.OpenTheDoor();
                        timer1.Enabled      = true;
                        evnt                = "允许进门.";
                        lbl_ordre.BackColor = Color.Blue;
                    }
                    else
                    {
                        lbl_ordre.BackColor = Color.Red;
                    }
                    lbl_card.Text  = stu.CARD;
                    lbl_class.Text = stu.CLASS;
                    lbl_dtime.Text = dt;
                    lbl_name.Text  = stu.NAME;
                    lbl_ordre.Text = evnt;
                    lbl_sno.Text   = stu.SNO;
                    DBO.Record(stu, dt, evnt);
                }
                else
                {
                    lbl_card.Text       = "N/A";
                    lbl_class.Text      = "N/A";
                    lbl_dtime.Text      = dt;
                    lbl_name.Text       = "N/A";
                    lbl_ordre.Text      = evnt;
                    lbl_ordre.BackColor = Color.Red;
                    lbl_sno.Text        = "N/A";

                    //MessageBox.Show("未注册!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception e)
            {
                DBO.Err(e);
                MessageBox.Show(e.Message);
            }
        }