Beispiel #1
0
        public bool addNewBrother(Brother newBrother)
        {
            using (SqlConnection conn = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = c:\users\grant folgate\documents\visual studio 2015\Projects\DeltaSigServiceCenter_DEV\DeltaSigServiceCenter_DEV\App_Data\DeltaSigServiceData.mdf; Integrated Security = True"))
            {
                SqlCommand cmd = new SqlCommand("AddNewBrother", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add("@FullName", System.Data.SqlDbType.NVarChar);
                cmd.Parameters.Add("@Class", System.Data.SqlDbType.NVarChar);
                cmd.Parameters.Add("@Email", System.Data.SqlDbType.NVarChar);
                cmd.Parameters.Add("@PhoneNum", System.Data.SqlDbType.NVarChar);
                cmd.Parameters["@FullName"].Value = newBrother.FullName;
                cmd.Parameters["@Class"].Value    = newBrother.ClassStanding;
                cmd.Parameters["@Email"].Value    = newBrother.Email;
                cmd.Parameters["@PhoneNum"].Value = newBrother.PhoneNum;
                conn.Open();

                try
                {
                    //attempt to insert into DB
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    return(true);
                }
                catch (Exception e)
                {
                    //close the connection ASAP
                    conn.Close();
                    //non-query exception error, can't insert
                    e.GetBaseException();
                    return(false);
                }
            }
        }
        public bool requestBrotherAddition(Brother pendingBrother)
        {
            broDataRetreiver = new BrothersInfo_DAL();

            try
            {
                if (broDataRetreiver.checkForExistingBro(pendingBrother) == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            } catch (Exception e)
            {
                LogException(e);
                //Error happened so the new brother could not be added
                return(false);
            }
        }
Beispiel #3
0
        public bool checkForExistingBro(Brother potentialBrother)
        {
            string emailAddressCheck = potentialBrother.Email;
            string emailHolder       = "";

            using (SqlConnection conn = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = c:\users\grant folgate\documents\visual studio 2015\Projects\DeltaSigServiceCenter_DEV\DeltaSigServiceCenter_DEV\App_Data\DeltaSigServiceData.mdf; Integrated Security = True"))
            {
                SqlCommand qry = new SqlCommand("CheckForExistingBrother", conn);
                qry.CommandType = System.Data.CommandType.StoredProcedure;
                qry.Parameters.Add("@Email", System.Data.SqlDbType.NVarChar);
                qry.Parameters["@Email"].Value = emailAddressCheck;
                conn.Open();
                dataReader = qry.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        //should return one item of information (Brother's name)
                        emailHolder = dataReader[0].ToString();
                    }
                }
            }

            if (emailHolder == emailAddressCheck)
            {
                return(false);
            }
            else
            {
                if (addNewBrother(potentialBrother) == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }