+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 18 of 18

Thread: Building Dynamic Conditional Statement

  1. #11
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by jmurrayhead
    How many possible options to check are there?
    I'm just trying to cover as many bases as possible. There's bound to be something they'll want that I don't include. Currently, all they use is the contact's title, firstname and lastname, I think...

    I'm thinking it might look something like this to the user:-
    Code:
    Fieldname: <<_Salutation_>>
    if <dropdownlist(contact properties)> <dropdownlist(equals, doesn't equal, is empty)> <textbox(for value to check)> then
        <<_Salutation_>> = <textbox(for generic text)> <dropdownlist(contact properties)> <dropdownlist(contact properties)>
    else
        <<_Salutation_>> = <textbox(for generic text)> <dropdownlist(contact properties)> <dropdownlist(contact properties)>
    end if
    
    It'll then use this conditional on the email it creates for each contact. In this case it would allow up to 2 properties to be concatenated together for each case of the conditional or use the generic text entered. It would be one or the other, so you couldn't enter generic text AND select properties.

  2. #12
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Code:
    PropertyInfo pi = contact.GetType().GetProperty(ddlFirstOptionToCheck.SelectedValue)
    if(string.IsNullOrEmpty(pi.GetValue(contact, null)))
    {
        Replace("<<_Salutation_>>", txtGenericText.Text);
    }
    else
    {
        Replace("<<_Salutation_>>", pi.GetValue(contact, null));
    }
    
    This is just a simple sample, using Reflection. However, you can't (or at least I don't know of a way) dynamically build the actual condition using the operators from a dropdown (i.e. = <>). So you will have to build a conditional based on what the user selected and then run the same code, while hard coding the operators in:
    Code:
    if(ddlOperator.SelectedValue == "equals")
    {
        if(pi.GetValue(contact, null) == txtFirstOptionToCheck.Text)
        // ... and so on
    }
    
    Make sense?
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #13
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by jmurrayhead
    Make sense?
    Yes, I think it does...

    Thanks J

  4. #14
    Ask Me About Dragons :D Shadow Wizard has a spectacular aura about Shadow Wizard has a spectacular aura about Shadow Wizard's Avatar
    Join Date
    Jul 2008
    Location
    Israel
    Posts
    795
    Blog Entries
    2
    Real Name
    Yahav
    Rep Power
    5

    Without reading everything here, I would advice on something you probably didn't
    really think about: Windows Workflow.. how far is it from what you need?

  5. #15
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by Shadow Wizard View Post
    Without reading everything here, I would advice on something you probably didn't
    really think about: Windows Workflow.. how far is it from what you need?
    I don't think it is what I need SW....The issue is that I don't know what property the user may want to check. I want them to be able to dynamically select the object property and check it against a value they enter.

  6. #16
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    Just a couple of hair-brained idea on the concept of 'dynamic conditionals'

    1. There is a small, finite set of possible conditionals the a user might want to choose from. Create some generic helper functions for them, like isEqual, isBetween, isLessThan, etc. Then invoke the correct function

    2. It is possible via reflection to actually compile and execute a method at run-time. I don't have the exact details of this here, but I remember doing it once for a giggle.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

  7. #17
    Ask Me About Dragons :D Shadow Wizard has a spectacular aura about Shadow Wizard has a spectacular aura about Shadow Wizard's Avatar
    Join Date
    Jul 2008
    Location
    Israel
    Posts
    795
    Blog Entries
    2
    Real Name
    Yahav
    Rep Power
    5

    Quote Originally Posted by richyrich View Post
    I don't think it is what I need SW....The issue is that I don't know what property the user may want to check. I want them to be able to dynamically select the object property and check it against a value they enter.
    Hmm.. in such case what J said is probably the best option.

  8. #18
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by Wolffy View Post
    Just a couple of hair-brained idea on the concept of 'dynamic conditionals'

    1. There is a small, finite set of possible conditionals the a user might want to choose from. Create some generic helper functions for them, like isEqual, isBetween, isLessThan, etc. Then invoke the correct function

    2. It is possible via reflection to actually compile and execute a method at run-time. I don't have the exact details of this here, but I remember doing it once for a giggle.
    Yeah, I think I'll give it a shot, but got other priorities at the moment..

    BTW, this is the syntax used in the mailing software they currently use:-
    Code:
    <IF(!*FIRSTNAME*! = Nothing THEN !*TITLE*! !*LASTNAME*!, ELSE  !*FIRSTNAME*!,)ENDIF>
    
    This is what I want to do in .NET

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. sql statement with an iif statement inside
    By arloguth in forum Microsoft Access
    Replies: 7
    Last Post: June 7th, 2009, 11:31 PM
  2. Conditional JOIN in Stored Procedure
    By richyrich in forum MySQL
    Replies: 5
    Last Post: April 6th, 2009, 04:55 PM
  3. Dynamic Stored Procedure without Building Strings
    By jmurrayhead in forum SQL Code Samples
    Replies: 11
    Last Post: March 17th, 2009, 01:12 PM
  4. Conditional data on report
    By tuxalot in forum Microsoft Access
    Replies: 16
    Last Post: March 3rd, 2009, 11:18 PM
  5. iif statement
    By Barkol in forum Microsoft Access
    Replies: 4
    Last Post: June 6th, 2008, 12:12 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO