Exemple #1
0
 public Expression <Func <Client, bool> > GetExpresion()
 {
     return(x =>
            (Name == null || x.Name.ToLower().Contains(Name.ToLower())) &&
            (Lastname == null || x.Lastname.ToLower().Contains(Lastname.ToLower())) &&
            (Dni == null || x.Dni == Dni) &&
            (Mail == null || x.Mail != null && x.Mail.ToLower().Contains(Mail.ToLower())) &&
            (Phone == null || x.Phone.Contains(Phone)));
 }
Exemple #2
0
 public Expression <Func <User, bool> > GetExpresion()
 {
     return(x =>
            (Username == null || x.Username.ToLower().Contains(Username.ToLower())) &&
            (Name == null || x.Name.ToLower().Contains(Name.ToLower())) &&
            (Lastname == null || x.Lastname.ToLower().Contains(Lastname.ToLower())) &&
            (Dni == null || x.Dni == Dni) &&
            (Mail == null || x.Mail != null && x.Mail.ToLower().Contains(Mail.ToLower())) &&
            (Phone == null || x.Phone.Contains(Phone)) &&
            (IsAdmin == null || x.IsAdmin == IsAdmin) &&
            (Active == null || x.Active == Active));
 }
        private void AddPatientRecord()
        {
            if (!VerifyRequiredFields())
            {
                return;
            }

            DateTime         dateOfBirth = (DateTime)DOB;
            SQLiteConnection connection  = OpenConnection("Patients");

            string cmdString = "";

            if (string.IsNullOrWhiteSpace(Middlename))
            {
                cmdString = @"SELECT COUNT(*) FROM PatientData WHERE Firstname = @firstname" +
                            " AND Lastname = @lastname AND DOB = @dob AND Gender = @gender AND ST_Number = @streetNumber AND Postcode = @postcode";
            }
            else
            {
                cmdString = @"SELECT COUNT(*) FROM PatientData WHERE Firstname = @firstname AND Middlename = @middlename " +
                            " AND Lastname = @lastname AND DOB = @dob AND Gender = @gender AND ST_Number = @streetNumber AND Postcode = @postcode";
            }

            SQLiteCommand cmd = new SQLiteCommand(cmdString, connection);

            cmd.Prepare();
            cmd.Parameters.Add("@firstname", DbType.String).Value = Firstname.ToLower(new System.Globalization.CultureInfo("en-UK", false));
            if (!string.IsNullOrWhiteSpace(Middlename))
            {
                cmd.Parameters.Add("@middlename", DbType.String).Value = Middlename.ToLower(new System.Globalization.CultureInfo("en-UK", false));
            }
            cmd.Parameters.Add("@lastname", DbType.String).Value     = Lastname.ToLower(new System.Globalization.CultureInfo("en-UK", false));
            cmd.Parameters.Add("@dob", DbType.String).Value          = dateOfBirth.ToString("dd/MM/yyyy");
            cmd.Parameters.Add("@gender", DbType.String).Value       = Gender;
            cmd.Parameters.Add("@streetNumber", DbType.String).Value = AddressNo;
            cmd.Parameters.Add("@postcode", DbType.String).Value     = Postcode.Replace(" ", "").ToUpper();

            //  Checks if record already exists, if it does a prompt is shown to the user,
            //  user decides if duplicate record is required.
            int recordsFound = Convert.ToInt32(cmd.ExecuteScalar());

            if (recordsFound > 0)
            {
                string createDuplicate = Confirmation("Are you sure?",
                                                      "Patient Record with identical information already exists. Are you sure you want to create another record with this data?");
                if (createDuplicate != "Yes")
                {
                    return;
                }
            }


            // Record added to patient database.

            if (string.IsNullOrWhiteSpace(Middlename))
            {
                cmdString = @"INSERT INTO PatientData (Firstname, Lastname, DOB, Gender, ST_Number, Postcode) 
                            VALUES (@firstname, @lastname, @dob, @gender, @streetNumber, @postcode)";
            }
            else
            {
                cmdString = @"INSERT INTO PatientData (Firstname, Middlename, Lastname, DOB, Gender, ST_Number, Postcode) 
                            VALUES (@firstname, @middlename, @lastname, @dob, @gender, @streetNumber, @postcode)";
            }

            cmd = new SQLiteCommand(cmdString, connection);
            cmd.Prepare();
            cmd.Parameters.Add("@firstname", DbType.String).Value = Firstname.ToLower(new System.Globalization.CultureInfo("en-UK", false));
            if (!string.IsNullOrEmpty(Middlename))
            {
                cmd.Parameters.Add("@middlename", DbType.String).Value = Middlename.ToLower(new System.Globalization.CultureInfo("en-UK", false));
            }
            cmd.Parameters.Add("@lastname", DbType.String).Value     = Lastname.ToLower(new System.Globalization.CultureInfo("en-UK", false));
            cmd.Parameters.Add("@dob", DbType.String).Value          = dateOfBirth.ToString("dd/MM/yyyy");
            cmd.Parameters.Add("@gender", DbType.String).Value       = Gender;
            cmd.Parameters.Add("@streetNumber", DbType.String).Value = AddressNo;
            cmd.Parameters.Add("@postcode", DbType.String).Value     = Postcode.Replace(" ", "").ToUpper();
            cmd.ExecuteNonQuery();

            Success("Success", "Record created. You can now proceed to create an appointment.");
            connection.Close();
        }
Exemple #4
0
 public bool FindLastname(string s)                 //It compares the name passed in the arguments with name in the object and returns true if found
 {
     return(Lastname.ToLower().Equals(s.ToLower()));
 }