none
Inputting validation RRS feed

  • Question

  • Hello, i'm making a program which allows users to enter, delete and display weather records is there a way to;

    1. Make it so locations can only be entered in one format, so one user can't put LNDN and one puts London?

    2. Stop duplicated records, so if there's already a record with the location London and the same date it won't let them enter it?

    Any help is appreciated ^^

    Friday, July 3, 2015 9:43 PM

Answers

  • Hi Lynchbox,

    1. Use ComboBox (property: DropDownStyle = DropDownList)

    2. Check whether the input value(location and date) exists in the values already stored.
       If used ComboBox, handle an event of TextChanged. 
       It may be the simplest way to use for-loop.
        (I cannot say more, since your infomation is insufficient. Where are the input values stored in?) 

    Regards,

    Saturday, July 4, 2015 4:54 AM
  • What is your backend storage? Because that sounds like rules the DBMS should enforce, not the GUI. The second you got another application writing the same data chaos will happen.

    I am unsure if mixing up selection and creation of a value like this is wise. It might be better to add a "Add Value" button that opens a new Formular to add an entry, then reloads the ComboBox from the Datasource to get the new value.

    2. This sounds like a Unique constraint on the DB column. Of course users might missspell during entry or write stuff like 'London - Soho' and get around any unique constraints. Nothing the DBMS or your code can do about that, however.
    Some sanity checks only the user or admin can make. Just provide a way to delete LNDN and put all reference to it onto London.

    1. What dispaly technology are you using? WinForms? WPF? ASP.Net?

    For each of them input validation has to be done differently.
    Personally I prefer a passive input error reporting via stuff like IDataErrorInfo (accept everything, validate on Focus loss, add or remove message to collection accordingly, block save if error count > 0).

    Saturday, July 4, 2015 8:24 AM
  • Exactly how you're best doing this depends on how many locations you're recording data for and how many concurrent users , how discrete their work is.

    A combobox could possibly handle both requirements.

    A lot of validation can be done just by arranging how your UI works and obviating the possibility of someone doing something wrong.

    EG

    You can't pick LNDN if it isn't in a combobox.

    .

    Say 99% of the time one user will be inputting the data for a country.

    ( This is a common usage pattern in business apps ).

    You would design your UI so the user picks a country and date first.

    If that country and date has entries already they see them, if not a blank records per location is created.

    They are then presented with a datagrid. That contains a row per location in that country for that day.

    They fill all or some of the records.

    Maybe you insist they fill them all.

    They commit their changes.

    You don't allow them to add or delete rows, all they can do is enter data.

    You also apply a rule in the database so a location and date is forced to be unique.

    Even if the Swedish data entry clerk decides to play a joke on the UK clerk then they can't add more records and the UK clerk will see those 99 degree centigrade entries the Swedish guy input for them.

    .

    Or you could pick a date, fill a combobox with locations and disable or remove each as they're picked for an entry.


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles

    Saturday, July 4, 2015 8:44 AM
    Moderator

All replies

  • Hi Lynchbox,

    1. Use ComboBox (property: DropDownStyle = DropDownList)

    2. Check whether the input value(location and date) exists in the values already stored.
       If used ComboBox, handle an event of TextChanged. 
       It may be the simplest way to use for-loop.
        (I cannot say more, since your infomation is insufficient. Where are the input values stored in?) 

    Regards,

    Saturday, July 4, 2015 4:54 AM
  • What is your backend storage? Because that sounds like rules the DBMS should enforce, not the GUI. The second you got another application writing the same data chaos will happen.

    I am unsure if mixing up selection and creation of a value like this is wise. It might be better to add a "Add Value" button that opens a new Formular to add an entry, then reloads the ComboBox from the Datasource to get the new value.

    2. This sounds like a Unique constraint on the DB column. Of course users might missspell during entry or write stuff like 'London - Soho' and get around any unique constraints. Nothing the DBMS or your code can do about that, however.
    Some sanity checks only the user or admin can make. Just provide a way to delete LNDN and put all reference to it onto London.

    1. What dispaly technology are you using? WinForms? WPF? ASP.Net?

    For each of them input validation has to be done differently.
    Personally I prefer a passive input error reporting via stuff like IDataErrorInfo (accept everything, validate on Focus loss, add or remove message to collection accordingly, block save if error count > 0).

    Saturday, July 4, 2015 8:24 AM
  • Exactly how you're best doing this depends on how many locations you're recording data for and how many concurrent users , how discrete their work is.

    A combobox could possibly handle both requirements.

    A lot of validation can be done just by arranging how your UI works and obviating the possibility of someone doing something wrong.

    EG

    You can't pick LNDN if it isn't in a combobox.

    .

    Say 99% of the time one user will be inputting the data for a country.

    ( This is a common usage pattern in business apps ).

    You would design your UI so the user picks a country and date first.

    If that country and date has entries already they see them, if not a blank records per location is created.

    They are then presented with a datagrid. That contains a row per location in that country for that day.

    They fill all or some of the records.

    Maybe you insist they fill them all.

    They commit their changes.

    You don't allow them to add or delete rows, all they can do is enter data.

    You also apply a rule in the database so a location and date is forced to be unique.

    Even if the Swedish data entry clerk decides to play a joke on the UK clerk then they can't add more records and the UK clerk will see those 99 degree centigrade entries the Swedish guy input for them.

    .

    Or you could pick a date, fill a combobox with locations and disable or remove each as they're picked for an entry.


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles

    Saturday, July 4, 2015 8:44 AM
    Moderator