WPF 医疗排队系统:输入框回车查询功能优化
}
//快捷键结束
//在输入框回车后调此方法
private void OnPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
string inputText = inputBox.Text;
Console.WriteLine('就诊卡号:' + inputText);
DataGrid2.Visibility = Visibility.Hidden;
DataGrid3.Visibility = Visibility.Hidden;
DataGrid1.Visibility = Visibility.Visible;
this.Height = 500;
query_type = 1;
String doctor_code = new Config().getDoctorCode();
String select_is_expert = ((ComboBoxItem)queue_type_v.SelectedItem).DataContext.ToString();
String select_dept_room_id = cmbBudgetYear.SelectedValue.ToString();
//String result = HttpRequestHelper.HttpGet(service_addreass + '/http-doctor-query-wait.html?doctor_code=' + doctor_code + '&ip=' + client_ip + '&is_expert=' + select_is_expert + '&dept_room_id=' + select_dept_room_id);
String result = HttpRequestHelper.HttpGet(service_addreass + '/http-this-doctor-query-wait-input.html?doctor_code=' + doctor_code + '&ip=' + client_ip + '&is_expert=' + select_is_expert + '&dept_room_id=' + select_dept_room_id + '&inputText=' + inputText);
JObject jsonObj = JObject.Parse(result);
String code = jsonObj['code'].ToString();
String message = jsonObj['message'].ToString().Substring(1, jsonObj['message'].ToString().Length - 2); ;
if (code.Equals('0'))
{
MessageBox.Show(message, '错误提示', MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
}
else
{
int queues_length = int.Parse(jsonObj['queues_length'].ToString());
current_visit_count_v.Text = '等待(' + queues_length + ')';
DataGrid1.ItemsSource = null;
if (queues_length > 0)
{
this.DataGrid1.ItemsSource = getAll(queues_length, jsonObj);
}
wait_patient_number = queues_length;
}
}
}
private DispatcherTimer inputTimer;
public MainWindow()
{
InitializeComponent();
inputTimer = new DispatcherTimer();
inputTimer.Interval = TimeSpan.FromSeconds(1);
inputTimer.Tick += InputTimer_Tick;
}
private void InputBox_TextChanged(object sender, TextChangedEventArgs e)
{
inputTimer.Stop();
inputTimer.Start();
}
private void InputTimer_Tick(object sender, EventArgs e)
{
inputTimer.Stop();
string inputText = inputBox.Text;
if(!string.IsNullOrEmpty(inputText))
{
//执行查询方法
//...
}
}
原文地址: https://www.cveoy.top/t/topic/oUM1 著作权归作者所有。请勿转载和采集!