Profiles.Edit.Utilities.DataIO.StoreAwardReceipt C# (CSharp) Method

StoreAwardReceipt() private method

private StoreAwardReceipt ( StoreAwardReceiptRequest sarr ) : bool
sarr StoreAwardReceiptRequest
return bool
        private bool StoreAwardReceipt(StoreAwardReceiptRequest sarr)
        {
            SessionManagement sm = new SessionManagement();
            string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;

            SqlConnection dbconnection = new SqlConnection(connstr);

            SqlParameter[] param = new SqlParameter[sarr.Length];

            bool error = false;

            try
            {
                dbconnection.Open();

                if (sarr.ExistingAwardReceiptURI != null)
                    param[sarr.ExistingAwardReceiptURI.ParamOrdinal] = new SqlParameter("@ExistingAwardReceiptURI", sarr.ExistingAwardReceiptURI.Value);

                if (sarr.AwardOrHonorForID != null)
                    param[sarr.AwardOrHonorForID.ParamOrdinal] = new SqlParameter("@awardOrHonorForID", Convert.ToInt64(sarr.AwardOrHonorForID.Value));

                if (sarr.Label != null)
                    param[sarr.Label.ParamOrdinal] = new SqlParameter("@Label", sarr.Label.Value.ToString());

                if (sarr.AwardConferedBy != null)
                    param[sarr.AwardConferedBy.ParamOrdinal] = new SqlParameter("@awardConferredBy", sarr.AwardConferedBy.Value.ToString());

                if (sarr.StartDate != null)
                    param[sarr.StartDate.ParamOrdinal] = new SqlParameter("@startDate", sarr.StartDate.Value.ToString());

                if (sarr.EndDate != null)
                    param[sarr.EndDate.ParamOrdinal] = new SqlParameter("@endDate", sarr.EndDate.Value.ToString());

                param[sarr.Length - 3] = new SqlParameter("@sessionID", sm.Session().SessionID);

                param[sarr.Length - 2] = new SqlParameter("@error", null);
                param[sarr.Length - 2].DbType = DbType.Boolean;
                param[sarr.Length - 2].Direction = ParameterDirection.Output;

                param[sarr.Length - 1] = new SqlParameter("@nodeid", null);
                param[sarr.Length - 1].DbType = DbType.Int64;
                param[sarr.Length - 1].Direction = ParameterDirection.Output;

                SqlCommand comm = GetDBCommand(ref dbconnection, "[Edit.Module].[CustomEditAwardOrHonor.StoreItem]", CommandType.StoredProcedure, CommandBehavior.CloseConnection, param);
                //For Output Parameters you need to pass a connection object to the framework so you can close it before reading the output params value.
                ExecuteSQLDataCommand(comm);

                comm.Connection.Close();

                if (dbconnection.State != ConnectionState.Closed)
                    dbconnection.Close();

                error = Convert.ToBoolean(param[sarr.Length - 2].Value);
            }
            catch (Exception e)
            {
                Framework.Utilities.DebugLogging.Log(e.Message + e.StackTrace);
                throw new Exception(e.Message);
            }

            return error;
        }