/// <summary> /// 输入标签后回来 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e) { string strBarcode = txtBarcode.Text.Trim(); ///如果不为空 if (!string.IsNullOrEmpty(strBarcode) && e.KeyChar == (char)Keys.Enter) { try { ///分离二维码 barcode = strBarcode.Split(Cast.Delimiter); //判断当前条码是否在来源单据中 dispatchLists = dispatchList.List.Find(delegate(DispatchLists temp) { return(temp.cInvCode.Equals(barcode[0]) && temp.cBatch.Equals(barcode[1])); }); if (dispatchLists == null) { MessageBox.Show("条码错误:存货编码批次不正确!"); txtBarcode.Focus(); txtBarcode.SelectAll(); return; } //判断该标签是否已经扫描过(排除同个存货多次扫描) RdRecords rds = rdRecord.List.Find( delegate(RdRecords temp) { return(temp.cInvCode.Equals(barcode[0]) && temp.cBatch.Equals(barcode[1])); }); if (rds != null)//如果不为空,判断标签序列号 { if (rds.SerialList.Contains(barcode[2])) { MessageBox.Show("条码错误:该存货已扫描!"); txtBarcode.Focus(); txtBarcode.SelectAll(); return; } } //显示信息 lblInvName.Text = dispatchLists.cInvName; lblInvStd.Text = dispatchLists.cInvStd; lblCWhName.Text = dispatchLists.cWhName; //lblEnterprise.Text = details.e lblProDate.Text = dispatchLists.dMDate == DateTime.MinValue ? "" : dispatchLists.dMDate.ToString("yyyy-MM-dd"); lblValidDate.Text = dispatchLists.dVDate == DateTime.MinValue ? "" : dispatchLists.dVDate.AddDays(-1).ToString("yyyy-MM-dd"); lblBatch.Text = dispatchLists.cBatch; //dispatchLists.cBarCode = barcode[0]; //显示已扫描数量 lblScanedNum.Text = dispatchLists.iScanQuantity.ToString(); txtCount.Text = (dispatchLists.iQuantity / Math.Abs(dispatchLists.iQuantity)).ToString();; txtCount.Focus(); txtCount.SelectAll(); //如果选择单品,则实现自动扫描 if (chkSingle.Checked) { KeyPressEventArgs args = new KeyPressEventArgs((char)Keys.Enter); txtCount_KeyPress(null, args); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// 输入数量后回车 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtCount_KeyPress(object sender, KeyPressEventArgs e) { string strCount = txtCount.Text.Trim(); if (e.KeyChar == (char)Keys.Enter && !string.IsNullOrEmpty(strCount)) { //判断数量是否正确 double quantity = Cast.ToDouble(strCount); if (quantity == 0) { MessageBox.Show("请输入正确的数量!"); txtCount.SelectAll(); txtCount.Focus(); return; } //判断是发货单还是退货单breturnflag if (dispatchList.bReturnFlag)//退货,数量不能为正 { if (quantity > 0) { MessageBox.Show("退货数量不能为正!"); txtCount.SelectAll(); txtCount.Focus(); return; } } else //发货,数量不能为负 { if (quantity < 0) { MessageBox.Show("发货数量不能为负!"); txtCount.SelectAll(); txtCount.Focus(); return; } } //如何录入数量大于订货数量-累计发货数量-已扫描数量,则返回 if (Math.Abs(quantity) > Math.Abs(dispatchLists.iQuantity) - Math.Abs(dispatchLists.fOutQuantity) - Math.Abs(dispatchLists.iScanQuantity)) { MessageBox.Show("输入数量大于应发货数量"); txtCount.SelectAll(); txtCount.Focus(); return; } //判断已扫数据中是否存在(存货编号、批次) RdRecords tempRdRecords = rdRecord.List.Find(delegate(RdRecords temp) { return(temp.cInvCode.Equals(barcode[0]) && temp.cBatch.Equals(barcode[1])); }); ///不存在 if (tempRdRecords == null) { ///累加扫描数量 dispatchLists.iScanQuantity += quantity; tempRdRecords = EntityConvert.ConvertToRdrecords(dispatchLists); tempRdRecords.iScanQuantity = quantity; tempRdRecords.iUnitCost = dispatchLists.iTaxUnitPrice; //原币含税单价 tempRdRecords.iPrice = tempRdRecords.iScanQuantity * tempRdRecords.iUnitCost; //原币价税合计 tempRdRecords.SerialList.Add(barcode[2]); //存储扫描的序列号 rdRecord.List.Add(tempRdRecords); btnDone.Enabled = true; btnSubmit.Enabled = true; } else { ///累加扫描数量 dispatchLists.iScanQuantity += quantity; tempRdRecords.iScanQuantity += quantity; tempRdRecords.iPrice = tempRdRecords.iScanQuantity * tempRdRecords.iUnitCost; //原币价税合计 tempRdRecords.SerialList.Add(barcode[2]); //存储扫描的序列号 } Clear();//清空数据 txtBarcode.Focus(); } }
/// <summary> /// 把销售发货子表转换成销售出库子表对象 /// </summary> /// <param name="dispatchLists"></param> /// <returns></returns> public static RdRecords ConvertToRdrecords(DispatchLists dispatchLists) { RdRecords rdRecords = new RdRecords(); //rdRecords.AutoID; rdRecords.bCosting = dispatchLists.bCosting; rdRecords.bGsp = dispatchLists.bGsp; rdRecords.cWhCode = dispatchLists.cWhCode; rdRecords.cWhName = dispatchLists.cWhName; //rdRecords.bVMIUsed; //rdRecords.cAssUnit = dispatchLists.cav; rdRecords.cbaccounter = dispatchLists.cbaccounter; //rdRecords.cBarCode = dispatchLists.cBarCode; rdRecords.cBatch = dispatchLists.cBatch; rdRecords.cBatchProperty1 = dispatchLists.cBatchProperty1; rdRecords.cBatchProperty2 = dispatchLists.cBatchProperty2; rdRecords.cBatchProperty3 = dispatchLists.cBatchProperty3; rdRecords.cBatchProperty4 = dispatchLists.cBatchProperty4; rdRecords.cBatchProperty5 = dispatchLists.cBatchProperty5; rdRecords.cBatchProperty6 = dispatchLists.cBatchProperty6; rdRecords.cBatchProperty7 = dispatchLists.cBatchProperty7; rdRecords.cBatchProperty8 = dispatchLists.cBatchProperty8; rdRecords.cBatchProperty9 = dispatchLists.cBatchProperty9; rdRecords.cBatchProperty10 = dispatchLists.cBatchProperty10; rdRecords.cbdlcode = dispatchLists.cDLCode; rdRecords.cCusInvCode = dispatchLists.cCusInvCode; rdRecords.cCusInvName = dispatchLists.cCusInvName; rdRecords.cDefine22 = dispatchLists.cDefine22; rdRecords.cDefine23 = dispatchLists.cDefine23; rdRecords.cDefine24 = dispatchLists.cDefine24; rdRecords.cDefine25 = dispatchLists.cDefine25; rdRecords.cDefine26 = dispatchLists.cDefine26; rdRecords.cDefine27 = dispatchLists.cDefine27; rdRecords.cDefine28 = dispatchLists.cDefine28; rdRecords.cDefine29 = dispatchLists.cDefine29; rdRecords.cDefine30 = dispatchLists.cDefine30; rdRecords.cDefine31 = dispatchLists.cDefine31; rdRecords.cDefine32 = dispatchLists.cDefine32; rdRecords.cDefine33 = dispatchLists.cDefine33; rdRecords.cDefine34 = dispatchLists.cDefine34; rdRecords.cDefine35 = dispatchLists.cDefine35; rdRecords.cDefine36 = dispatchLists.cDefine36; rdRecords.cDefine37 = dispatchLists.cDefine37; rdRecords.cExpirationdate = dispatchLists.cExpirationdate; rdRecords.cFree1 = dispatchLists.cFree1; rdRecords.cFree2 = dispatchLists.cFree2; rdRecords.cFree3 = dispatchLists.cFree3; rdRecords.cFree4 = dispatchLists.cFree4; rdRecords.cFree5 = dispatchLists.cFree5; rdRecords.cFree6 = dispatchLists.cFree6; rdRecords.cFree7 = dispatchLists.cFree7; rdRecords.cFree8 = dispatchLists.cFree8; rdRecords.cFree9 = dispatchLists.cFree9; rdRecords.cFree10 = dispatchLists.cFree10; rdRecords.cGspState = dispatchLists.cGspState; //rdRecords.cinva_unit = dispatchLists.cinvde; //rdRecords.cInvAddCode= dispatchLists.cinvadd; rdRecords.cInvCode = dispatchLists.cInvCode; rdRecords.cInvName = dispatchLists.cInvName; rdRecords.cInvStd = dispatchLists.cInvStd; rdRecords.cInvDefine1 = dispatchLists.cInvDefine1; rdRecords.cInvDefine6 = dispatchLists.cInvDefine6; rdRecords.cinvm_unit = dispatchLists.cinvm_unit; //rdRecords.cInVouchCode = dispatchLists.cinvouch; rdRecords.cItem_class = dispatchLists.cItem_class; rdRecords.cItemCName = dispatchLists.cItem_CName; rdRecords.cItemCode = dispatchLists.cItemCode; rdRecords.cMassUnit = dispatchLists.cMassUnit; rdRecords.iMassDate = dispatchLists.iMassDate; //rdRecords.corufts = dispatchLists.cou; //rdRecords.cPosition = dispatchLists.cPosition; //rdRecords.cReplaceItem = dispatchLists.crelacusc; rdRecords.csocode = dispatchLists.cSoCode; //rdRecords.cVenName= dispatchLists.Inventory.cv; rdRecords.cvmivencode = dispatchLists.cvmivencode; //rdRecords.cvmivenname= dispatchLists.cv; //rdRecords.cVouchCode= dispatchLists.cvouc; rdRecords.dExpirationdate = dispatchLists.dExpirationdate; rdRecords.dMadeDate = dispatchLists.dMDate; rdRecords.dVDate = dispatchLists.dVDate; rdRecords.iTaxRate = dispatchLists.iTaxRate; //rdRecords.editprop= "A"; //rdRecords.iAvaNum = dispatchLists.iav; //rdRecords.iAvaQuantity = ; //rdRecords.iBondedSumQty = ; //rdRecords.iCheckIds = ; //rdRecords.ID =; rdRecords.iDLsID = dispatchLists.iDLsID; //rdRecords.iEnsID = dispatchLists.iend; rdRecords.iExpiratDateCalcu = dispatchLists.iExpiratDateCalcu; //rdRecords.iGrossWeight= dispatchLists.igr; rdRecords.iInvExchRate = dispatchLists.iInvExchRate; rdRecords.iInvSNCount = dispatchLists.iInvSNCount; //rdRecords.iMPoIds = dispatchLists.imoneys; //rdRecords.iNetWeight= dispatchLists.inat; //rdRecords.iNNum= dispatchLists.innum; rdRecords.iNQuantity = dispatchLists.iQuantity - dispatchLists.fOutQuantity; rdRecords.iNum = dispatchLists.iNum - dispatchLists.fOutNum; rdRecords.iordercode = dispatchLists.cSoCode; rdRecords.iorderdid = dispatchLists.iSOsID; rdRecords.iorderseq = dispatchLists.iorderrowno; //rdRecords.iordertype = dispatchLists.iorer; //rdRecords.iPPrice = dispatchLists.ippric; //rdRecords.iPresent = dispatchLists.ipr; //rdRecords.iPresentNum =; //rdRecords.iPrice = dispatchLists.fSalePrice; //rdRecords.iPUnitCost= dispatchLists.fSaleCost; //rdRecords.iUnitCost = dispatchLists.fSaleCost; rdRecords.iQuantity = dispatchLists.iQuantity; //rdRecords.iSBsID = dispatchLists.isb; //rdRecords.iSendNum = dispatchLists.iNum; //rdRecords.iSendQuantity= dispatchLists.iScanQuantity; //rdRecords.iSoDID = dispatchLists.iSOsID; //rdRecords.isoseq = dispatchLists.irowno; //rdRecords.iSoType = dispatchLists.iSettle; rdRecords.iSOutNum = dispatchLists.fOutNum; rdRecords.iSOutQuantity = dispatchLists.fOutQuantity; //rdRecords.iTrIds = dispatchLists.; //rdRecords.iVMISettleNum=; //rdRecords.iVMISettleQuantity =; //rdRecords.scrapufts=; //rdRecords.strCode = dispatchLists.str; //rdRecords.strContractId =; return(rdRecords); }