Exemplo n.º 1
0
        /// <summary>
        /// Delete the ArmorType object from the database (by ArmorTypeID)
        /// </summary>
        /// <returns>Boolean</returns>
        public bool DeleteArmorType()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "Delete_ArmorType";
                command.Parameters.Add(dbconn.GenerateParameterObj("@ArmorTypeID", SqlDbType.Int, ArmorTypeID.ToString(), 0));
                result = command.ExecuteReader();
            }
            catch
            {
                Exception e = new Exception();
                this._deleteOK = false;
                this._deletionMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this.DeleteOK);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the armor.
        /// </summary>
        /// <returns>Armor Object</returns>
        public Armor SaveArmor()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "InsertUpdate_Armor";
                command.Parameters.Add(dbconn.GenerateParameterObj("@ArmorID", SqlDbType.Int, ArmorID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ArmorTypeID", SqlDbType.Int, ArmorTypeID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ArmorName", SqlDbType.VarChar, ArmorName.ToString(), 100));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ArmorDescription", SqlDbType.VarChar, ArmorDescription.ToString(), 1000));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ReflexAdjustment", SqlDbType.Int, ReflexAdjustment.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@FortitudeAdjustment", SqlDbType.Int, FortitudeAdjustment.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ArmorProficiencyFeatID", SqlDbType.Int, ArmorProficiencyFeatID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@EmplacementPoints", SqlDbType.Int, EmplacementPoints.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Cost", SqlDbType.Int, Cost.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Weight", SqlDbType.Decimal, Weight.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@MaxDefBonus", SqlDbType.Int, MaxDefBonus.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@BookID", SqlDbType.Int, BookID.ToString(), 0));

                result = command.ExecuteReader();

                result.Read();
                SetReaderToObject(ref result);
            }
            catch
            {
                Exception e = new Exception();
                this._insertUpdateOK = false;
                this._insertUpdateMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Saves the current instance of the armor type object.
        /// </summary>
        /// <returns>ArmorType object</returns>
        public ArmorType SaveArmorType()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "InsertUpdate_ArmorType";
                command.Parameters.Add(dbconn.GenerateParameterObj("@ArmorTypeID", SqlDbType.Int, ArmorTypeID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ArmorTypeName", SqlDbType.VarChar, ArmorTypeName.ToString(), 1000));
                //command.Parameters.Add(dbconn.GenerateParameterObj("@Speed", SqlDbType.Int, Speed.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ArmorCheckPenalty", SqlDbType.Int, ArmorCheckPenalty.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Speed_6", SqlDbType.Int, Speed_6.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Speed_4", SqlDbType.Int, Speed_4.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Speed_8", SqlDbType.Int, Speed_8.ToString(), 0));
                result = command.ExecuteReader();

                result.Read();
                SetReaderToObject(ref result);
            }
            catch
            {
                Exception e = new Exception();
                this._insertUpdateOK = false;
                this._insertUpdateMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this);
        }