C# se if(tiempo.TotalHours

C# se if(tiempo.TotalHours,c#,visual-studio,datetime,ms-access-2007,C#,Visual Studio,Datetime,Ms Access 2007,se if(tiempo.TotalHours


se if(tiempo.TotalHours<2&&fechaHora.TimeOfDay)是否可以从数据库中添加一些数据以使其更清晰。因为我不明白这个问题。创建那个“表”真的很痛苦。如您所见,此用户登录时间为上午,注销时间为下午。登录时间位于RecordTime字段中,登录时间的RecordType值为0,注销时间的值为1到5(我没有设计此数据库,它是由指纹捕获程序创建的)。问题在于重复的值,如果不存在,我可以将登录小时数和注销小时数拆分为两个字段或表,按记录类型进行选择
1|||||399---||||||||28/04/2016 06:55:36 a.m.|||||----- 0----------|

2|||||399---||||||||28/04/2016 06:57:32 a.m.|||||------0----------|

3|||||399---||||||||28/04/2016 05:07:15 p.m.|||||------1----------|

4|||||399---||||||||28/04/2016 05:16:33 p.m.|||||------1----------|

5|||||399---||||||||02/05/2016 07:04:02 a.m.|||||------0----------|

6|||||399---||||||||02/05/2016 05:15:53 p.m.|||||------1----------|
try
        {
            huella.Open();
            OleDbCommand comando = new OleDbCommand();
            comando.Connection = huella;
            string consulta = "select [User].IdUser,[User].IdentificationNumber,[User].name,[Record].RecordTime," +
                "[Record].RecordType from [User] inner join [Record] on [User].IdUser = [Record].IdUser " +

            "where " + "[Record].IdUser=@01 and [Record].RecordTime between @time1 and @time2 order by [User].IdUser asc,[Record].RecordTime asc";
            comando.CommandText = consulta;
            comando.Parameters.AddWithValue("@01", IDcm.Text.ToString());
            comando.Parameters.AddWithValue("@time1", dateTimePicker1.Value.Date);
            comando.Parameters.AddWithValue("@time2", dateTimePicker2.Value.Date);
            OleDbDataAdapter datos = new OleDbDataAdapter(comando);
            // using( OleDbDataReader lector = comando.ExecuteReader())
            tabla = new DataTable();
            datos.Fill(tabla);
            //MessageBox.Show(""+tabla);
            clu.DataSource = tabla;
        }
        catch (Exception ex)
        {
            MessageBox.Show("ERROR " + ex);
        }
        finally
        {
            huella.Close();
        }
StreamWriter archivo = new StreamWriter("D:\\MAXIMUM PC.csv", true);
        {
            archivo.WriteLine('"' + "usuario" + '"' + ";" + '"' + "Hora de entrada" + '"' + ";" + '"' + "Hora de salida" + '"' + ";" + '"' + "Tiempo" + '"' + ";" + '"' + "Pago" + '"');
            for (i = 0; i < rows; i++)
            {
                //assign the first variable, in my case, DateTime data types
                fechaHora = Convert.ToDateTime(clu.Rows[i].Cells[0].Value.ToString());
                for (j = i + 1; j < rows; j++)
                {
                    //assign the second variable
                    fechaActual = Convert.ToDateTime(clu.Rows[j].Cells[0].Value.ToString());
                    if (fechaHora.Date == fechaActual.Date)
                    {

                        //here i start the compare process
                        if (fechaHora.TimeOfDay != fechaActual.TimeOfDay)
                        {
                            tiempo = fechaActual.Subtract(fechaHora);
                            // if the dates are the same, but their time is different..
                            if (tiempo.TotalHours > 7 && fechaHora.TimeOfDay > fechaActual.TimeOfDay)
                            {
                                //if the timespan between the times is over 7 hours and the first date is over the second....
                                entrada = fechaHora;
                                salida = fechaActual;
                                pay = Convert.ToDouble(tiempo.TotalHours * hourPay);
                                archivo.WriteLine(usuario + ";" + entrada + ";" + salida + ";" + tiempo.TotalHours + ";" + pay);

                            }
                            //if the timespan between the times is over 7 hours and the second date is over the fist....
                            else if (tiempo.TotalHours > 7 && fechaHora.TimeOfDay < fechaActual.TimeOfDay)
                            {
                                entrada = fechaHora;
                                salida = fechaActual;
                                pay = Convert.ToDouble(tiempo.TotalHours * hourPay);
                                archivo.WriteLine(usuario + ";" + entrada + ";" + salida + ";" + tiempo.TotalHours + ";" + pay);
                            }
                            //if the timespan between the times is under 2 hours and the first date is under or equal the second....
                            else if (tiempo.TotalHours < 2 && fechaHora.TimeOfDay <= fechaActual.TimeOfDay)
                            {
                                error = fechaActual;

                            }
                        }
                    }
                }
            }
        }