- installation_-_sqlexpr.zip
- Makanan2
- John Kenedy DAL.pdf
- JohnKenedy.DataAccess
- JohnKenedy.DataAccessModule
- MenuMakanan
- ProgramTools.sln
- ProgramTools.suo
- SetupMakanan
- Debug
- Release
- SetupMakanan.vdproj
- SetupMakananSqlExpr
- Debug
- Release
- SetupMakananSqlExpr.vdproj
|
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using JohnKenedy.DataAccess;
namespace JohnKenedy.Samples
{
public class MUserEntity
{
#region Properties
private string _TableName = "MUser";
private DataAccessTableFiller _Filler = null;
public DataAccessTableFiller Filler
{
get
{
return _Filler;
}
}
public DataRow RowData
{
get
{
if (Filler != null) return Filler.RowData;
return null;
}
}
#endregion
public MUserEntity()
{
_Filler = DataAccessLayer.Manager[_TableName].GetFiller();
}
public void SetDataByDataRow(DataRow _row)
{
Filler.SetColumnValueByDataRow(_row);
}
public MUserEntity GetFullDataByUniqueRow()
{
MUserEntityCollection _collection = new MUserEntityCollection();
IList<IDbDataParameter> _parameters = new List<IDbDataParameter>();
string _sql = Filler.GetWhereFilterByAll(ref _parameters);
_collection.GetDataByWhere(null, _sql, _parameters.ToArray<IDbDataParameter>(), null);
if (_collection.Collection.Count <= 0) return null;
return _collection[0];
}
public MUserEntity GetFullDataByPrimaryKey()
{
MUserEntityCollection _collection = new MUserEntityCollection();
IDbDataParameter[] _parameters = null;
string _sql = Filler.GetWhereFilterByPrimaryKey(ref _parameters);
_collection.GetDataByWhere(null, _sql, _parameters, null);
if (_collection.Collection.Count <= 0) return null;
return _collection[0];
}
public long InsertIdentity()
{
ModifyFillerLoginMUserEncryptPasswordColumn();
IDbCommand _com = Filler.GetInsertStatementFilterIdentity();
long _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryInsertIdentityValueFromCommand(_Filler);
return _result;
}
public int Insert()
{
ModifyFillerLoginMUserEncryptPasswordColumn();
IDbCommand _com = Filler.GetInsertStatementNoFilter();
int _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryInsertFromCommand(_Filler);
return _result;
}
public int Delete()
{
IDbCommand _com = Filler.GetDeleteStatementForAllFilter();
int _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryDeleteFromCommand(_Filler);
return _result;
}
public int DeletePrimaryKey()
{
IDbCommand _com = Filler.GetDeleteStatementForPrimaryKey();
int _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryDeleteFromCommand(_Filler);
return _result;
}
public int DeleteByWhere(string _sql, IDbDataParameter[] _parameters)
{
return DataAccessLayer.Manager[_TableName].ExecuteNonQueryDeleteFromWhere(_sql, _parameters);
}
public int Update()
{
IDbCommand _com = Filler.GetUpdateStatementFilterIdentity();
int _result = DataAccessLayer.Manager[_TableName].ExecuteNonQueryUpdateFromCommand(_Filler);
return _result;
}
#region LoginModuleExtend
public void ModifyFillerLoginMUserEncryptPasswordColumn()
{
BusinessHash _hash = new BusinessHash(ServiceProviderEnum.MD5);
_hash.Salt = "~M@k@N4n3N@K/";
string _username = Filler.GetColumnValue("Username").ToString();
string _password = Filler.GetColumnValue("Password").ToString();
string _encPassword = _hash.Encrypt(_username.ToLower() + _password);
Filler.AddColumnValue("Password", _encPassword);
}
public int InsertLoginMUserPassword()
{
ModifyFillerLoginMUserEncryptPasswordColumn();
return Insert();
}
public bool IsLoginMUserValid(string _username, string _password)
{
BusinessHash _hash = new BusinessHash(ServiceProviderEnum.MD5);
_hash.Salt = "~M@k@N4n3N@K/";
_password = _hash.Encrypt(_username.ToLower() + _password);
Filler.AddColumnValue("Username", _username);
MUserEntity _item = GetFullDataByUniqueRow();
if (_item == null) return false;
object _pass = _item.Filler.GetColumnValue("Password");
if (_pass == null) return false;
if (_pass.ToString() == _password) return true;
return false;
}
#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.