コード例 #1
0
 public override string Message()
 {
     return($"The {Name}: {Description}. It is a {WeaponTypeName.ToString().ToLower()} type of weapon. ");
 }
コード例 #2
0
        /// <summary>
        /// Saves the type of the weapon.
        /// </summary>
        /// <returns>WeaponType objects</returns>
        public WeaponType SaveWeaponType()
        {
            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_WeaponType";
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponTypeID", SqlDbType.Int, WeaponTypeID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponTypeName", SqlDbType.VarChar, WeaponTypeName.ToString(), 50));
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponTypeDescription", SqlDbType.VarChar, WeaponTypeDescription.ToString(), 100));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Universal", SqlDbType.Bit, Universal.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);
        }