public void UpdateObject(BusinessObject obj) { if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colSelected)) { ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colSelected, false); } if (String.IsNullOrWhiteSpace(ABCBaseUserProvider.CurrentUserName) == false && DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colUpdateUser)) { ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colUpdateUser, ABCBaseUserProvider.CurrentUserName); } if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colUpdateTime)) { ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colUpdateTime, ABCApp.ABCDataGlobal.WorkingDate); } BusinessObjectHelper.GenerateNoColumn(obj, false); if (DatabaseHelper.IsSQLConnection()) { (DatabaseHelper as SqlDatabaseHelper).RunStoredProcedure(StoredProcedureGenerator.GetSPName(StoredProcedureGenerator.SPType.Update, TableName), obj); } else { DatabaseHelper.RunScript(QueryTemplateGenerator.GenUpdate(TableName), obj); } }
public BusinessObject GetTemplateObject( ) { String strSQL = String.Format("Select * From [{0}] Where [{1}]='{2}'", TableName, ABCCommon.ABCConstString.colABCStatus, ABCCommon.ABCConstString.ABCStatusTemplate); DataSet ds = DatabaseHelper.RunQuery(strSQL); return(BusinessObjectHelper.GetBusinessObject(ds, TableName)); }
public void GetFromBusinessObject(BusinessObject objBusinessObject) { BusinessObjectHelper.InitPropertyList(this.AATableName); BusinessObjectHelper.InitPropertyList(objBusinessObject.AATableName); foreach (PropertyInfo srcProp in BusinessObjectHelper.PropertyList[objBusinessObject.AATableName].Values) { PropertyInfo destProp = BusinessObjectHelper.GetProperty(this.AATableName, srcProp.Name); if (destProp != null) { object objValue = ABCDynamicInvoker.GetValue(objBusinessObject, srcProp); ABCDynamicInvoker.SetValue(this, destProp, objValue); } } }
public BusinessObject GetObjectByName(String strObjectName) { DataSet ds = null; if (DatabaseHelper.IsSQLConnection()) { ds = (DatabaseHelper as SqlDatabaseHelper).RunStoredProcedure(StoredProcedureGenerator.GetSPName(StoredProcedureGenerator.SPType.SelectByName, TableName), strObjectName); } else { ds = (DatabaseHelper as SQLiteDatabaseHelper).RunScript(QueryGenerator.GenSelectByName(TableName, strObjectName, false, true)); } return(BusinessObjectHelper.GetBusinessObject(ds, TableName)); }
public BusinessObject SetToBusinessObject(String strDestTableName) { BusinessObject objResultObject = BusinessObjectFactory.GetBusinessObject(strDestTableName + "Info"); foreach (PropertyInfo destProp in BusinessObjectHelper.PropertyList[strDestTableName].Values) { PropertyInfo srcProp = BusinessObjectHelper.GetProperty(this.AATableName, destProp.Name); if (srcProp != null) { object objValue = ABCDynamicInvoker.GetValue(this, srcProp); ABCDynamicInvoker.SetValue(objResultObject, destProp, objValue); } } return(objResultObject); }
public virtual Guid CreateObject(BusinessObject obj) { #region Default Value if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colSelected)) { ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colSelected, false); } if (String.IsNullOrWhiteSpace(ABCBaseUserProvider.CurrentUserName) == false && DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateUser)) { ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colCreateUser, ABCBaseUserProvider.CurrentUserName); } if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateTime)) { ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colCreateTime, ABCApp.ABCDataGlobal.WorkingDate); } #endregion Guid iID = Guid.Empty; if (DatabaseHelper.IsSQLConnection()) { iID = ABCHelper.DataConverter.ConvertToGuid((DatabaseHelper as SqlDatabaseHelper).RunStoredProcedure(StoredProcedureGenerator.GetSPName(StoredProcedureGenerator.SPType.Insert, TableName), obj)); } else { String strQuery = QueryTemplateGenerator.GenInsert(TableName); iID = Guid.NewGuid(); strQuery = strQuery.Replace(String.Format("@{0}", DataStructureProvider.GetPrimaryKeyColumn(TableName)), "'" + iID.ToString() + "'"); DatabaseHelper.RunScript(strQuery, obj); } ABCDynamicInvoker.SetValue(obj, DataStructureProvider.GetPrimaryKeyColumn(obj.AATableName), iID); if (BusinessObjectHelper.GenerateNoColumn(obj, true)) { UpdateObject(obj); } return(iID); }
public static void SetValue(BusinessObject obj, String strColName, object value) { string key = obj.AATableName + strColName; try { SetHandler setHandler = null; if (lstSetHandler.TryGetValue(key, out setHandler) == false) { Type type = obj.GetType(); PropertyInfo proInfo = BusinessObjectHelper.GetProperty(obj.AATableName, strColName); if (proInfo == null) { proInfo = type.GetProperty(strColName); } setHandler = ABCDynamicMethodCompiler.CreateSetHandler(type, proInfo); lstSetHandler.Add(key, setHandler); } if (value is String && value.ToString().Replace("'", "").ToUpper() == "TRUE") { value = true; } else if (value is String && value.ToString().Replace("'", "").ToUpper() == "FALSE") { value = false; } setHandler(obj, value); } catch (System.Exception ex) { PropertyInfo proInfo = obj.GetType().GetProperty(strColName); if (proInfo == null) { // Utilities.ABCLogging.LogNewMessage( "ABCDataLib" , "" , "SetValue" , obj.GetType().Name+" not contain "+strColName , "FAILE" ); return; } proInfo.SetValue(obj, value, null); } }
public BusinessObject GetObjectByID(Guid iObjectID) { try { DataSet ds = null; if (DatabaseHelper.IsSQLConnection()) { ds = (DatabaseHelper as SqlDatabaseHelper).RunStoredProcedure(StoredProcedureGenerator.GetSPName(StoredProcedureGenerator.SPType.Select, TableName), iObjectID); } else { ds = (DatabaseHelper as SQLiteDatabaseHelper).RunScript(QueryGenerator.GenSelectByID(TableName, iObjectID)); } return(BusinessObjectHelper.GetBusinessObject(ds, TableName)); } catch (Exception ex) { return(null); } }
public static object GetValue(BusinessObject obj, String strColName) { if (obj == null) { return(null); } string key = obj.AATableName + strColName; try { GetHandler getHandler = null; if (lstGetHandler.TryGetValue(key, out getHandler) == false) { Type type = obj.GetType(); PropertyInfo proInfo = BusinessObjectHelper.GetProperty(obj.AATableName, strColName); if (proInfo == null) { proInfo = type.GetProperty(strColName); } getHandler = ABCDynamicMethodCompiler.CreateGetHandler(type, proInfo); lstGetHandler.Add(key, getHandler); } return(getHandler(obj)); } catch (System.Exception ex) { PropertyInfo proInfo = obj.GetType().GetProperty(strColName); if (proInfo == null) { // Utilities.ABCLogging.LogNewMessage( "ABCDataLib" , "" , "GetValue" , obj.GetType().Name+" not contain "+strColName , "FAILE" ); return(null); } return(proInfo.GetValue(obj, null)); } }
public BusinessObject GetFirstObject( ) { StringBuilder strBuilder = new StringBuilder(); strBuilder.Append(String.Format("Select Top(1) * From [{0}] ", TableName)); if (DataStructureProvider.IsExistABCStatus(TableName)) { strBuilder.Append(" WHERE "); strBuilder.Append(String.Format("[{0}]='{1}'", ABCCommon.ABCConstString.colABCStatus, ABCCommon.ABCConstString.ABCStatusAlive)); } String strQuery = strBuilder.ToString(); if (DatabaseHelper.IsSQLConnection() == false) { strQuery = SQLiteDatabaseHelper.RepairSelectSQLite(strQuery); } DataSet ds = DatabaseHelper.RunQuery(strQuery); return(BusinessObjectHelper.GetBusinessObject(ds, TableName)); }
public static bool CopyFKFields(BusinessObject objFrom, BusinessObject objTo, Boolean isCleanFieldOnly) { if (objFrom == null || objTo == null) { return(false); } bool isCopied = false; String strFromName = objFrom.AATableName; String strToName = objTo.AATableName; BusinessObjectHelper.InitPropertyList(strToName); foreach (PropertyInfo propTo in BusinessObjectHelper.PropertyList[strToName].Values) { if (DataStructureProvider.IsForeignKey(strToName, propTo.Name) == false) { continue; } PropertyInfo propFrom = BusinessObjectHelper.GetProperty(strFromName, propTo.Name); if (propFrom != null) { if (isCleanFieldOnly == false || (isCleanFieldOnly && IsCleanField(objTo, propTo.Name))) { object objValue = ABCDynamicInvoker.GetValue(objFrom, propFrom); object objOldValue = ABCDynamicInvoker.GetValue(objTo, propTo); ABCDynamicInvoker.SetValue(objTo, propTo, objValue); if (objOldValue != objValue) { isCopied = true; } } } } return(isCopied); }
public void SetIDValue(Guid id) { BusinessObjectHelper.SetIDValue(this, id); }
public BusinessObject GetObject(String strQuery) { DataSet ds = GetDataSet(strQuery); return(BusinessObjectHelper.GetBusinessObject(ds, TableName)); }
public BusinessObject GetObjectFromDataRow(DataRow row) { return(BusinessObjectHelper.GetBusinessObject(row, TableName)); }
public void SetNoValue(String strNo) { BusinessObjectHelper.SetNOValue(this, strNo); }
public bool IsCleanObject( ) { return(BusinessObjectHelper.IsCleanObject(this)); }
public BusinessObject GetObjectBySqlSP(string spName, params object[] paramValues) { DataSet ds = GetDataSetBySqlSP(spName, paramValues); return(BusinessObjectHelper.GetBusinessObject(ds, TableName)); }
public bool IsModifiedObject( ) { return(BusinessObjectHelper.IsModifiedObject(this)); }
public bool IsExistObject( ) { return(BusinessObjectHelper.IsExistObject(this)); }
public String GetNameValue( ) { return(BusinessObjectHelper.GetNameValue(this)); }
public BusinessObject GetObjectByCondition(String strConditionQuery) { DataSet ds = GetDataSetByCondition(strConditionQuery); return(BusinessObjectHelper.GetBusinessObject(ds, TableName)); }
public Guid GetID( ) { return(BusinessObjectHelper.GetIDValue(this)); }