예제 #1
0
        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);
            }
        }
예제 #2
0
        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));
        }
예제 #3
0
        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);
                }
            }
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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));
            }
        }
예제 #10
0
        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));
        }
예제 #11
0
        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);
        }
예제 #12
0
 public void SetIDValue(Guid id)
 {
     BusinessObjectHelper.SetIDValue(this, id);
 }
예제 #13
0
        public BusinessObject GetObject(String strQuery)
        {
            DataSet ds = GetDataSet(strQuery);

            return(BusinessObjectHelper.GetBusinessObject(ds, TableName));
        }
예제 #14
0
 public BusinessObject GetObjectFromDataRow(DataRow row)
 {
     return(BusinessObjectHelper.GetBusinessObject(row, TableName));
 }
예제 #15
0
 public void SetNoValue(String strNo)
 {
     BusinessObjectHelper.SetNOValue(this, strNo);
 }
예제 #16
0
 public bool IsCleanObject( )
 {
     return(BusinessObjectHelper.IsCleanObject(this));
 }
예제 #17
0
        public BusinessObject GetObjectBySqlSP(string spName, params object[] paramValues)
        {
            DataSet ds = GetDataSetBySqlSP(spName, paramValues);

            return(BusinessObjectHelper.GetBusinessObject(ds, TableName));
        }
예제 #18
0
 public bool IsModifiedObject( )
 {
     return(BusinessObjectHelper.IsModifiedObject(this));
 }
예제 #19
0
 public bool IsExistObject( )
 {
     return(BusinessObjectHelper.IsExistObject(this));
 }
예제 #20
0
 public String GetNameValue( )
 {
     return(BusinessObjectHelper.GetNameValue(this));
 }
예제 #21
0
        public BusinessObject GetObjectByCondition(String strConditionQuery)
        {
            DataSet ds = GetDataSetByCondition(strConditionQuery);

            return(BusinessObjectHelper.GetBusinessObject(ds, TableName));
        }
예제 #22
0
 public Guid GetID( )
 {
     return(BusinessObjectHelper.GetIDValue(this));
 }