/// <summary>
 /// Constructor for ClsPreparedQuery, uses the ClsConnection_SqlServer object
 /// </summary>
 /// <param name="Cn">
 /// An open ClsConnection_SqlServer object
 /// </param>
 public ClsPreparedQuery_Ex(Interface_Connection Cn)
 {
     this.mCn = Cn;
     this.mCmd = this.mCn.CreateCommand();
     this.mCmd.Connection = this.mCn.pConnection;
     this.mCmd.Transaction = this.mCn.pTransaction;
     this.mCmd.CommandType = CommandType.Text;
 }
        /// <summary>
        /// Constructor for ClsPreparedQuery, uses the ClsConnection_SqlServer object
        /// </summary>
        /// <param name="Cn">
        /// An open ClsConnection_SqlServer object
        /// </param>
        /// <param name="Query">
        /// The query string to be executed
        /// </param>
        /// <param name="Parameters">
        /// </param>
        public ClsPreparedQuery_Ex(Interface_Connection Cn, string Query, List<Do_Constants.Str_Parameters> Parameters)
        {
            this.mCn = Cn;
            this.mCmd = this.mCn.CreateCommand();
            this.mCmd.Connection = this.mCn.pConnection;
            this.mCmd.Transaction = this.mCn.pTransaction;
            this.mCmd.CommandType = CommandType.Text;
            this.mCmd.CommandText = Query;

            this.mParameters = Parameters;

            foreach (Do_Constants.Str_Parameters Sp in this.mParameters)
            {
                DbParameter P = this.mCn.CreateParameter();
                P.ParameterName = Sp.Name;
                P.Value = Sp.Value;
                P.Size = Sp.Size;

                //this.mCmd.Parameters.Add( this.mCn.CreateParameter() {  }   )
            }

            //foreach (DbParameter Sp in ArrSp)
            //{ this.mCmd.Parameters.Add(Sp); }
        }
        public DataSet ExecuteQuery(Interface_Connection Connection, string Query)
        {
            Do_Constants.Str_Request_Execute Rqe = new Do_Constants.Str_Request_Execute();
            Rqe.ConnectionString = (Connection as Connection_Wcf).pConnectionString;
            Rqe.Query = Query;

            Do_Constants.Str_Request_Session Rs = new Do_Constants.Str_Request_Session();
            Rs.SessionID = ClsDataAccess_Wcf_Session.Instance.pSessionID;

            Client_WcfService Client = Client_WcfService.CreateObject();
            String ResponseData = Client.ExecuteQuery(Rs, Rqe);
            SimpleDataSet Sds = SimpleDataSet.Deserialize(ResponseData);

            return Sds.ToDataSet();
        }
 public DataSet ExecuteQuery(Interface_Connection Cn, DbCommand Cmd)
 {
     return (Cn as Connection_SqlServer).ExecuteQuery((SqlCommand)Cmd);
 }
        public int ExecuteNonQuery(Interface_Connection Connection, string Query)
        {
            Do_Constants.Str_Request_Execute Rqe = new Do_Constants.Str_Request_Execute();
            Rqe.ConnectionString = (Connection as Connection_Wcf).pConnectionString;
            Rqe.Query = Query;

            Do_Constants.Str_Request_Session Rs = new Do_Constants.Str_Request_Session();
            Rs.SessionID = ClsDataAccess_Wcf_Session.Instance.pSessionID;

            Client_WcfService Client = Client_WcfService.CreateObject();
            String ResponseData = Client.ExecuteNonQuery(Rs, Rqe);
            Int32 Result = (Int32)Do_Methods.DeserializeObject_Json(typeof(Int32), ResponseData);
            return Result;
        }
        public DataTable GetQuery(Interface_Connection Connection, string ViewObject, string Fields, ClsQueryCondition Condition, string Sort = "", long Top = 0, int Page = 0)
        {
            string Query_RowNumberSort = Sort;
            if (Query_RowNumberSort.Trim() == "") Query_RowNumberSort = "(Select 0)";

            string Query_Top = "";
            if (Top > 0) Query_Top = "Top " + Top.ToString();

            Int64 PageCondition = 0;
            if (Page > 0)
            { PageCondition = Top * (Page - 1); }

            if (ViewObject.Trim() != "") ViewObject = " From " + ViewObject + " ";
            if (Fields.Trim() == "") Fields = " * ";
            if (Sort.Trim() != "") Sort = " Order By " + Sort;

            ClsPreparedQuery Pq = new ClsPreparedQuery((ClsConnection_SqlServer)Connection);
            Pq.Add_Parameter("ViewObject", SqlDbType.VarChar, 8000, 0, 0, ViewObject);
            Pq.Add_Parameter("Fields", SqlDbType.VarChar, 8000, 0, 0, Fields);
            Pq.Add_Parameter("Sort", SqlDbType.VarChar, 8000, 0, 0, Sort);

            string Query_Condition = "";
            if (Condition != null)
            {
                Query_Condition = " Where 1 = 1 ";
                Query_Condition += " And " + Condition.GetQueryCondition();
                Pq.Add_Parameter(Condition.GetParameters());
            }

            Pq.pQuery = @"Select " + Query_Top + @" [Tb].* From ( Select Row_Number() Over (Order By " + Query_RowNumberSort + @") As [RowNumber], " + Fields + " " + ViewObject + " " + Query_Condition + @" ) As [Tb] Where [Tb].RowNumber > " + PageCondition + " " + Sort;
            Pq.Prepare();

            return Pq.ExecuteQuery().Tables[0];
        }
 public DataTable List_Empty(Interface_Connection Connection, string ObjectName)
 {
     return this.GetQuery(Connection, ObjectName, "*", "1 = 0");
 }
        public long List_Count(Interface_Connection Cn, string ObjectName, QueryCondition Condition = null)
        {
            Do_Constants.Str_Request_List Rl = new Do_Constants.Str_Request_List();
            Rl.ObjectName = ObjectName;
            Rl.Condition = Condition;
            Rl.ConnectionString = (Cn as Connection_Wcf).pConnectionString;

            Do_Constants.Str_Request_Session Rs = new Do_Constants.Str_Request_Session();
            Rs.SessionID = ClsDataAccess_Wcf_Session.Instance.pSessionID;

            Client_WcfService Client = Client_WcfService.CreateObject();
            Int64 ResponseData = Client.List_Count(Rs, Rl);
            return ResponseData;
        }
        public void SetSystemParameter(Interface_Connection Connection, string ParameterName, string ParameterValue)
        {
            Do_Constants.Str_Request_SystemParameter Rsp = new Do_Constants.Str_Request_SystemParameter();
            Rsp.ParameterName = ParameterName;
            Rsp.ParameterValue = ParameterValue;
            Rsp.ConnectionString = (Connection as Connection_Wcf).pConnectionString;

            Do_Constants.Str_Request_Session Rs = new Do_Constants.Str_Request_Session();
            Rs.SessionID = ClsDataAccess_Wcf_Session.Instance.pSessionID;

            Client_WcfService Client = Client_WcfService.CreateObject();
            Client.SetSystemParameter(Rs, Rsp);
        }
 public DataSet ExecuteQuery(Interface_Connection Cn, DbCommand Cmd)
 {
     throw new NotImplementedException();
 }
        public string GetSystemParameter(Interface_Connection Connection, string ParameterName, string DefaultValue = "")
        {
            Do_Constants.Str_Request_SystemParameter Rsp = new Do_Constants.Str_Request_SystemParameter();
            Rsp.ParameterName = ParameterName;
            Rsp.ParameterValue = DefaultValue;
            Rsp.ConnectionString = (Connection as Connection_Wcf).pConnectionString;

            Do_Constants.Str_Request_Session Rs = new Do_Constants.Str_Request_Session();
            Rs.SessionID = ClsDataAccess_Wcf_Session.Instance.pSessionID;

            Client_WcfService Client = Client_WcfService.CreateObject();
            String ResponseData = Client.GetSystemParameter(Rs, Rsp);

            return ResponseData;
        }
 public DataTable List(Interface_Connection Cn, string ObjectName, QueryCondition Condition, string Sort = "", long Top = 0, int Page = 0)
 {
     DataTable Dt = this.GetQuery(Cn, ObjectName, "*", Condition, Sort, Top, Page);
     return Dt;
 }
 public long List_Count(Interface_Connection Cn, string ObjectName, QueryCondition Condition = null)
 {
     DataTable Dt = this.GetQuery(Cn, ObjectName, "Count(1) As [Ct]", Condition);
     Int64 ReturnValue = 0;
     try { ReturnValue = Do_Methods.Convert_Int64(Dt.Rows[0]["Ct"], 0); }
     catch { }
     return ReturnValue;
 }
 public DataTable List(Interface_Connection Cn, string ObjectName, string Condition = "", string Sort = "")
 {
     DataTable Dt = this.GetQuery(Cn, ObjectName, "*", Condition, Sort);
     return Dt;
 }
        /// <summary>
        /// Gets the specified system parameter value, or creates a new system parameter with the specified default value
        /// </summary>
        /// <param name="Connection">
        /// An open connection object
        /// </param>
        /// <param name="ParameterName">
        /// The system parameter name
        /// </param>
        /// <param name="DefaultValue">
        /// The default value for the parameter if it doesn't exists
        /// </param>
        /// <returns></returns>
        public string GetSystemParameter(Interface_Connection Connection, string ParameterName, string DefaultValue = "")
        {
            Connection_SqlServer Cn = (Connection_SqlServer)Connection;

            string Rv = "";
            List<QueryParameter> Sp = new List<QueryParameter>();
            Sp.Add(new QueryParameter("ParameterName", ParameterName));
            Sp.Add(new QueryParameter("DefaultValue", DefaultValue));
            DataTable Dt = Cn.ExecuteQuery("usp_DataObjects_Parameter_Get", Sp).Tables[0];
            if (Dt.Rows.Count > 0)
            { Rv = (string)Dt.Rows[0][0]; }
            return Rv;
        }
        public DataTable GetQuery(Interface_Connection Connection, Do_Constants.Str_QuerySource SourceObject, string Fields, QueryCondition Condition, string Sort = "", long Top = 0, int Page = 0)
        {
            Fields = Do_Methods.Convert_String(Fields);
            Sort = Do_Methods.Convert_String(Sort);

            string Query_RowNumberSort = Sort;
            if (Query_RowNumberSort.Trim() == "")
            { Query_RowNumberSort = "(Select 0)"; }

            string Query_Top = "";
            if (Top > 0)
            { Query_Top = "Top " + Top.ToString(); }

            Int64 PageCondition = 0;
            if (Page > 0)
            { PageCondition = Top * (Page - 1); }

            if (SourceObject.ObjectName.Trim() != "")
            { SourceObject.ObjectName = @" From  " + SourceObject.ObjectName + " "; }
            if (SourceObject.Fields.Trim() == "")
            { SourceObject.Fields = @" * "; }
            if (SourceObject.Condition.Trim() != "")
            { SourceObject.Condition = @" Where " + SourceObject.Condition; }

            if (Fields.Trim() == "")
            { Fields = " * "; }
            if (Sort.Trim() != "")
            { Sort = " Order By " + Sort; }

            PreparedQuery Pq = this.CreatePreparedQuery();
            string Query_Condition = "";
            if (Condition != null)
            {
                Query_Condition = " Where 1 = 1 ";
                Query_Condition += " And " + Condition.GetQueryCondition();
                Pq.Add_Parameter(Condition.GetParameters());
            }

            //Pq.pQuery = @"Select " + Query_Top + @" [Tb].* From ( Select Row_Number() Over (Order By " + Query_RowNumberSort + @") As [RowNumber], " + Fields + " " + SourceObject + " " + Query_Condition + @" ) As [Tb] Where [Tb].RowNumber > " + PageCondition + " " + Sort;
            //Pq.pQuery = @"Declare @Query As VarChar(Max); Set @Query = 'Select ' + @Top + ' [Tb].* From ( Select Row_Number() Over (Order By ' + @RowNumberSort + ') As [RowNumber], ' + @Fields + ' ' + @ViewObject + ' ' + @Condition + ' ) As [Tb] Where [Tb].RowNumber >= ' + @PageCondition + ' ' + @Sort; Exec(@Query)";
            Pq.pQuery = @"Declare @ViewObject As VarChar(Max); Set @ViewObject = ' Select * ' + @Param_ViewObject_TableName + ' ' + @Param_ViewObject_Condition + ' ';  Declare @Query As VarChar(Max); Set @Query = 'Select ' + @Param_Top + ' [Tb].* From ( Select Row_Number() Over (Order By ' + @Param_RowNumberSort + ') As [RowNumber] , ' + @Param_Fields + ' From ('+ @ViewObject + ') As [Source] '" + @Query_Condition + @"' ) As [Tb] Where [Tb].RowNumber >= ' + @Param_PageCondition + ' ' + @Param_Sort; Exec(@Query);";
            Pq.Add_Parameter(new QueryParameter() { Name = "Param_ViewObject_TableName", Value = SourceObject.ObjectName, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Param_ViewObject_Condition", Value = SourceObject.Condition, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Param_Top", Value = Query_Top, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Param_RowNumberSort", Value = Query_RowNumberSort, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Param_PageCondition", Value = PageCondition.ToString(), Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Param_Fields", Value = Fields, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Param_Sort", Value = Sort, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Prepare();

            return Pq.ExecuteQuery().Tables[0];
        }
        /// <summary>
        /// Fetches a result set from a data source object
        /// </summary>
        /// <param name="Connection">
        /// An open connection object
        /// </param>
        /// <param name="SourceObject">
        /// Data source object to fetch from
        /// </param>
        /// <param name="Fields">
        /// List of fields tp fetch (SQL valid syntax)
        /// </param>
        /// <param name="Condition">
        /// ClsQueryCondition Object to use the filter the result set
        /// </param>
        /// <param name="Sort">
        /// Sort expression to use to sort the result set (SQL Order By valid syntax)
        /// </param>
        /// <param name="Top">
        /// Limits the number of returned rows in the result set,
        /// used in pagination
        /// </param>
        /// <param name="Page">
        /// Selects a section based on the Page and Top values in the result set,
        /// used in pagination
        /// </param>
        /// <returns></returns>
        public DataTable GetQuery(Interface_Connection Connection, String SourceObject, String Fields, QueryCondition Condition, String Sort = "", Int64 Top = 0, Int32 Page = 0)
        {
            SourceObject = Do_Methods.Convert_String(SourceObject);
            Fields = Do_Methods.Convert_String(Fields);
            Sort = Do_Methods.Convert_String(Sort);

            string Query_RowNumberSort = Sort;
            if (Query_RowNumberSort.Trim() == "") Query_RowNumberSort = "(Select 0)";

            string Query_Top = "";
            if (Top > 0) Query_Top = "Top " + Top.ToString();

            Int64 PageCondition = 0;
            if (Page > 0)
            { PageCondition = Top * (Page - 1); }

            if (SourceObject.Trim() != "") SourceObject = " From " + SourceObject + " ";
            if (Fields.Trim() == "") Fields = " * ";
            if (Sort.Trim() != "") Sort = " Order By " + Sort;

            PreparedQuery Pq = this.CreatePreparedQuery();
            string Query_Condition = "";
            if (Condition != null)
            {
                Query_Condition = " Where 1 = 1 ";
                Query_Condition += " And " + Condition.GetQueryCondition();
                Pq.Add_Parameter(Condition.GetParameters());
            }

            Pq.pQuery = @"Select " + Query_Top + @" [Tb].* From ( Select Row_Number() Over (Order By " + Query_RowNumberSort + @") As [RowNumber], " + Fields + " " + SourceObject + " " + Query_Condition + @" ) As [Tb] Where [Tb].RowNumber > " + PageCondition + " " + Sort;
            Pq.Prepare();

            return Pq.ExecuteQuery().Tables[0];
        }
        /// <summary>
        /// Fetches a result set from a data source object
        /// </summary>
        /// <param name="Connection">
        /// An open connection object
        /// </param>
        /// <param name="SourceObject">
        /// Data source object to fetch from
        /// </param>
        /// <param name="Fields">
        /// List of fields tp fetch (SQL valid syntax)
        /// </param>
        /// <param name="Condition">
        /// Condition to use the filter the result set (SQL Where valid syntax)
        /// </param>
        /// <param name="Sort">
        /// Sort expression to use to sort the result set (SQL Order By valid syntax)
        /// </param>
        /// <param name="Top">
        /// Limits the number of returned rows in the result set,
        /// used in pagination
        /// </param>
        /// <param name="Page">
        /// Selects a section based on the Page and Top values in the result set,
        /// used in pagination
        /// </param>
        /// <returns></returns>
        public DataTable GetQuery(Interface_Connection Connection, String SourceObject, String Fields = "", String Condition = "", String Sort = "", Int64 Top = 0, Int32 Page = 0)
        {
            SourceObject = Do_Methods.Convert_String(SourceObject);
            Fields = Do_Methods.Convert_String(Fields);
            Condition = Do_Methods.Convert_String(Condition);
            Sort = Do_Methods.Convert_String(Sort);

            string Query_RowNumberSort = Sort;
            if (Query_RowNumberSort.Trim() == "") Query_RowNumberSort = "(Select 0)";

            string Query_Top = "";
            if (Top > 0) { Query_Top = "Top " + Top.ToString(); }

            Int64 PageCondition = 0;
            if (Page > 0) { PageCondition = Top * (Page - 1); }

            if (SourceObject.Trim() != "") SourceObject = " From " + SourceObject + " ";
            if (Fields.Trim() == "") Fields = " * ";
            if (Condition.Trim() != "") Condition = " Where " + Condition;
            if (Sort.Trim() != "") Sort = " Order By " + Sort;

            PreparedQuery Pq = this.CreatePreparedQuery();
            Pq.pQuery = @"Declare @Query As VarChar(Max); Set @Query = 'Select ' + @Top + ' [Tb].* From ( Select Row_Number() Over (Order By ' + @RowNumberSort + ') As [RowNumber], ' + @Fields + ' ' + @ViewObject + ' ' + @Condition + ' ) As [Tb] Where [Tb].RowNumber >= ' + @PageCondition + ' ' + @Sort; Exec(@Query)";
            Pq.Add_Parameter(new QueryParameter() { Name = "ViewObject", Value = SourceObject, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Top", Value = Query_Top, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "RowNumberSort", Value = Query_RowNumberSort, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "PageCondition", Value = PageCondition.ToString(), Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Fields", Value = Fields, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Condition", Value = Condition, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });
            Pq.Add_Parameter(new QueryParameter() { Name = "Sort", Value = Sort, Type = Do_Constants.eParameterType.VarChar, Size = 8000 });

            Pq.Prepare();

            return Pq.ExecuteQuery().Tables[0];
        }
        public DataTable GetQuery(Interface_Connection Connection, Do_Constants.Str_QuerySource SourceObject, string Fields, QueryCondition Condition, string Sort = "", long Top = 0, int Page = 0)
        {
            Do_Constants.Str_Request_GetQuery Rgq = new Do_Constants.Str_Request_GetQuery();
            Rgq.ObjectQuerySource = SourceObject;
            Rgq.Fields = Fields;
            Rgq.Condition = Condition;
            Rgq.Sort = Sort;
            Rgq.Top = Do_Methods.Convert_Int32(Top);
            Rgq.Page = Page;

            Rgq.ConnectionString = (Connection as Connection_Wcf).pConnectionString;

            Do_Constants.Str_Request_Session Rs = new Do_Constants.Str_Request_Session();
            Rs.SessionID = ClsDataAccess_Wcf_Session.Instance.pSessionID;

            Client_WcfService Client = Client_WcfService.CreateObject();
            string ResponseData = Client.GetQuery(Rs, Rgq);
            SimpleDataTable Sdt = SimpleDataTable.Deserialize(ResponseData);

            return Sdt.ToDataTable();
        }
 /// <summary>
 /// Constructor for ClsPreparedQuery, uses the ClsConnection_SqlServer object
 /// </summary>
 public ClsPreparedQuery_Ex()
 {
     this.mCn = Do_Methods.CreateDataAccess().CreateConnection();
     this.mCn.Connect();
     this.mCmd = this.mCn.CreateCommand();
     this.mCmd.Connection = this.mCn.pConnection;
     this.mCmd.Transaction = this.mCn.pTransaction;
     this.mCmd.CommandType = CommandType.Text;
     //this.IsConnection = true;
 }
        public DataTable List(Interface_Connection Cn, string ObjectName, QueryCondition Condition, string Sort = "", long Top = 0, int Page = 0)
        {
            Do_Constants.Str_Request_List Rl = new Do_Constants.Str_Request_List();
            Rl.ObjectName = ObjectName;
            Rl.Condition = Condition;
            Rl.Sort = Sort;
            Rl.Top = Top;
            Rl.Page = Page;
            Rl.ConnectionString = (Cn as Connection_Wcf).pConnectionString;

            Do_Constants.Str_Request_Session Rs = new Do_Constants.Str_Request_Session();
            Rs.SessionID = ClsDataAccess_Wcf_Session.Instance.pSessionID;

            Client_WcfService Client = Client_WcfService.CreateObject();
            string ResponseData = Client.List(Rs, Rl);

            SimpleDataTable Sdt = SimpleDataTable.Deserialize(ResponseData);
            return Sdt.ToDataTable();
        }
        void Setup(Interface_Connection Cn, String Query = "", List<QueryParameter> Parameters = null)
        {
            this.mCn = Cn;
            this.mCmd = this.mCn.CreateCommand();
            this.mCmd.Connection = this.mCn.pConnection;
            this.mCmd.Transaction = this.mCn.pTransaction;
            this.mCmd.CommandType = CommandType.Text;

            if (Query != "")
            { this.mCmd.CommandText = Query; }

            if (Parameters != null)
            { this.Add_Parameter(Parameters); }
        }
        public DataTable List_Empty(Interface_Connection Cn, string ObjectName)
        {
            Do_Constants.Str_Request_List Rl = new Do_Constants.Str_Request_List();
            Rl.ObjectName = ObjectName;
            Rl.ConnectionString = (Cn as Connection_Wcf).pConnectionString;

            Do_Constants.Str_Request_Session Rs = new Do_Constants.Str_Request_Session();
            Rs.SessionID = ClsDataAccess_Wcf_Session.Instance.pSessionID;

            Client_WcfService Client = Client_WcfService.CreateObject();
            string ResponseData = Client.List_Empty(Rs, Rl);

            SimpleDataTable Sdt = SimpleDataTable.Deserialize(ResponseData);
            return Sdt.ToDataTable();
        }
 public PreparedQuery(Interface_Connection Cn, String Query = "", List<QueryParameter> Parameters = null)
 {
     this.Setup(Cn, Query, Parameters);
 }
        public DataTable GetQuery(
            Interface_Connection Connection
            , string ViewObject
            , string Fields = ""
            , string Condition = ""
            , string Sort = "")
        {
            if (ViewObject.Trim() != "") ViewObject = " From " + ViewObject + " ";
            if (Fields.Trim() == "") Fields = " * ";
            if (Condition.Trim() != "") Condition = " Where " + Condition;
            if (Sort.Trim() != "") Sort = " Order By " + Sort;

            ClsPreparedQuery Pq = new ClsPreparedQuery((ClsConnection_SqlServer)Connection);
            Pq.pQuery = @"Declare @Query As VarChar(Max); Set @Query = 'Select ' + @Fields + ' ' + @ViewObject + ' ' + @Condition + ' ' + @Sort; Exec(@Query)";
            Pq.Add_Parameter("ViewObject", SqlDbType.VarChar, 8000, 0, 0, ViewObject);
            Pq.Add_Parameter("Fields", SqlDbType.VarChar, 8000, 0, 0, Fields);
            Pq.Add_Parameter("Condition", SqlDbType.VarChar, 8000, 0, 0, Condition);
            Pq.Add_Parameter("Sort", SqlDbType.VarChar, 8000, 0, 0, Sort);
            Pq.Prepare();

            return Pq.ExecuteQuery().Tables[0];
        }
 public PreparedQuery_Wcf(Interface_Connection Cn, String Query = "", List<QueryParameter> Parameters = null)
 {
     this.mCn = Cn;
     this.mQuery = Query;
     this.mParameters = Parameters ?? new List<QueryParameter>();
 }
        public string GetSystemParameter(Interface_Connection Connection, string ParameterName, string DefaultValue = "")
        {
            ClsConnection_SqlServer Cn = (ClsConnection_SqlServer)Connection;

            string Rv = "";
            List<Layer01_Constants.Str_Parameters> Sp = new List<Layer01_Constants.Str_Parameters>();
            Sp.Add(new Layer01_Constants.Str_Parameters("ParameterName", ParameterName));
            Sp.Add(new Layer01_Constants.Str_Parameters("DefaultValue", DefaultValue));
            DataTable Dt = Cn.ExecuteQuery("usp_Get_System_Parameter", Sp).Tables[0];
            if (Dt.Rows.Count > 0)
            { Rv = (string)Dt.Rows[0][0]; }
            return Rv;
        }
 public PreparedQuery CreatePreparedQuery(Interface_Connection Cn, string Query = "", List<QueryParameter> Parameters = null)
 {
     return new PreparedQuery_Wcf(Cn, Query, Parameters);
 }
 public void SetSystemParameter(Interface_Connection Connection, string ParameterName, string ParameterValue)
 {
     ClsConnection_SqlServer Cn = (ClsConnection_SqlServer)Connection;
     List<Layer01_Constants.Str_Parameters> Sp = new List<Layer01_Constants.Str_Parameters>();
     Sp.Add(new Layer01_Constants.Str_Parameters("ParameterName", ParameterName));
     Sp.Add(new Layer01_Constants.Str_Parameters("ParameterValue", ParameterValue));
     Cn.ExecuteNonQuery("usp_Set_System_Parameter", Sp);
 }
 public DataSet ExecuteQuery(Interface_Connection Connection, string Query)
 {
     return (Connection as Connection_SqlServer).ExecuteQuery(Query);
 }