/// <summary> /// 根据CompleteApplyBarCodeDataTable添加记录 /// </summary> /// <param name="dto"></param> /// <param name="moDocNo"></param> /// <param name="docID"></param> /// <param name="docLineID"></param> /// <returns></returns> public CompleteApplyBarCodeRow AddNewRow(BarCodeInfoDTO dto, string moDocNo, long docID, long docLineID) { CompleteApplyBarCodeRow dataRow = this.NewCompleteApplyBarCodeRow(); // 组织ID dataRow.OrgID = PDAContext.LoginOrgID; // 料品 dataRow.ItemID = dto.ItemID; dataRow.ItemCode = dto.ItemCode; dataRow.ItemName = dto.ItemName; dataRow.ItemSPECS = dto.ItemSPECS; //条码 dataRow.BarCode = dto.BarCode; //实际长度 dataRow.Qty = dto.ActualLength; //检验员 dataRow.QcOperatorID = dto.QcOperatorID; dataRow.QcOperatorCode = dto.QcOperatorCode; // 扫描人 dataRow.ScanBy = PDAContext.LoginUserName; // 扫描日期 dataRow.ScanOn = DateTime.Now; //申报单和申报行 dataRow.CompleteApplyDocID = docID; dataRow.CompleteApplyDocLineID = docLineID; //MO dataRow.MO = moDocNo; this.AddCompleteApplyBarCodeRow(dataRow); return(dataRow); }
/// <summary> /// 扫描条码 /// </summary> private void ScanBarCode() { try { tabOrderManager.Reset(); string barcode = txtBarCode.Text.Trim(); if (string.IsNullOrEmpty(barcode)) { return; } BarCodeInfoDTO dto = ServiceAgent.Agent.QueryBarCodeInfo(PDAContext.LoginOrgID, barcode); mainInvCheckRow = dataSet.InvCheckBarCode.AddNewRow(dto); if (mainInvCheckRow == null) { throw new PDAException(txtBarCode, "没有找到该条形码的料品信息!"); } // 料品信息 txtInfo.Text = mainInvCheckRow.ToString(); // 显示行数 ShowRowCount(); // 焦点定位到最后一行 this.dataGrid1.Focus(); this.dataGrid1.CurrentRowIndex = this.dataSet.InvCheckBarCode.Count - 1; // 跳转到下一个控件 tabOrderManager.Next(); } catch (Exception ex) { MessageBox.Show(ExceptionParser.ParseError(ex)); tabOrderManager.DealException(ex); } }
/// <summary> /// 根据ShipBarCodeDataTable添加记录 /// </summary> /// <param name="dto"></param> /// <param name="docID"></param> /// <param name="docLineID"></param> /// <returns></returns> public ShipBarCodeRow AddNewRow(BarCodeInfoDTO dto, long docID, long docLineID) { ShipBarCodeRow dataRow = this.NewShipBarCodeRow(); // 组织ID dataRow.OrgID = PDAContext.LoginOrgID; // 料品 dataRow.ItemID = dto.ItemID; dataRow.ItemCode = dto.ItemCode; dataRow.ItemName = dto.ItemName; dataRow.ItemSPECS = dto.ItemSPECS; //条码 dataRow.BarCode = dto.BarCode; //实际长度 dataRow.Qty = dto.ActualLength; //检验员 dataRow.QcOperatorID = dto.QcOperatorID; dataRow.QcOperatorCode = dto.QcOperatorCode; // 扫描人 dataRow.ScanBy = PDAContext.LoginUserName; // 扫描日期 dataRow.ScanOn = DateTime.Now; //申报单和申报行 dataRow.ShipPlanID = docID; dataRow.ShipPlanLineID = docLineID; this.AddShipBarCodeRow(dataRow); return(dataRow); }
/// <summary> /// 匹配出货计划信息 /// </summary> /// <param name="dto"></param> /// <returns></returns> private ShipPlanDocDTO MatchCompleteApplyDocDTO(BarCodeInfoDTO dto) { if (docInfoArray == null || docInfoArray.Length == 0) { return(null); } List <ShipPlanDocDTO> matchedDTOs = new List <ShipPlanDocDTO>(); foreach (ShipPlanDocDTO docDTO in docInfoArray) { //按照料品+段长匹配 if (docDTO.ItemID == dto.ItemID && docDTO.SegLength == dto.ActualLength) { matchedDTOs.Add(docDTO); } } if (matchedDTOs.Count == 0) { throw new PDAException(txtBarCode, "该条码没有匹配到出货计划信息"); } //统计已经录入的盘数 Dictionary <long, int> inputedDict = new Dictionary <long, int>(); foreach (ShipBarCodeDataSet.ShipBarCodeRow barCodeRow in dataSet.ShipBarCode) { if (barCodeRow.BarCode == dto.BarCode) { throw new PDAException(txtBarCode, string.Format("条码{0}已经扫描,不允许重复扫描", dto.BarCode)); } if (!inputedDict.ContainsKey(barCodeRow.ShipPlanLineID)) { inputedDict.Add(barCodeRow.ShipPlanLineID, 0); } inputedDict[barCodeRow.ShipPlanLineID] += 1; } foreach (ShipPlanDocDTO docDTO in matchedDTOs) { int inputedCount = (inputedDict.ContainsKey(docDTO.ShipPlanLineID) ? inputedDict[docDTO.ShipPlanLineID] : 0); if (inputedCount < docDTO.Count) { return(docDTO); } } throw new PDAException(txtBarCode, string.Format("条码{0}对应料品录入的数量已超过出货计划所允许的数量,不允许扫描", dto.BarCode)); }
public BarCodeInfoDTO QueryBarCodeInfo(long orgID, string barCode) { try { if (string.IsNullOrEmpty(barCode)) { return(null); } string sql = string.Format(@" select barcode.BarCode, barcode.Item as ItemID, item.Code as ItemCode, item.Name as ItemName, item.SPECS as ItemSPECS, item.DescFlexField_PrivateDescSeg1 as ItemCheckStandard, barcode.ActualLength, ISNULL(op.ID, 0) as opID, ISNULL(op.Code,'') as opCode from Cust_CompleteApplyBarCode as barcode left join CBO_ItemMaster as item on barcode.Item = item.ID left join CBO_Operators as op on barcode.Operators = op.ID where barcode.BarCode='{0}' and barcode.Org='{1}' ", barCode, orgID); DataSet dataSet = SQLHelper.ExecuteDataSet(sql); if (dataSet == null || dataSet.Tables.Count == 0 || dataSet.Tables[0].Rows.Count == 0) { return(null); } DataRow dataRow = dataSet.Tables[0].Rows[0]; BarCodeInfoDTO dto = new BarCodeInfoDTO(); dto.ItemID = TypeHelper.ConvertType <long>(dataRow["ItemID"], 0); dto.ItemCode = TypeHelper.ConvertType <string>(dataRow["ItemCode"], string.Empty); dto.ItemName = TypeHelper.ConvertType <string>(dataRow["ItemName"], string.Empty); dto.ItemSPECS = TypeHelper.ConvertType <string>(dataRow["ItemSPECS"], string.Empty); dto.BarCode = TypeHelper.ConvertType <string>(dataRow["BarCode"], string.Empty); dto.ActualLength = TypeHelper.ConvertType <int>(dataRow["ActualLength"], 0); dto.ItemCheckStandard = TypeHelper.ConvertType <string>(dataRow["ItemCheckStandard"], string.Empty); dto.QcOperatorID = TypeHelper.ConvertType <long>(dataRow["opID"], 0); dto.QcOperatorCode = TypeHelper.ConvertType <string>(dataRow["opCode"], string.Empty); return(dto); } catch (Exception ex) { PDALog.Error(ex); throw ExceptionHelper.CreateSoapException(ex.Message, ex.Source); } }
/// <summary> /// 扫描条码 /// </summary> private void ScanBarCode() { try { string barcode = txtBarCode.Text.Trim(); if (string.IsNullOrEmpty(barcode)) { return; } if (docInfoArray == null || docInfoArray.Length == 0) { BuildTabOrder(true); throw new PDAException(txtDocNo, "请先录入出货计划单号或者扫描出货计划单条码"); } BuildTabOrder(false); tabOrderManager.Reset(); BarCodeInfoDTO dto = ServiceAgent.Agent.QueryBarCodeInfo(PDAContext.LoginOrgID, barcode); if (dto == null) { throw new PDAException(txtBarCode, "没有找到该条形码的料品信息!"); } ShipPlanDocDTO docDTO = MatchCompleteApplyDocDTO(dto); if (docDTO == null) { throw new PDAException(txtBarCode, "该条码没有匹配到出货计划信息或者录入的条码超过该出货计划单!"); } mainRow = dataSet.ShipBarCode.AddNewRow(dto, docDTO.ShipPlanID, docDTO.ShipPlanLineID); ShowInfo(); // 显示行数 ShowRowCount(); // 焦点定位到最后一行 this.dataGrid1.Focus(); this.dataGrid1.CurrentRowIndex = this.dataSet.ShipBarCode.Count - 1; // 跳转到下一个控件 tabOrderManager.Next(); } catch (Exception ex) { MessageBox.Show(ExceptionParser.ParseError(ex)); tabOrderManager.DealException(ex); } }
/// <summary> /// 根据InvCheckBarCodeDataTable添加记录 /// </summary> /// <param name="dto"></param> /// <returns></returns> public InvCheckBarCodeRow AddNewRow(BarCodeInfoDTO dto) { if (dto == null) { return(null); } foreach (InvCheckBarCodeRow row in this) { if (row.BarCode == dto.BarCode) { throw new Exception(string.Format("条码{0}已经扫描,不允许重复扫描", dto.BarCode)); } } InvCheckBarCodeRow dataRow = this.NewInvCheckBarCodeRow(); // 组织ID dataRow.OrgID = PDAContext.LoginOrgID; // 料品 dataRow.ItemID = dto.ItemID; dataRow.ItemCode = dto.ItemCode; dataRow.ItemName = dto.ItemName; dataRow.ItemSPECS = dto.ItemSPECS; //条码 dataRow.BarCode = dto.BarCode; //实际长度 dataRow.Qty = dto.ActualLength; // 扫描人 dataRow.ScanPerson = PDAContext.LoginUserName; // 扫描日期 dataRow.ScanDate = DateTime.Now; this.AddInvCheckBarCodeRow(dataRow); return(dataRow); }