示例#1
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="clientRow"></param>
    /// <param name="proposedActive"></param>
    /// <param name="message"></param>
    /// <param name="reasonRequired"></param>
    /// <param name="reason"></param>
    /// <returns>true = save was allowed, false = further action required</returns>
    public bool CheckClientActiveRules(DataRowView clientRow, bool proposedActive, out string message, out bool reasonRequired, string reason = null)
    {
      //nugget: this DataTable.ColumnChanging => Exception based approach doesn't really work out... 
      //nugget: good to document and remember since it's conceptually appealing
      //nugget: unfortunately the UI checkbox still flips itself even if the underlying field doesn't
      //nugget: DataTable.ColumnChanging: if (error) { e.Row.CancelEdit(); e.Row.SetColumnError(e.Column, err); throw (new Exception(err)); }

      message = null;
      reasonRequired = false;

      //sponsor rules...
      if (clientRow.Field<bool>("IsSponsor"))
      {
        //make sure not PCS'ed, which should be resolved via PCS specific logic elsewhere
        if (IsPCS) 
        {
          message = "Resolving PCS status will clear de-active.";
          return (false);
        }
        //otherwise get Reason for hitting Active ...
        if (reason == null) //... and no reason has been provided yet, ...
        {
          message = !proposedActive ? "Why deactivating this Household?\n(if Suspension or PCS, use those buttons)" :
                                                                                                                      "Why allowing this Household to be active again?";
          reasonRequired = true; // indicate reason required
          return (false);
        }

// ReSharper disable InconsistentNaming
        using (var Sponsor_Active_u = new iTRAACProc("Sponsor_Active_u"))
// ReSharper restore InconsistentNaming
        {
          Sponsor_Active_u["@SponsorGUID"] = GUID;
          Sponsor_Active_u["@RemarkTypeId"] = 23 * (!proposedActive ? 1 : -1); //! necessary because it's a "deactivated" oriented status 
          Sponsor_Active_u["@Reason"] = reason;
          CacheTables(Sponsor_Active_u);
        }
        if (!proposedActive) ShowDeactiveMembers = true;
        OnPropertyChanged("ShowDeactiveMembers");
        HouseMembers = HouseMembers; //for some reason OnPropertyChanged("HouseMembers") didn't refresh the Members Grid, i don't have a good guess but this little hack worked immediately so i'm moving on
        OnPropertyChanged("Fields");

        return (true); //no further processing desired after special sponsor level sproc
      }

      //spousal rules...
      //if attempting to deactivate spouse, let them know the rules...
      if (clientRow.Field<bool>("IsSpouse") && !proposedActive)
      {
        message = "Only valid way to deactivate Spouse is by *official* divorce (\"Legal Separation\" is not sufficient).\r\n"+
                  "Use the hidden Divorce button to the left of the Spouse.";
        return (false);
      }

        //if this is just a fresh new row the user doesn't want to fill out, just whack it straight away
      if (clientRow.Row.RowState == DataRowState.Added)
      {
        clientRow.DetachRow();
        //can't track an IsModified "undo" anymore now that i've had to move to a flat property that's set by everything that can be dirty:
        //OnPropertyChanged("IsModified");
        return (true);
      }

      //finally!  set the flag... 
      clientRow.Row.SetReadonlyField("Active", proposedActive);
      OnPropertyChanged("DependentsSelectionList");
      IsModified = true;
      return (true); //return success
    }
示例#2
0
    static public bool DenyEdit(DataRowView r, string columnName, out string message)
    {
      message = null;

      if (!UserModel.Current.Access.IsAdmin && r.Field<bool>("Alert") && r.Field<int>("CreateTaxOfficeId") != SettingsModel.TaxOfficeId)
      {
        message = "Alerted Remarks can only be changed by originating office (or Admin)";
      }
      else if (r["CategoryId"].ToString() != "")
      {
        message = "This kind of sytem generated remark should only be changed via the corresponding special alert button located elsewhere";
      }
      //system generated Titles aren't editable since they come from the RemarkType table (see Remark_v)
      else if (columnName == "Title" && r.Field<int>("RemarkTypeId") != 0)
        message = "System generated Titles aren't editable";

      return (message != null);
    }