private void btn_Search_Click(object sender, EventArgs e) { decimal mainbeltno; decimal groupnono; try { if (txt_mainbeltno.Text.Length <= 0) { mainbeltno = 0; } else { mainbeltno = Convert.ToDecimal(txt_mainbeltno.Text); } } catch (Exception) { MessageBox.Show("主皮带输入格式有误!"); return; } try { if (txt_groupnono.Text.Length <= 0) { groupnono = 0; } else { groupnono = Convert.ToDecimal(txt_groupnono.Text); } } catch (Exception) { MessageBox.Show("分拣组号输入格式有误!"); return; } dataGridView1.DataSource = UnionCacheServer.GetSearchData(mainbeltno, groupnono); }