コード例 #1
0
        partial void AddButtonPressed(AppKit.NSButton sender)
        {
            DateTime dtPay    = ((DateTime)this.DatePicker.DateValue).Date;
            DateTime dtRecord = ((DateTime)this.RecordDateOverridePicker.DateValue).Date;
            double   dAmount  = this.AmountTextField.DoubleValue;

            // VALIDATE ENTRIES
            if (this.typeChosen == clsCashflow.Type.Unknown)
            {
                this.SystemMessageTextField.StringValue = "INVALID CASHFLOW TYPE, UNABLE TO ADD";
            }
            else if (this.entityID < 0)
            {
                this.SystemMessageTextField.StringValue = "NO ENTITY SELECTED, UNABLE TO ADD";
            }
            else
            {
                // CREATE NEW CASHFLOW
                clsCashflow cashflow = new clsCashflow(dtPay, dtRecord, System.DateTime.MaxValue, -this.entityID, dAmount,
                                                       false, this.typeChosen, this.CommentTextField.StringValue);
                if (dtPay <= System.DateTime.Today.Date)
                {
                    cashflow.MarkActual(System.DateTime.Today.Date);
                }
                // SAVE TO TABLE
                cashflow.Save();
                this.CashflowIDTextField.IntValue = cashflow.ID();
                // UPDATE COMMENT BOX
                this.SystemMessageTextField.StringValue = "CASHFLOW SAVED.";
                if ((cashflow.TypeID() == clsCashflow.Type.InterestAdditional) && (cashflow.Amount() < 0D))
                {
                    this.SystemMessageTextField.StringValue += "\nCheck Amount.  Additional Interest is usually >= 0.";
                }
                else if ((cashflow.TypeID() == clsCashflow.Type.CapitalCall) && (cashflow.Amount() < 0D))
                {
                    this.SystemMessageTextField.StringValue += "\nCheck Amount.  Capital Calls are usually >= 0.";
                }
                else if ((cashflow.TypeID() == clsCashflow.Type.CatchUp) && (cashflow.Amount() < 0D))
                {
                    this.SystemMessageTextField.StringValue += "\nCheck Amount.  Catchup Payments are usually >= 0.";
                }
                else if (cashflow.Amount() > 0)
                {
                    this.SystemMessageTextField.StringValue += "\nCheck Amount.  Expenses are normally <0.";
                }
            }
            RedrawTable();
        }