/// <summary> /// 清除方法 /// </summary> public void Clear() { this.productModel = null; this.lblHJCode.Text = null; this.lblProductCode.Text = null; this.lblMaterialCode.Text = null; this.lblBarCode.Text = null; this.lblTip.Text = "请扫描合件条码"; this.IsHjScan = true; this.lvMaterial.Items.Clear(); }
/// <summary> /// 清除方法 /// </summary> public void Clear() { this.productModel = null; this.lblHJCode.Text = null; this.lblProductCode.Text = null; //this.lblCurrentCount.Text = null; this.lblOK.Text = null; this.lblScanCode.Text = null; this.lblTip.Text = "请扫描合件条码"; this.IsOK = true; this.IsHjScan = true; this.lvMaterial.Items.Clear(); }
//3.产品表 #region 载产品表 private void DownloadProduct() { try { DataTable table = productDAL.GetDataTable(BaseVariable.DeviceEntity.ProductType); if (table != null && table.Rows.Count > 0) { int count = table.Rows.Count; this.progressBar.Maximum = count; this.progressBar.Value = 0; for (int i = 0; i < count; i++) { DataRow row = table.Rows[i]; ProductInfoMDL model = productDAL.DataRowToModel(row); bool rst = lProductDAL.Add(model); this.progressBar.Value = i; } } } catch (Exception ex) { CLog.WriteErrLog(ex.Message); } }
private void ValidateHj(string barcode) { this.lblHJCode.Text = barcode; bool isNew = false;//新产品标识 #region 判断合件条码长度 bool CheckBitRST = Opt.HJValidate(barcode); //校验位判断 if (!CheckBitRST) { this.lblTip.Text = "合件条码长度不符合!"; Audio.SoundTip(0);//错误提示音 return; } #endregion #region 判断校验位 //判断校验位 string CheckCode = barcode.Substring(0, 13); //校验合件条码 string CheckBitOrigin = barcode.Substring(13, 1); //校验位 string CheckBit = Opt.CheckBit(CheckCode); //获取校验位 if (!CheckBit.ToLower().Equals(CheckBitOrigin.ToLower())) { this.lblTip.Text = "合件条码校验位错误!"; Audio.SoundTip(0);//错误提示音 return; } #endregion #region //判断特征码 string fc = barcode.Substring(0, 6); //前一个特征码与现在扫描相同 if (this.productModel != null && this.productModel.FeatureCode == fc) { //清除前一次信息 foreach (ListViewItem item in lvMaterial.Items) { item.SubItems[2].Text = ""; //初始化状态为空 item.ForeColor = Color.Black; //初始化字体颜色为黑色 } } else { isNew = this.productModel == null; if (Opt.FeatureCodeList.ContainsKey(fc)) { //扫描合件的特征码存在 this.productModel = Opt.FeatureCodeList[fc]; isNew = true; } else { //扫描合件的特征码不存在 IsHjScan = true; this.lblTip.Text = "合件条码不符,请重新扫描合件"; Audio.SoundTip(0);//错误提示音 return; } } #endregion #region 加载ListView数据 if (isNew) { InitListView(); } #endregion Audio.SoundTip(1); //扫描提示音 RecordScanInfo(); //记录扫描信息 IsHjScan = false; this.lblTip.Text = "请扫描零件条码或批次条码"; }
/// <summary> /// 获取产品信息 /// </summary> private void Select() { try { string method = context.Request.Params["method"].ToString(); if (method == "model") { string TID = context.Request.Params["TID"].ToString(); string ProductCode = context.Request.Params["ProductCode"].ToString(); string sql = " 1=1 "; if (!string.IsNullOrEmpty(TID)) { sql += string.Format(" AND TID = {0}", TID); } if (!string.IsNullOrEmpty(ProductCode)) { sql += string.Format(" AND ProductCode = '{0}'", ProductCode); } //CLog.WriteErrLog(sql); ProductInfoMDL model = DataDAL.GetModel(sql); if (model != null) { ReturnData.Code = "1"; ReturnData.Msg = "OK"; ReturnData.Data = model; } } else if (method == "search") { string sql = " 1=1 "; string ProductType = context.Request.Params["ProductType"].ToString(); //string ProductCode = context.Request.Params["ProductCode"].ToString(); //CLog.WriteErrLog(ProductType); //if (!string.IsNullOrEmpty(ProductCode)) //{ // sql += string.Format(" AND ProductCode = '{0}'", ProductCode); //} if (!string.IsNullOrEmpty(ProductType)) { sql += string.Format(" AND ProductType = '{0}'", ProductType); } sql += " ORDER BY ProductCode ASC"; //CLog.WriteErrLog(sql); DataSet set = DataDAL.GetList(sql); if (set != null && set.Tables.Count > 0) { DataTable table = set.Tables[0]; if (table != null && table.Rows.Count > 0) { object obj = TableHelper.TableToObj(table); ReturnData.Code = "1"; ReturnData.Msg = "OK"; ReturnData.Data = obj; } } } } catch (Exception ex) { CLog.WriteErrLog(ex.Message); } }
/// <summary> /// 加载产品信息 /// </summary> /// <param name="productCode"></param> public void LoadProductInfo() { try { this.lvMaterial.Items.Clear(); this.txtProductCode.Text = BaseVariable.ProductInfo.ProductCode; this.txtHJCode.Text = ""; //清空合件条码 this.lblCurrentMaterialCode.Text = ""; //清空当前零件条码 this.lblTip.Text = ""; this.lblOK.Text = ""; //获取当前产品信息表 productModel = BaseVariable.ProductInfo; //获取产品的特征码 featureCode = productModel.FeatureCode; //获取BOM表的信息 if (!BaseVariable.NetworkStatus || !BaseVariable.ServerStatus) { bomTable = lBomDAL.GetList(string.Format("ProductType='{0}' AND ProductCode = '{1}' AND TraceType='{2}' AND FeatureCode IS NOT NULL AND FeatureCode !=''", BaseVariable.DeviceEntity.ProductType, BaseVariable.ProductInfo.ProductCode, "扫描追溯")).Tables[0]; } else { bomTable = bomDAL.GetList(string.Format("ProductType='{0}' AND ProductCode = '{1}' AND TraceType='{2}' AND FeatureCode IS NOT NULL AND FeatureCode !=''", BaseVariable.DeviceEntity.ProductType, BaseVariable.ProductInfo.ProductCode, "扫描追溯")).Tables[0]; } //添加到ListView中 if (bomTable != null && bomTable.Rows.Count > 0) { int count = bomTable.Rows.Count; for (int i = 0; i < count; i++) { DataRow row = bomTable.Rows[i]; ListViewItem item = new ListViewItem(row["MaterialCode"].ToString()); //材料条码 item.SubItems.Add(""); item.SubItems.Add(row["MaterialNum"].ToString()); item.SubItems.Add("0"); item.SubItems.Add(row["MaterialName"].ToString()); item.Tag = row["TID"].ToString(); if (i % 2 == 0) { item.BackColor = Color.Gainsboro; //偶数背景色淡灰色 } else { item.BackColor = Color.Silver; //奇数背景色为银色 } item.ForeColor = Color.Black; //字体颜色为黑色 this.lvMaterial.Items.Add(item); } IsHjScan = true; //扫描合件标示为true if (BaseVariable.NetworkStatus && BaseVariable.ServerStatus) { GetMaterialInfo(); //获取材料信息 } else { IsAbleScan = true; } } else { this.Tip("当前型号没有扫描追溯零件"); } } catch (Exception ex) { CLog.WriteErrLog("[FrmScan.loadProduct]" + ex.Message); } }
//方法 #region 方法 #region 通用扫描方法 /// <summary> /// 通用扫描方法 /// </summary> /// <param name="obj"></param> private void doCommonScan(string barcode) { try { this.lblScanCode.Text = "";//清空提示信息 this.lblScanCode.ForeColor = Color.Navy; //判断是合件条码还是材料条码 if (IsHjScan) //当为合件时 { RequestParam.Clear(); //清除数据 this.lblScanCode.Text = barcode; #region 合件 bool isNew = false;//新产品标识 #region 判断合件条码长度 bool CheckBitRST = Opt.HJValidate(barcode); //校验位判断 if (!CheckBitRST) { this.Tip("合件条码长度不符合!"); Audio.SoundTip(0);//错误提示音 return; } #endregion #region 判断校验位 //判断校验位 string CheckCode = barcode.Substring(0, 13); //校验合件条码 string CheckBitOrigin = barcode.Substring(13, 1); //校验位 string CheckBit = Opt.CheckBit(CheckCode); //获取校验位 if (!CheckBit.ToLower().Equals(CheckBitOrigin.ToLower())) { this.Tip("合件条码校验位错误!"); Audio.SoundTip(0);//错误提示音 return; } #endregion #region //判断特征码 string fc = barcode.Substring(0, 6); //前一个特征码与现在扫描相同 if (this.productModel != null && this.productModel.FeatureCode == fc) { //清除前一次信息 foreach (ListViewItem item in lvMaterial.Items) { item.SubItems[1].Text = ""; //初始化状态为空 item.SubItems[3].Text = "0"; //初始化状态为空 item.ForeColor = Color.Black; //初始化字体颜色为黑色 } } else { isNew = this.productModel == null; if (Opt.FeatureCodeList.ContainsKey(fc)) { //扫描合件的特征码存在 this.productModel = Opt.FeatureCodeList[fc]; isNew = true; this.lblTitle.Text = "扫描-" + this.productModel.ProductName; this.lblProductCode.Text = this.productModel.ProductCode; } else { //扫描合件的特征码不存在 IsHjScan = true; this.Tip("合件条码不符,请重新扫描合件"); Audio.SoundTip(0);//错误提示音 return; } } #endregion #region //判断合件是否存在 if (IsValidateBarcode) //if (IsValidateBarcode && CurrnetScanType==1) { if (ValidateScanIsExist(1, barcode, "")) { Tip("当前合件已存在"); Audio.SoundTip(0);//错误提示音 return; } } #endregion this.lblHJCode.Text = barcode; this.lblOK.Text = ""; #region //判断是否有子零件 if (CurrnetScanType == 0) { #region //判断是否为新的产品 if (isNew || this.lvMaterial.Items == null || this.lvMaterial.Items.Count == 0) { InitListView();//加载子零件编码列表 } #endregion } else { IsOK = true; IsHjScan = true; //更新到数据库 bool ret = ScanResultToDb(); if (ret) { Audio.SoundTip(2); } else { Audio.SoundTip(0);//错误提示音 } return; } #endregion if (!this.productModel.HaveSub) { IsOK = true; IsHjScan = true; Audio.SoundTip(0);//错误提示音 this.Tip("当前合件没有子零件"); return; } //记录扫描信息 RecordScanInfo(); IsOK = false; IsHjScan = false; this.Tip("请扫描子零件条码"); #endregion //BatchTip();//批次信息提醒 } else { //当为子零件时 barcode = barcode.Replace("<cr><lf>", "").Replace("\r", "").Replace("\n", "").Replace("]C1", ""); //获取条码/二维码,过滤回车换行 this.lblScanCode.Text = barcode; ValidateMaterialInfo(barcode); //材料防错,对比特征码 } } catch (Exception ex) { CLog.WriteErrLog("扫描条码," + ex.Message); } }