private bool isSkuRight() { string sku = tBSku.Text.Trim(); using (ASRS_ServiceSoapClient srv = new ASRS_ServiceSoapClient()) { if (tBContainer.Enabled == true) { MessageBox.Show("请先对托盘号绑定再进行扫码工作"); return(false); } if (string.IsNullOrEmpty(tBContainer.Text.Trim())) { return(true); //无条码则退出 } if (sku == "") { return(true); } try { var item = srv.IM_Item_GetOneBySku(sku); if (item == null || string.IsNullOrEmpty(item.SKU)) { MessageBox.Show("无此物料!"); tBSku.Text = ""; return(false); } if (AlreadyScan.Text.IndexOf(tBSku.Text) != -1) { MessageBox.Show("物料条码不能重复扫描!"); tBSku.Text = ""; return(false); } if (tBSku.Text != "0000" && label4.Visible == false) { label4.Visible = true; AlreadyScan.Visible = true; } if (AlreadyScan.Text == "") { AlreadyScan.Text = tBSku.Text; } else { AlreadyScan.Text += ";\r\n" + tBSku.Text; } // MessageBox.Show(AlreadyScan.Height.ToString()); AlreadyScan.Height = 32 * (AlreadyScan.Text.ToString().Split(';').Length); var cvi = new IV_container_vs_item(); cvi.ID = Guid.NewGuid().ToString(); cvi.ITEMDESC = item.SKUDESC; cvi.ITEMQTY = 1; cvi.ITEMSKU = sku; cvi.UPDATETIME = srv.CommonMethod_GetServerTime().ToString("yyyy-MM-dd HH:mm:ss"); cvi.UPDATEUSER = ""; cvi.VOID = 0; cvi.CONTAINERID = tBContainer.Text.Trim(); srv.Container_Vs_Items_InsertOne(cvi); itemDetails += "" + cvi.ITEMDESC + ":" + cvi.ITEMQTY + "套 " + ";"; tBSku.Text = ""; tBSku.Focus(); return(true); } catch (Exception e) { MessageBox.Show(e.ToString()); return(false); MessageBox.Show("连接数据库失败!"); } } }