コード例 #1
0
 private void Connect_Click(object sender, EventArgs e)
 {
     if (hasDevice)
     {
         dc.disconnect();
         hasDevice             = false;
         deviceBuilding        = "";
         Connect.Text          = "Connect";
         connection_label.Text = "         No Device Connected";
         port_box.Enabled      = true;
         //device_dashboard.Enabled = false;
     }
     else
     {
         if (dc.connect(port_box.GetItemText(port_box.SelectedItem)))
         {
             string w = dc.wait();
             if (w != "OK")
             {
                 MetroFramework.MetroMessageBox.Show(this, w, "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             deviceBuilding   = dc.get();
             hasDevice        = true;
             Connect.Text     = "Disonnect";
             port_box.Enabled = false;
             //btn_time.Enabled = btn_empty_database.Enabled = btn_add_new_employee.Enabled = true;
             device_dashboard.Enabled = true;
             connection_label.Text    = deviceBuilding + " device is now connected at " + port_box.GetItemText(port_box.SelectedItem);
         }
         else
         {
             hasDevice                = false;
             deviceBuilding           = "";
             port_box.Enabled         = true;
             Connect.Text             = "Connect";
             connection_label.Text    = "           No Device Connected";
             device_dashboard.Enabled = false;
         }
     }
 }
コード例 #2
0
        private void performDelete()
        {
            DataGridViewRow row = dataGrid.CurrentRow;
            string          q   = "DELETE FROM employee WHERE id='" + row.Cells["id"].Value.ToString() + "'";

            if (oc.insert(q))
            {
                df++;
            }
            else
            {
                df = 0;
                return;
            }
            dc.deleteRequest(Convert.ToInt32(row.Cells["fid"].Value.ToString().Substring(3)));
            dc.wait();
            if (dc.get() == "Deleted!")
            {
                df++;
            }
        }
コード例 #3
0
        private bool EnrollProcess()
        {
            bool f = dc.send("ENROLL\n");

            if (!f)
            {
                fid = -100;
                MetroFramework.MetroMessageBox.Show(this, "Couldn't send command to device\nForm is closing...", "STOP", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return(false);
            }
            updateLabel("Waiting...");
            while (true)
            {
                string ws = dc.wait();
                if (ws.Equals("Time Limit"))
                {
                    fid = -100;
                    MetroFramework.MetroMessageBox.Show(this, "Sorry !!!\nThe device is not responding", "STOP", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //Close();
                    return(false);
                }
                else if (ws != "OK")
                {
                    fid = -100;
                    MetroFramework.MetroMessageBox.Show(this, "Exception occured!!!\n" + ws + "\nForm is closing...", "STOP", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //Close();
                    return(false);
                }
                string   line = dc.get();
                string[] arr  = line.Split(' ');
                if (arr.Length <= 1)
                {
                    fid = -100;
                    MetroFramework.MetroMessageBox.Show(this, "Unknown Behaviour !!!", "STOP", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //Close();
                    return(false);
                }
                if (arr[0].Equals("Success"))
                {
                    updateLabel("Success: " + arr[1]);
                    fid = Convert.ToInt32(arr[1]);
                    updateLabel(fid.ToString());
                    Refresh();
                    return(true);
                }
                else if (arr[0].Equals("ERROR"))
                {
                    updateLabel(arr[1] + " Error\nRetry");
                    Refresh();
                    MetroFramework.MetroMessageBox.Show(this, arr[1] + " Error", "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                else if (arr[0].Equals("Failed"))
                {
                    updateLabel("Fingerprint didn't match\nRetry");
                    Refresh();
                    MetroFramework.MetroMessageBox.Show(this, "Fingerprint didn't match", "ERROR !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                else
                {
                    updateLabel(line);
                    if (!arr[0].Equals("Waiting") && !arr[0].Equals("Free") && !arr[0].Equals("Remove") && !arr[0].Equals("Place"))
                    {
                        ProgressBar.Value += 10;
                    }
                }
                Refresh();
            }
        }