예제 #1
0
        public void BindTo(LaundryCardEntry entry)
        {
            dataSource = entry;

            cboDate.DataBindings.Add("DateTime", dataSource, "Date");
            numAmount.DataBindings.Add("Value", dataSource, "Amount");
            txtNotes.DataBindings.Add("Text", dataSource, "Notes");
        }
예제 #2
0
 private void AddEntries(LaundryCardEntry entry, int quantity)
 {
     for (int i = 0; i < quantity; ++i)
     {
         var duplicate = entry.Duplicate();
         duplicate.ID = Duid.Next;
         entrySource.Add(duplicate);
     }
 }
예제 #3
0
        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);
                }
            }
        }
예제 #4
0
        private void DoEditEntry(LaundryCardEntry entry)
        {
            var copy  = entry.Duplicate();
            var index = entrySource.IndexOf(entry);

            using (EditEntryDialog dlg = new EditEntryDialog())
            {
                dlg.AllowAmountEdit   = (entry.Type == LaundryCardEntryType.Deposit || entry.Type == LaundryCardEntryType.Withdrawal);
                dlg.AllowQuantityEdit = false;
                dlg.Text = string.Format("Edit {0}", entry.Type);
                dlg.BindTo(copy);
                if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    entrySource[index] = copy;
                }
            }
        }
예제 #5
0
        private void DoAddWithdrawal()
        {
            var deposit = new LaundryCardEntry
            {
                Amount = 0,
                Date   = DateTime.Today,
                ID     = Duid.Next,
                Notes  = "",
                Type   = LaundryCardEntryType.Withdrawal,
            };

            using (EditEntryDialog dlg = new EditEntryDialog())
            {
                dlg.AllowAmountEdit   = true;
                dlg.AllowQuantityEdit = false;
                dlg.Text = "Add Withdrawal";
                dlg.BindTo(deposit);
                if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    entrySource.Add(deposit);
                }
            }
        }