private void DBController_RunStoredProcedure(object sender, EventArgs e) { //We check to see what E is, and then we parse it into our own EventArgs to get the ChipIdNumber and put that into our own ChipId if (e is CheckInEventArgs) { CheckInEventArgs ch = (CheckInEventArgs)e; newScanChipId = ch.ChipIdNumber; } //Connection to DB using (var conn = new SqlConnection(connection)) { int r = new Random().Next(1, 5); //Call the stored procedure called CheckIn in the DB //Simulates that a customer enters a random area SqlCommand command = new SqlCommand("dbo.CheckIn", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@ChipID", newScanChipId); command.Parameters.AddWithValue("@Area", r); command.Parameters.AddWithValue("@CheckInTime", DateTime.Now); command.Parameters.AddWithValue("@CheckOutTime", DateTime.Now); conn.Open(); command.ExecuteNonQuery(); } }
//Gets called when a scan from ComportListener happend private void OnNewInput(object sender, EventArgs e) { //We check to see what E is, and then we parse it into our own EventArgs to get the ChipIdNumber and put that into our own ChipId if (e is CheckInEventArgs) { CheckInEventArgs ch = (CheckInEventArgs)e; MyChipId = ch.ChipIdNumber; } }