protected override bool ProcessCmdKey(ref System.Windows.Forms.Message m, System.Windows.Forms.Keys k) { try { string data = null; // detect the pushing of Enter Key if (k == System.Windows.Forms.Keys.Enter) { if (!string.IsNullOrEmpty(txt_BarCode.Text.Trim())) { lbl_BarCode.Text = txt_BarCode.Text.Trim(); txt_BarCode.Text = ""; if (ConfigurationManager.AppSettings["GATESELECTED"] != null) { data = ConfigurationManager.AppSettings["GATESELECTED"].ToString(); SMSServiceClient sc = new SMSServiceClient(); ServiceReference.BookingDTO BookingData = sc.UpdateGateInformation(Convert.ToInt32(data), Convert.ToInt32(lbl_BarCode.Text.Trim())); if (BookingData != null) { if (!string.IsNullOrEmpty(BookingData.Booking_Truck_RegNo)) lbl_truckno.Text = BookingData.Booking_Truck_RegNo; else lbl_truckno.Text = BookingData.Booking_StandaloneTruck_RegNo; if (data == "1") { if(BookingData.Booking_TruckInTime != null) lbl_Time.Text = (Convert.ToDateTime(BookingData.Booking_TruckInTime.ToString())).ToShortTimeString(); } if (data == "2") { if (BookingData.Booking_TruckMatLiftedTime != null) lbl_Time.Text = (Convert.ToDateTime(BookingData.Booking_TruckMatLiftedTime.ToString())).ToShortTimeString(); } } lbl_TotalCount.Text = sc.GetTruckCountForDateBarcode(DateTime.Now.Date, Convert.ToInt32(data)).ToString().Trim(); } txt_BarCode.Focus(); // return true to stop any further interpretation of this key action return true; } } // if not pushing Enter Key, then process the signal as usual return base.ProcessCmdKey(ref m, k); } catch (Exception ex) { return false; } }