Пример #1
0
        /// <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, "没有找到该条形码的料品信息!");
                }

                CompleteApplyDocDTO docDTO = MatchCompleteApplyDocDTO(dto);
                if (docDTO == null)
                {
                    throw new PDAException(txtBarCode, "该条码没有匹配到申报单信息或者录入的条码超过该申报单!");
                }
                mainRow = dataSet.CompleteApplyBarCode.AddNewRow(dto, docDTO.MoDocNo, docDTO.CompleteApplyDocID, docDTO.CompleteApplyLineID);

                ShowInfo();
                // 显示行数
                ShowRowCount();
                // 焦点定位到最后一行
                this.dataGrid1.Focus();
                this.dataGrid1.CurrentRowIndex = this.dataSet.CompleteApplyBarCode.Count - 1;
                // 跳转到下一个控件
                tabOrderManager.Next();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ExceptionParser.ParseError(ex));
                tabOrderManager.DealException(ex);
            }
        }
Пример #2
0
    public List <CompleteApplyDocDTO> QueryCompleteApplyDocInfo(long orgID, string barCode)
    {
        try
        {
            if (string.IsNullOrEmpty(barCode))
            {
                return(null);
            }

            string sql = string.Format(@"
select *, (case when a.SegLength=0 then 0 else a.TotalLength/a.SegLength end)-a.RcvCount as JCount
from(
	select mo.ID as MOID,
		mo.DocNo as MODocNo,
		item.ID as ItemID,
		item.Code as ItemCode,
		item.Name as ItemName,
		item.SPECS as ItemSPECS,
		doc.ID as CompleteApplyDocID,
		line.ID as CompleteApplyLineID,
		convert(decimal(24,9), (case when line.DescFlexField_PubDescSeg1='' then '0' else line.DescFlexField_PubDescSeg1 end)) as SegLength,
		line.CompleteQty*1000 as TotalLength,
		convert(decimal(24,9), (case when line.DescFlexField_PrivateDescSeg2='' then '0' else line.DescFlexField_PrivateDescSeg2 end)) as RcvCount
	from Complete_CompleteApplyDocLine as line
	inner join CBO_ItemMaster as item on line.Item=item.ID
	inner join MO_MO as mo on line.MO=mo.ID
	inner join Complete_CompleteApplyDoc as doc on line.CompleteApplyDoc=doc.ID
	where doc.Org='{0}' and doc.DocNo='{1}'
) as a where a.SegLength>0 and a.RcvCount<(a.TotalLength/a.SegLength) ", orgID, barCode);

            DataSet dataSet = SQLHelper.ExecuteDataSet(sql);
            if (dataSet == null || dataSet.Tables.Count == 0 || dataSet.Tables[0].Rows.Count == 0)
            {
                return(null);
            }

            List <CompleteApplyDocDTO> resultList = new List <CompleteApplyDocDTO>();
            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                CompleteApplyDocDTO dto = new CompleteApplyDocDTO();
                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.MO                  = TypeHelper.ConvertType <long>(dataRow["MOID"], 0);
                dto.MoDocNo             = TypeHelper.ConvertType <string>(dataRow["MODocNo"], string.Empty);
                dto.CompleteApplyDocID  = TypeHelper.ConvertType <long>(dataRow["CompleteApplyDocID"], 0);
                dto.CompleteApplyLineID = TypeHelper.ConvertType <long>(dataRow["CompleteApplyLineID"], 0);

                dto.SegLength   = (int)TypeHelper.ConvertType <decimal>(dataRow["SegLength"], 0);
                dto.Count       = (int)TypeHelper.ConvertType <decimal>(dataRow["JCount"], 0);
                dto.TotalLength = (int)TypeHelper.ConvertType <decimal>(dataRow["TotalLength"], 0);
                resultList.Add(dto);
            }
            return(resultList);
        }
        catch (Exception ex)
        {
            PDALog.Error(ex);
            throw ExceptionHelper.CreateSoapException(ex.Message, ex.Source);
        }
    }