Beispiel #1
0
        private void FillDataGrid()
        {
            dataGridView1.Rows.Clear();
            List <Elements> CarData = new List <Elements>();

            CarData = SO.GetCarData();
            foreach (var elment in CarData)
            {
                TagElments TimeOfCar = SO.GetCarTime(elment.CarID);
                dataGridView1.Rows.Add(elment.CarOwner, elment.CarNumber, TimeOfCar.TimeIn, TimeOfCar.TimeOut, elment.CarID);
            }
        }
Beispiel #2
0
        public TagElments GetCarTime(string CarNumber)
        {
            TagElments LastTime = new TagElments();
            String     TagNum   = GetTagNumber(CarNumber);
            string     Query    = @"select * from CarMovement where TagNumber=";

            Query += "'" + TagNum + "'";
            SqlConnection con = new SqlConnection(ConnectionString);

            con.Open();
            SqlCommand    cmd       = new SqlCommand(Query, con);
            SqlDataReader rdr       = cmd.ExecuteReader();
            List <String> myTagData = new List <String>();

            while (rdr.Read())
            {
                String temp;
                temp = rdr["TimeStatus"].ToString();
                myTagData.Add(temp);
            }
            if (myTagData.Count > 0)
            {
                if (myTagData.Count == 1)
                {
                    LastTime.TimeIn  = myTagData[0];
                    LastTime.TimeOut = "";
                }
                else
                {
                    LastTime.TimeIn  = myTagData[0];
                    LastTime.TimeOut = myTagData[myTagData.Count - 1];
                }
            }
            con.Close();
            return(LastTime);
        }