private void btnSubmit_Click(object sender, EventArgs e) { stin.cmaker = Common.CurrentUser.UserName; stin.cdefine10 = txtRegCode.Text; stin.cwhcode = cmbWarehouse.SelectedValue.ToString(); try { this.Enabled = false; Cursor.Current = Cursors.WaitCursor; string errMsg = ""; int rt = STInProductBusiness.SaveProductIn(stin, out errMsg); if (rt == 0) { MessageBox.Show("提交成功!"); } else { MessageBox.Show("提交失败!" + errMsg); } Close(); } catch (Exception ex) { MessageBox.Show("提交失败!" + ex.Message); } finally { this.Enabled = true; Cursor.Current = Cursors.Default; } }
/// <summary> /// 扫描条码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e) { //成品标签扫描 if (e.KeyChar == 13 && txtBarcode.Text.Length > 0) { try { string errMsg = null; //首先判断扫描的是一维条码还是二维条码,条件是否包含@ string strBarcode = txtBarcode.Text.Trim(); string[] barcode = new string[7] { "", "", "", "", "", "", "" }; if (strBarcode.IndexOf('@') == -1) //没有找到@,说明该条码是一维条码 { string cInvCode = string.Empty; //存货编码 //根据一维条码查询存货编码 bool flag = Common.GetCInvCode(strBarcode, out cInvCode, out errMsg); if (!flag) { MessageBox.Show("没有找到对应的存货编码!" + errMsg); return; } barcode[1] = cInvCode; IsQR = false; } else //二维码 { barcode = strBarcode.Split('@'); IsQR = true; } this.cInvCode = barcode[1]; if (STInProductBusiness.GetSTInProduct(barcode[1], out dd, out errMsg)) { if (dd == null) { MessageBox.Show("获取条码错误"); txtCost.Enabled = false; txtBarcode.SelectAll(); txtBarcode.Focus(); txtCost.Text = ""; txtCount.Text = ""; } else { lblInvName.Text = dd.cinvname; lblInvStd.Text = dd.cinvstd; lblEnterprise.Text = dd.cinvdefine1; //保质期天数与保质期单位 iMassDate = dd.imassdate; cMassUnit = dd.cmassunit; if (IsQR)//如果扫描的是二维条码 { dd.cbatch = barcode[3]; dd.dmadedate = barcode[4]; dd.dvdate = Convert.ToDateTime(barcode[5]).AddDays(1).ToString("yyyy-MM-dd"); txtCBatch.Text = dd.cbatch; dtpProDate.Value = Convert.ToDateTime(dd.dmadedate); dtpValidDate.Value = Convert.ToDateTime(dd.dvdate).AddDays(-1); VerifyPCB(txtCPosition.Text, barcode[1], dd.cbatch); } else //一维条码 { ////触发日期的计算,生产日期默认为今天 dtpProDate_ValueChanged(dtpProDate, e); txtCBatch.Focus(); //dtpProDate.Focus(); } } } else { MessageBox.Show("条码解析失败"); txtCost.Enabled = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); txtCost.Enabled = false; } } }