private void DoAddEntries(LaundryCardEntryType type, Func <decimal> cost) { if (IsCostSetup(type)) { // create the seed item var seed = new LaundryCardEntry { Amount = -cost(), Date = DateTime.Today, ID = "", Notes = "", Type = type, }; // retrieve the default quantity int?quantity = Math.Max(1, SaveFile.Instance.Settings.DefaultQuantity); // if the quick entry hasn't been enabled if (!SaveFile.Instance.Settings.EnableQuickEntry) { using (EditEntryDialog dlg = new EditEntryDialog()) { dlg.Quantity = quantity.Value; dlg.AllowAmountEdit = false; dlg.AllowQuantityEdit = true; dlg.Text = string.Format("Add {0}", type); dlg.BindTo(seed); if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { quantity = dlg.Quantity; } else { quantity = null; } } } // if a quantity has been specified if (quantity.HasValue) { AddEntries(seed, quantity.Value); } } }
private bool IsCostSetup(LaundryCardEntryType type) { if (IsEmpty(SaveFile.Instance.Settings)) { var msg = string.Format(Resources.IsCostSetupMessage, type); var result = XtraMessageBox.Show(this, msg, type.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.No) { return(false); } } else { return(true); } // if we get here, it means the cost isn't setup and the user would like to do so DoEditSettings(); // return if we're empty return(!IsEmpty(SaveFile.Instance.Settings)); }