How to Handle and validate Time on a Form c #? [closed]

0

How to Handle Time on a Form c #? What would be the code to save and validate?

Attached Graphic Example Image of what I want to do Example:

....

Greetings

    
asked by byok22 13.10.2017 в 23:08
source

1 answer

0

You can use the DateTimePicker component, and place the property format = Time , then to validate the dates you can do something like this

    if (DateTime.Parse("01/01/1900 " + dateTimePicker1.Text) > DateTime.Parse("01/01/1900 " + dateTimePicker2.Text))
    {
        MessageBox.Show("Las 1 hora es mayor", "..::Aviso del Sistema::..");
    }
    else if (DateTime.Parse("01/01/1900 " + dateTimePicker1.Text) == DateTime.Parse("01/01/1900 " + dateTimePicker2.Text))
    {
        MessageBox.Show("Las horas son iguales", "..::Aviso del Sistema::..");
    }
    else if (DateTime.Parse("01/01/1900 " + dateTimePicker1.Text) < DateTime.Parse("01/01/1900 " + dateTimePicker2.Text))
    {
        MessageBox.Show("Las 2 hora es mayor", "..::Aviso del Sistema::..");
    }

where dateTimePicker1 and dateTimePicker2 are the components you use in the form.

    
answered by 13.10.2017 / 23:36
source