private void SetInvoiceCounts()
 {
     if (ToDateAll != null && FromDateAll != null && InvoiceTarget != null)
     {
         InvoiceCounts = InvoiceTarget.FetchCount(FromDateAll, ToDateAll);
     }
 }
 public void AddGroups()
 {
     try
     {
         PopSwitch = false;
         foreach (InvoiceGroup group in SelectedGroups)
         {
             group.ContractID = CurrentContract.CONTRACT_ID;
             InvoiceTarget.Update(group);
             //GroupsAssigned.Add(group);
         }
     }
     catch (Exception x)
     {
         _view.ShowMsg(x.ToString());
     }
     SetContractDetails();
 }
 public void RemoveGroups()
 {
     try
     {
         foreach (InvoiceGroup group in SelectedGroups)
         {
             group.ContractID = null;
             InvoiceTarget.Update(group);
             //SelectedGroups.Remove(group);
             //GroupsAssigned.Remove(group);
         }
     }
     catch (Exception x)
     {
         _view.ShowMsg(x.ToString());
     }
     SetContractDetails();
 }
 void SetContractDetails()
 {
     if (currentContract == null)
     {
         //this.GracePeriod = 0;
         this.GroupsAssigned      = null;
         this.SelectedPaymentTerm = null;
         return;
     }
     SelectedPaymentTerm = (PaymentTermList.FirstOrDefault(ptl => ptl.PAYMENT_TERMS == currentContract.PAYMENT_TERMS) as PaymentTerm);
     // Because this comes from the INVOICE_GRP table
     // and if they are adding a NEW contract, then it's ID
     // has not yet been assigned and no fetch action can take place
     GroupsAssigned = (currentContract.CONTRACT_ID == 0) ? null : InvoiceTarget.FetchGroups(null,
                                                                                            null,
                                                                                            currentContract.CONTRACT_ID.ToString(),
                                                                                            null);
     currentContract.Modified = false;
 }
 void Refresh()
 {
     try
     {
         Loading = visible;
         if (OnlyThisGroup)
         {
             Invoices = InvoiceTarget.FetchInvoices(FromDate, ToDate, CurrentGroupItem.InvoiceGrpId, !ByRange);
         }
         else
         {
             Invoices = InvoiceTarget.FetchInvoices(FromDate, ToDate, null, !ByRange);
         }
         Loading = hidden;
     }
     catch (Exception x)
     {
         ThisView.ShowMsg(x.ToString());
     }
 }