//============================================================================*
        // Comparer()
        //============================================================================*

        public static int Comparer(cManufacturer Manufacturer1, cManufacturer Manufacturer2)
        {
            if (Manufacturer1 == null)
            {
                if (Manufacturer2 != null)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }

            return(Manufacturer1.CompareTo(Manufacturer2));
        }
示例#2
0
        //============================================================================*
        // UpdateButtons()
        //============================================================================*

        private void UpdateButtons()
        {
            if (m_fViewOnly)
            {
                return;
            }

            bool   fEnableOK  = m_fChanged;
            string strToolTip = "";

            //----------------------------------------------------------------------------*
            // Check Model
            //----------------------------------------------------------------------------*

            if (!ModelTextBox.ValueOK)
            {
                fEnableOK = false;
            }

            //----------------------------------------------------------------------------*
            // Check for duplicate
            //----------------------------------------------------------------------------*

            ModelTextBox.ToolTip = cm_strModelToolTip;

            bool fDuplicate = false;

            cManufacturer Manufacturer = (cManufacturer)ManufacturerCombo.SelectedItem;

            if (Manufacturer != null && m_OriginalManufacturer != null && m_strOriginalModel != null)
            {
                if (Manufacturer.CompareTo(m_OriginalManufacturer) != 0 ||
                    ModelTextBox.Text.ToUpper() != m_strOriginalModel.ToUpper())
                {
                    foreach (cPrimer CheckPrimer in m_DataFiles.PrimerList)
                    {
                        if (Manufacturer.CompareTo(CheckPrimer.Manufacturer) == 0)
                        {
                            if (ModelTextBox.Text.ToUpper() == CheckPrimer.Model.ToUpper())
                            {
                                fDuplicate = true;

                                fEnableOK = false;

                                ModelTextBox.BackColor = Color.LightPink;

                                strToolTip += String.Format("\n\nThis primer, \"{0} {1}\", already exists.  Duplicate primers are not allowed.", (ManufacturerCombo.SelectedItem as cManufacturer).Name, ModelTextBox.Text);

                                break;
                            }
                        }
                    }

                    if (!fDuplicate)
                    {
                        ModelTextBox.BackColor = SystemColors.Window;
                    }
                }
            }

            if (m_DataFiles.Preferences.ToolTips)
            {
                ModelTextBox.ToolTip += strToolTip;
            }

            //----------------------------------------------------------------------------*
            // Check Uses
            //----------------------------------------------------------------------------*

            strToolTip = "";

            if (!StandardCheckBox.Checked && !MagnumCheckBox.Checked)
            {
                fEnableOK = false;

                StandardCheckBox.BackColor = Color.LightPink;
                MagnumCheckBox.BackColor   = Color.LightPink;

                strToolTip += "\n\nYou must select either Standard, Magnum, or both.";
            }
            else
            {
                StandardCheckBox.BackColor = SystemColors.Control;
                MagnumCheckBox.BackColor   = SystemColors.Control;
            }

            if (m_DataFiles.Preferences.ToolTips)
            {
                m_StandardToolTip.SetToolTip(StandardCheckBox, cm_strStandardToolTip + strToolTip);
                m_MagnumToolTip.SetToolTip(MagnumCheckBox, cm_strMagnumToolTip + strToolTip);
            }

            //----------------------------------------------------------------------------*
            // Check Quantity
            //----------------------------------------------------------------------------*

            if (!QuantityTextBox.ValueOK)
            {
                fEnableOK = false;
            }

            //----------------------------------------------------------------------------*
            // Check Price
            //----------------------------------------------------------------------------*

            if (!CostTextBox.ValueOK)
            {
                fEnableOK = false;
            }

            //----------------------------------------------------------------------------*
            // Enable or disable OK button
            //----------------------------------------------------------------------------*

            PrimerOKButton.Enabled = fEnableOK;
        }
示例#3
0
        //============================================================================*
        // VerifyAmmo()
        //============================================================================*

        public bool VerifyAmmo(cAmmo Ammo)
        {
            //----------------------------------------------------------------------------*
            // Make sure we're tracking reloads if this is a reload
            //----------------------------------------------------------------------------*


            //----------------------------------------------------------------------------*
            // Check the internal filters
            //----------------------------------------------------------------------------*

            if (m_eFirearmType != cFirearm.eFireArmType.None && Ammo.FirearmType != m_eFirearmType)
            {
                return(false);
            }

            if (m_Caliber != null && m_Caliber.CompareTo(Ammo.Caliber) != 0)
            {
                return(false);
            }

            if (m_Manufacturer != null && m_Manufacturer.CompareTo(Ammo.Manufacturer) != 0)
            {
                return(false);
            }

            //----------------------------------------------------------------------------*
            // Check the external filters
            //----------------------------------------------------------------------------*

            if (Ammo.Reload)
            {
                if (Ammo.BatchID != 0)
                {
                    if (!m_DataFiles.Preferences.AmmoMyReloadFilter)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!m_DataFiles.Preferences.AmmoFactoryReloadFilter)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (!m_DataFiles.Preferences.AmmoFactoryFilter)
                {
                    return(false);
                }
            }

            //----------------------------------------------------------------------------*
            // Check the inventory control filters
            //----------------------------------------------------------------------------*

            if (m_DataFiles.Preferences.TrackInventory)
            {
                if (!m_DataFiles.Preferences.TrackReloads && Ammo.Reload && Ammo.BatchID != 0)
                {
                    return(false);
                }

                if (Ammo.QuantityOnHand <= 0.0 && m_DataFiles.Preferences.AmmoNonZeroFilter)
                {
                    return(false);
                }

                if (Ammo.QuantityOnHand >= Ammo.MinimumStockLevel && m_DataFiles.Preferences.AmmoMinStockFilter)
                {
                    return(false);
                }
            }

            return(true);
        }
示例#4
0
        //============================================================================*
        // CompareTo()
        //============================================================================*

        public virtual int CompareTo(Object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            int rc = 0;

            //----------------------------------------------------------------------------*
            // Gear Type
            //----------------------------------------------------------------------------*

            cGear Gear = (cGear)obj;

            if (sm_fSortByType)
            {
                rc = m_eType.CompareTo(Gear.m_eType);
            }

            //----------------------------------------------------------------------------*
            // Manufacturer
            //----------------------------------------------------------------------------*

            if (rc == 0)
            {
                if (m_Manufacturer != null)
                {
                    rc = m_Manufacturer.CompareTo(Gear.m_Manufacturer);
                }
                else
                {
                    if (Gear.m_Manufacturer != null)
                    {
                        rc = -1;
                    }
                    else
                    {
                        rc = 0;
                    }
                }

                //----------------------------------------------------------------------------*
                // Part Number
                //----------------------------------------------------------------------------*

                if (rc == 0)
                {
                    rc = cDataFiles.ComparePartNumbers(m_strPartNumber, Gear.PartNumber);

                    //----------------------------------------------------------------------------*
                    // Serial Number
                    //----------------------------------------------------------------------------*

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(m_strSerialNumber, Gear.SerialNumber);
                    }
                }
            }

            return(rc);
        }