Example #1
0
        /// <summary>
        /// Maintances the details.
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <param name="xmlPath">The XML path.</param>
        /// <param name="gunId">The gun identifier.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        /// <exception cref="System.Exception"></exception>
        /// <exception cref="System.Exception"></exception>
        /// <exception cref="System.Exception"></exception>
        /// <exception cref="System.Exception"></exception>
        /// <exception cref="System.Exception"></exception>
        public static bool MaintanceDetails(string databasePath, string xmlPath, long gunId, out string errOut)
        {
            bool bAns = false;

            errOut = "";
            try
            {
                XmlDocument doc = new XmlDocument();

                doc.Load(xmlPath);
                XmlNodeList elemlist = doc.GetElementsByTagName("Maintance_Details");
                foreach (XmlNode xn in elemlist)
                {
                    string name      = Helpers.FormatFromXml(GetXmlNode(xn["Name"]));
                    string opDate    = XmlExport.StringHelper(Helpers.FormatFromXml(GetXmlNode(xn["OpDate"])), true);
                    string opDueDate = XmlExport.StringHelper(Helpers.FormatFromXml(GetXmlNode(xn["OpDueDate"])), true);
                    long   rndFired  = Convert.ToInt32(Helpers.FormatFromXml(GetXmlNode(xn["RndFired"])));
                    string ammoUsed  = XmlExport.StringHelper(Helpers.FormatFromXml(GetXmlNode(xn["ammoUsed"])));
                    string notes     = XmlExport.StringHelper(Helpers.FormatFromXml(GetXmlNode(xn["Notes"])));

                    if (!MaintancePlans.Exists(databasePath, name, out errOut))
                    {
                        if (!MaintancePlans.Add(databasePath, name, "N/A from Import", "N/A from Import", "N/A from Import", "N/A from Import", out errOut))
                        {
                            throw new Exception(errOut);
                        }
                    }
                    if (errOut.Length > 0)
                    {
                        throw new Exception(errOut);
                    }
                    long maintenancePlansId = MaintancePlans.GetId(databasePath, name, out errOut);
                    if (errOut.Length > 0)
                    {
                        throw new Exception(errOut);
                    }
                    //Thread.Sleep(1000);
                    long defaultBarrelId =
                        ExtraBarrelConvoKits.GetDefaultBarrelId(databasePath, gunId, out errOut);
                    if (errOut.Length > 0)
                    {
                        throw new Exception(errOut);
                    }
                    if (!Firearms.MaintanceDetails.Add(databasePath, name, gunId, maintenancePlansId, opDate, opDueDate, rndFired, notes, ammoUsed, defaultBarrelId, rndFired > 0, out errOut))
                    {
                        throw new Exception(errOut);
                    }
                    //Thread.Sleep(1000);
                }

                bAns = true;
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("MaintanceDetails", e);
            }
            return(bAns);
        }
Example #2
0
        /// <summary>
        /// Barrels the converstion kit details.
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <param name="xmlPath">The XML path.</param>
        /// <param name="gunId">The gun identifier.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        /// <exception cref="System.Exception"></exception>
        /// <exception cref="System.Exception"></exception>
        public static bool BarrelConverstionKitDetails(string databasePath, string xmlPath, long gunId, out string errOut)
        {
            bool bAns = false;

            errOut = "";
            try
            {
                XmlDocument doc = new XmlDocument();

                doc.Load(xmlPath);
                XmlNodeList elemlist = doc.GetElementsByTagName("BarrelConverstionKit_Details");
                foreach (XmlNode xn in elemlist)
                {
                    string modelName    = Helpers.FormatFromXml(GetXmlNode(xn["ModelName"]));
                    string caliber      = Helpers.FormatFromXml(GetXmlNode(xn["Caliber"]));
                    string finish       = Helpers.FormatFromXml(GetXmlNode(xn["Finish"]));
                    string barrelLength = Helpers.FormatFromXml(GetXmlNode(xn["BarrelLength"]));
                    string petLoads     = XmlExport.StringHelper(Helpers.FormatFromXml(GetXmlNode(xn["petLoads"])));

                    string action         = Helpers.FormatFromXml(GetXmlNode(xn["Action"]));
                    string feedsystem     = Helpers.FormatFromXml(GetXmlNode(xn["Feedsystem"]));
                    string sights         = Helpers.FormatFromXml(GetXmlNode(xn["Sights"]));
                    string purchasedPrice = Helpers.FormatFromXml(GetXmlNode(xn["PurchasedPrice"]));
                    string purchasedFrom  = Helpers.FormatFromXml(GetXmlNode(xn["PurchasedFrom"]));
                    string dtp            = Helpers.FormatFromXml(GetXmlNode(xn["dtp"]));
                    string height         = Helpers.FormatFromXml(GetXmlNode(xn["Height"]));
                    string type           = Helpers.FormatFromXml(GetXmlNode(xn["Type"]));
                    bool   isDefault      = Convert.ToInt32(Helpers.FormatFromXml(GetXmlNode(xn["IsDefault"]))) == 1;

                    if (!ExtraBarrelConvoKits.Exists(databasePath, gunId, modelName, caliber, finish,
                                                     barrelLength, petLoads, action, feedsystem, sights, purchasedPrice,
                                                     purchasedFrom, height, type, isDefault, out errOut))
                    {
                        if (!ExtraBarrelConvoKits.Add(databasePath, gunId, modelName, caliber, finish,
                                                      barrelLength, petLoads, action, feedsystem, sights, purchasedPrice,
                                                      purchasedFrom, height, type, isDefault, dtp, out errOut))
                        {
                            throw new Exception(errOut);
                        }
                    }
                    if (errOut.Length > 0)
                    {
                        throw new Exception(errOut);
                    }
                }

                bAns = true;
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("BarrelConverstionKitDetails", e);
            }
            return(bAns);
        }
Example #3
0
        /// <summary>
        /// Generates the barrel convers kit.
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <param name="gunId">The gun identifier.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.Exception"></exception>
        private static string GenerateBarrelConversKit(string databasePath, long gunId, out string errOut)
        {
            string sAns = $"   <BarrelConverstionKit_Details>{Environment.NewLine}";

            errOut = "";
            try
            {
                string sql = $"SELECT * from Gun_Collection_Ext where GID={gunId}";
                List <BarrelSystems> lst = ExtraBarrelConvoKits.GetList(databasePath, sql, out errOut);
                if (errOut.Length > 0)
                {
                    throw new Exception(errOut);
                }
                foreach (BarrelSystems l in lst)
                {
                    sAns += $"       <ModelName>{StringHelper(l.ModelName)}</ModelName>{Environment.NewLine}";
                    sAns += $"       <Caliber>{StringHelper(l.Caliber)}</Caliber>{Environment.NewLine}";
                    sAns += $"       <Finish>{StringHelper(l.Finish)}</Finish>{Environment.NewLine}";
                    sAns += $"       <BarrelLength>{StringHelper(l.BarrelLength)}</BarrelLength>{Environment.NewLine}";
                    sAns += $"       <PetLoads>{StringHelper(l.PetLoads)}</PetLoads>{Environment.NewLine}";
                    sAns += $"       <Action>{StringHelper(l.Action)}</Action>{Environment.NewLine}";
                    sAns += $"       <Feedsystem>{StringHelper(l.FeedSystem)}</Feedsystem>{Environment.NewLine}";
                    sAns += $"       <Sights>{StringHelper(l.Sights)}</Sights>{Environment.NewLine}";
                    sAns += $"       <PurchasedPrice>{l.PurchasedPrice}</PurchasedPrice>{Environment.NewLine}";
                    sAns += $"       <PurchasedFrom>{StringHelper(l.PurchasedFrom)}</PurchasedFrom>{Environment.NewLine}";
                    sAns += $"       <dtp>{StringHelper(l.PurchaseDate,true)}</dtp>{Environment.NewLine}";
                    sAns += $"       <Height>{StringHelper(l.Height)}</Height>{Environment.NewLine}";
                    sAns += $"       <IsDefault>{l.Idefault}</IsDefault>{Environment.NewLine}";
                    sAns += $"       <BarrelLength>{StringHelper(l.BarrelLength)}</BarrelLength>{Environment.NewLine}";
                }
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("GenerateBarrelConversKit", e);
            }
            sAns += $"   </BarrelConverstionKit_Details>{Environment.NewLine}";
            return(sAns);
        }