예제 #1
0
        private void btnFrontDesk_Click(object sender, EventArgs e)
        {
            FormStaff formStaff = new FormStaff(conn, userID, firstName, lastName, userType);

            formStaff.Show();
            this.Close();
        }
예제 #2
0
        } // Action[Click]: btnClear

        private void btnLogIn_Click(object sender, EventArgs e)
        {
            bool isValid = true;

            if (textUsername.Text.Trim().Equals(""))
            {
                MetroMessageBox.Show(this, "Please enter a valid username!");
                isValid = false;
            }
            else if (textPassword.Text.Trim().Equals(""))
            {
                MetroMessageBox.Show(this, "Please enter a valid password!");
                isValid = false;
            }

            if (isValid)
            {
                string sql = "SELECT strLastName, strFirstName, strStaffID, strPositionCode " +
                             "FROM tblStaff " +
                             "WHERE strUserName = @userName AND strPassword = @password AND boolIsActive;";

                try
                {
                    int resultCount = 0;

                    MySqlCommand cmd = new MySqlCommand(sql, conn);

                    /* Prepare statements */
                    cmd.Parameters.AddWithValue("@userName", textUsername.Text.Trim());
                    cmd.Parameters.AddWithValue("@password", textPassword.Text.Trim());
                    cmd.Prepare();

                    reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        firstName    = reader.GetString("strFirstName");
                        lastName     = reader.GetString("strLastName");
                        userID       = reader.GetString("strStaffID");
                        userPosition = reader.GetString("strPositionCode");

                        resultCount++;
                    }

                    reader.Close();

                    if (resultCount == 1)
                    {
                        sql = "SELECT strPositionDescription " +
                              "FROM tblPositionDetails " +
                              "WHERE strPositionCode = @posCode;";

                        cmd = new MySqlCommand(sql, conn);

                        /* Prepare statements */
                        cmd.Parameters.AddWithValue("@posCode", userPosition);
                        cmd.Prepare();

                        reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            userType = reader.GetString("strPositionDescription");
                        }

                        reader.Close();

                        if (userPosition.Equals("FRONTDESK") || userPosition.Equals("DOCT") || userPosition.Equals("ADMIN"))
                        {
                            string loginID = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() +
                                             DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "";

                            sql = "INSERT INTO tblLogIn(strLogInCode, strStaffID, dtmDateTimeLogged, strDoctStatus) ";

                            if (userPosition.Equals("DOCT"))
                            {
                                sql += "VALUES(@loginID, @userID, NOW(), 'ON');";
                            }
                            else
                            {
                                sql += "VALUES(@loginID, @userID, NOW(), 'OFF');";
                            }

                            cmd             = new MySqlCommand();
                            cmd.Connection  = conn;
                            cmd.CommandText = sql;

                            /* Prepare statements */
                            cmd.Parameters.AddWithValue("@loginID", loginID);
                            cmd.Parameters.AddWithValue("@userID", userID);
                            cmd.Prepare();

                            /* Update time in and time out */
                            cmd.ExecuteNonQuery();

                            if (userPosition.Equals("FRONTDESK"))
                            {
                                FormStaff formStaff = new FormStaff(conn, userID, firstName, lastName, userType);
                                formStaff.Show();
                                this.Close();
                            }
                            else if (userPosition.Equals("DOCT"))
                            {
                                FormDoctor formDoctor = new FormDoctor(conn, userID, firstName, lastName, userType);
                                formDoctor.Show();
                                this.Close();
                            }
                            else
                            {
                                FormSelection formSelect = new FormSelection(conn, userID, firstName, lastName, userType);
                                formSelect.Show();
                                this.Close();
                            }
                        }
                        else
                        {
                            Integrity.ShowInvalidTypeDialog();
                        }
                    }
                    else if (resultCount >= 2)
                    {
                        Integrity.ShowDuplicateDialog();
                    }
                    else
                    {
                        MetroMessageBox.Show(this,
                                             "Invalid Username / Password!",
                                             "Access Denied",
                                             MessageBoxButtons.OK,
                                             MessageBoxIcon.Error);
                    }
                }
                catch (MySqlException me)
                {
                    Integrity.GetExceptionDetails(me);
                }
            }
        } // Action[Click]: btnLogIn
예제 #3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string sql = "";

            if (controls == ControlsList.Logs || controls == ControlsList.Patient || (controls == ControlsList.Add_Appt && search == 1) ||
                controls == ControlsList.Del_Pat)
            {
                if (!textPatID.Text.Trim().Equals("") || !textPatNo.Text.Trim().Equals("") ||
                    !textLastName.Text.Trim().Equals("") || !textFirstName.Text.Trim().Equals("") ||
                    !textContact.Text.Trim().Equals("") || !textGender.Text.Trim().Equals(""))
                {
                    sql += "SELECT strPatientID, strIDNumber, strPatientLastName, strPatientFirstName, strPatientContactNumber, strGender " +
                           "FROM tblPatient " +
                           "WHERE boolIsActive ";

                    if (!textPatID.Text.Trim().Equals(""))
                    {
                        sql += "AND  strPatientID = '%" + textPatID.Text.Trim() + "%' ";
                    }

                    if (!textPatNo.Text.Trim().Equals(""))
                    {
                        sql += "AND strIDNumber LIKE '%" + textPatNo.Text.Trim() + "%' ";
                    }

                    if (!textLastName.Text.Trim().Equals(""))
                    {
                        sql += "AND strPatientLastName LIKE '%" + textLastName.Text.Trim() + "%' ";
                    }

                    if (!textFirstName.Text.Trim().Equals(""))
                    {
                        sql += "AND strPatientFirstName LIKE '%" + textFirstName.Text.Trim() + "%' ";
                    }

                    if (!textContact.Text.Trim().Equals(""))
                    {
                        sql += "AND strPatientContactNumber LIKE '+639" + textContact.Text.Trim() + "%' ";
                    }

                    if (!textGender.Text.Trim().Equals(""))
                    {
                        sql += "AND strGender = '" + textGender.Text.Trim() + "' ";
                    }

                    sql += ";";

                    if (controls == ControlsList.Logs)
                    {
                        logs.UpdateListSearch(sql);
                        formStaff.Visible = true;
                        this.Close();
                    }
                    else if (controls == ControlsList.Patient)
                    {
                        patient.UpdateView(sql);
                        formStaff.Visible = true;
                        this.Close();
                    }
                    else if (controls == ControlsList.Add_Appt)
                    {
                        addAppt.UpdatePatient(sql);
                        formStaff.Visible = true;
                        this.Close();
                    }
                    else if (controls == ControlsList.Del_Pat)
                    {
                        delPatient.UpdatePatient(sql);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter an invalid search key!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (controls == ControlsList.Add_Appt && search == 2)
            {
                if (!textDocID.Text.Trim().Equals("") || !textDocLast.Text.Trim().Equals("") ||
                    !textDocFirst.Text.Trim().Equals("") || !textDocContact.Text.Trim().Equals("") ||
                    !textDocGender.Text.Trim().Equals(""))
                {
                    sql += "SELECT a.strStaffID, a.strFirstName, a.strLastName, a.strContactNumber, a.strGender " +
                           "FROM tblStaff a, tblPositionDetails b " +
                           "WHERE a.strPositionCode = b.strPositionCode AND " +
                           "b.strPositionCode = 'DOCT'  AND " +
                           "a.boolIsActive ";

                    if (!textDocID.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " a.strStaffID = '%" + textDocID.Text.Trim() + "%' ";
                    }

                    if (!textDocLast.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += "a.strLastName LIKE '%" + textDocLast.Text.Trim() + "%' ";
                    }

                    if (!textDocFirst.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += "a.strFirstName LIKE '%" + textDocFirst.Text.Trim() + "%' ";
                    }

                    if (!textDocContact.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += "a.strContactNumber LIKE '+639" + textDocContact.Text.Trim() + "%' ";
                    }

                    if (!textDocGender.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += "a.strGender = '" + textDocGender.Text.Trim() + "' ";
                    }

                    sql += ";";

                    if (controls == ControlsList.Add_Appt)
                    {
                        addAppt.UpdateDoctor(sql);
                        formStaff.Visible = true;
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter an invalid search key!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (controls == ControlsList.Check_Appt)
            {
                if (!chboUnknown.Checked || !textAppID.Text.Trim().Equals("") || !textAppDocID.Text.Trim().Equals("") ||
                    !textAppDocCont.Text.Trim().Equals("") || !textAppDocGender.Text.Trim().Equals("") ||
                    !textAppPatID.Text.Trim().Equals("") || !textAppPatNo.Text.Trim().Equals("") ||
                    !textAppPatLast.Text.Trim().Equals("") || !textAppPatFirst.Text.Trim().Equals("") ||
                    !textAppPatCont.Text.Trim().Equals("") || !textAppPatGender.Text.Trim().Equals(""))
                {
                    sql += "SELECT a.strStaffID, a.strLastName, a.strFirstName, a.strContactNumber, a.strGender, " +
                           "b.strAppointmentCode, c.dtmDateTimeStart, " +
                           "d.strPatientID, d.strIDNumber, d.strPatientLastName, d.strPatientFirstName, d.strPatientContactNumber, " +
                           "d.strGender AS 'strPatGender' " +
                           "FROM tblStaff a, tblAppointment b, tblAppointmentDetails c, tblPatient d " +
                           "WHERE a.strPositionCode = 'DOCT' AND " +
                           "b.strAppointmentCode = c.strAppointmentCode AND " +
                           "b.strStaffID = a.strStaffID AND " +
                           "b.strPatientID = d.strPatientID AND " +
                           "c.strAppointmentStatusCode = 'APPR' AND " +
                           "a.boolIsActive AND d.boolIsActive ";
                    DateTime schedApp = new DateTime();

                    if (!textAppID.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " b.strAppointmentCode LIKE '%" + textAppPatID.Text.Trim() + "%' ";
                    }

                    if (!chboUnknown.Checked)
                    {
                        schedApp = new DateTime(datSchedule.Value.Year, datSchedule.Value.Month,
                                                datSchedule.Value.Day, tmAppointment.Value.Hour,
                                                tmAppointment.Value.Minute,
                                                tmAppointment.Value.Second);
                        sql += " AND ";
                        sql += " c.dtmDateTimeStart = '" + schedApp.ToString("yyyy-MM-dd HH:mm:ss") + "' ";
                    }

                    if (!textAppDocID.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " a.strStaffID LIKE '%" + textAppDocID.Text.Trim() + "%' ";
                    }

                    if (!textAppDocLast.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " a.strLastName LIKE '%" + textAppDocLast.Text.Trim() + "%' ";
                    }

                    if (!textAppDocFirst.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " a.strFirstName LIKE '%" + textAppDocFirst.Text.Trim() + "%' ";
                    }

                    if (!textAppDocCont.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " a.strAppDocCont LIKE '+639" + textAppDocCont.Text.Trim() + "%' ";
                    }

                    if (!textAppDocGender.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " a.strGender = '" + textAppDocGender.Text.Trim() + "' ";
                    }

                    if (!textAppPatID.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " d.strPatientID LIKE '%" + textAppPatID.Text.Trim() + "%' ";
                    }

                    if (!textAppPatNo.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " d.strIDNumber LIKE '%" + textAppPatNo.Text.Trim() + "%' ";
                    }

                    if (!textAppPatLast.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " d.strPatientLastName LIKE '%" + textAppPatLast.Text.Trim() + "%' ";
                    }

                    if (!textAppPatFirst.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " d.strPatientFirstName LIKE '%" + textAppPatFirst.Text.Trim() + "%' ";
                    }

                    if (!textAppPatCont.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " d.strPatientContactNumber LIKE '%" + textAppPatCont.Text.Trim() + "%' ";
                    }

                    if (!textAppPatGender.Text.Trim().Equals(""))
                    {
                        sql += " AND ";
                        sql += " d.strGender = '" + textAppPatGender.Text.Trim() + "' ";
                    }

                    sql += ";";

                    checkAppt.UpdateList(sql);
                    formStaff.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("No valid search key!");
                    MessageBox.Show("Please enter an invalid search key!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
            }
        }