今天在写代码的时候被一个小细节坑了,以前没注意,现在才发现,代码如下:
private void btnChangeCartonID_Click(object sender, EventArgs e)
{
if (Convert.ToDouble(this.txtPickedQty.Text) > 0)
{
AddScanningEntity();
this.lblQty.Text = Convert.ToString(Convert.ToDouble(this.lblQty.Text) - Convert.ToDouble(this.txtPickedQty.Text));
this.txtPickedQty.Text = string.Empty;
}
this.txtCartonID.Text = string.Empty;
this.ChangeCurrentField(Convert.ToInt16(ScanningValue.Tag), 3);
this.ScanningValue.Focus();
}
Convert.ToDouble(this.txtPickedQty.Text) 在转换的时候,this.txtPickedQty.Text不能为空,否则会报错:“字符串格式错误”,在转换之前加一个不为空的判断就好了