Exemple #1
0
        /// <summary>
        /// Main form constructor
        /// </summary>
        public DDTuneTrackForm()
        {
            InitializeComponent();

            /*
             * Checks if the current date is equal to or greater than the
             * season end date. If it is the user is informed that DDTT has
             * expired for the season. It will still operate, but it is likely
             * to break and act strangely. This should be fixed properly at a
             * later date
             */
            if (DateTime.Today.CompareTo(mSeasonEndDate) > 0)
            {
                DialogResult dialogResult = MessageBox.Show("Double Diamond Tune Track has expired for the 2015/2016 season.", "Double Diamond Tune Track Expired", MessageBoxButtons.OK);
            }

            // Load tune types from disk
            TuneTypes.LoadTuneTypesList(cmbTuneType);

            // Load staff list from disk
            LoadStaffList();

            mTuneList = new TuneList(this, this.dgv);

            // Load charge lists from file
            ChargeListManager.GetInstance().LoadChargeLists();

            // Make sure the tune entry date is set correctly
            UpdateEntryDate();

            // Ensure the charged button in the charge list tab has the right text
            UpdateChargedButtonText();

            // Set dateTimePicker date formats
            dtpTuneDate.CustomFormat = CultureHelper.GetInstance().GetDefaultDateFormatString();
            dtpChargeListDate.CustomFormat = CultureHelper.GetInstance().GetDefaultDateFormatString();

            // Set dateTimePicker min/max dates
            dtpTuneDate.MinDate = mSeasonStartDate;
            dtpTuneDate.MaxDate = DateTime.Today;
            dtpChargeListDate.MinDate = mSeasonStartDate;
            dtpChargeListDate.MaxDate = mSeasonEndDate;

            // Set the current charge list date to today. If a list already
            // exists for today it will be displayed immediately in the viewer.
            dtpChargeListDate.Value = DateTime.Today;
        }
        /// <summary>
        /// Builds a ChargeList from a collection for data rows from a 
        /// TuneList. 
        /// </summary>
        /// <param name="tl">TuneList to build from</param>
        /// <returns>Newly created ChargeList</returns>
        public ChargeList BuildChargeList(TuneList tl)
        {
            ChargeList cl = new ChargeList();
            DataGridViewRowCollection tuneRows = tl.GetAllTuneRows();

            foreach (DataGridViewRow row in tuneRows)
            {
                string noteCell = row.Cells["colNotes"].Value.ToString();
                if (noteCell != string.Empty)
                {
                    cl.AddTune(row.Cells["colTuneType"].Value.ToString(), row.Cells["colAssetNumber"].Value.ToString() + ": " + noteCell);
                }
                else
                {
                    cl.AddTune(row.Cells["colTuneType"].Value.ToString(), string.Empty);
                }
            }

            return cl;
        }