private void txtGoodsID_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == 13 && txtGoodsID.Text.Trim() != "") { CMSMData.CMSMStruct.GoodsStruct gs = new CMSMData.CMSMStruct.GoodsStruct(); err = null; gs = cs.GetGoodsByID(txtGoodsID.Text.Trim(), out err); if (gs != null) { txtGoodsID.Text = gs.strGoodsID; cmbGoodsName.Text = gs.strGoodsName; txtPrice.Text = gs.dPrice.ToString(); txtCount.Text = "1"; txtCount.Focus(); } else { if (err != null) { clog.WriteLine(err); } MessageBox.Show("无此商品信息!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); cmbGoodsName.Text = "请输入..."; txtGoodsID.Focus(); return; } } }