unit U_PRTJYDJList; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, cxCheckBox, RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, Menus, BtnEdit; type TfrmPRTJYDJList = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBExport: TToolButton; TBClose: TToolButton; Panel1: TPanel; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DataSource1: TDataSource; cxGridPopupMenu1: TcxGridPopupMenu; Label4: TLabel; Color: TEdit; Label1: TLabel; Label2: TLabel; BegDate: TDateTimePicker; EndDate: TDateTimePicker; CDS_Main: TClientDataSet; Label5: TLabel; orderNo: TEdit; cxGrid2: TcxGrid; Tv1: TcxGridDBTableView; v1Column1: TcxGridDBColumn; v2Column3: TcxGridDBColumn; v1Column5: TcxGridDBColumn; v1Column2: TcxGridDBColumn; v1Column10: TcxGridDBColumn; cxGrid2Level1: TcxGridLevel; Label10: TLabel; GangNo: TEdit; RM1: TRMGridReport; RMDBMain: TRMDBDataSet; RMXLSExport1: TRMXLSExport; RMDBHZ: TRMDBDataSet; CDS_HZ: TClientDataSet; CDS_PRT: TClientDataSet; TBRKCX: TToolButton; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; ToolButton1: TToolButton; v1Column11: TcxGridDBColumn; v1Column12: TcxGridDBColumn; v1Column16: TcxGridDBColumn; CDS_Juan: TClientDataSet; CDS_JuanPRT: TClientDataSet; RMDBMX: TRMDBDataSet; RM3: TRMGridReport; BtnEditA1: TBtnEditA; ADOQueryPrint: TADOQuery; Lot: TComboBox; Label11: TLabel; HX: TEdit; v1Column20: TcxGridDBColumn; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure ConNoMChange(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBExportClick(Sender: TObject); procedure TBFindClick(Sender: TObject); procedure MPRTCodeNameChange(Sender: TObject); procedure orderNoChange(Sender: TObject); procedure orderNoKeyPress(Sender: TObject; var Key: Char); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure TBRKCXClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure BtnEditA1BtnClick(Sender: TObject); private FLeft,FTop:Integer; procedure InitGrid(); procedure GetLotData(); procedure GetLotDataLie(); procedure GetLotDataLie38(); procedure GetLotDataLie38Ye(); { Private declarations } public { Public declarations } end; var frmPRTJYDJList: TfrmPRTJYDJList; implementation uses U_DataLink,U_RTFun,U_ZDYHelp,U_MJEdit; {$R *.dfm} procedure TfrmPRTJYDJList.FormDestroy(Sender: TObject); begin frmPRTJYDJList:=nil; end; procedure TfrmPRTJYDJList.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end; procedure TfrmPRTJYDJList.FormCreate(Sender: TObject); begin //cxGrid1.Align:=alClient; BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp); EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp) end; procedure TfrmPRTJYDJList.InitGrid(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered:=False; Close; sql.Clear; sql.Add('select A.* '); sql.Add(',JYDate=Convert(Varchar(10),FillTime,120)'); sql.Add(' from DJ_JY A where FillTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+''''); sql.Add(' and FillTime<='''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.Date+1))+''''); Open; //ShowMessage(SQL.Text); end; SCreateCDS20(ADOQueryMain,CDS_Main); SInitCDSData20(ADOQueryMain,CDS_Main); finally ADOQueryMain.EnableControls; end; end; procedure TfrmPRTJYDJList.TBRafreshClick(Sender: TObject); begin BegDate.SetFocus; InitGrid(); end; procedure TfrmPRTJYDJList.ConNoMChange(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2)); end; end; procedure TfrmPRTJYDJList.TBCloseClick(Sender: TObject); begin WriteCxGrid('成品检验管理CX',Tv1,'成品检验'); Close; end; procedure TfrmPRTJYDJList.FormShow(Sender: TObject); begin ReadCxGrid('成品检验管理CX',Tv1,'成品检验'); {if Trim(DParameters2)='管理' then begin TBRKCX.Visible:=True; end else begin v1Column4.Visible:=False; end; } //InitGrid(); end; procedure TfrmPRTJYDJList.TBExportClick(Sender: TObject); begin if ADOQueryMain.IsEmpty then exit; TcxGridToExcel('检验列表',cxGrid2); end; procedure TfrmPRTJYDJList.TBFindClick(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2)); SCreateCDS20(ADOQueryMain,CDS_Main); SInitCDSData20(ADOQueryMain,CDS_Main); end; end; procedure TfrmPRTJYDJList.MPRTCodeNameChange(Sender: TObject); begin TBFind.Click; end; procedure TfrmPRTJYDJList.orderNoChange(Sender: TObject); begin //if Length(Trim(orderNo.Text))<4 then Exit; TBFind.Click; end; procedure TfrmPRTJYDJList.orderNoKeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then begin if Length(Trim(orderNo.Text))<4 then Exit; try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered:=False; Close; sql.Clear; sql.Add('select A.* '); sql.Add(',JYDate=Convert(Varchar(10),FillTime,120)'); sql.Add(' from DJ_JY A '); sql.add('where A.OrderNo like :OrderNo'); Parameters.ParamByName('orderNo').Value:='%'+Trim(orderNo.Text)+'%'; Open; //ShowMessage(SQL.Text); end; SCreateCDS20(ADOQueryMain,CDS_Main); SInitCDSData20(ADOQueryMain,CDS_Main); finally ADOQueryMain.EnableControls; end; end; end; procedure TfrmPRTJYDJList.N1Click(Sender: TObject); begin SelOKNo(CDS_Main,True); end; procedure TfrmPRTJYDJList.N2Click(Sender: TObject); begin SelOKNo(CDS_Main,False); end; procedure TfrmPRTJYDJList.TBRKCXClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; if Application.MessageBox('确定要执行操作吗?','提示',32+4)<>IDYES then Exit; BegDate.SetFocus; try ADOQueryCmd.Connection.BeginTrans; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete WFB_MJJY where MJID='''+Trim(CDS_Main.fieldbyname('MJID').AsString)+''''); ExecSQL; end; ADOQueryCmd.Connection.CommitTrans; CDS_Main.Delete; except ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('撤销失败!','提示',0); end; end; procedure TfrmPRTJYDJList.GetLotData(); var i,j,z,h,q,Hang,GHang:Integer; FGangNo,FHZ,FSubId:String; begin if CDS_Main.IsEmpty then Exit; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select GangNo=MD.SelfGangNo,A.MJXH,A.MJMaoZ,A.SubId,A.MainId,A.MJQty4,'); sql.Add(' Case when isnull(A.DuoPinNote,'''')<>'''' then ''(''+RTrim(A.DuoPinNote)+'')'' else A.DuoPinNote end as DPNote,'); if Pos('Y',Trim(BtnEditA1.Text))>0 then begin //sql.Add('MJLen=Cast(A.MJLen*1.0936 as decimal(18,1)),'); sql.Add(' Case when isnull(A.MJLenMa,-1)=-1 then Cast(A.MJLen*1.0936 as decimal(18,1)) else Cast(A.MJLenMa*1 as decimal(18,1)) end as MJLen, '); end else begin sql.Add('A.MJLen,'); end; sql.Add('DD.OrderNo,JS.PRTColor,PRTEColor=JS.PRTColorEng,PRTColorNo=JS.PRTColorNo,JS.PRTHX,'); sql.Add(' JJQty=(select Count(*) from WFB_MJJY WM where WM.SubId=JS.SubId),'); sql.Add(' GGQty=(select Count(*) from WFB_MJJY WM inner join JYOrder_Main_MD JMD on WM.APID=JMD.MDID '); sql.add(' where WM.SubId=JS.SubId and JMD.SelfGangNo=MD.SelfGangNo)') ; sql.Add(' from WFB_MJJY A'); sql.Add(' inner join JYOrder_Main DD on A.MainId=DD.MainId'); sql.Add(' inner join JYOrder_Sub JS on A.SubId=JS.SubId'); sql.Add(' inner join JYOrder_Main_MD MD on A.APID=MD.MDID'); sql.Add(' where A.MainId='''+Trim(CDS_Main.fieldbyname('MainId').AsString)+''''); sql.Add(' and A.ZhuangXiangSYFlag=0'); sql.Add(' order by A.SubId,Cast(MD.SelfGangNo as int),A.MJXH'); Open; end; SCreateCDS20(ADOQueryTemp,CDS_Juan); SInitCDSData20(ADOQueryTemp,CDS_Juan); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select MainId=Cast('''' as varchar(20)),SubId=Cast('''' as varchar(20)),'); sql.Add(' PRTEColor=Cast('''' as varchar(20)),PRTHX=Cast('''' as varchar(20)),PRTColorNo=Cast('''' as varchar(20)),'); sql.Add(' GangNo=Cast('''' as varchar(20)),BaoNo=Cast('''' as varchar(20)),XH=Cast(0 as int),'); sql.Add(' LenQty0=Cast(1.00 as decimal(18,1)),LenQty1=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty2=Cast(1.00 as decimal(18,1)),LenQty3=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty4=Cast(1.00 as decimal(18,1)),LenQty5=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty6=Cast(1.00 as decimal(18,1)),LenQty7=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty8=Cast(1.00 as decimal(18,1)),LenQty9=Cast(1.00 as decimal(18,1)),'); sql.Add(' MZ0=Cast(1.00 as decimal(18,2)),MZ1=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ2=Cast(1.00 as decimal(18,2)),MZ3=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ4=Cast(1.00 as decimal(18,2)),MZ5=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ6=Cast(1.00 as decimal(18,2)),MZ7=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ8=Cast(1.00 as decimal(18,2)),MZ9=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ0=Cast(1.00 as decimal(18,2)),JZ1=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ2=Cast(1.00 as decimal(18,2)),JZ3=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ4=Cast(1.00 as decimal(18,2)),JZ5=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ6=Cast(1.00 as decimal(18,2)),JZ7=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ8=Cast(1.00 as decimal(18,2)),JZ9=Cast(1.00 as decimal(18,2)),'); sql.Add(' DP0=Cast('''' as varchar(20)),DP1=Cast('''' as varchar(20)),'); sql.Add(' DP2=Cast('''' as varchar(20)),DP3=Cast('''' as varchar(20)),'); sql.Add(' DP4=Cast('''' as varchar(20)),DP5=Cast('''' as varchar(20)),'); sql.Add(' DP6=Cast('''' as varchar(20)),DP7=Cast('''' as varchar(20)),'); sql.Add(' DP8=Cast('''' as varchar(20)),DP9=Cast('''' as varchar(20)),'); sql.Add(' MJPS0=Cast(1 as int),MJPS1=Cast(1 as int),'); sql.Add(' MJPS2=Cast(1 as int),MJPS3=Cast(1 as int),'); sql.Add(' MJPS4=Cast(1 as int),MJPS5=Cast(1 as int),'); sql.Add(' MJPS6=Cast(1 as int),MJPS7=Cast(1 as int),'); sql.Add(' MJPS8=Cast(1 as int),MJPS9=Cast(1 as int),'); sql.Add(' JuanQty=Cast(0 as int),GangQty=Cast(0 as int),'); sql.Add(' XH=Cast(0 as int),Hang=Cast(0 as int),GHang=Cast(0 as int)'); Open; end; SCreateCDS20(ADOQueryTemp,CDS_JuanPRT); SInitCDSData20(ADOQueryTemp,CDS_JuanPRT); if CDS_JuanPRT.IsEmpty=False then begin CDS_JuanPRT.Delete; end; i:=0;j:=0;z:=0;FGangNo:='';h:=0;hang:=0; GHang:=0; CDS_Juan.DisableControls; with CDS_Juan do begin First; while not Eof do begin //FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString)+Trim(CDS_Juan.fieldbyname('BaoNO').AsString) //+Trim(CDS_Juan.fieldbyname('GangNo').AsString); with CDS_JuanPRT do begin if CDS_JuanPRT.IsEmpty then begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('GangNo').Value:=CDS_Juan.fieldbyname('GangNo').Value; // CDS_JuanPRT.FieldByName('BaoNO').Value:=CDS_Juan.fieldbyname('BaoNO').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('XH').Value:=0; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('GHang').Value:=0; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('DP0').Value:=CDS_Juan.fieldbyname('DPNote').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('JuanQty').Value:=CDS_Juan.fieldbyname('JJQty').Value; CDS_JuanPRT.FieldByName('GangQty').Value:=CDS_Juan.fieldbyname('GGQty').Value; CDS_JuanPRT.Post; FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); Z:=0;//gang 后缀 j:=0;//行号 for i:=1 to 9 do begin CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(i))).Value:=0; CDS_JuanPRT.Post; end; end else begin if (Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString))<>FHZ then begin GHang:=0; if Trim(CDS_Juan.fieldbyname('SubId').AsString)<>FSubId then begin Hang:=0; end else begin Hang:=Hang+1; end; CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('GangNo').Value:=CDS_Juan.fieldbyname('GangNo').Value; //CDS_JuanPRT.FieldByName('BaoNO').Value:=CDS_Juan.fieldbyname('BaoNO').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('XH').Value:=J+1; CDS_JuanPRT.FieldByName('Hang').Value:=Hang; CDS_JuanPRT.FieldByName('GHang').Value:=GHang; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('DP0').Value:=CDS_Juan.fieldbyname('DPNote').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('JuanQty').Value:=CDS_Juan.fieldbyname('JJQty').Value; CDS_JuanPRT.FieldByName('GangQty').Value:=CDS_Juan.fieldbyname('GGQty').Value; CDS_JuanPRT.Post; FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString); Z:=0;//gang 后缀 j:=j+1;//行号 for i:=1 to 9 do begin CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(i))).Value:=0; CDS_JuanPRT.Post; end; end else begin if Z<10 then begin CDS_JuanPRT.Locate('XH',j,[]); with CDS_JuanPRT do begin Edit; FieldByName('GangNo').Value:=CDS_Juan.fieldbyname('GangNo').Value; //FieldByName('BaoNO').Value:=CDS_Juan.fieldbyname('BaoNO').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; FieldByName('MJPS'+Trim(IntToStr(Z))).Value:=1; FieldByName('LenQty'+Trim(IntToStr(Z))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(Z))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(Z))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('DP'+Trim(IntToStr(Z))).Value:=CDS_Juan.fieldbyname('DPNote').Value; FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; Post; end; end else begin GHang:=GHang+1; Hang:=Hang+1; CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('GangNo').Value:=CDS_Juan.fieldbyname('GangNo').Value; //CDS_JuanPRT.FieldByName('BaoNO').Value:=CDS_Juan.fieldbyname('BaoNO').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('XH').Value:=J+1; CDS_JuanPRT.FieldByName('Hang').Value:=Hang; CDS_JuanPRT.FieldByName('GHang').Value:=GHang; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('DP0').Value:=CDS_Juan.fieldbyname('DPNote').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('JuanQty').Value:=CDS_Juan.fieldbyname('JJQty').Value; CDS_JuanPRT.FieldByName('GangQty').Value:=CDS_Juan.fieldbyname('GGQty').Value; CDS_JuanPRT.Post; Z:=0;//gang 后缀 j:=j+1;//行号 for i:=1 to 9 do begin CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(i))).Value:=0; CDS_JuanPRT.Post; end; end; end; end end; Z:=Z+1; Next; end; end; CDS_Juan.EnableControls; end; procedure TfrmPRTJYDJList.GetLotDataLie(); var i,j,z,H,q,L,Y:Integer; FGangNo,FHZ,Lot0,Lot1,Lot2,Lot3,FSubId:String; begin if CDS_Main.IsEmpty then Exit; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select GangNo=MD.SelfGangNo,A.MJXH,A.MJMaoZ,A.SubId,A.MainId,A.MJQty4,'); if Pos('Y',Trim(BtnEditA1.Text))>0 then begin //sql.Add('MJLen=Cast(A.MJLen*1.0936 as decimal(18,1)),'); sql.Add(' Case when isnull(A.MJLenMa,-1)=-1 then Cast(A.MJLen*1.0936 as decimal(18,1)) else Cast(A.MJLenMa*1 as decimal(18,1)) end as MJLen '); end else begin sql.Add('A.MJLen,'); end; sql.Add('DD.OrderNo,JS.PRTColor,PRTEColor=JS.PRTColorEng,PRTColorNo=JS.PRTColorNo,JS.PRTHX,'); sql.Add(' JQty=(select Count(*) from WFB_MJJY WM where WM.SubId=JS.SubId),'); sql.Add(' GQty=(select Count(*) from WFB_MJJY WM inner join JYOrder_Main_MD JMD on WM.APID=JMD.MDID '); sql.add(' where WM.SubId=JS.SubId and JMD.SelfGangNo=MD.SelfGangNo)') ; sql.Add(' from WFB_MJJY A'); sql.Add(' inner join JYOrder_Main DD on A.MainId=DD.MainId'); sql.Add(' inner join JYOrder_Sub JS on A.SubId=JS.SubId'); sql.Add(' inner join JYOrder_Main_MD MD on A.APID=MD.MDID'); sql.Add(' where A.MainId='''+Trim(CDS_Main.fieldbyname('MainId').AsString)+''''); sql.Add(' and A.ZhuangXiangSYFlag=0'); //sql.Add(' and A.SubId=''JS1402100003'' '); //sql.Add(' and A.Valie=''Y'' '); sql.Add(' order by JS.SubId,Cast(MD.SelfGangNo as int),A.MJXH'); Open; end; //ShowMessage(IntToStr(ADOQueryTemp.RecordCount)); SCreateCDS20(ADOQueryTemp,CDS_Juan); SInitCDSData20(ADOQueryTemp,CDS_Juan); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select MainId=Cast('''' as varchar(20)),SubId=Cast('''' as varchar(20)),'); sql.Add(' PRTEColor=Cast('''' as varchar(20)),PRTHX=Cast('''' as varchar(20)),PRTColorNo=Cast('''' as varchar(20)),'); sql.Add(' Lot0=Cast('''' as varchar(20)),Lot1=Cast('''' as varchar(20)),'); sql.Add(' Lot2=Cast('''' as varchar(20)),Lot3=Cast('''' as varchar(20)),'); sql.Add(' BaoNo=Cast('''' as varchar(20)),XH=Cast(0 as int),JJQty=Cast(0 as int),GGQty=Cast(0 as int),'); sql.Add(' LenQty0=Cast(1.00 as decimal(18,1)),LenQty1=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty2=Cast(1.00 as decimal(18,1)),LenQty3=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty4=Cast(1.00 as decimal(18,1)),LenQty5=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty6=Cast(1.00 as decimal(18,1)),LenQty7=Cast(1.00 as decimal(18,1)),'); sql.Add(' MZ0=Cast(1.00 as decimal(18,2)),MZ1=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ2=Cast(1.00 as decimal(18,2)),MZ3=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ4=Cast(1.00 as decimal(18,2)),MZ5=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ6=Cast(1.00 as decimal(18,2)),MZ7=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ0=Cast(1.00 as decimal(18,2)),JZ1=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ2=Cast(1.00 as decimal(18,2)),JZ3=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ4=Cast(1.00 as decimal(18,2)),JZ5=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ6=Cast(1.00 as decimal(18,2)),JZ7=Cast(1.00 as decimal(18,2)),'); sql.Add(' MJPS0=Cast(1 as int),MJPS1=Cast(1 as int),'); sql.Add(' MJPS2=Cast(1 as int),MJPS3=Cast(1 as int),'); sql.Add(' MJPS4=Cast(1 as int),MJPS5=Cast(1 as int),'); sql.Add(' MJPS6=Cast(1 as int),MJPS7=Cast(1 as int),'); sql.Add(' JH0=Cast(1 as int),JH1=Cast(1 as int),'); sql.Add(' JH2=Cast(1 as int),JH3=Cast(1 as int),'); sql.Add(' JH4=Cast(1 as int),JH5=Cast(1 as int),'); sql.Add(' JH6=Cast(1 as int),JH7=Cast(1 as int),'); sql.Add(' Hang=Cast(0 as int),'); sql.Add(' Ye=Cast(0 as int),'); sql.Add(' Lie=Cast(0 as int)'); Open; end; SCreateCDS20(ADOQueryTemp,CDS_JuanPRT); SInitCDSData20(ADOQueryTemp,CDS_JuanPRT); if CDS_JuanPRT.IsEmpty=False then begin CDS_JuanPRT.Delete; end; i:=0;j:=0;z:=0;FGangNo:='';h:=0;L:=0;Y:=0; CDS_Juan.DisableControls; with CDS_Juan do begin First; while not Eof do begin //FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString)+Trim(CDS_Juan.fieldbyname('BaoNO').AsString) //+Trim(CDS_Juan.fieldbyname('GangNo').AsString); with CDS_JuanPRT do begin if CDS_JuanPRT.IsEmpty then begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=0; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=26; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=26; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=26; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=26; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); H:=0;//行号 L:=0;//列号 Y:=0;//页号 for i:=1 to 24 do begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=26+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=26+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=26+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=26+i; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //CDS_JuanPRT.FieldByName('Lot0').Value:=Lot.Items[0]; // CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.Post; end; end else //如果数据集不为空,色号缸号变为新的。 begin if Trim(CDS_Juan.fieldbyname('SubId').AsString)<>Trim(FSubId) then begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=Y+1; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=26; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=26; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=26; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=26; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //CDS_JuanPRT.FieldByName('JQty').Value:=CDS_Juan.fieldbyname('JQty').Value; //CDS_JuanPRT.FieldByName('GQty').Value:=CDS_Juan.fieldbyname('GQty').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); H:=0;//行号 L:=0;//列号 Y:=Y+1;//页号 for i:=1 to 24 do begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=26+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=26+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=26+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=26+i; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //CDS_JuanPRT.FieldByName('Lot0').Value:=Lot.Items[0]; // CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.Post; end; end else //subid 相同,缸号不同 begin if (Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString))<>FHZ then begin if (L mod 2)=1 then L:=L+1 else L:=L+2; if L<8 then begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, 0]), [loPartialKey]);//如果列号小于8 定位到当前页第一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L div 2))).Value:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); H:=0; end else //如果列号大于7,则增加新的一页 begin H:=0;//行号 L:=0;//列号 Y:=Y+1;//页号 CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; //Lot0:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=Y; // CDS_JuanPRT.FieldByName('Lie').Value:=0; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=26; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=26; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=26; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=26; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //CDS_JuanPRT.FieldByName('JQty').Value:=CDS_Juan.fieldbyname('JQty').Value; //CDS_JuanPRT.FieldByName('GQty').Value:=CDS_Juan.fieldbyname('GQty').Value; CDS_JuanPRT.Post; FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); for i:=1 to 24 do begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=26+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=26+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=26+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=26+i; //CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('gangno').Value; //CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; // CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; end; end; end else //数据集不为空,缸号色号相同 begin H:=H+1; if H<25 then //如果行号小于25 数据集不为空,缸号色号相同 begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, H]), [loPartialKey]);//定位到当前页下一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L div 2))).Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; // Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); end else begin //如果行号大于25,进行换列 数据集不为空,缸号色号相同 H:=0; L:=L+1; {if (L mod 2)=1 then L:=L+1 else L:=L+2; } if L<8 then //如果还在当前页 数据集不为空,缸号色号相同 begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, 0]), [loPartialKey]);//定位到当前页下一列第一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L div 2))).Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); end else //如果不在当前页,则增加一页 数据集不为空,缸号色号相同 begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; // Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; //Lot0:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=Y+1; // CDS_JuanPRT.FieldByName('Lie').Value:=0; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=26; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=26; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=26; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=26; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //CDS_JuanPRT.FieldByName('JQty').Value:=CDS_Juan.fieldbyname('JQty').Value; //CDS_JuanPRT.FieldByName('GQty').Value:=CDS_Juan.fieldbyname('GQty').Value; CDS_JuanPRT.Post; FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); H:=0;//行号 L:=0;//列号 Y:=Y+1;//页号 for i:=1 to 24 do begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=26+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=26+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=26+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=26+i; CDS_JuanPRT.FieldByName('Lot0').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; end; end; end; end; end; end end; Next; end; end; CDS_Juan.EnableControls; end; procedure TfrmPRTJYDJList.GetLotDataLie38(); var i,j,z,H,q,L,Y:Integer; FGangNo,FHZ,Lot0,Lot1,Lot2,Lot3,FSubId:String; begin if CDS_Main.IsEmpty then Exit; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select GangNo=MD.SelfGangNo,A.MJXH,A.MJMaoZ,A.SubId,A.MainId,A.MJQty4,'); if Pos('Y',Trim(BtnEditA1.Text))>0 then begin sql.Add('MJLen=Cast(A.MJLen*1.0936 as decimal(18,1)),'); end else begin sql.Add('A.MJLen,'); end; sql.Add('DD.OrderNo,JS.PRTColor,PRTEColor=JS.PRTColorEng,PRTColorNo=JS.PRTColorNo,JS.PRTHX,'); sql.Add(' JQty=(select Count(*) from WFB_MJJY WM where WM.SubId=JS.SubId),'); sql.Add(' GQty=(select Count(*) from WFB_MJJY WM inner join JYOrder_Main_MD JMD on WM.APID=JMD.MDID '); sql.add(' where WM.SubId=JS.SubId and JMD.SelfGangNo=MD.SelfGangNo)') ; sql.Add(' from WFB_MJJY A'); sql.Add(' inner join JYOrder_Main DD on A.MainId=DD.MainId'); sql.Add(' inner join JYOrder_Sub JS on A.SubId=JS.SubId'); sql.Add(' inner join JYOrder_Main_MD MD on A.APID=MD.MDID'); sql.Add(' where A.MainId='''+Trim(CDS_Main.fieldbyname('MainId').AsString)+''''); sql.Add(' and A.ZhuangXiangSYFlag=0'); //sql.Add(' and A.SubId=''JS1402100003'' '); //sql.Add(' and A.Valie=''Y'' '); sql.Add(' order by JS.SubId,Cast(MD.SelfGangNo as int),A.MJXH'); Open; end; //ShowMessage(IntToStr(ADOQueryTemp.RecordCount)); SCreateCDS20(ADOQueryTemp,CDS_Juan); SInitCDSData20(ADOQueryTemp,CDS_Juan); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select MainId=Cast('''' as varchar(20)),SubId=Cast('''' as varchar(20)),'); sql.Add(' PRTEColor=Cast('''' as varchar(20)),PRTHX=Cast('''' as varchar(20)),PRTColorNo=Cast('''' as varchar(20)),'); sql.Add(' Lot0=Cast('''' as varchar(20)),Lot1=Cast('''' as varchar(20)),'); sql.Add(' Lot2=Cast('''' as varchar(20)),Lot3=Cast('''' as varchar(20)),'); sql.Add(' Lot4=Cast('''' as varchar(20)),Lot5=Cast('''' as varchar(20)),'); sql.Add(' Lot6=Cast('''' as varchar(20)),Lot7=Cast('''' as varchar(20)),'); sql.Add(' BaoNo=Cast('''' as varchar(20)),XH=Cast(0 as int),JJQty=Cast(0 as int),GGQty=Cast(0 as int),'); sql.Add(' LenQty0=Cast(1.00 as decimal(18,1)),LenQty1=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty2=Cast(1.00 as decimal(18,1)),LenQty3=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty4=Cast(1.00 as decimal(18,1)),LenQty5=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty6=Cast(1.00 as decimal(18,1)),LenQty7=Cast(1.00 as decimal(18,1)),'); sql.Add(' MZ0=Cast(1.00 as decimal(18,2)),MZ1=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ2=Cast(1.00 as decimal(18,2)),MZ3=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ4=Cast(1.00 as decimal(18,2)),MZ5=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ6=Cast(1.00 as decimal(18,2)),MZ7=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ0=Cast(1.00 as decimal(18,2)),JZ1=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ2=Cast(1.00 as decimal(18,2)),JZ3=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ4=Cast(1.00 as decimal(18,2)),JZ5=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ6=Cast(1.00 as decimal(18,2)),JZ7=Cast(1.00 as decimal(18,2)),'); sql.Add(' MJPS0=Cast(1 as int),MJPS1=Cast(1 as int),'); sql.Add(' MJPS2=Cast(1 as int),MJPS3=Cast(1 as int),'); sql.Add(' MJPS4=Cast(1 as int),MJPS5=Cast(1 as int),'); sql.Add(' MJPS6=Cast(1 as int),MJPS7=Cast(1 as int),'); sql.Add(' JH0=Cast(1 as int),JH1=Cast(1 as int),'); sql.Add(' JH2=Cast(1 as int),JH3=Cast(1 as int),'); sql.Add(' JH4=Cast(1 as int),JH5=Cast(1 as int),'); sql.Add(' JH6=Cast(1 as int),JH7=Cast(1 as int),'); sql.Add(' Hang=Cast(0 as int),'); sql.Add(' Ye=Cast(0 as int),'); sql.Add(' Lie=Cast(0 as int)'); Open; end; SCreateCDS20(ADOQueryTemp,CDS_JuanPRT); SInitCDSData20(ADOQueryTemp,CDS_JuanPRT); if CDS_JuanPRT.IsEmpty=False then begin CDS_JuanPRT.Delete; end; i:=0;j:=0;z:=0;FGangNo:='';h:=0;L:=0;Y:=0; CDS_Juan.DisableControls; with CDS_Juan do begin First; while not Eof do begin //FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString)+Trim(CDS_Juan.fieldbyname('BaoNO').AsString) //+Trim(CDS_Juan.fieldbyname('GangNo').AsString); with CDS_JuanPRT do begin if CDS_JuanPRT.IsEmpty then begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=0; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=1; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=1; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=1; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=1; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); H:=0;//行号 L:=0;//列号 Y:=0;//页号 for i:=1 to 37 do begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=1+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=1+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=1+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=1+i; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //CDS_JuanPRT.FieldByName('Lot0').Value:=Lot.Items[0]; // CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.Post; end; end else //如果数据集不为空,色号缸号变为新的。 begin if Trim(CDS_Juan.fieldbyname('SubId').AsString)<>Trim(FSubId) then begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=Y+1; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=1; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=1; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=1; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=1; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //CDS_JuanPRT.FieldByName('JQty').Value:=CDS_Juan.fieldbyname('JQty').Value; //CDS_JuanPRT.FieldByName('GQty').Value:=CDS_Juan.fieldbyname('GQty').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); H:=0;//行号 L:=0;//列号 Y:=Y+1;//页号 for i:=1 to 37 do begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=1+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=1+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=1+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=1+i; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //CDS_JuanPRT.FieldByName('Lot0').Value:=Lot.Items[0]; // CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.Post; end; end else //subid 相同,缸号不同 begin if (Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString))<>FHZ then begin L:=L+1; if L<8 then begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, 0]), [loPartialKey]);//如果列号小于8 定位到当前页第一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); H:=0; end else //如果列号大于7,则增加新的一页 begin H:=0;//行号 L:=0;//列号 Y:=Y+1;//页号 CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; //Lot0:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=Y; // CDS_JuanPRT.FieldByName('Lie').Value:=0; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=1; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=1; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=1; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=1; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //CDS_JuanPRT.FieldByName('JQty').Value:=CDS_Juan.fieldbyname('JQty').Value; //CDS_JuanPRT.FieldByName('GQty').Value:=CDS_Juan.fieldbyname('GQty').Value; CDS_JuanPRT.Post; FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); for i:=1 to 37 do begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=1+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=1+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=1+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=1+i; //CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('gangno').Value; //CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; // CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; end; end; end else //数据集不为空,缸号色号相同 begin H:=H+1; if H<38 then //如果行号小于38 数据集不为空,缸号色号相同 begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, H]), [loPartialKey]);//定位到当前页下一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; // Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); end else begin //如果行号大于38,进行换列 数据集不为空,缸号色号相同 H:=0; L:=L+1; {if (L mod 2)=1 then L:=L+1 else L:=L+2; } if L<8 then //如果还在当前页 数据集不为空,缸号色号相同 begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, 0]), [loPartialKey]);//定位到当前页下一列第一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); end else //如果不在当前页,则增加一页 数据集不为空,缸号色号相同 begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; // Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; //Lot0:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=Y+1; // CDS_JuanPRT.FieldByName('Lie').Value:=0; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=1; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=1; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=1; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=1; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //CDS_JuanPRT.FieldByName('JQty').Value:=CDS_Juan.fieldbyname('JQty').Value; //CDS_JuanPRT.FieldByName('GQty').Value:=CDS_Juan.fieldbyname('GQty').Value; CDS_JuanPRT.Post; FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); H:=0;//行号 L:=0;//列号 Y:=Y+1;//页号 for i:=1 to 37 do begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=1+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=1+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=1+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=1+i; //CDS_JuanPRT.FieldByName('Lot0').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; end; end; end; end; end; end end; Next; end; end; CDS_Juan.EnableControls; end; procedure TfrmPRTJYDJList.GetLotDataLie38Ye();//按页分 var i,j,z,H,q,L,Y:Integer; FGangNo,FHZ,Lot0,Lot1,Lot2,Lot3,FSubId:String; begin if CDS_Main.IsEmpty then Exit; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select GangNo=MD.SelfGangNo,A.MJXH,A.MJMaoZ,A.SubId,A.MainId,A.MJQty4,'); if Pos('Y',Trim(BtnEditA1.Text))>0 then begin //sql.Add('MJLen=Cast(A.MJLen*1.0936 as decimal(18,1)),'); sql.Add(' Case when isnull(A.MJLenMa,-1)=-1 then Cast(A.MJLen*1.0936 as decimal(18,1)) else Cast(A.MJLenMa*1 as decimal(18,1)) end as MJLen '); end else begin sql.Add('A.MJLen,'); end; sql.Add('DD.OrderNo,JS.PRTColor,PRTEColor=JS.PRTColorEng,PRTColorNo=JS.PRTColorNo,JS.PRTHX,'); sql.Add(' JQty=(select Count(*) from WFB_MJJY WM where WM.SubId=JS.SubId),'); sql.Add(' GQty=(select Count(*) from WFB_MJJY WM inner join JYOrder_Main_MD JMD on WM.APID=JMD.MDID '); sql.add(' where WM.SubId=JS.SubId and JMD.SelfGangNo=MD.SelfGangNo)') ; sql.Add(' from WFB_MJJY A'); sql.Add(' inner join JYOrder_Main DD on A.MainId=DD.MainId'); sql.Add(' inner join JYOrder_Sub JS on A.SubId=JS.SubId'); sql.Add(' inner join JYOrder_Main_MD MD on A.APID=MD.MDID'); sql.Add(' where A.MainId='''+Trim(CDS_Main.fieldbyname('MainId').AsString)+''''); sql.Add(' and A.ZhuangXiangSYFlag=0'); //sql.Add(' and A.SubId=''JS1402100003'' '); //sql.Add(' and A.Valie=''Y'' '); sql.Add(' order by JS.SubId,Cast(MD.SelfGangNo as int),A.MJXH'); Open; end; //ShowMessage(IntToStr(ADOQueryTemp.RecordCount)); SCreateCDS20(ADOQueryTemp,CDS_Juan); SInitCDSData20(ADOQueryTemp,CDS_Juan); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select MainId=Cast('''' as varchar(20)),SubId=Cast('''' as varchar(20)),'); sql.Add(' PRTEColor=Cast('''' as varchar(20)),PRTHX=Cast('''' as varchar(20)),PRTColorNo=Cast('''' as varchar(20)),'); sql.Add(' Lot0=Cast('''' as varchar(20)),Lot1=Cast('''' as varchar(20)),'); sql.Add(' Lot2=Cast('''' as varchar(20)),Lot3=Cast('''' as varchar(20)),'); sql.Add(' Lot4=Cast('''' as varchar(20)),Lot5=Cast('''' as varchar(20)),'); sql.Add(' Lot6=Cast('''' as varchar(20)),Lot7=Cast('''' as varchar(20)),'); sql.Add(' CoL0=Cast('''' as varchar(80)),CoL1=Cast('''' as varchar(80)),'); sql.Add(' CoL2=Cast('''' as varchar(80)),CoL3=Cast('''' as varchar(80)),'); sql.Add(' CoL4=Cast('''' as varchar(80)),CoL5=Cast('''' as varchar(80)),'); sql.Add(' CoL6=Cast('''' as varchar(80)),CoL7=Cast('''' as varchar(80)),'); sql.Add(' BaoNo=Cast('''' as varchar(20)),XH=Cast(0 as int),JJQty=Cast(0 as int),GGQty=Cast(0 as int),'); sql.Add(' LenQty0=Cast(1.00 as decimal(18,1)),LenQty1=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty2=Cast(1.00 as decimal(18,1)),LenQty3=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty4=Cast(1.00 as decimal(18,1)),LenQty5=Cast(1.00 as decimal(18,1)),'); sql.Add(' LenQty6=Cast(1.00 as decimal(18,1)),LenQty7=Cast(1.00 as decimal(18,1)),'); sql.Add(' MZ0=Cast(1.00 as decimal(18,2)),MZ1=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ2=Cast(1.00 as decimal(18,2)),MZ3=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ4=Cast(1.00 as decimal(18,2)),MZ5=Cast(1.00 as decimal(18,2)),'); sql.Add(' MZ6=Cast(1.00 as decimal(18,2)),MZ7=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ0=Cast(1.00 as decimal(18,2)),JZ1=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ2=Cast(1.00 as decimal(18,2)),JZ3=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ4=Cast(1.00 as decimal(18,2)),JZ5=Cast(1.00 as decimal(18,2)),'); sql.Add(' JZ6=Cast(1.00 as decimal(18,2)),JZ7=Cast(1.00 as decimal(18,2)),'); sql.Add(' MJPS0=Cast(1 as int),MJPS1=Cast(1 as int),'); sql.Add(' MJPS2=Cast(1 as int),MJPS3=Cast(1 as int),'); sql.Add(' MJPS4=Cast(1 as int),MJPS5=Cast(1 as int),'); sql.Add(' MJPS6=Cast(1 as int),MJPS7=Cast(1 as int),'); sql.Add(' JH0=Cast(1 as int),JH1=Cast(1 as int),'); sql.Add(' JH2=Cast(1 as int),JH3=Cast(1 as int),'); sql.Add(' JH4=Cast(1 as int),JH5=Cast(1 as int),'); sql.Add(' JH6=Cast(1 as int),JH7=Cast(1 as int),'); sql.Add(' Hang=Cast(0 as int),'); sql.Add(' Ye=Cast(0 as int),'); sql.Add(' Lie=Cast(0 as int)'); Open; end; SCreateCDS20(ADOQueryTemp,CDS_JuanPRT); SInitCDSData20(ADOQueryTemp,CDS_JuanPRT); if CDS_JuanPRT.IsEmpty=False then begin CDS_JuanPRT.Delete; end; i:=0;j:=0;z:=0;FGangNo:='';h:=0;L:=0;Y:=0; CDS_Juan.DisableControls; with CDS_Juan do begin First; while not Eof do begin //FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString)+Trim(CDS_Juan.fieldbyname('BaoNO').AsString) //+Trim(CDS_Juan.fieldbyname('GangNo').AsString); with CDS_JuanPRT do begin if CDS_JuanPRT.IsEmpty then begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('CoL0').Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=0; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=1; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=1; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=1; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=1; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); H:=0;//行号 L:=0;//列号 Y:=0;//页号 for i:=1 to 37 do begin CDS_JuanPRT.Append; {CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; } CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=1+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=1+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=1+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=1+i; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('CoL0').Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); //CDS_JuanPRT.FieldByName('Lot0').Value:=Lot.Items[0]; // CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.Post; end; end else //如果数据集不为空,色号缸号变为新的。 begin if Trim(CDS_Juan.fieldbyname('SubId').AsString)<>Trim(FSubId) then begin L:=L+1; if L<8 then begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, 0]), [loPartialKey]);//如果列号小于8 定位到当前页第一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('CoL'+Trim(IntToStr(L))).Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); //Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); H:=0; end else //另起一页 begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('CoL0').Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); //Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=Y+1; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=1; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=1; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=1; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=1; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //CDS_JuanPRT.FieldByName('JQty').Value:=CDS_Juan.fieldbyname('JQty').Value; //CDS_JuanPRT.FieldByName('GQty').Value:=CDS_Juan.fieldbyname('GQty').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); H:=0;//行号 L:=0;//列号 Y:=Y+1;//页号 for i:=1 to 37 do begin CDS_JuanPRT.Append; { CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; } CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=1+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=1+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=1+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=1+i; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('CoL0').Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); //CDS_JuanPRT.FieldByName('Lot0').Value:=Lot.Items[0]; // CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; CDS_JuanPRT.Post; end; end; end else //subid 相同,缸号不同 begin if (Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString))<>FHZ then begin L:=L+1; if L<8 then begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, 0]), [loPartialKey]);//如果列号小于8 定位到当前页第一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('CoL'+Trim(IntToStr(L))).Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); //Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); H:=0; end else //如果列号大于7,则增加新的一页 begin H:=0;//行号 L:=0;//列号 Y:=Y+1;//页号 CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('CoL0').Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); //Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; //Lot0:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=Y; // CDS_JuanPRT.FieldByName('Lie').Value:=0; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=1; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=1; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=1; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=1; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //CDS_JuanPRT.FieldByName('JQty').Value:=CDS_Juan.fieldbyname('JQty').Value; //CDS_JuanPRT.FieldByName('GQty').Value:=CDS_Juan.fieldbyname('GQty').Value; CDS_JuanPRT.Post; FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); for i:=1 to 37 do begin CDS_JuanPRT.Append; {CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; } CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=1+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=1+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=1+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=1+i; //CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('gangno').Value; //CDS_JuanPRT.FieldByName('Lot1').Value:=Lot.Items[0]; //CDS_JuanPRT.FieldByName('Lot2').Value:=Lot.Items[0]; // CDS_JuanPRT.FieldByName('Lot3').Value:=Lot.Items[0]; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; { CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value;} CDS_JuanPRT.Post; end; end; end else //数据集不为空,缸号色号相同 begin H:=H+1; if H<38 then //如果行号小于38 数据集不为空,缸号色号相同 begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, H]), [loPartialKey]);//定位到当前页下一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('CoL'+Trim(IntToStr(L))).Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; // Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); end else begin //如果行号大于38,进行换列 数据集不为空,缸号色号相同 H:=0; L:=L+1; {if (L mod 2)=1 then L:=L+1 else L:=L+2; } if L<8 then //如果还在当前页 数据集不为空,缸号色号相同 begin CDS_JuanPRT.Locate('Ye;Hang', VarArrayOf([Y, 0]), [loPartialKey]);//定位到当前页下一列第一行 CDS_JuanPRT.Edit; CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('LenQty'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('MJPS'+Trim(IntToStr(L))).Value:=1; CDS_JuanPRT.FieldByName('Lot'+Trim(IntToStr(L))).Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('CoL'+Trim(IntToStr(L))).Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //Lot.Items[L div 2]:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.Post; FHZ:=Trim((CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString)); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); end else //如果不在当前页,则增加一页 数据集不为空,缸号色号相同 begin CDS_JuanPRT.Append; CDS_JuanPRT.FieldByName('Lot0').Value:=CDS_Juan.fieldbyname('GangNo').Value; CDS_JuanPRT.FieldByName('CoL0').Value:=Trim(CDS_Juan.fieldbyname('PRTColorNo').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTEColor').AsString) +' '+Trim(CDS_Juan.fieldbyname('PRTHX').AsString); // Lot.Items[0]:=CDS_Juan.fieldbyname('GangNo').Value; //Lot.Items[1]:=''; //Lot.Items[2]:=''; //Lot.Items[3]:=''; //Lot0:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value; CDS_JuanPRT.FieldByName('MJPS0').Value:=1; CDS_JuanPRT.FieldByName('Hang').Value:=0; CDS_JuanPRT.FieldByName('Ye').Value:=Y+1; // CDS_JuanPRT.FieldByName('Lie').Value:=0; CDS_JuanPRT.FieldByName('JH0').Value:=1; CDS_JuanPRT.FieldByName('JH1').Value:=1; CDS_JuanPRT.FieldByName('JH2').Value:=1; CDS_JuanPRT.FieldByName('JH3').Value:=1; CDS_JuanPRT.FieldByName('JH4').Value:=1; CDS_JuanPRT.FieldByName('JH5').Value:=1; CDS_JuanPRT.FieldByName('JH6').Value:=1; CDS_JuanPRT.FieldByName('JH7').Value:=1; CDS_JuanPRT.FieldByName('LenQty0').Value:=CDS_Juan.fieldbyname('MJLen').Value; CDS_JuanPRT.FieldByName('MZ0').Value:=CDS_Juan.fieldbyname('MJMaoZ').Value; CDS_JuanPRT.FieldByName('JZ0').Value:=CDS_Juan.fieldbyname('MJQty4').Value; CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; //CDS_JuanPRT.FieldByName('JQty').Value:=CDS_Juan.fieldbyname('JQty').Value; //CDS_JuanPRT.FieldByName('GQty').Value:=CDS_Juan.fieldbyname('GQty').Value; CDS_JuanPRT.Post; FHZ:=Trim(CDS_Juan.fieldbyname('SubId').AsString) +Trim(CDS_Juan.fieldbyname('GangNo').AsString); FSubId:=Trim(CDS_Juan.fieldbyname('SubId').AsString); //FGangNo:=Trim(CDS_Juan.fieldbyname('GangNo').AsString); H:=0;//行号 L:=0;//列号 Y:=Y+1;//页号 for i:=1 to 37 do begin CDS_JuanPRT.Append; {CDS_JuanPRT.FieldByName('PRTEColor').Value:=CDS_Juan.fieldbyname('PRTEColor').Value; CDS_JuanPRT.FieldByName('PRTColorNo').Value:=CDS_Juan.fieldbyname('PRTColorNo').Value; CDS_JuanPRT.FieldByName('PRTHX').Value:=CDS_Juan.fieldbyname('PRTHX').Value;} CDS_JuanPRT.FieldByName('JH0').Value:=1+i; CDS_JuanPRT.FieldByName('JH1').Value:=1+i; CDS_JuanPRT.FieldByName('JH2').Value:=1+i; CDS_JuanPRT.FieldByName('JH3').Value:=1+i; CDS_JuanPRT.FieldByName('JH4').Value:=1+i; CDS_JuanPRT.FieldByName('JH5').Value:=1+i; CDS_JuanPRT.FieldByName('JH6').Value:=1+i; CDS_JuanPRT.FieldByName('JH7').Value:=1+i; CDS_JuanPRT.FieldByName('Ye').Value:=Y; CDS_JuanPRT.FieldByName('Hang').Value:=i; {CDS_JuanPRT.FieldByName('SubId').Value:=CDS_Juan.fieldbyname('SubId').Value; CDS_JuanPRT.FieldByName('MainId').Value:=CDS_Juan.fieldbyname('MainId').Value; } CDS_JuanPRT.Post; end; end; end; end; end; end end; Next; end; end; CDS_Juan.EnableControls; end; procedure TfrmPRTJYDJList.ToolButton1Click(Sender: TObject); var fPrintFile:String; begin if Trim(BtnEditA1.Text)='' then begin Application.MessageBox('码单名称不能为空!','提示',0); Exit; end; fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\'+Trim(BtnEditA1.Text)+'.rmf' ; if Trim(BtnEditA1.Text)='通用外销码单(缸号列)' then begin GetLotDataLie(); end else if Trim(BtnEditA1.Text)='通用外销码单(缸号38列)' then begin //GetLotDataLie38(); GetLotDataLie38Ye(); end else begin GetLotData(); end; with ADOQueryCmd do begin Close; sql.Clear; sql.add('select AAA.*,JSM.OrderNo,JSB.PRTColorEng,JSB.PRTHX,JSB.PRTColorNo from('); sql.Add('select Sum(MJLen) MQty,Sum(YQty) YQty,Count(*) PS,Sum(MJQty4) MJJingZ,Sum(MJMaoZ) MJMaoZ ,SubId'); SQL.Add('from (select A.MJLen,A.MJQty4,A.MJMaoZ,A.SubId,'); sql.Add(' Case when isnull(A.MJLenMa,-1)<=0 then Cast(A.MJLen*1.0936 as decimal(18,1)) else Cast(A.MJLenMa*1 as decimal(18,1)) end as YQty '); //sql.Add('GangNo=(select GangNo from JYOrder_Main_MD B where B.MDID=A.APID),A.Subid'); sql.Add(' from WFB_MJJY A'); sql.Add(' inner join JYOrder_Main DD on A.MainId=DD.MainId'); sql.Add(' where A.MainId='''+Trim(CDS_Main.fieldbyname('MainId').AsString)+''''); sql.Add(' and A.ZhuangXiangSYFlag=0'); begin SQL.Add(' and 1=1 )AA'); end; sql.Add('Group by SubId)AAA'); sql.add(' inner join JYOrder_Sub JSB on AAA.SubId=JSB.SubID'); sql.Add(' inner join JYOrder_Main JSM on JSB.MainId=JSM.MainId'); sql.add(' order by SubId'); //ShowMessage(SQL.Text); Open; end; SCreateCDS20(ADOQueryCmd,CDS_HZ); SInitCDSData20(ADOQueryCmd,CDS_HZ); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select sum(MJLen) MQty,Cast(sum(MJLen)*1.0936 as decimal(18,1)) YQty, '); sql.Add(' sum(MJMaoZ) MaoZ,sum(MJQty4) JingZ,Count(*) PS'); sql.Add(' from WFB_MJJY where MainId='''+Trim(CDS_Main.fieldbyname('MainId').AsString)+''''); sql.Add(' and ZhuangXiangSYFlag=0'); sql.Add(' group by MainId'); Open; end; if FileExists(fPrintFile) then begin RMVariables['OrderNo']:=Trim(CDS_Main.fieldbyname('OrderNo').AsString); RMVariables['MPRTCode']:=Trim(CDS_Main.fieldbyname('MPRTCode').AsString); RMVariables['MQty']:=ADOQueryTemp.fieldbyname('MQty').Value; RMVariables['MaoZ']:=ADOQueryTemp.fieldbyname('MaoZ').Value; RMVariables['JingZ']:=ADOQueryTemp.fieldbyname('JingZ').Value; RMVariables['PS']:=ADOQueryTemp.fieldbyname('PS').Value; // RMVariables['QtyUnit']:=Trim(CDS_Main.fieldbyname('QtyUnit').AsString); RM3.LoadFromFile(fPrintFile); RM3.ShowReport; end else begin Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\'+Trim(BtnEditA1.Text)+'.rmf'),'提示',0); end; end; procedure TfrmPRTJYDJList.BtnEditA1BtnClick(Sender: TObject); begin try frmZDYHelp:=TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag:='CKMD'; flagname:='出库码单'; if ShowModal=1 then begin BtnEditA1.Text:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString); end; end; finally frmZDYHelp.Free; end; end; end.