public virtual void DeleteObject(int iObjectID) { DbCommand storedProcedure = SqlDatabaseHelper.GetStoredProcedure(this.GenerateDeleteStoredProcedureName()); SqlDatabaseHelper.AddInParameter(storedProcedure, SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName), SqlDbType.Int, (object)iObjectID); SqlDatabaseHelper.RunStoredProcedure(storedProcedure); }
private string GenerateUpdateQueryWhereClause(DataSet dsTableColumns) { string empty = string.Empty; string primaryKeyColumn = SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName); return(empty + "[" + primaryKeyColumn + "] = @" + primaryKeyColumn); }
public virtual DataSet GetDataSetByID(int iObjectID) { DbCommand storedProcedure = SqlDatabaseHelper.GetStoredProcedure(this.GenerateSelectByPrimaryKeyStoredProcedureName()); SqlDatabaseHelper.AddInParameter(storedProcedure, SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName), SqlDbType.Int, (object)iObjectID); return(SqlDatabaseHelper.RunStoredProcedure(storedProcedure)); }
public DataSet DeleteMembersFromOwner(string strOwnerTable, int iOwnerID, string strMemberTable, string strSwitcherTable) { string primaryKeyColumn1 = SqlDatabaseHelper.GetPrimaryKeyColumn(strOwnerTable); SqlDatabaseHelper.GetPrimaryKeyColumn(strSwitcherTable); string primaryKeyColumn2 = SqlDatabaseHelper.GetPrimaryKeyColumn(strMemberTable); string str = string.Format("Select [{0}] From [{1}] Where [{1}].[{2}] IN (Select [{2}] From [{3}] Where [{3}].[{2}]={4}))", (object)primaryKeyColumn2, (object)strSwitcherTable, (object)primaryKeyColumn1, (object)strOwnerTable, (object)iOwnerID); return(SqlDatabaseHelper.RunQuery(SqlDatabaseHelper.GetQuery(string.Format("Detete From [{0}] Where [{1}] IN ({2})", (object)strMemberTable, (object)primaryKeyColumn2, (object)str)))); }
public void DeleteAllObjectsByObjectParentID(int iObjectParentID) { string primaryKeyColumn = SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName); string strColumnName = primaryKeyColumn.Substring(0, primaryKeyColumn.Length - 2) + "ParentID"; if (!SqlDatabaseHelper.ColumnIsExistInTable(this.TableName, strColumnName)) { return; } SqlDatabaseHelper.RunQuery(SqlDatabaseHelper.GetQuery(string.Format("Update [{0}] Set AAStatus = 'Delete' Where ([{1}]={2}) And ({2}>0)", (object)this.TableName, (object)strColumnName, (object)iObjectParentID))); }
public virtual object GetDeletedObjectByID(int iObjectID) { DbCommand storedProcedure = SqlDatabaseHelper.GetStoredProcedure(this.GenerateSelectDeletedByPrimayKeyStoredProcedureName()); SqlDatabaseHelper.AddInParameter(storedProcedure, SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName), SqlDbType.Int, (object)iObjectID); DataSet dataSet = SqlDatabaseHelper.RunStoredProcedure(storedProcedure); if (dataSet.Tables.Count <= 0) { return((object)null); } return(SqlDatabaseHelper.GetSingleObject(dataSet.Tables[0], this.ObjectType)); }
public virtual string GetObjectNoByID(int iObjectID) { object objectById = this.GetObjectById(iObjectID); if (objectById != null) { PropertyInfo property = this.ObjectType.GetProperty(SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName).Substring(0, SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName).Length - 2) + "No"); if (property != null) { return(property.GetValue(objectById, (object[])null).ToString()); } } return(string.Empty); }
public virtual void DeleteObject(int iObjectID, DbTransaction transaction) { try { DbCommand storedProcedure = SqlDatabaseHelper.GetStoredProcedure(this.GenerateDeleteStoredProcedureName()); SqlDatabaseHelper.AddInParameter(storedProcedure, SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName), SqlDbType.Int, (object)iObjectID); storedProcedure.Transaction = transaction; SqlDatabaseHelper.RunStoredProcedure(storedProcedure); SqlDatabaseHelper.CommitTransaction(transaction); } catch (Exception ex) { SqlDatabaseHelper.RollbackTransaction(transaction); } }
public DataSet GetAllObjectsByObjectParentID(int iObjectParentID) { string primaryKeyColumn = SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName); return(SqlDatabaseHelper.RunQuery(SqlDatabaseHelper.GetQuery(string.Format("Select *, (select COUNT(*) from [{0}] tbl2 where tbl2.[{1}] = tbl1.[{3}] and tbl2.AAStatus = 'Alive') as TheNumberOfChild From [{0}] tbl1 Where AAStatus = 'Alive' And ([{1}]={2}) And ({2}>0)", (object)this.TableName, (object)(primaryKeyColumn.Substring(0, primaryKeyColumn.Length - 2) + "ParentID"), (object)iObjectParentID, (object)primaryKeyColumn)))); }
private string GenerateDeleteQuery() { return(string.Format("DELETE FROM [dbo].[{0}] WHERE [{1}]=@{2}", (object)this.TableName, (object)SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName), (object)SqlDatabaseHelper.GetPrimaryKeyColumn(this.TableName))); }
public static int InsertObject(object obj, DALBaseProvider provider, string spName, DbTransaction transaction) { try { DbCommand storedProcCommand = ((Database)SqlDatabaseHelper.database).GetStoredProcCommand(spName); SqlDatabaseHelper.AddParameterForObject(obj, provider, storedProcCommand); storedProcCommand.Transaction = transaction; ((Database)SqlDatabaseHelper.database).ExecuteNonQuery(storedProcCommand, transaction); transaction.Commit(); return((int)((Database)SqlDatabaseHelper.database).GetParameterValue(storedProcCommand, SqlDatabaseHelper.GetPrimaryKeyColumn(provider.TableName))); } catch (Exception ex) { transaction.Rollback(); throw ex; } }
public static int GetMaxID(string tableName) { int num = 0; string str = string.Format("SELECT Max({0}) AS MaxID FROM [{1}]", (object)SqlDatabaseHelper.GetPrimaryKeyColumn(tableName), (object)tableName); DbCommand sqlStringCommand = ((Database)SqlDatabaseHelper.database).GetSqlStringCommand(str); DataSet dataSet = ((Database)SqlDatabaseHelper.database).ExecuteDataSet(sqlStringCommand); if (dataSet.Tables.Count > 0) { DataRow row = dataSet.Tables[0].Rows[0]; if (row[0].ToString() != "") { num = (int)row[0]; } } return(num); }
public static object GetPrimaryColumnValue(object obj, DALBaseProvider provider) { string primaryKeyColumn = SqlDatabaseHelper.GetPrimaryKeyColumn(provider.TableName); return(provider.ObjectType.GetProperty(primaryKeyColumn).GetValue(obj, (object[])null)); }
public static void SetValueToIDStringColumn(object obj, DALBaseProvider provider, int iObjectID) { string primaryKeyColumn = SqlDatabaseHelper.GetPrimaryKeyColumn(provider.TableName); provider.ObjectType.GetProperty(primaryKeyColumn + "String")?.SetValue(obj, (object)iObjectID.ToString(), (object[])null); }
public static DataSet GetObjectbyId(string tableName, int id) { string str = string.Format("Select * From {0} where {1} = {2}", (object)SqlDatabaseHelper.GetPrimaryKeyColumn(tableName), (object)id); DbCommand sqlStringCommand = ((Database)SqlDatabaseHelper.database).GetSqlStringCommand(str); return(((Database)SqlDatabaseHelper.database).ExecuteDataSet(sqlStringCommand)); }