Beispiel #1
0
        public bool ReturnForm(bool isClosing = false, bool displaySuccess = true)
        {
            Save();

// ReSharper disable InconsistentNaming
            using (Proc TaxForm_ReturnFile = new iTRAACProc("TaxForm_ReturnFile"))
// ReSharper restore InconsistentNaming
            {
                TaxForm_ReturnFile["@TaxFormGUID"] = GUID;
                TaxForm_ReturnFile["@File"]        = false;
                if (!TaxForm_ReturnFile.ExecuteDataSet(UserMessagePrefix + "Return - ", true))
                {
                    return(false);
                }

                //if we're firing Returned and this object is remaining visible (i.e. user didn't select the Return-and-Close button) then pull back the updated values reflecting the Returned status change
                if (!isClosing)
                {
                    CacheTables(TaxForm_ReturnFile);
                    OnPropertyChanged("Fields"); //nugget: amazingly inconsistent IMHO, DataTable.Merge() does *not* fire DataRowView.PropertyChanged events!?! (tsk tsk Microsoft!!)
                }
            }

            OnFormStatusChange();
            return(true);
        }
Beispiel #2
0
        static public void SaveRemarks(string ownerGUIDFieldName, string ownerGUID, string userMessagePrefix, DataView v)
        {
            if (v == null)
            {
                return;
            }

            string savefilter = v.RowFilter;

            v.RowFilter = "";

// ReSharper disable InconsistentNaming
            using (var Remark_u = new iTRAACProc("Remark_u"))
// ReSharper restore InconsistentNaming
                foreach (var remark in v.Cast <DataRowView>().Where(remark => remark.IsDirty()))
                {
                    Remark_u.AssignValues(remark);
                    if (!Remark_u.ExecuteNonQuery(userMessagePrefix + " Save Remark: "))
                    {
                        continue;
                    }
                    remark["RowGUID"] = Remark_u["@RowGUID"]; //for inserts
                    remark.AcceptChanges();
                }
            v.RowFilter = savefilter;
        }
Beispiel #3
0
        public void Suspend(SuspendDuration duration, string remarks = null)
        {
            Assert.Check(duration == SuspendDuration.Remove || !String.IsNullOrEmpty(remarks), "Remarks must be provided when customer is suspended.");

            object suspensionExpiry;

            switch (duration)
            {
            case SuspendDuration.Remove: suspensionExpiry = DBNull.Value; break;

            case SuspendDuration.OneMonth: suspensionExpiry = DateTime.Today.AddMonths(1); break;

            case SuspendDuration.OneYear: suspensionExpiry = DateTime.Today.AddYears(1); break;

            case SuspendDuration.Forever: suspensionExpiry = DateTime.MaxValue; break;

            default: throw (new Exception("fix me"));
            }

// ReSharper disable InconsistentNaming
            using (var Sponsor_Suspend = new iTRAACProc("Sponsor_Suspend"))
// ReSharper restore InconsistentNaming
            {
                Sponsor_Suspend["@SponsorGUID"]      = GUID;
                Sponsor_Suspend["@SuspensionExpiry"] = suspensionExpiry;
                Sponsor_Suspend["@Remarks"]          = remarks;
                CacheTables(Sponsor_Suspend);
                OnPropertyChanged("Fields"); //nugget: this really bums me out that the DataSet.Merge() called by TableCache doesn't fire PropertyChanged events... i don't get how that makes sense!?!
                OnPropertyChanged("SponsorRemarks");
            }
        }
Beispiel #4
0
        public void MoveClient(string moveClientGUID)
        {
            DropInMemAddMember();
            if (HouseMembers.Count == 0)
            {
                SaveJustSponsorRecord();                    //if brand new cust, save it so that there's something to connect the newly moved Client to below
            }
// ReSharper disable InconsistentNaming
            using (var Sponsor_MoveClient = new iTRAACProc("Sponsor_MoveClient"))
// ReSharper restore InconsistentNaming
            {
                Sponsor_MoveClient["@SponsorGUID"]    = GUID;
                Sponsor_MoveClient["@MoveClientGUID"] = moveClientGUID;
                CacheTables(Sponsor_MoveClient);
                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("HasSpouse");
                OnPropertyChanged("DependentsSelectionList");
            }

            if (!(bool)HouseMembers.Table.Rows.Find(moveClientGUID)["Active"])
            {
                ShowDeactiveMembers = true; //out of convenience, if the newly brought in member is flagged as deactive then disable deactive filter
                OnPropertyChanged("ShowDeactiveMembers");
                OnPropertyChanged("HasDeactiveMembers");
            }
        }
Beispiel #5
0
        //the pattern of assumptions for model retrieval sprocs:
        //- all take a standard @GUID UNIQUEIDENTIFIER parameter as a consistent primary key (also required by replication)
        //- can return multiple resultsets in order to bulk load in one proc call
        //- if multiple resultsets, then must also return a standard @TableNames varchar(1000) OUT parameter with a comma list of names to cache each recordset

        /// <summary>
        /// Lookup entity by 'RowGUID'=GUID in TableName, if doesn't exist, retrieve via specified Proc
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="entityTableName"></param>
        /// <param name="procName"></param>
        /// <param name="refresh"></param>
        /// <returns></returns>
        static protected DataRowView EntityLookup(string guid, string entityTableName, string procName, bool refresh = false)
        {
// ReSharper disable InconsistentNaming
            using (var Entity_s = new iTRAACProc(procName))
// ReSharper restore InconsistentNaming
            {
                return(EntityLookup(guid, entityTableName, Entity_s, refresh));
            }
        }
Beispiel #6
0
        protected bool SaveMe(bool isFiling = false, bool updateSponsor = true)
        {
            // generally, inserts and deletes will be edge cases handled elsewhere, modified fields on existing rows are the primary save scenario for child lists hanging off main entities like TaxForm (e.g. TaxFormRemarks)

            //pulling back on this for now... seems theoretically possible to save a pending NF2 with un-printed status just like NF1's, it's not "issued" until it's printed
            //if (IsClass2 && !Validate())
            //{
            //  ShowUserMessage("It is invalid to save an NF2/EF2 that's not fully completed.");
            //  return (false);
            //}

            if (Fields.IsDirty()) //the "Fields" logic does actually need to be here if called from FileForm() rather than base.Save();
            {
// ReSharper disable InconsistentNaming
                using (var TaxForm_u = new iTRAACProc("TaxForm_u"))
// ReSharper restore InconsistentNaming
                {
                    TaxForm_u.AssignValues(Fields);
                    TaxForm_u["@IsFiling"] = isFiling;
                    if (!TaxForm_u.ExecuteDataSet(UserMessagePrefix))
                    {
                        return(false);
                    }
                    Fields.AcceptChanges();
                    if (isFiling)
                    {
                        CacheTables(TaxForm_u);
                    }
                }

                if (updateSponsor)
                {
                    OnFormStatusChange();
                }
            }

            if (ExtendedFields.IsDirty())
            {
// ReSharper disable InconsistentNaming
                using (var TaxForm_TransactionTypeExt_u = new Proc("TaxForm_TransactionTypeExt_u"))
// ReSharper restore InconsistentNaming
                {
                    TaxForm_TransactionTypeExt_u.AssignValues(ExtendedFields);
                    TaxForm_TransactionTypeExt_u["@TaxFormGUID"] = GUID;
                    if (!TaxForm_TransactionTypeExt_u.ExecuteNonQuery(UserMessagePrefix))
                    {
                        return(false);
                    }
                }
                ExtendedFields.AcceptChanges();
            }

            RemarkModel.SaveRemarks("FKRowGUID", GUID, UserMessagePrefix, TaxFormRemarks);

            return(true);
        }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 /// <returns>The SponsorGUID for the new replacement form</returns>
 public void VoidAndNew(out string sponsorGUID, out string newTaxFormGUID, out decimal serviceFee)
 {
     using (Proc taxFormVoidAndNew = new iTRAACProc("TaxForm_VoidAndNew"))
     {
         taxFormVoidAndNew["@VoidTaxFormGUID"] = GUID;
         sponsorGUID    = taxFormVoidAndNew["@SponsorGUID"].ToString();
         newTaxFormGUID = taxFormVoidAndNew["@NewTaxFormGUID"].ToString();
         serviceFee     = Convert.ToDecimal(taxFormVoidAndNew["@NewTaxFormGUID"]);
     }
 }
Beispiel #8
0
        static public void SaveLocalSettings(bool displaySuccess = false)
        {
// ReSharper disable InconsistentNaming
            using (var Settings_u = new iTRAACProc("Settings_u"))
// ReSharper restore InconsistentNaming
            {
                Settings_u["@Settings"] = Local._table;
                Settings_u.ExecuteNonQuery("Settings - ", displaySuccess);
            }
        }
Beispiel #9
0
        /// <summary>
        /// To be used by update sprocs that are only concerned with returning a batch of records to keep the DataTable cache in sync with database state
        /// </summary>
        /// <param name="procName"></param>
        /// <returns>Array of tablenames that were returned</returns>
        static protected string[] CacheTables(string procName)
        {
// ReSharper disable InconsistentNaming
            using (var Entity_s = new iTRAACProc(procName))
// ReSharper restore InconsistentNaming
            {
                CacheTables(Entity_s);
                return(Entity_s.TableNames);
            }
        }
Beispiel #10
0
        public void SetSponsor(string newSponsorClientGUID, bool fixExistingPackageLinks)
        {
// ReSharper disable InconsistentNaming
            using (var Sponsor_SetSponsor = new iTRAACProc("Sponsor_SetSponsor"))
// ReSharper restore InconsistentNaming
            {
                Sponsor_SetSponsor["@SponsorGUID"]             = GUID;
                Sponsor_SetSponsor["@NewSponsorClientGUID"]    = newSponsorClientGUID;
                Sponsor_SetSponsor["@FixExistingPackageLinks"] = fixExistingPackageLinks;
                CacheTables(Sponsor_SetSponsor);
                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
            }
        }
Beispiel #11
0
    static public void SaveNew(string fkguid, int remarkTypeId, string remarks = null, string title = null, bool alert = false)
    {
// ReSharper disable InconsistentNaming
      using (var Remark_u = new iTRAACProc("Remark_u"))
// ReSharper restore InconsistentNaming
      {
        Remark_u["@FKRowGUID"] = fkguid;
        Remark_u["@RemarkTypeId"] = remarkTypeId;
        Remark_u["@Title"] = title;
        Remark_u["@Remarks"] = remarks;
        ModelBase.CacheTables(Remark_u);
      }
    }
Beispiel #12
0
        static public void SaveNew(string fkguid, int remarkTypeId, string remarks = null, string title = null, bool alert = false)
        {
// ReSharper disable InconsistentNaming
            using (var Remark_u = new iTRAACProc("Remark_u"))
// ReSharper restore InconsistentNaming
            {
                Remark_u["@FKRowGUID"]    = fkguid;
                Remark_u["@RemarkTypeId"] = remarkTypeId;
                Remark_u["@Title"]        = title;
                Remark_u["@Remarks"]      = remarks;
                ModelBase.CacheTables(Remark_u);
            }
        }
Beispiel #13
0
        public void SetCCodesSame()
        {
// ReSharper disable InconsistentNaming
            using (var Sponsor_SetCCodesSame = new iTRAACProc("Sponsor_SetCCodesSame"))
// ReSharper restore InconsistentNaming
            {
                Sponsor_SetCCodesSame["@SponsorGUID"] = GUID;
                if (HouseMembers.Count > 0)
                {
                    Sponsor_SetCCodesSame["@NewCCode"] = HouseMembers[0]["CCode"];
                }
                CacheTables(Sponsor_SetCCodesSame);
                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
            }
        }
    private void ActivityStartEndDateChanged(object sender, SelectionChangedEventArgs e)
    {
      if (WPFHelpers.DesignMode) return; //there was an annoying exception that would close down all of VS2010

      if (dateActivityStart == null || dateActivityStart.SelectedDate == null || dateActivityEnd == null || dateActivityEnd.SelectedDate == null) return;

      long minticks = Math.Min(dateActivityStart.SelectedDate.Value.Ticks, dateActivityEnd.SelectedDate.Value.Ticks);
      if (minticks < dateRangeActivity.Minimum.Ticks) dateRangeActivity.Minimum = new DateTime(minticks); //expand the slider's minimum allowed if we're trying to go further back in time with the date boxes

      if (_queryThread != null) _queryThread.Abort();
      _queryThread = new Thread(delegate(object state)
      {
        Thread.Sleep(1500); //slight delay to smooth out reacting to the slider while it's still being drug around

        var parms = state as DateRange;
        Debug.Assert(parms != null, "parms != null");
        var daysspanned = (parms.End - parms.Start).Days;
        if (daysspanned > 30) if (MessageBoxResult.Cancel == MessageBox.Show(
          String.Format("That's a {0} day span.\rIt will make the database really smoke, are you sure?", daysspanned),
            "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning)) return; //nugget: aint that nice that MessageBox goes switches to the UI thread for us

// ReSharper disable InconsistentNaming
        using (Proc DailyActivity_s = new iTRAACProc("DailyActivity_s"))
// ReSharper restore InconsistentNaming
        {
          DailyActivity_s["@ActivityType"] = parms.ActivityType;
          DailyActivity_s["@StartDate"] = parms.Start;
          DailyActivity_s["@EndDate"] = parms.End;
          var t = DailyActivity_s.ExecuteDataSet().Table0;
          parms.Me.Dispatcher.Invoke((Action)delegate
          {
            var dv = (parms.Me.gridDailyActivity.ItemsSource as DataView);
            if (dv != null) dv.Table.Dispose();
            parms.Me.gridDailyActivity.ItemsSource = t.DefaultView;
            WPFHelpers.GridSort(parms.Me.gridDailyActivity, "Purchased", System.ComponentModel.ListSortDirection.Descending);
          });
        }
      });
      _queryThread.Start(new DateRange(this, (string)cbxActivityType.SelectedValue, dateActivityStart.SelectedDate.Value, dateActivityEnd.SelectedDate.Value));

      if (_skipCbxActivityDateSelectionChanged) return;
      cbxActivityDate.SelectedValue = "CUSTOM";
    }
Beispiel #15
0
        protected override bool SaveSubClass()
        {
            bool success = true;

            if (Fields.IsDirty())
            {
                using (var taxOfficeU = new iTRAACProc("TaxOffice_u"))
                {
                    if (taxOfficeU.AssignValues(Current.Fields).ExecuteNonQuery("Tax Office - ", true))
                    {
                        Fields.AcceptChanges();
                    }
                    else
                    {
                        success = false;
                    }
                }
            }

            if (UserTable.GetChanges() != null)
            {
                using (var userU = new iTRAACProc("User_u"))
                {
                    foreach (DataRowView r in from DataRowView r in UserTable.DefaultView where r.IsDirty() select r)
                    {
                        if (userU.AssignValues(r).ExecuteNonQuery(String.Format("Saving User: {0} - ", r["UserNameId"])))
                        {
                            r.AcceptChanges();
                        }
                        else
                        {
                            success = false;
                        }
                    }
                }
            }

            return(success);
        }
Beispiel #16
0
        private bool SaveJustSponsorRecord()
        {
// ReSharper disable InconsistentNaming
            using (var Sponsor_u = new iTRAACProc("Sponsor_u"))
// ReSharper restore InconsistentNaming
            {
                Fields.Row.SetAllNonDBNullColumnsToEmptyString("-");
                try
                {
                    Sponsor_u.AssignValues(Fields);
                    if (!Sponsor_u.ExecuteDataSet(UserMessagePrefix))
                    {
                        return(false);                                      //base class clears "Fields" dirty flags for us
                    }
                    CacheTables(Sponsor_u);
                }
                finally
                {
                    Fields.Row.RemoveEmptyPlaceholder("-");
                }
            }
            return(true);
        }
Beispiel #17
0
            public override bool Execute()
            {
                if (!IsPrintOK())
                {
                    return(false);
                }

                string[] taxFormGUIDs;
                using (var taxFormPackageNew = new iTRAACProc("TaxFormPackage_New"))
                {
                    taxFormPackageNew["@PackageCode"] = PackageCode; //for merging multiple requests for the same form type during this same customer session
                    taxFormPackageNew["@FormTypeID"]  = Convert.ToInt32(FormType);
                    taxFormPackageNew["@FormCount"]   = Qty;
                    taxFormPackageNew["@SponsorGUID"] = SponsorGUID;
                    taxFormPackageNew["@ClientGUID"]  = AuthorizedDependentClientGUID;
                    taxFormPackageNew["@Pending"]     = IsPending;

                    taxFormPackageNew.ExecuteNonQuery();

                    Price        = (decimal)taxFormPackageNew["@ServiceFee"];
                    GUID         = taxFormPackageNew["@TaxFormPackageGUID"].ToString();
                    PackageCode  = taxFormPackageNew["@PackageCode"].ToString();
                    taxFormGUIDs = taxFormPackageNew["@TaxFormGUIDs"].ToString().Split(',');

                    IsPending = false;
                    NotifyPropertyChanged("IsPending");
                }

                if (taxFormGUIDs.Any(taxFormGUID => !Print(PackageComponent.OrderForm | PackageComponent.Abw, taxFormGUID)))
                {
                    return(false);
                }

                FormStatusChangeCallback(SponsorGUID);

                return(true);
            }
Beispiel #18
0
        public void SetSpouse(string newSpouseClientGUID, bool isDivorce = false)
        {
            //if we're doing a "Clear Spouse", check if we've just got a brand new raw row created for the spouse to be entered here on the client...
            //then we just drop it out of memory since it's not on the database yet anyway
            if (string.IsNullOrEmpty(newSpouseClientGUID) && DropInMemAddMember())
            {
                OnPropertyChanged("HasSpouse");
                OnPropertyChanged("DependentsSelectionList");
                return;
            }

// ReSharper disable InconsistentNaming
            using (var Sponsor_SetSpouse = new iTRAACProc("Sponsor_SetSpouse"))
// ReSharper restore InconsistentNaming
            {
                Sponsor_SetSpouse["@SponsorGUID"]         = GUID;
                Sponsor_SetSpouse["@NewSpouseClientGUID"] = newSpouseClientGUID;
                Sponsor_SetSpouse["@IsDivorce"]           = isDivorce;
                CacheTables(Sponsor_SetSpouse);
                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("HasSpouse");
                OnPropertyChanged("DependentsSelectionList");
            }
        }
Beispiel #19
0
    private bool SaveJustSponsorRecord()
    {
// ReSharper disable InconsistentNaming
      using (var Sponsor_u = new iTRAACProc("Sponsor_u"))
// ReSharper restore InconsistentNaming
      {
        Fields.Row.SetAllNonDBNullColumnsToEmptyString("-");
        try
        {
          Sponsor_u.AssignValues(Fields);
          if (!Sponsor_u.ExecuteDataSet(UserMessagePrefix)) return (false); //base class clears "Fields" dirty flags for us
          CacheTables(Sponsor_u);
        }
        finally
        {
          Fields.Row.RemoveEmptyPlaceholder("-");
        }
      }
      return (true);
    }
Beispiel #20
0
    public void SetSpouse(string newSpouseClientGUID, bool isDivorce = false)
    {
      //if we're doing a "Clear Spouse", check if we've just got a brand new raw row created for the spouse to be entered here on the client...
      //then we just drop it out of memory since it's not on the database yet anyway
      if (string.IsNullOrEmpty(newSpouseClientGUID) && DropInMemAddMember())
      {
        OnPropertyChanged("HasSpouse");
        OnPropertyChanged("DependentsSelectionList");
        return;
      }

// ReSharper disable InconsistentNaming
      using (var Sponsor_SetSpouse = new iTRAACProc("Sponsor_SetSpouse"))
// ReSharper restore InconsistentNaming
      {
        Sponsor_SetSpouse["@SponsorGUID"] = GUID;
        Sponsor_SetSpouse["@NewSpouseClientGUID"] = newSpouseClientGUID;
        Sponsor_SetSpouse["@IsDivorce"] = isDivorce;
        CacheTables(Sponsor_SetSpouse);
        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("HasSpouse");
        OnPropertyChanged("DependentsSelectionList");
      }
    }
Beispiel #21
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
    }
Beispiel #22
0
    protected override bool SaveSubClass()
    {
      //validate everything first so we see all the red boxes at once... 
      var isValid = true;

      ValidateGeneric(ref isValid, "Rank");
      ValidateGeneric(ref isValid, "DEROS");
      ValidateGeneric(ref isValid, "DutyLocation");

      ValidateGeneric(ref isValid, "DutyPhoneDSN1", "'?'.Length == 3", "Enter 3 Digits");
      ValidateGeneric(ref isValid, "DutyPhoneDSN2", "'?'.Length == 4", "Enter 4 Digits");

      ValidateGeneric(ref isValid, "OfficialMailCMR");
      ValidateGeneric(ref isValid, "OfficialMailBox");
      ValidateGeneric(ref isValid, "OfficialMailCity");
      ValidateGeneric(ref isValid, "OfficialMailState");
      ValidateGeneric(ref isValid, "OfficialMailZip", "'?'.Length == 5", "Enter 5 Digits");

      ValidateGeneric(ref isValid, "HomePhoneCountry");
      ValidateGeneric(ref isValid, "HomePhone");

      var validateUTAP = Fields.Field<bool>("IsUTAPActive");
      ValidateGeneric(Fields, ref isValid, "HomeStreet,IsUTAPActive", validateUTAP);
      ValidateGeneric(Fields, ref isValid, "HomeStreetNumber,IsUTAPActive", validateUTAP);
      ValidateGeneric(Fields, ref isValid, "HomeCity,IsUTAPActive", validateUTAP);
      ValidateGeneric(Fields, ref isValid, "HomePostal,IsUTAPActive", validateUTAP);

      foreach(DataRowView member in HouseMembers)
      {
        ValidateGeneric(member, ref isValid, "SSN1", true, "'?'.Length == 3", "Enter 3 Digits");
        ValidateGeneric(member, ref isValid, "SSN2", true, "'?'.Length == 2", "Enter 2 Digits");
        ValidateGeneric(member, ref isValid, "SSN3", true, "'?'.Length == 4", "Enter 4 Digits");
        if (ValidateGeneric(member, ref isValid, "FName"))
          ValidateGeneric(member, ref isValid, "FName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case.");
        if (ValidateGeneric(member, ref isValid, "LName"))
          ValidateGeneric(member, ref isValid, "LName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case.");
      }

      if (!isValid)
      {
        ShowUserMessage("Please correct all highlighted fields before saving.");
        return (false);
      }

      //then save attempt to save everything if we made it through all the validation...
      if (Fields.IsDirty()) if (!SaveJustSponsorRecord()) return (false);

      foreach (var member in HouseMembers.Cast<DataRowView>().Where(member => member.IsDirty()))
// ReSharper disable InconsistentNaming
        using (Proc Client_u = new iTRAACProc("Client_u"))
// ReSharper restore InconsistentNaming
        {
          Client_u.AssignValues(member);
          if (!Client_u.ExecuteDataSet(UserMessagePrefix)) return (false);
          member.AcceptChanges();
          CacheTables(Client_u);
        }

      RemarkModel.SaveRemarks("SponsorGUID", GUID, UserMessagePrefix, SponsorRemarks);

      return (true);
    }
Beispiel #23
0
    public void MoveClient(string moveClientGUID)
    {
      DropInMemAddMember();
      if (HouseMembers.Count == 0) SaveJustSponsorRecord(); //if brand new cust, save it so that there's something to connect the newly moved Client to below

// ReSharper disable InconsistentNaming
      using (var Sponsor_MoveClient = new iTRAACProc("Sponsor_MoveClient"))
// ReSharper restore InconsistentNaming
      {
        Sponsor_MoveClient["@SponsorGUID"] = GUID;
        Sponsor_MoveClient["@MoveClientGUID"] = moveClientGUID;
        CacheTables(Sponsor_MoveClient);
        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("HasSpouse");
        OnPropertyChanged("DependentsSelectionList");
      }

      if (!(bool)HouseMembers.Table.Rows.Find(moveClientGUID)["Active"])
      {
        ShowDeactiveMembers = true; //out of convenience, if the newly brought in member is flagged as deactive then disable deactive filter 
        OnPropertyChanged("ShowDeactiveMembers");
        OnPropertyChanged("HasDeactiveMembers");
      }
    }
Beispiel #24
0
    public void Suspend(SuspendDuration duration, string remarks = null)
    {
      Assert.Check(duration == SuspendDuration.Remove || !String.IsNullOrEmpty(remarks), "Remarks must be provided when customer is suspended.");

      object suspensionExpiry;
      switch (duration)
      {
        case SuspendDuration.Remove: suspensionExpiry = DBNull.Value; break;
        case SuspendDuration.OneMonth: suspensionExpiry = DateTime.Today.AddMonths(1); break;
        case SuspendDuration.OneYear: suspensionExpiry = DateTime.Today.AddYears(1); break;
        case SuspendDuration.Forever: suspensionExpiry = DateTime.MaxValue; break;
        default: throw (new Exception("fix me"));
      }

// ReSharper disable InconsistentNaming
      using (var Sponsor_Suspend = new iTRAACProc("Sponsor_Suspend"))
// ReSharper restore InconsistentNaming
      {
        Sponsor_Suspend["@SponsorGUID"] = GUID;
        Sponsor_Suspend["@SuspensionExpiry"] = suspensionExpiry;
        Sponsor_Suspend["@Remarks"] = remarks;
        CacheTables(Sponsor_Suspend);
        OnPropertyChanged("Fields"); //nugget: this really bums me out that the DataSet.Merge() called by TableCache doesn't fire PropertyChanged events... i don't get how that makes sense!?!
        OnPropertyChanged("SponsorRemarks");
      }

    }
Beispiel #25
0
    static public void SaveRemarks(string ownerGUIDFieldName, string ownerGUID, string userMessagePrefix, DataView v)
    {
      if (v == null) return;

      string savefilter = v.RowFilter;
      v.RowFilter = "";

// ReSharper disable InconsistentNaming
      using (var Remark_u = new iTRAACProc("Remark_u"))
// ReSharper restore InconsistentNaming
      foreach (var remark in v.Cast<DataRowView>().Where(remark => remark.IsDirty()))
      {
        Remark_u.AssignValues(remark);
        if (!Remark_u.ExecuteNonQuery(userMessagePrefix + " Save Remark: ")) continue;
        remark["RowGUID"] = Remark_u["@RowGUID"]; //for inserts
        remark.AcceptChanges();
      }
      v.RowFilter = savefilter;
    }
Beispiel #26
0
    protected bool SaveMe(bool isFiling = false, bool updateSponsor = true)
    {
      // generally, inserts and deletes will be edge cases handled elsewhere, modified fields on existing rows are the primary save scenario for child lists hanging off main entities like TaxForm (e.g. TaxFormRemarks)

      //pulling back on this for now... seems theoretically possible to save a pending NF2 with un-printed status just like NF1's, it's not "issued" until it's printed
      //if (IsClass2 && !Validate())
      //{
      //  ShowUserMessage("It is invalid to save an NF2/EF2 that's not fully completed.");
      //  return (false);
      //}

      if (Fields.IsDirty()) //the "Fields" logic does actually need to be here if called from FileForm() rather than base.Save();
      {
// ReSharper disable InconsistentNaming
        using (var TaxForm_u = new iTRAACProc("TaxForm_u"))
// ReSharper restore InconsistentNaming
        {
          TaxForm_u.AssignValues(Fields);
          TaxForm_u["@IsFiling"] = isFiling;
          if (!TaxForm_u.ExecuteDataSet(UserMessagePrefix)) return (false);
          Fields.AcceptChanges();
          if (isFiling) CacheTables(TaxForm_u);
        }

        if (updateSponsor) OnFormStatusChange();
      }

      if (ExtendedFields.IsDirty())
      {
// ReSharper disable InconsistentNaming
        using (var TaxForm_TransactionTypeExt_u = new Proc("TaxForm_TransactionTypeExt_u"))
// ReSharper restore InconsistentNaming
        {
          TaxForm_TransactionTypeExt_u.AssignValues(ExtendedFields);
          TaxForm_TransactionTypeExt_u["@TaxFormGUID"] = GUID;
          if (!TaxForm_TransactionTypeExt_u.ExecuteNonQuery(UserMessagePrefix)) return (false);
        }
        ExtendedFields.AcceptChanges();
      }

      RemarkModel.SaveRemarks("FKRowGUID", GUID, UserMessagePrefix, TaxFormRemarks);

      return (true);
    }
Beispiel #27
0
      public override bool Execute()
      {
        if (!IsPrintOK()) return (false);

        string[] taxFormGUIDs;
        using (var taxFormPackageNew = new iTRAACProc("TaxFormPackage_New"))
        {
          taxFormPackageNew["@PackageCode"] = PackageCode; //for merging multiple requests for the same form type during this same customer session
          taxFormPackageNew["@FormTypeID"] = Convert.ToInt32(FormType);
          taxFormPackageNew["@FormCount"] = Qty;
          taxFormPackageNew["@SponsorGUID"] = SponsorGUID;
          taxFormPackageNew["@ClientGUID"] = AuthorizedDependentClientGUID;
          taxFormPackageNew["@Pending"] = IsPending;

          taxFormPackageNew.ExecuteNonQuery();

          Price = (decimal)taxFormPackageNew["@ServiceFee"];
          GUID = taxFormPackageNew["@TaxFormPackageGUID"].ToString();
          PackageCode = taxFormPackageNew["@PackageCode"].ToString();
          taxFormGUIDs = taxFormPackageNew["@TaxFormGUIDs"].ToString().Split(',');

          IsPending = false;
          NotifyPropertyChanged("IsPending");
        }

        if (taxFormGUIDs.Any(taxFormGUID => !Print(PackageComponent.OrderForm | PackageComponent.Abw, taxFormGUID)))
        {
          return(false);
        }

        FormStatusChangeCallback(SponsorGUID);

        return (true);
      }
Beispiel #28
0
        private void ActivityStartEndDateChanged(object sender, SelectionChangedEventArgs e)
        {
            if (WPFHelpers.DesignMode)
            {
                return;                  //there was an annoying exception that would close down all of VS2010
            }
            if (dateActivityStart == null || dateActivityStart.SelectedDate == null || dateActivityEnd == null || dateActivityEnd.SelectedDate == null)
            {
                return;
            }

            long minticks = Math.Min(dateActivityStart.SelectedDate.Value.Ticks, dateActivityEnd.SelectedDate.Value.Ticks);

            if (minticks < dateRangeActivity.Minimum.Ticks)
            {
                dateRangeActivity.Minimum = new DateTime(minticks);                                       //expand the slider's minimum allowed if we're trying to go further back in time with the date boxes
            }
            if (_queryThread != null)
            {
                _queryThread.Abort();
            }
            _queryThread = new Thread(delegate(object state)
            {
                Thread.Sleep(1500); //slight delay to smooth out reacting to the slider while it's still being drug around

                var parms = state as DateRange;
                Debug.Assert(parms != null, "parms != null");
                var daysspanned = (parms.End - parms.Start).Days;
                if (daysspanned > 30)
                {
                    if (MessageBoxResult.Cancel == MessageBox.Show(
                            String.Format("That's a {0} day span.\rIt will make the database really smoke, are you sure?", daysspanned),
                            "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning))
                    {
                        return;                                                     //nugget: aint that nice that MessageBox goes switches to the UI thread for us
                    }
                }
// ReSharper disable InconsistentNaming
                using (Proc DailyActivity_s = new iTRAACProc("DailyActivity_s"))
// ReSharper restore InconsistentNaming
                {
                    DailyActivity_s["@ActivityType"] = parms.ActivityType;
                    DailyActivity_s["@StartDate"]    = parms.Start;
                    DailyActivity_s["@EndDate"]      = parms.End;
                    var t = DailyActivity_s.ExecuteDataSet().Table0;
                    parms.Me.Dispatcher.Invoke((Action) delegate
                    {
                        var dv = (parms.Me.gridDailyActivity.ItemsSource as DataView);
                        if (dv != null)
                        {
                            dv.Table.Dispose();
                        }
                        parms.Me.gridDailyActivity.ItemsSource = t.DefaultView;
                        WPFHelpers.GridSort(parms.Me.gridDailyActivity, "Purchased", System.ComponentModel.ListSortDirection.Descending);
                    });
                }
            });
            _queryThread.Start(new DateRange(this, (string)cbxActivityType.SelectedValue, dateActivityStart.SelectedDate.Value, dateActivityEnd.SelectedDate.Value));

            if (_skipCbxActivityDateSelectionChanged)
            {
                return;
            }
            cbxActivityDate.SelectedValue = "CUSTOM";
        }
Beispiel #29
0
        protected override bool SaveSubClass()
        {
            //validate everything first so we see all the red boxes at once...
            var isValid = true;

            ValidateGeneric(ref isValid, "Rank");
            ValidateGeneric(ref isValid, "DEROS");
            ValidateGeneric(ref isValid, "DutyLocation");

            ValidateGeneric(ref isValid, "DutyPhoneDSN1", "'?'.Length == 3", "Enter 3 Digits");
            ValidateGeneric(ref isValid, "DutyPhoneDSN2", "'?'.Length == 4", "Enter 4 Digits");

            ValidateGeneric(ref isValid, "OfficialMailCMR");
            ValidateGeneric(ref isValid, "OfficialMailBox");
            ValidateGeneric(ref isValid, "OfficialMailCity");
            ValidateGeneric(ref isValid, "OfficialMailState");
            ValidateGeneric(ref isValid, "OfficialMailZip", "'?'.Length == 5", "Enter 5 Digits");

            ValidateGeneric(ref isValid, "HomePhoneCountry");
            ValidateGeneric(ref isValid, "HomePhone");

            var validateUTAP = Fields.Field <bool>("IsUTAPActive");

            ValidateGeneric(Fields, ref isValid, "HomeStreet,IsUTAPActive", validateUTAP);
            ValidateGeneric(Fields, ref isValid, "HomeStreetNumber,IsUTAPActive", validateUTAP);
            ValidateGeneric(Fields, ref isValid, "HomeCity,IsUTAPActive", validateUTAP);
            ValidateGeneric(Fields, ref isValid, "HomePostal,IsUTAPActive", validateUTAP);

            foreach (DataRowView member in HouseMembers)
            {
                ValidateGeneric(member, ref isValid, "SSN1", true, "'?'.Length == 3", "Enter 3 Digits");
                ValidateGeneric(member, ref isValid, "SSN2", true, "'?'.Length == 2", "Enter 2 Digits");
                ValidateGeneric(member, ref isValid, "SSN3", true, "'?'.Length == 4", "Enter 4 Digits");
                if (ValidateGeneric(member, ref isValid, "FName"))
                {
                    ValidateGeneric(member, ref isValid, "FName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case.");
                }
                if (ValidateGeneric(member, ref isValid, "LName"))
                {
                    ValidateGeneric(member, ref isValid, "LName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case.");
                }
            }

            if (!isValid)
            {
                ShowUserMessage("Please correct all highlighted fields before saving.");
                return(false);
            }

            //then save attempt to save everything if we made it through all the validation...
            if (Fields.IsDirty())
            {
                if (!SaveJustSponsorRecord())
                {
                    return(false);
                }
            }

            foreach (var member in HouseMembers.Cast <DataRowView>().Where(member => member.IsDirty()))
            {
// ReSharper disable InconsistentNaming
                using (Proc Client_u = new iTRAACProc("Client_u"))
// ReSharper restore InconsistentNaming
                {
                    Client_u.AssignValues(member);
                    if (!Client_u.ExecuteDataSet(UserMessagePrefix))
                    {
                        return(false);
                    }
                    member.AcceptChanges();
                    CacheTables(Client_u);
                }
            }

            RemarkModel.SaveRemarks("SponsorGUID", GUID, UserMessagePrefix, SponsorRemarks);

            return(true);
        }
Beispiel #30
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
        }
Beispiel #31
0
    public bool ReturnForm(bool isClosing = false, bool displaySuccess = true)
    {
      Save();

// ReSharper disable InconsistentNaming
      using (Proc TaxForm_ReturnFile = new iTRAACProc("TaxForm_ReturnFile"))
// ReSharper restore InconsistentNaming
      {
        TaxForm_ReturnFile["@TaxFormGUID"] = GUID;
        TaxForm_ReturnFile["@File"] = false;
        if (!TaxForm_ReturnFile.ExecuteDataSet(UserMessagePrefix + "Return - ", true)) return (false);

        //if we're firing Returned and this object is remaining visible (i.e. user didn't select the Return-and-Close button) then pull back the updated values reflecting the Returned status change
        if (!isClosing)
        {
          CacheTables(TaxForm_ReturnFile);
          OnPropertyChanged("Fields"); //nugget: amazingly inconsistent IMHO, DataTable.Merge() does *not* fire DataRowView.PropertyChanged events!?! (tsk tsk Microsoft!!) 
        }
      }

      OnFormStatusChange();
      return (true);
    }
Beispiel #32
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns>The SponsorGUID for the new replacement form</returns>
 public void VoidAndNew(out string sponsorGUID, out string newTaxFormGUID, out decimal serviceFee)
 {
   using (Proc taxFormVoidAndNew = new iTRAACProc("TaxForm_VoidAndNew"))
   {
     taxFormVoidAndNew["@VoidTaxFormGUID"] = GUID;
     sponsorGUID = taxFormVoidAndNew["@SponsorGUID"].ToString();
     newTaxFormGUID = taxFormVoidAndNew["@NewTaxFormGUID"].ToString();
     serviceFee = Convert.ToDecimal(taxFormVoidAndNew["@NewTaxFormGUID"]);
   }
 }
Beispiel #33
0
    public void SetCCodesSame()
    {
// ReSharper disable InconsistentNaming
      using (var Sponsor_SetCCodesSame = new iTRAACProc("Sponsor_SetCCodesSame"))
// ReSharper restore InconsistentNaming
      {
        Sponsor_SetCCodesSame["@SponsorGUID"] = GUID;
        if (HouseMembers.Count > 0)
          Sponsor_SetCCodesSame["@NewCCode"] = HouseMembers[0]["CCode"];
        CacheTables(Sponsor_SetCCodesSame);
        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
      }
    }
Beispiel #34
0
    public void SetSponsor(string newSponsorClientGUID, bool fixExistingPackageLinks)
    {
// ReSharper disable InconsistentNaming
      using (var Sponsor_SetSponsor = new iTRAACProc("Sponsor_SetSponsor"))
// ReSharper restore InconsistentNaming
      {
        Sponsor_SetSponsor["@SponsorGUID"] = GUID;
        Sponsor_SetSponsor["@NewSponsorClientGUID"] = newSponsorClientGUID;
        Sponsor_SetSponsor["@FixExistingPackageLinks"] = fixExistingPackageLinks;
        CacheTables(Sponsor_SetSponsor);
        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
      }
    }
Beispiel #35
0
    protected override bool SaveSubClass()
    {
      bool success = true;

      if (Fields.IsDirty())
      {
        using (var taxOfficeU = new iTRAACProc("TaxOffice_u"))
        {
          if (taxOfficeU.AssignValues(Current.Fields).ExecuteNonQuery("Tax Office - ", true))
            Fields.AcceptChanges();
          else success = false;
        }
      }

      if (UserTable.GetChanges() != null)
      {
        using (var userU = new iTRAACProc("User_u"))
        {
          foreach (DataRowView r in from DataRowView r in UserTable.DefaultView where r.IsDirty() select r)
          {
            if (userU.AssignValues(r).ExecuteNonQuery(String.Format("Saving User: {0} - ", r["UserNameId"])))
              r.AcceptChanges();
            else success = false;
          }
        }
      }

      return (success);
    }