How should I insert my data using an inherited class in an inherited form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Warpig
    New Member
    • Sep 2010
    • 3

    How should I insert my data using an inherited class in an inherited form

    Hello,
    this seems like it should be more strait forward but I feel like I am missing the boat on best practices somewhere.
    I have inherited types with contractual insert update and delete methods. I also have an inherited "EditData" form wherein the Base form takes my base type in its constructor. My trouble comes when I want to assign the control values of the form to the properties of the sub- type. The base form calls the base type's insert method but since the base type is highly generic it doesn't know which properties need to be mapped to the forms controls.
    I seems like I have to do that in the sup-type but the sub-type has no access to the form. Also NOT all the properties of the type are going to be changed by this form only one or two but it will vary from type to type.
    SO... after that mouthfull, my question is should I...
    1) give access to the form by passing the form to the insert method and make the form controls public and have the insert method set the type's properties accordingly?
    or
    2) make the insert method take a bunch of parameters (9 to be exact) and have the type set its properties from those accordingly?

    OR is some other option I am not seeing?

    let me know if you dont get my question of if you need to see some code

    thanks in advance
  • hype261
    New Member
    • Apr 2010
    • 207

    #2
    Warpig,

    Is the insert method in the parent class virtual and overriden in the child class? I think this will solve your problem.

    Comment

    • Warpig
      New Member
      • Sep 2010
      • 3

      #3
      Yes, parent is virtual and overridden in child. I settled on passing the instance of the inherited form to the inherited classes insert method that way it has momentary access to the form controls and can use the values it needs to accordingly. This way each inherited instance of my class and it's Insert(EditForm form) method has what it needs and I don't have to figure out which class is going to need different values sent to it.

      Thank you hype261 for your reply. It looks like I am on to the next phase.

      Comment

      Working...