Пример #1
0
 private void cmbSearchBy_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.cmbFilterBy.Items.Clear();
     this.cmbFilterBy.Items.Add("- Select filter by -");
     this.cmbFilterBy.Text = "- Select filter by -";
     if (!cmbSearchBy.Text.Equals("   Select Search By"))
     {
         if (cmbSearchBy.Text.Equals("National ID Number"))
         {
             this.cmbFilterBy.Items.Clear();
             this.cmbFilterBy.Items.Add("Equals");
             this.cmbFilterBy.Items.Add("Not Equals");
         }
         else if (cmbSearchBy.Text.Equals("Date"))
         {
             this.cmbFilterBy.Items.Clear();
             this.cmbFilterBy.Items.Add("Equals");
             this.cmbFilterBy.Items.Add("Not Equals");
             this.cmbFilterBy.Items.Add("Between");
             this.cmbFilterBy.Items.Add("Less Than");
             this.cmbFilterBy.Items.Add("Greater Than");
         }
         else if (cmbSearchBy.Text.Equals("Date and National ID Number"))
         {
             this.cmbFilterBy.Items.Clear();
             this.cmbFilterBy.Items.Add("Equals");
             this.cmbFilterBy.Items.Add("Not Equals");
         }
     }
     else
     {
         Messaging.warning("Please select search criteria", title);
         cmbSearchBy.Focus();
     }
 }
Пример #2
0
        private void saveSignIn()
        {
            diff          = 0;
            attendance_id = txtId.Text + " " + dayDate + " " + timeIn;
            try
            {
                //create the command
                using (command = connection.GetCommand("select p.person_id pid, p.national_id nid " +
                                                       "from dbo.person p where p.national_id=@national_id", CommandType.Text))
                {
                    // add the parameter
                    command.AddParameter("@national_id", txtId.Text, SqlDbType.VarChar);
                    command.AddParameter("@time_in", timeIn, SqlDbType.DateTime);
                    command.AddParameter("@dayDate", dayDate, SqlDbType.Date);
                    command.AddParameter("@action", 1, SqlDbType.Int);
                    command.AddParameter("@attendance_id", attendance_id, SqlDbType.VarChar);

                    // initialize the reader and execute the command
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                person_id = Convert.ToString(reader["pid"]);
                                //national_id = Convert.ToString(reader["nid"]);
                            }
                            command.AddParameter("@person_id", person_id, SqlDbType.VarChar);
                            reader.Close();
                            command.CommandText = "INSERT INTO dbo.time_attendance (person_id, national_id, time_in, dayDate, action,attendance_id) " +
                                                  "VALUES (@person_id, @national_id, @time_in, @dayDate, @action,@attendance_id)";

                            int i = command.ExecuteNonQuery();
                            if (i > 0)
                            {
                                new OpenForms().openModalForm(new Welcome(txtName.Text));
                                data.getAttendanceRecords();
                                clearConrols();
                            }
                            else
                            {
                                Messaging.information("Log in failed!", title);
                            }
                        }
                        else
                        {
                            Messaging.warning("Person not found!", title);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void identify()
        {
            bool   isAuthentic = false;
            string personId    = "";
            string nationalId  = "";
            string name        = "";

            try
            {
                //create the command
                using (command = connection.GetCommand("SELECT * FROM dbo.fingerprint f, dbo.person e where f.person_id=e.person_id", CommandType.Text))
                {
                    // initialize the reader and execute the command
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                name       = Convert.ToString(reader["surname"]) + " " + Convert.ToString(reader["first_name"]) + " " + Convert.ToString(reader["other_name"]);
                                personId   = Convert.ToString(reader["person_id"]);
                                nationalId = Convert.ToString(reader["national_id"]);

                                if (fingerprintOP.authenticate((byte[])reader["Template1"], (byte[])reader["Template2"], (byte[])reader["Template3"]))
                                {
                                    isAuthentic = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            Messaging.warning("No fingerprint data found!", title);
                        }
                        reader.Close();
                    }
                }

                if (isAuthentic)
                {
                    isOpen = true;
                    PersonalDetails details = new PersonalDetails(parent, this);
                    details.searchPerson(nationalId);
                    new OpenForms(parent).openModalForm(details);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void cmdEnrollFingerprintBiometrics_Click(object sender, EventArgs e)
        {
            int j = lstvStaffDetails.SelectedIndices.Count;

            if (j > 0)
            {
                action    = "ENROLL";
                biometric = new EnrollFingerprints(grFingerXCtrl, data, this);
                new OpenForms().openModalForm(biometric);
            }
            else
            {
                Messaging.warning("You must select person name in the list to proceed", title);
            }
        }
Пример #5
0
        private string findPerson()
        {
            string act = "";

            if (txtId.Text.Equals(""))
            {
                Messaging.warning("Enter student national ID to proceed", title);
            }
            else
            {
                try
                {
                    command = connection.GetCommand("select p.action action, p.attendance_id attendance, p.time_in timeIn " +
                                                    "from dbo.time_attendance p where p.national_id=@national_id " +
                                                    "and dayDate=@dayDate", CommandType.Text);
                    //create the command
                    command.AddParameter("@national_id", txtId.Text, SqlDbType.VarChar);
                    command.AddParameter("@dayDate", dayDate, SqlDbType.Date);

                    using (command)
                    {
                        // initialize the reader and execute the command
                        SqlDataReader reader = command.ExecuteReader();

                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                act           = Convert.ToString(reader["action"]);
                                attendance_id = Convert.ToString(reader["attendance"]);
                                timeIn        = Convert.ToDateTime(reader["timeIn"]);
                            }
                        }
                        else
                        {
                            act = "2";
                        }
                        reader.Close();
                    }
                }
                catch (Exception ex)
                {
                    Messaging.error(ex.ToString(), title);
                }
            }
            return(act);
        }
Пример #6
0
        private bool isStaff()
        {
            bool isFound = false;

            if (txtId.Text.Equals(""))
            {
                Messaging.warning("Enter staff national ID to proceed", title);
            }
            else
            {
                try
                {
                    command = connection.GetCommand("select * from dbo.person p where p.national_id=@national_id ", CommandType.Text);
                    //create the command
                    command.AddParameter("@national_id", txtId.Text, SqlDbType.VarChar);

                    using (command)
                    {
                        // initialize the reader and execute the command
                        SqlDataReader reader = command.ExecuteReader();

                        if (reader.HasRows)
                        {
                            isFound = true;
                            while (reader.Read())
                            {
                                name = Convert.ToString(reader["surname"]) + " " + Convert.ToString(reader["first_name"]) + " "
                                       + Convert.ToString(reader["other_name"]);
                                txtName.Text = name;
                            }
                        }
                        else
                        {
                            Messaging.warning("Invalid ID number! Please re-enter ID number.", title);
                            txtId.Focus();
                        }
                        reader.Close();
                    }
                }
                catch (Exception ex)
                {
                    Messaging.error(ex.ToString(), title);
                }
            }
            return(isFound);
        }
        private void cmdViewStaffDetails_Click(object sender, EventArgs e)
        {
            int j = lstvStaffDetails.SelectedIndices.Count;

            if (j > 0)
            {
                string[]     data = new string[2];
                ListViewItem lvi  = lstvStaffDetails.Items[lstvStaffDetails.SelectedIndices[0]];

                data[0] = lvi.SubItems[1].Text;
                data[1] = lvi.SubItems[2].Text;

                PersonalDetails details = new PersonalDetails(parent, this);
                details.searchPerson(data[0]);
                new OpenForms(parent).openModalForm(details);
            }
            else
            {
                Messaging.warning("You must select person name in the list to proceed", title);
            }
        }
Пример #8
0
        private void delete(string id)
        {
            try
            {
                command = connection.GetCommand("SELECT * FROM dbo.person WHERE national_id = @national_id", CommandType.Text);
                //create the command
                command.AddParameter("@national_id", id, SqlDbType.VarChar);
                using (command)
                {
                    // initialize the reader and execute the command
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            reader.Close();
                            command.CommandText = "DELETE FROM dbo.person WHERE national_id = @national_id";

                            int i = command.ExecuteNonQuery();
                            if (i > 0)
                            {
                                searchPerson("");
                                Messaging.information("Deleted successfully!", title);
                                clearControls();
                            }
                        }
                        else
                        {
                            Messaging.warning("No staff details found!", title);
                        }
                    }
                    studentList.searchPerson("");
                }
            }
            catch (Exception ex)
            {
                Messaging.error("Error! Failed deleting!\n" + ex.ToString(), title);
            }
        }
Пример #9
0
        public void verify()
        {
            bool   isAuthentic = false;
            string personId    = "";
            string name        = "";

            try
            {
                //create the command
                using (command = connection.GetCommand("SELECT * FROM dbo.fingerprint f, dbo.person e where f.person_id=e.person_id and e.national_id =@national_id", CommandType.Text))
                {
                    command.AddParameter("@national_id", findNationalID, SqlDbType.VarChar);
                    // initialize the reader and execute the command
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                found    = 1;
                                name     = Convert.ToString(reader["surname"]) + " " + Convert.ToString(reader["first_name"]) + " " + Convert.ToString(reader["other_name"]);
                                personId = Convert.ToString(reader["person_id"]);

                                if (fingerprintOP.authenticate((byte[])reader["Template1"], (byte[])reader["Template2"], (byte[])reader["Template3"]))
                                {
                                    isAuthentic = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            found = 0;
                            Messaging.warning("The ID you have entered is not found! Try again!", title);
                        }
                        reader.Close();
                    }
                }

                if (isAuthentic)
                {
                    if (findPerson(personId).Equals("1"))
                    {
                        timeOut = Convert.ToDateTime(DateTime.Now);

                        timeDifference = timeOut - timeIn;
                        //MessageBox.Show(timeDifference.Minutes.ToString());

                        diff = Convert.ToDouble(timeDifference.Minutes);
                        saveSignOut(findNationalID, name);
                    }
                    else
                    {
                        timeIn = Convert.ToDateTime(DateTime.Now);
                        saveSignIn(personId, findNationalID, name);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }