예제 #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);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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";
    }
예제 #5
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);
    }
예제 #6
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);
    }
예제 #7
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";
        }
예제 #8
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);
        }
예제 #9
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);
    }
예제 #10
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);
    }