- lek.zip
- ChangeLog.txt
- ClientServer
- ClientUtil
- DalEF
- DalLinqToSql
- DalNH
- DomainUtil
- DomainUtilTest
- DTO
- GlobalType
- Lek.sln
- Lek1.vsmdi
- LocalTestRun.testrunconfig
- NHibernate
- NhLambdaExtensions
- Presenter
- ProjDep.ppt
- Schema.ppt
- SchemaAdd.sql
- SchemaAdd2000.sql
- SchemaAdd2000Raw.sql
- SchemaDrop.sql
- ServerUtil
- ServiceEF
- ServiceFactory
- ServiceInterface
- ServiceInterfaceTest
- ServiceLinqToSql
- ServiceNH
- Transaction.sql
- UIInterface
- UIType
- Util
- UtilTest
- Web
- 001Launch.gif
- 002Transactions.gif
- 002TransactionsSHRUNK.gif
- 003Items.gif
- 004ERD.gif
- 005NWAccntDlts.gif
- 006Transaction.gif
- 007Arch_Base.gif
- 008Arch_Util.gif
- 009Arch_WinApp.gif
- 010Arch_ClientServer.gif
- 011Arch_UIInterface.gif
- 012Arch_GlobalType.gif
- 013Arch_DTO.gif
- 014Arch_TierUtils.gif
- 015Arch_Dal.gif
- 016Arch_ORM.gif
- 017ERDSQL.gif
- 018ERDEF.gif
- 018ERDEFSHRUNK.gif
- 019ERDLinqToSQL.gif
- 019ERDLinqToSQLSHRUNK.gif
- AddORMClasses_EF.GIF
- AddORMClasses_LtS.GIF
- csharp.css
- DalEFProject.GIF
- DalLinqToSqlProject.GIF
- DalNHlProject.GIF
- DeltaAllocationAccounts.GIF
- DependencyMatrix.GIF
- Items.GIF
- ItemsForAnAccount.gif
- ItemsForAnAccountSHRUNK.gif
- ItemsSHRUNK.GIF
- Lek.GIF
- lek.htm
- NetWorthAccountDeltasForAnAccount.GIF
- NetWorthAccounts.GIF
- Ownerships.GIF
- Participants.GIF
- SaveTransFunctions.GIF
- Summary.GIF
- WinApp
- WinFormClient
- WinFormServer
- WinUI
- WRLEASTransaction.sql
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using sch = Schema;
using s = System;
using cub = ClientUtil;
//using ddal = DomainDAL;
using du = DomainUtil;
using u = Util;
using ns = Presenter;
using ui=UIInterface.Ownership;
using uib=UIInterface;
using si=ServiceInterface;
using uit=UIType.Ownership;
using gt=GlobalType;
namespace Presenter
{
public class Ownership : C, ui.IPresenter
{
class DataForUI
{
public string[] Participants;
public uit.SharesForAccount[] SharesForAccounts;
}
class DataFromDB
{
public u.ROArray<DTO.Cache.Ownership> Ownerships;
public u.ROArray<DTO.Cache.NWAccnt> Accounts;
public du.Participants Participants;
}
si.IService _Service;
ui.IView _view;
DataFromDB _DataFromDB;
DataForUI _DataForUI;
protected override UIInterface.IView GetView(){return _view;}
static DataFromDB GetDataFromDB(si.IService ddal)
{
DataFromDB output = new DataFromDB();
output.Participants = CreateDomainParticipants(ddal.GetParticipants());
DTO.Cache aCache = ddal.GetCache();
output.Ownerships = aCache.Ownerships;
output.Accounts = aCache.NWAccnts;
return output;
}
static DataForUI RepackageDataForUI(DataFromDB aDataFromDB)
{
DataForUI output = new DataForUI();
cub.OwnershipDictionary aOwnershipDictionary = new ClientUtil.OwnershipDictionary(aDataFromDB.Ownerships, aDataFromDB.Participants);
var lstSharesForAccounts = new List<uit.SharesForAccount>();
foreach(DTO.Cache.NWAccnt aNWAccnt in aDataFromDB.Accounts)
{
uit.SharesForAccount o = new uit.SharesForAccount();
o.Account = aNWAccnt.Name;
o.Shares = aOwnershipDictionary.GetParticipantShares(aNWAccnt.ID);
lstSharesForAccounts.Add(o);
}
gt.IParticipant[] arrParticipantObjects = aDataFromDB.Participants.GetArryOfObjects();
output.Participants = arrParticipantObjects.Select( p=>p.Name).ToArray();
output.SharesForAccounts = lstSharesForAccounts.ToArray();
return output;
}
static DTO.Ownership[] GetNewValues(DataFromDB aDataFromDB, ui.IView view)
{
List<DTO.Ownership> lstOwnerships = new List<DTO.Ownership>();
ClientUtil.OwnershipDictionary aOwnershipDictionary = new ClientUtil.OwnershipDictionary(aDataFromDB.Ownerships, aDataFromDB.Participants);
for (int iNWAccnt = 0; iNWAccnt < aDataFromDB.Accounts.Count; iNWAccnt++)
{
int iNWAccntID = aDataFromDB.Accounts[iNWAccnt].ID;
int[] arrSharesLastRetreivedFromDB = aOwnershipDictionary.GetParticipantShares(iNWAccntID);
for (int iPI = 0; iPI < aDataFromDB.Participants.Count; iPI++)
{
int iShareInView = view.GetShare(iPI, iNWAccnt);
if (iShareInView == arrSharesLastRetreivedFromDB[iPI])
continue;
int iParticipantID = aDataFromDB.Participants.IDFromIndex(iPI);
var dto = new DTO.Ownership(iNWAccntID, iParticipantID, iShareInView);
lstOwnerships.Add(dto);
}
}
return lstOwnerships.ToArray();
}
public Ownership(uib.IViewFactory theViewFactory, si.IService theService)
{
_Service = theService;
_view = theViewFactory.CreateViewForOwnership();
_view.SetPresenter(this);
_DataFromDB = GetDataFromDB(_Service);
_DataForUI = RepackageDataForUI(_DataFromDB);
}
public void Show()
{
_view.Show(_DataForUI.Participants, _DataForUI.SharesForAccounts);
}
public void LLSaveChangesDesired()
{
DTO.Ownership[] arr = GetNewValues(_DataFromDB, _view);
if(arr==null)
return;
if(arr.Length==0)
return;
_Service.UpdateOwnerships(arr);
DataFromDB aDataFromDB = GetDataFromDB(_Service);
DataForUI aDataForUI = RepackageDataForUI(aDataFromDB);
_view.ReLoad(aDataForUI.Participants, aDataForUI.SharesForAccounts);
_DataFromDB = aDataFromDB;
}
public void SaveChangesDesired()
{
this.ExecuteWithErrorHandlingAndBusyIndicatorAndDoneMessage(LLSaveChangesDesired);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.