/// <summary>
        /// Count the number of firearms this document is attached to.
        /// </summary>
        /// <param name="databasePath">database path and name</param>
        /// <param name="id">document id</param>
        /// <param name="errOut">exception message if any</param>
        /// <returns></returns>
        public static long CountLinkedDocs(string databasePath, long id, out string errOut)
        {
            long lAns = 0;

            errOut = "";
            try
            {
                string sql = $"select count(*) as T from Gun_Collection_Docs_Links where did={id}";
                lAns = DatabaseRelated.GetTotal(databasePath, sql, "CountLinkedDocs", out errOut);
                if (errOut.Length > 0)
                {
                    throw new Exception(errOut);
                }
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("CountLinkedDocs", e);
            }
            return(lAns);
        }
Пример #2
0
        /// <summary>
        /// Determines whether [has multi barrels listed] [the specified database path].
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns><c>true</c> if [has multi barrels listed] [the specified database path]; otherwise, <c>false</c>.</returns>
        /// <exception cref="System.Exception"></exception>
        public static bool HasMultiBarrelsListed(string databasePath, long id, out string errOut)
        {
            bool bAns = false;

            errOut = @"";

            try
            {
                string sql   = $"SELECT Count(*) as T from Gun_Collection_Ext where GID={id}";
                long   count = DatabaseRelated.GetTotal(databasePath, sql, "HasMultiBarrelsListed", out errOut);
                if (errOut.Length > 0)
                {
                    throw new Exception(errOut);
                }
                bAns = count > 0;
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("HasMultiBarrelsListed", e);
            }
            return(bAns);
        }
 /// <summary>
 /// Averages the rounds fired bs.
 /// </summary>
 /// <param name="databasePath">The database path.</param>
 /// <param name="barrelSystemId">barrel system id</param>
 /// <param name="errOut">The error out.</param>
 /// <returns>System.Int64.</returns>
 /// <exception cref="System.Exception"></exception>
 public static long AverageRoundsFiredBs(string databasePath, int barrelSystemId, out string errOut)
 {
     return(DatabaseRelated.GetTotal(databasePath,
                                     $"SELECT AVG(cInt(RndFired)) as T from Maintance_Details where BSID={barrelSystemId} and DC=1",
                                     "AverageRoundsFiredBS", out errOut));
 }
 /// <summary>
 /// Totals the rounds fired.
 /// </summary>
 /// <param name="databasePath">The database path.</param>
 /// <param name="gunId">The gun identifier.</param>
 /// <param name="errOut">The error out.</param>
 /// <returns>System.Int64.</returns>
 /// <exception cref="System.Exception"></exception>
 public static long TotalRoundsFired(string databasePath, int gunId, out string errOut)
 {
     return(DatabaseRelated.GetTotal(databasePath,
                                     $"SELECT SUM(cInt(RndFired)) as T from Maintance_Details where GID={gunId} and DC=1",
                                     "TotalRoundsFired", out errOut));
 }
 /// <summary>
 /// Totals the ammo selected.
 /// </summary>
 /// <param name="databasePath">The database path.</param>
 /// <param name="caliber">The caliber.</param>
 /// <param name="caliber2">The caliber2.</param>
 /// <param name="caliber3">The caliber3.</param>
 /// <param name="errOut">The error out.</param>
 /// <returns>System.Int64.</returns>
 public static long TotalAmmoSelected(string databasePath, string caliber, string caliber2, string caliber3, out string errOut)
 {
     return(DatabaseRelated.GetTotal(databasePath,
                                     $"SELECT SUM(QTY) as T from Gun_Collection_Ammo where Cal='{caliber}' or Cal='{caliber2}' or Cal='{caliber3}'",
                                     "TotalRoundsFired", out errOut));
 }
 /// <summary>
 /// Gets the total inventory.
 /// </summary>
 /// <param name="databasePath">The database path.</param>
 /// <param name="errOut">The error out.</param>
 /// <returns>System.Int64.</returns>
 /// <exception cref="System.Exception"></exception>
 public static long GetTotalInventory(string databasePath, out string errOut)
 {
     return(DatabaseRelated.GetTotal(databasePath,
                                     "SELECT SUM(QTY) as T from Gun_Collection_Ammo",
                                     "GetTotalInventory", out errOut));
 }