- 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.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using s = System;
using u = Util;
using ns = WinUI;
using ui=UIInterface.TransactionNWAccntDlts;
namespace WinUI
{
public partial class TransactionNWAccntDltsForm : Form, ui.IView
{
#region Data
ui.IPresenter _Prsntr;
string[] _collDltAllocAccntNames;
bool _bCloakUIHandlers;
bool _bInEdit;
bool _bEditValidated;
#endregion
#region Columns
System.Windows.Forms.DataGridViewComboBoxColumn _dgvcbcAccount;
DGTBColumn _dgvtcAmount;
#endregion
#region Private Functions
void CloakUIHandlers(bool b)
{
_bCloakUIHandlers = b;
}
bool IsUICloaked(){return _bCloakUIHandlers;}
void SetupColumns()
{
this._dgv.AutoGenerateColumns = false;
System.Windows.Forms.DataGridViewCellStyle oNumberColumnStyle = Misc.CreateDataGridViewCellStyleForAmountDisplay();
_dgvcbcAccount = new DataGridViewComboBoxColumn();
_dgvtcAmount = new DGTBColumn();
_dgvcbcAccount .HeaderText = "Accnt";
_dgvtcAmount .HeaderText = "Amount";
_dgvtcAmount.DefaultCellStyle = oNumberColumnStyle;
_dgvcbcAccount.DataSource = _collDltAllocAccntNames;
this._dgv.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
_dgvcbcAccount ,
_dgvtcAmount});
}
void HandleDownArrowPressed(bool bAdjustOnlyIfOnLast)
{
bool bOnLast = _dgv.CurrentCell.RowIndex == _dgv.RowCount - 1;
if (bOnLast)
{
if (this._dgv.ReadOnly)
return;
_Prsntr.NewRecordDesired();
}
if(bOnLast || !bAdjustOnlyIfOnLast)
_dgv.CurrentCell = _dgv.Rows[_dgv.CurrentCell.RowIndex+1].Cells[_dgv.CurrentCell.ColumnIndex];
}
#endregion
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}
#region Event Handlers
void tb_KeyDown(object sender, KeyEventArgs e)
{
// s.Diagnostics.Trace.WriteLine(string.Format("Caught keydown:{0}-{1}-{2}-{3}-{4}-{5} ",e.KeyCode, e.Shift, e.Alt, e.Control, e.KeyData, e.KeyValue));
if (e.KeyCode != Keys.Down)
return;
HandleDownArrowPressed(/*bAdjustOnlyIfOnLast=*/false);
}
void _btnSaveAndClose_Click(object sender, EventArgs e)
{
_Prsntr.CloseAndAcceptDesired();
}
void _dgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if(this.IsUICloaked())
return;
if ((e.Control is s.Windows.Forms.TextBox))
{
var tb = e.Control as s.Windows.Forms.TextBox;
tb.KeyDown -= new KeyEventHandler(tb_KeyDown);
tb.KeyDown += new KeyEventHandler(tb_KeyDown);
}
if(_dgv.CurrentCell.ColumnIndex == _dgvcbcAccount.Index)
{
var cb = e.Control as s.Windows.Forms.ComboBox;
AutoCompleteStringCollection acsc = new AutoCompleteStringCollection();
acsc.AddRange(_collDltAllocAccntNames);
cb.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cb.AutoCompleteSource = AutoCompleteSource.ListItems;
cb.AutoCompleteCustomSource = acsc;
}
}
bool LLBeginEditCell(int iRow, int iCol)
{
bool bOK = false;
if( iCol == this._dgvcbcAccount .Index)bOK = _Prsntr.EditAccountDesired( iRow);
else if(iCol == this._dgvtcAmount .Index)bOK = _Prsntr.EditAmountDesired( iRow);
else
throw new s.Exception();
return bOK;
}
private void _dgv_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
if(this.IsUICloaked())
return;
bool bOK = LLBeginEditCell(e.RowIndex, e.ColumnIndex);
if(!bOK) e.Cancel = true;
else
{
_bInEdit = true;
_bEditValidated = false;
}
}
void _dgv_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if(this.IsUICloaked())
return;
if(!_bEditValidated)
_Prsntr.CancelEdit();
_bInEdit = false;
_bEditValidated = false;
_dgv.Rows[e.RowIndex].ErrorText = String.Empty;
}
bool EditCell(int iRow, int iCol, string strVal)
{
bool bOK = LLBeginEditCell(iRow, iCol);
if(!bOK)
return false;
string strError = _Prsntr.SetValueAndEndEditOrReturnError(strVal);
if(strError != null)
return false;
return true;
}
void _dgv_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Down)
{
HandleDownArrowPressed(/*bAdjustOnlyIfOnLast=*/true);
return;
}
if (e.Control && e.KeyCode == Keys.V)
{
_Prsntr.BeginBatchUpdates();
bool bHasUnhandledErrors;
ns.Misc.PasteClipboardDataToGrid(_dgv, null, EditCell, out bHasUnhandledErrors);
_Prsntr.EndBatchUpdates();
if(bHasUnhandledErrors)
s.Windows.Forms.MessageBox.Show("Not all the values could be updated.");
return;
}
}
void _cbReverseSign_CheckedChanged(object sender, EventArgs e)
{
if(this.IsUICloaked())
return;
_Prsntr.DisplayWithReverseSignDesired(_cbReverseSign.Checked);
}
void _cbCents_CheckedChanged(object sender, EventArgs e)
{
if(this.IsUICloaked())
return;
_Prsntr.DisplayAsCentsDesired(_cbCents.Checked);
}
void _dgv_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if(this.IsUICloaked())
return;
if(!_bInEdit)
return;
string strError = _Prsntr.SetValueAndEndEditOrReturnError(e.FormattedValue.ToString());
if(strError !=null)
{
_dgv.Rows[e.RowIndex].ErrorText = strError;
e.Cancel = true;
}
else
_bEditValidated = true;
}
#endregion
#region IView functions
public void SetPresenter( ui.IPresenter aPresenter){_Prsntr = aPresenter ;}
public void ShowBusyIndicator( ){Misc.ShowBusyIndicator() ;}
public void ClearBusyIndicator( ){Misc.ClearBusyIndicator() ;}
public void ShowSimpleMessage( string str ){Misc.ShowSimpleMessage(str) ;}
public void ShowException( System.Exception ex ){Misc.ShowException(ex) ;}
public void Init(string[] arrAccountOptions, bool bReadOnly)
{
_dgv.ReadOnly = bReadOnly;
_btnSaveAndClose.Enabled = !bReadOnly;
_collDltAllocAccntNames = arrAccountOptions;
SetupColumns();
}
public void SetRowCount(int iRows)
{
using(Cloak aCloak = new Cloak(CloakUIHandlers))
{
_dgv.RowCount = iRows;
}
}
public void SetAccount(string str, int iRow)
{
using(Cloak aCloak = new Cloak(CloakUIHandlers))
{
this._dgv.Rows[iRow].Cells[_dgvcbcAccount.Index].Value = str;
}
}
public void SetAmount(string str, int iRow)
{
using(Cloak aCloak = new Cloak(CloakUIHandlers))
{
this._dgv.Rows[iRow].Cells[this._dgvtcAmount.Index].Value = str;
}
}
public void IndicateCentsBeingDisplayed(bool b)
{
using(Cloak aCloak = new Cloak(CloakUIHandlers))
{
this._cbCents.Checked = b;
}
}
public void IndicateSignReversed(bool b)
{
using(Cloak aCloak = new Cloak(CloakUIHandlers))
{
this._cbReverseSign.Checked = b;
}
}
public void SetBalance(string str, bool bInBalance)
{
if(bInBalance)
{
this._tbBalance.BackColor = s.Drawing.SystemColors.Window;
this._tbBalance.ForeColor = s.Drawing.SystemColors.WindowText;
}
else
{
this._tbBalance.BackColor = s.Drawing.Color.White;
this._tbBalance.ForeColor = s.Drawing.Color.Red;
}
this._tbBalance.Text = str;
}
public void FreezeDisplay()
{
}
public void UpdateDisplay()
{
}
public void ShowUntilUserDoneAndThenDestroy()
{
this.ShowDialog();
this.Dispose();
}
#endregion
#region Other Public Functions
public TransactionNWAccntDltsForm()
{
InitializeComponent();
}
#endregion
}
}
|
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.