How to compare arrays and datagridview through loops?

Asked

Viewed 51 times

0

Good afternoon, everyone

I have 7 text boxes that I made this way

long[] Jornada;
Jornada = new long[7];

           Jornada[0] = TimeSpan.Parse(textboxjornadaseg.Text.ToString()).Ticks;
           Jornada[1]= TimeSpan.Parse(textboxjornadater.Text.ToString()).Ticks;
           Jornada[2] = TimeSpan.Parse(textboxjornadaqua.Text.ToString()).Ticks;
           Jornada[3] = TimeSpan.Parse(textboxjornadaqui.Text.ToString()).Ticks;
           Jornada[4] = TimeSpan.Parse(textboxjornadasex.Text.ToString()).Ticks;
           Jornada[5] = TimeSpan.Parse(textboxjornadasab.Text.ToString()).Ticks;
           Jornada[6] = TimeSpan.Parse(textboxjornadadom.Text.ToString()).Ticks;

each journey is a maskedtexbox referring to the total contractual journey of the day, I have a calculate button in which it fills a line and plays this content in a grid cell.

What I did : I put a FOR for him to take the 7 conditions and put in a variable : Jornada[i]

 for (long i = 0; i < 1; i++)

           {

            IdentificaHoraExtra = HorasDoDia + HorasDaNoite > Jornada[i]; //verifica se há horas extras
            ResultadoHE = IdentificaHoraExtra ? (HorasDoDia + HorasDaNoite) - Jornada[i] : (new TimeSpan(0).Ticks)
            }

By clicking it generates a line in datagridview, this Journey[i] is a contractual journey field.

What I want to do: on the grid it has a column called "day", then it takes the day of the week : "Monday"/ "Tuesday" / [...] and so on, each insert in the line it adds the next day, i wanted to find a way in which he compared the day cell with the corresponding vector and returned the vector identification equal to the day position on the line.

for example: in datagridview appeared a cell written "second"/ second he takes Journey[0], on Tuesday he takes the Journey1

Does anyone have any hint as I compare the index of the in cell that appears the day with the index that I created in the array?

Edit will put prints for easy viewing

inserir a descrição da imagem aqui

In the first image above in the workday field it returns the values of the textbox.

inserir a descrição da imagem aqui

In this second image in the left-hand textbox are the values that are inserted in the dategridview

In the field of journey was to show the value of Friday which is 08:00 Only he takes Monday every time I wanted to find a way to identify the content of the day for each value in these textbox.

  • Why Voce does not store your array’s input in a column, or simply do the reverse, since Voce knows that the second is 0 and so on. You have both possibilities

  • Windowsforms, WPF or Webforms?

  • Windows Forms!!

  • Personal I edited and placed the images for easy viewing.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.