Example #1
0
        public SqlDataReader ExecuteReaderQuery(TTDictionaryQuery SQLDictionery, TTDictionary parDictionery, object objEntity)
        {
            SqlDataReader drResult = null;

            try
            {
                GetConnection();
                Connection.GetConnection.OpenConnection(sqlCon);
                sqlCMD.Parameters.Clear();
                CommonMSSQL.AddParameter(sqlCMD, parDictionery, objEntity);

                StringBuilder SQLQuery = new StringBuilder();

                SQLQuery.Append(SQLDictionery.SelectPart).AppendLine();
                SQLQuery.Append(SQLDictionery.TablePart).AppendLine();
                if (parDictionery.Count > 0)
                {
                    SQLQuery.Append(HelperMethod.GetParameter(parDictionery, SQLQuery)).AppendLine();
                }
                if (!string.IsNullOrEmpty(SQLDictionery.ParameterPart))
                {
                    if (SQLDictionery.ParameterPart.Trim() != "")
                    {
                        SQLQuery.Append(SQLDictionery.ParameterPart).AppendLine();
                    }
                }
                if (SQLDictionery.GroupPart != null)
                {
                    SQLQuery.Append(SQLDictionery.GroupPart).AppendLine();
                }
                if (SQLDictionery.HavingPart != null)
                {
                    SQLQuery.Append(SQLDictionery.HavingPart).AppendLine();
                }

                if (TTPagination.isPageing)
                {
                    if (TTPagination.PageSize != -1)
                    {
                        SQLQuery.Append(string.Format("{0} {1}", SQLDictionery.OrderPart, HelperMethod.GetPageingString(SQLDictionery.OrderPart, objEntity))).AppendLine();
                    }
                }
                else
                {
                    if (SQLDictionery.OrderPart != null)
                    {
                        SQLQuery.Append(SQLDictionery.OrderPart).AppendLine();
                    }
                }

                sqlCMD.CommandType = CommandType.Text;
                sqlCMD.CommandText = SQLQuery.ToString();
                SqlDataReader dr = sqlCMD.ExecuteReader();
                if (TTPagination.isPageing)
                {
                    TTPagination.RecordCount = PagerRecordCount(SQLDictionery, parDictionery, objEntity);
                }
                drResult = dr;
            }
            catch (Exception er)
            {
                throw;
            }
            finally
            {
                TTPagination.isPageing = false;
            }
            return(drResult);
        }
Example #2
0
        public DataTable GetDatasetByCommand(TTDictionaryQuery SQLDictionery, TTDictionary parDictionery, object objEntity)
        {
            try
            {
                GetConnection();
                Connection.GetConnection.OpenConnection(sqlCon);
                sqlCMD.Parameters.Clear();
                CommonMSSQL.AddParameter(sqlCMD, parDictionery, objEntity);

                StringBuilder SQLQuery = new StringBuilder();

                SQLQuery.Append(SQLDictionery.SelectPart).AppendLine();
                SQLQuery.Append(SQLDictionery.TablePart).AppendLine();
                if (parDictionery.Count > 0)
                {
                    SQLQuery.Append(HelperMethod.GetParameter(parDictionery, SQLQuery)).AppendLine();
                }
                if (!string.IsNullOrEmpty(SQLDictionery.ParameterPart))
                {
                    if (SQLDictionery.ParameterPart.Trim() != "")
                    {
                        SQLQuery.Append(SQLDictionery.ParameterPart).AppendLine();
                    }
                }
                if (SQLDictionery.GroupPart != null)
                {
                    SQLQuery.Append(SQLDictionery.GroupPart).AppendLine();
                }
                if (SQLDictionery.HavingPart != null)
                {
                    SQLQuery.Append(SQLDictionery.HavingPart).AppendLine();
                }

                if (TTPagination.isPageing)
                {
                    if (TTPagination.PageSize != -1)
                    {
                        SQLQuery.Append(string.Format("{0} {1}", SQLDictionery.OrderPart, HelperMethod.GetPageingString(SQLDictionery.OrderPart, objEntity))).AppendLine();
                    }
                }
                else
                {
                    if (SQLDictionery.OrderPart != null)
                    {
                        SQLQuery.Append(SQLDictionery.OrderPart).AppendLine();
                    }
                }

                sqlCMD.CommandType    = CommandType.Text;
                sqlCMD.CommandText    = SQLQuery.ToString();
                sqlCMD.CommandTimeout = 180;
                //objSqlCommand.CommandText = Command;
                //objSqlCommand.CommandTimeout = 60;
                //objSqlCommand.CommandType = CommandType.StoredProcedure;

                //mobj_SqlConnection.Open();

                SqlDataAdapter adpt = new SqlDataAdapter(sqlCMD);
                DataTable      dt   = new DataTable();
                adpt.Fill(dt);
                return(dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Connection.GetConnection.CloseConnection(sqlCon);
            }
        }
Example #3
0
        public SqlDataReader ExecuteReaderQuery(TTDictionaryQuery SQLDictionery, object objEntity)
        {
            SqlDataReader drResult = null;

            try
            {
                GetConnection();
                if (!Connection.GetConnection.isConnectionOpen)
                {
                    sqlCon.Open();
                }
                sqlCMD.Parameters.Clear();
                StringBuilder SQLQuery = new StringBuilder();

                SQLQuery.Append(SQLDictionery.SelectPart).AppendLine();
                SQLQuery.Append(SQLDictionery.TablePart).AppendLine();
                if (SQLDictionery.GroupPart.Trim() != "")
                {
                    SQLQuery.Append(SQLDictionery.GroupPart).AppendLine();
                }
                if (SQLDictionery.HavingPart.Trim() != "")
                {
                    SQLQuery.Append(SQLDictionery.HavingPart).AppendLine();
                }

                if (TTPagination.isPageing)
                {
                    SQLQuery.Append(string.Format("{0} {1}", SQLDictionery.OrderPart, HelperMethod.GetPageingString(SQLDictionery.OrderPart, objEntity))).AppendLine();
                }
                else
                {
                    SQLQuery.Append(SQLDictionery.OrderPart).AppendLine();
                }

                sqlCMD.CommandType = CommandType.Text;
                sqlCMD.CommandText = SQLQuery.ToString();
                SqlDataReader dr = sqlCMD.ExecuteReader();
                if (dr.HasRows)
                {
                    drResult = dr;
                    TTPagination.RecordCount = PagerRecordCount(SQLDictionery, null, objEntity);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Connection.GetConnection.CloseConnection(sqlCon);
            }
            return(drResult);
        }