Oracle and SQL BO for a single Windows GUI


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
This is not a quick sample to write and would ultimately involve me writing your entire base logic for you.  This is something that falls outside of the scope of this forum and falls on the side of consulting.  I have provided you with as much detail above as I could think of to get started.  You are welcome to post additional questions as you work through your solution as that is the intention of this forum.  We try to provide new samples and so I will add this to the list of possible future samples, but this will not be anything done in the near term. 
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
I did do the following as you suggested:

1. Create a base business object

2. Inherit all of your application BOs from this base BO

3. Within the base BO, override the FillDataTable method. 

Couple of questions.

1. On a Strataframe Maintenance form when is the FillDataTable method called? IE.. when to user SEARCHES on the Browse?, When the user clicks on SAVE?

2. Currently it appears that the Overridden FillDataTable method is not being executed from the BO that inherits from my BaseBO form although it appears that everything is set as you suggested. Is there something else I need to do?

Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Could it be that the BO is a Smart BO and not using the FillDataTable method? IE... the SF Maintenance browse automatically fills the BO without any custom fill methods.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Not sure this will help your over all issue, but the FillDataTable isn't every called by the maintenance form....It never knows how you're going to need to fill your data. However, it is the root method that will get called any time you do fill the BO. Thus, any time you fill the BO, you will either call this method or write a method that ends up calling this method.
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
How can I force every Maintenance form to call the FillDataTable method. IE... the ones that I totally let the framework do everything for me. What I am asking is in the Maintenance form, or the Browse, what code do I insert and where to have the framework call the FillDataTable method with the select statement it automatically generated?
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Ross L. Rooker, Sr. (11/24/2008)
How can I force every Maintenance form to call the FillDataTable method. IE... the ones that I totally let the framework do everything for me. What I am asking is in the Maintenance form, or the Browse, what code do I insert and where to have the framework call the FillDataTable method with the select statement it automatically generated?

Hi Ross,

You don't need to insert any code, just make sure your form is using a BO which is subclassed from your based BO which has the FillDataTable method override.

Edhy Rijo

Dustin Taylor
Dustin Taylor
StrataFrame Team Member (660 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
If you are inheriting your custom BaseBO from all of your business objects, then they should be using your overridden FillDataTable whenever they get filled. As Greg mentioned, this is BO logic, not Form logic, so there isn't anything on your maintenance form to change. In your example, you need to ensure that MyDatabaseBO inherits from MyBaseBO, and that MyBaseBO overrides the filldatatable method as Trent outlined.  That is how to go about plumbing in your logic and what allows you to make the changes Trent described.
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
I am doing exactly what you described above in terms of the  MyDatabaseBO inheriting from MyBaseBO, and that MyBaseBO overrides the filldatatable method. But if the SF Maintenance framework is not always calling the FillDataTable method as pointed out about then I need to make sure it does get called. 
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (660 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
If you handle the filldatatable, it should catch everything. Is this not what you are experiencing?

There are a small number of intrinsic calls such as FillByParent that use changedatatable, but these use QueryInformation which is, by nature, completely database independent and, as such, don't need to go through your translation routines.

Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
If you handle the filldatatable, it should catch everything. Is this not what you are experiencing? The BaseBO for FillDataTable is not firing off. Here is my code:

The base bo is called : TrustedVALETBaseBO and inherits from MicroFour.StrataFrame.Business.BusinessLayer

using MicroFour.StrataFrame.Business;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Runtime.Serialization;
using System.Text;
using System.Data.Common;
using System.Data.OleDb;
using System.Text.RegularExpressions;
using System.Data.OracleClient;

namespace TrustedVALET_BO
{
    [Serializable()]
    public partial class TrustedVALETBaseBO : MicroFour.StrataFrame.Business.BusinessLayer
    {
        public enum DatabaseType : int
        {
            SQLServer = 0,
            Oracle = 1
        }

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the BusinessObject1 class.
        /// </summary>
        public TrustedVALETBaseBO()
            : base()
        {
            InitializeComponent();
        }


        /// <summary>
        /// Initializes a new instance of the BusinessObject1 class.
        /// </summary>
        /// <param name="container">The IContainer to which this business object will be added.</param>
        public TrustedVALETBaseBO(IContainer container)
            : base()
        {
            container.Add(this);

            InitializeComponent();
        }

        /// <summary>
        /// Initializes a new instance of the BusinessObject1 class.
        /// </summary>
        /// <param name="info">The SerializationInfo for the object to create.</param>
        /// <param name="context">The StreamingContext for the source stream.</param>
        protected TrustedVALETBaseBO(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            InitializeComponent();
        }

        #endregion

        #region Data Retrieval Methods

        #endregion

        #region Event Handlers

        /// <summary>
        /// Checks the business rules on the current row
        /// </summary>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private void TrustedVALETBaseBO_CheckRulesOnCurrentRow(CheckRulesEventArgs e)
        {

        }

        /// <summary>
        /// Sets the default values for a new row
        /// </summary>
        /// <remarks></remarks>
        private void TrustedVALETBaseBO_SetDefaultValues()
        {
           
        }

        #endregion


 
        private static DatabaseType _DatabaseQueryType =  DatabaseType.SQLServer ;

        public static DatabaseType DatabaseQueryType
        {
            get { return _DatabaseQueryType; }
            set { _DatabaseQueryType = value; }
        }

        private OracleCommand ConvertSqlToOracleCommand(SqlCommand cmd)
        {
     //  inserted next 2 lines just to have the code compile
            System.Data.OracleClient.OracleCommand strOr = null;
            return strOr;
            //-- Convert the SqlCommand into an Oracle Command
        }

        //-- Override the base FillDataTable and add a test to see if the command should be converted to Oracle
        public override void FillDataTable(DbCommand cmd)
        {
            if (TrustedVALETBaseBO.DatabaseQueryType ==  DatabaseType.Oracle)
                cmd = ConvertSqlToOracleCommand((SqlCommand)cmd);

                //  added write to see if this is being executed
  Console.WriteLine("Base class Constructor");

            base.FillDataTable(cmd);
            
        }

    }
}

The actual database bo for the table is: tbl_BargeClass_1 and inherits from TrustedVALETBaseBO

using MicroFour.StrataFrame.Business;

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Runtime.Serialization;

using System.Text;

using MicroFour.StrataFrame.Security;

namespace TrustedVALET_BO

{

[Serializable()]

//public partial class tbl_BargeClass_1 : MicroFour.StrataFrame.Business.BusinessLayer

public partial class tbl_BargeClass_1 : TrustedVALETBaseBO

{

#region Constructors

/// <summary>

/// Initializes a new instance of the BusinessObject1 class.

/// </summary>

public tbl_BargeClass_1()

: base()

{

InitializeComponent();

}

/// <summary>

/// Initializes a new instance of the BusinessObject1 class.

/// </summary>

/// <param name="container">The IContainer to which this business object will be added.</param>

public tbl_BargeClass_1(IContainer container)

: base()

{

container.Add(this);

InitializeComponent();

}

/// <summary>

/// Initializes a new instance of the BusinessObject1 class.

/// </summary>

/// <param name="info">The SerializationInfo for the object to create.</param>

/// <param name="context">The StreamingContext for the source stream.</param>

protected tbl_BargeClass_1(SerializationInfo info, StreamingContext context)

: base(info, context)

{

InitializeComponent();

}

#endregion

#region Data Retrieval Methods

#endregion

#region Event Handlers

/// <summary>

/// Checks the business rules on the current row

/// </summary>

/// <param name="e"></param>

/// <remarks></remarks>

private void tbl_BargeClass_1_CheckRulesOnCurrentRow(CheckRulesEventArgs e)

{

}

/// <summary>

/// Sets the default values for a new row

/// </summary>

/// <remarks></remarks>

private void tbl_BargeClass_1_SetDefaultValues()

{

this.BARGECLASS_ENTDT = DateTime.Now;

this.BARGECLASS_USERE = SecurityBasics.CurrentUser.UserName;

}

#endregion

private void tbl_BargeClass_1_BeforeSave(MicroFour.StrataFrame.Data.BeforeSaveUndoEventArgs e)

{

this.BARGECLASS_UPDT = DateTime.Now;

this.BARGECLASS_USERU = SecurityBasics.CurrentUser.UserName;

}

}

}

The SF Maintenance form has the tbl_BargeClass_1 BO on the form. This is a typical Maint Form where it has a browse where the user searches and there is no code which I coded to fill th BO other than what the SF framework does internally.

 

 


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search