- installation.zip
- Makanan2
- John Kenedy DAL.pdf
- JohnKenedy.DataAccess
- JohnKenedy.DataAccessModule
- MenuMakanan
- ProgramTools.sln
- SetupMakanan
- Debug
- Release
- SetupMakanan.vdproj
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using JohnKenedy.DataAccess;
namespace JohnKenedy.Samples
{
#region IEnumerator
public class MIngredientsEnumerator : IEnumerator<MIngredientsEntity>
{
MIngredientsEntityCollection _Item = null;
int _position = -1;
public MIngredientsEnumerator(MIngredientsEntityCollection _item)
{
_Item = _item;
}
public void Dispose()
{
}
public void Reset()
{
_position = -1;
}
public MIngredientsEntity Current
{
get
{
if (_position >= 0 && _position < _Item.Collection.Count)
{
return _Item.Collection[_position];
}
return null;
}
}
object IEnumerator.Current
{
get
{
if (_position >= 0 && _position < _Item.Collection.Count)
{
return _Item.Collection[_position];
}
return null;
}
}
public bool MoveNext()
{
_position += 1;
if (_position >= _Item.Collection.Count)
{
_position = -1;
return false;
}
return true;
}
}
#endregion
public class MIngredientsEntityCollection : IEnumerable<MIngredientsEntity>
{
#region Properties
private string _TableName = "MIngredients";
private DataAccessTableFiller _Filler = null;
public DataAccessTableFiller Filler
{
get
{
return _Filler;
}
}
private IList<MIngredientsEntity> _Collection = new List<MIngredientsEntity>();
public IList<MIngredientsEntity> Collection
{
get
{
return _Collection;
}
}
private DataTable _LastSelectTable = null;
public DataTable LastSelectTable
{
get
{
return _LastSelectTable;
}
}
#endregion
public MIngredientsEntityCollection()
{
}
public MIngredientsEntity this[int _index]
{
get
{
if (_index < _Collection.Count)
{
return _Collection[_index];
}
return null;
}
set
{
if (_index < _Collection.Count)
{
_Collection[_index] = value;
}
}
}
#region IEnumerable
public IEnumerator<MIngredientsEntity> GetEnumerator()
{
MIngredientsEnumerator _item = new MIngredientsEnumerator(this);
return _item;
}
IEnumerator IEnumerable.GetEnumerator()
{
MIngredientsEnumerator _item = new MIngredientsEnumerator(this);
return _item;
}
#endregion
public void SetDataByTable(DataTable _table)
{
_Collection.Clear();
if (_table == null) return;
foreach (DataRow _row in _table.Rows)
{
MIngredientsEntity _item = new MIngredientsEntity();
_item.Filler.SetColumnValueByDataRow(_row);
_Collection.Add(_item);
}
}
public void GetDataAll(string _sort)
{
IDbCommand _com = DataAccessLayer.Manager[_TableName].GetDataAll(_sort);
_LastSelectTable = DataAccessLayer.Manager[_TableName].ExecuteDataTableFromCommand(_com);
SetDataByTable(_LastSelectTable);
}
public void GetDataByManual(string _sql, IDbDataParameter[] _params)
{
IDbCommand _com = DataAccessLayer.Manager[_TableName].GetDataByManual(_sql, _params);
_LastSelectTable = DataAccessLayer.Manager[_TableName].ExecuteDataTableFromCommand(_com);
SetDataByTable(_LastSelectTable);
}
public void GetDataBy(IList<string> _selectColumn, IList<KeyValuePair<string, object>> _pairFilter, string _sort)
{
IDbCommand _com = DataAccessLayer.Manager[_TableName].GetDataBy(_selectColumn, _pairFilter, _sort);
_LastSelectTable = DataAccessLayer.Manager[_TableName].ExecuteDataTableFromCommand(_com);
SetDataByTable(_LastSelectTable);
}
public void GetDataByWhere(IList<string> _selectColumn, string _sql, IDbDataParameter[] _parameters, string _sort)
{
IDbCommand _com = DataAccessLayer.Manager[_TableName].GetDataByWhere(_selectColumn, _sql, _parameters, _sort);
_LastSelectTable = DataAccessLayer.Manager[_TableName].ExecuteDataTableFromCommand(_com);
SetDataByTable(_LastSelectTable);
}
public MIngredientsEntity[] FilterLastSelectByTableFilter(string _filter)
{
DataRow[] _rows = _LastSelectTable.Select(_filter);
MIngredientsEntity[] _results = new MIngredientsEntity[_rows.Length];
for (int i=0; i<_rows.Length; i++)
{
foreach(MIngredientsEntity _item in _Collection)
{
if (_item.RowData == _rows[i])
{
_results[i] = _item;
break;
}
}
}
return _results;
}
#region HeaderDetailModuleExtend
protected MFoodEntity _HeaderDetailMFoodHeader = null;
public void SetHeaderDetailMFoodHeader(MFoodEntity _header)
{
_HeaderDetailMFoodHeader = _header;
}
public MFoodEntity GetHeaderDetailMFoodHeader()
{
return _HeaderDetailMFoodHeader;
}
public long InsertHeaderDetailMIngredientsIdentityToHeader(MIngredientsEntity _detail)
{
return _detail.InsertHeaderDetailMIngredientsIdentityToHeader(_HeaderDetailMFoodHeader);
}
public int InsertHeaderDetailMIngredientsToHeader(MIngredientsEntity _detail)
{
return _detail.InsertHeaderDetailMIngredientsToHeader(_HeaderDetailMFoodHeader);
}
public int UpdateHeaderDetailMIngredientsToHeader(MIngredientsEntity _detail)
{
return _detail.UpdateHeaderDetailMIngredientsToHeader(_HeaderDetailMFoodHeader);
}
#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.