unit U_SCMDList; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, ExtCtrls, ToolWin, cxPC, cxControls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxCheckBox; type TfrmSCMDList = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBExport: TToolButton; TBClose: TToolButton; Panel1: TPanel; Label3: TLabel; Label1: TLabel; Label2: TLabel; Label5: TLabel; ConName: TEdit; BegDate: TDateTimePicker; EndDate: TDateTimePicker; orderNo: TEdit; Label6: TLabel; MDNO: TEdit; DataSource3: TDataSource; ClientDataSet3: TClientDataSet; ADOQueryCmd: TADOQuery; ADOQueryTemp: TADOQuery; ADOQuery1: TADOQuery; cxGridPopupMenu3: TcxGridPopupMenu; DataSource1: TDataSource; ClientDataSet1: TClientDataSet; cxGridPopupMenu1: TcxGridPopupMenu; ADOQuery3: TADOQuery; PSName: TComboBox; Label9: TLabel; Label11: TLabel; FactoryName: TEdit; cxPageControl1: TcxPageControl; cxTabSheet1: TcxTabSheet; cxGrid3: TcxGrid; Tv3: TcxGridDBTableView; v3Column1: TcxGridDBColumn; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridDBColumn11: TcxGridDBColumn; cxGridDBColumn14: TcxGridDBColumn; cxGridDBColumn12: TcxGridDBColumn; v3Column15: TcxGridDBColumn; v3Column16: TcxGridDBColumn; Tv3Column1: TcxGridDBColumn; v3Column4: TcxGridDBColumn; v3Column5: TcxGridDBColumn; v3Column17: TcxGridDBColumn; Tv3Column2: TcxGridDBColumn; Tv3Column3: TcxGridDBColumn; v3Column3: TcxGridDBColumn; v3Column7: TcxGridDBColumn; v3Column8: TcxGridDBColumn; v3Column9: TcxGridDBColumn; v3Column10: TcxGridDBColumn; v3Column11: TcxGridDBColumn; v3Column12: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; cxTabSheet2: TcxTabSheet; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; cxGridDBColumn5: TcxGridDBColumn; cxGridDBColumn6: TcxGridDBColumn; cxGridDBColumn8: TcxGridDBColumn; cxGridDBColumn9: TcxGridDBColumn; cxGridDBColumn10: TcxGridDBColumn; cxGridDBColumn13: TcxGridDBColumn; Tv1Column1: TcxGridDBColumn; Tv1Column2: TcxGridDBColumn; Tv1Column3: TcxGridDBColumn; Tv1Column4: TcxGridDBColumn; cxGridDBColumn16: TcxGridDBColumn; cxGridDBColumn17: TcxGridDBColumn; cxGridDBColumn18: TcxGridDBColumn; cxGridDBColumn19: TcxGridDBColumn; cxGridDBColumn20: TcxGridDBColumn; cxGridDBColumn22: TcxGridDBColumn; cxGridDBColumn23: TcxGridDBColumn; cxGridDBColumn24: TcxGridDBColumn; cxGridDBColumn25: TcxGridDBColumn; cxGridDBColumn26: TcxGridDBColumn; v1Column1: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; cxTabSheet3: TcxTabSheet; cxTabSheet4: TcxTabSheet; cxGrid2: TcxGrid; Tv2: TcxGridDBTableView; cxGridDBColumn27: TcxGridDBColumn; v1Column9: TcxGridDBColumn; cxGridDBColumn28: TcxGridDBColumn; cxGridDBColumn29: TcxGridDBColumn; v2Column3: TcxGridDBColumn; v1Column7: TcxGridDBColumn; v2Column1: TcxGridDBColumn; v1Column15: TcxGridDBColumn; v1Column11: TcxGridDBColumn; cxGridDBColumn30: TcxGridDBColumn; v1Column8: TcxGridDBColumn; v1Column5: TcxGridDBColumn; v2Column5: TcxGridDBColumn; v1Column10: TcxGridDBColumn; cxGrid2Level1: TcxGridLevel; cxGrid5: TcxGrid; Tv5: TcxGridDBTableView; cxGridDBColumn31: TcxGridDBColumn; cxGridDBColumn32: TcxGridDBColumn; cxGridDBColumn33: TcxGridDBColumn; cxGridDBColumn34: TcxGridDBColumn; cxGridDBColumn35: TcxGridDBColumn; cxGridDBColumn36: TcxGridDBColumn; cxGridDBColumn37: TcxGridDBColumn; cxGridDBColumn38: TcxGridDBColumn; v1Column14: TcxGridDBColumn; cxGridDBColumn39: TcxGridDBColumn; cxGridDBColumn40: TcxGridDBColumn; cxGridDBColumn41: TcxGridDBColumn; cxGridDBColumn42: TcxGridDBColumn; cxGridDBColumn45: TcxGridDBColumn; v1Column12: TcxGridDBColumn; v1Column13: TcxGridDBColumn; v1Column16: TcxGridDBColumn; cxGridLevel3: TcxGridLevel; cxGridPopupMenu2: TcxGridPopupMenu; cxGridPopupMenu4: TcxGridPopupMenu; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBRafreshClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure cxPageControl1Change(Sender: TObject); procedure TBFindClick(Sender: TObject); procedure orderNoKeyPress(Sender: TObject; var Key: Char); procedure MDNOKeyPress(Sender: TObject; var Key: Char); procedure TBExportClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure Tv3CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure Tv2CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure Tv5CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure Tv1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); private { Private declarations } canshu1,canshu2:string; public { Public declarations } end; var frmSCMDList: TfrmSCMDList; implementation uses U_DataLink,U_RTFun; {$R *.dfm} procedure TfrmSCMDList.FormDestroy(Sender: TObject); begin frmSCMDList:=nil; end; procedure TfrmSCMDList.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end; procedure TfrmSCMDList.TBRafreshClick(Sender: TObject); var fsj:string; begin try ADOQuery3.DisableControls; with ADOQuery3 do begin Close; Filtered:=False; sql.Clear; if cxPageControl1.ActivePageIndex<2 then begin sql.Add('exec P_View_MD :begdate,:enddate,:orderno,:MDType,:WSql'); Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date)); Parameters.ParamByName('enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1)); Parameters.ParamByName('orderno').Value:=''; Parameters.ParamByName('MDType').Value:=''; if cxPageControl1.ActivePageIndex=0 then begin fsj:=' and isnull(JMM.CKName,'''')='''' '; end else begin fsj:=' and isnull(JMM.CKName,'''')<>'''' '; end; Parameters.ParamByName('WSql').Value:=fsj; end else if cxPageControl1.ActivePageIndex=2 then begin sql.Add(' select A.*,MDNO=A.SPID,ConName=A.SPName,PSName=''纱线'' '); sql.Add(',orderNo=(select ConNo from Contract_Main CM where CM.MainId=A.CGMainId)'); sql.Add(' from CK_SXPB_CR A'); sql.add(' where A.CRTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+''''); sql.Add(' and A.CRTime<='''+Trim(FormatDateTime('yyyy-MM-dd',enddate.DateTime+1))+''''); sql.Add(' and isnull(CKName,'''')=''纱线'''); SQL.Add(' and CRFlag=''入库'' '); end else if cxPageControl1.ActivePageIndex=3 then begin sql.Add(' select A.*,MDNO=A.SPID,ConName=A.SPName,PSName=''纱线'',orderno='''' '); sql.Add(' from CK_SXPB_CR A'); sql.add('where A.CRTime>=:begdate and A.CRTime<:enddate and isnull(CKName,'''')=''坯布'' '); SQL.Add(' and CRFlag=''入库'' '); Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date)); Parameters.ParamByName('enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1)); end; Open; end; SCreateCDS20(ADOQuery3,ClientDataSet3); SInitCDSData20(ADOQuery3,ClientDataSet3); finally ADOQuery3.EnableControls; end; TBFind.Click; end; procedure TfrmSCMDList.FormCreate(Sender: TObject); begin canshu1:=Trim(DParameters1); canshu2:=Trim(DParameters2); EndDate.Date:=SGetServerDate(ADOQueryTemp); BegDate.Date:=EndDate.Date-7; cxPageControl1.ActivePageIndex:=0; end; procedure TfrmSCMDList.TBCloseClick(Sender: TObject); begin WriteCxGrid('SCTV1',Tv1,'码单管理'); WriteCxGrid('SCTV2',Tv2,'码单管理'); WriteCxGrid('SCTV3',Tv3,'码单管理'); WriteCxGrid('SCTV5',Tv5,'码单管理'); Close; end; procedure TfrmSCMDList.cxPageControl1Change(Sender: TObject); begin TBRafresh.Click; end; procedure TfrmSCMDList.TBFindClick(Sender: TObject); begin if ADOQuery3.Active=False then Exit; SDofilter(ADOQuery3,SGetFilters(Panel1,1,2)); SCreateCDS20(ADOQuery3,ClientDataSet3); SInitCDSData20(ADOQuery3,ClientDataSet3); end; procedure TfrmSCMDList.orderNoKeyPress(Sender: TObject; var Key: Char); var fsj:string; begin if Key=#13 then begin if cxPageControl1.ActivePageIndex>1 then Exit; if Trim(orderNo.Text)='' then Exit; if Length(Trim(orderNo.Text))<4 then Exit; try ADOQuery3.DisableControls; with ADOQuery3 do begin Close; Filtered:=False; sql.Clear; sql.Add('exec P_View_MD :begdate,:enddate,:orderno,:MDType,:WSql'); Parameters.ParamByName('begdate').Value:=''; Parameters.ParamByName('enddate').Value:=''; Parameters.ParamByName('orderno').Value:=Trim(orderNo.Text); Parameters.ParamByName('MDType').Value:=Trim(canshu1); if cxPageControl1.ActivePageIndex=0 then begin fsj:=' and isnull(JMM.CKName,'''')='''' '; end else begin fsj:=' and isnull(JMM.CKName,'''')<>'''' '; end; {if Trim(canshu2)<>'高权限' then begin fsj:=fsj+' and JMM.Filler='''+Trim(DName)+''''; end; } Parameters.ParamByName('WSql').Value:=fsj; Open; end; SCreateCDS20(ADOQuery3,ClientDataSet3); SInitCDSData20(ADOQuery3,ClientDataSet3); finally ADOQuery3.EnableControls; end; end; end; procedure TfrmSCMDList.MDNOKeyPress(Sender: TObject; var Key: Char); var fsj:string; begin if Key=#13 then begin if Trim(MDNO.Text)='' then Exit; if Length(Trim(MDNO.Text))<4 then Exit; try ADOQuery3.DisableControls; with ADOQuery3 do begin Close; Filtered:=False; sql.Clear; if cxPageControl1.ActivePageIndex<2 then begin sql.Add('exec P_View_MD :begdate,:enddate,:orderno,:MDType,:WSql'); Parameters.ParamByName('begdate').Value:=''; Parameters.ParamByName('enddate').Value:=''; Parameters.ParamByName('orderno').Value:=''; Parameters.ParamByName('MDType').Value:=Trim(canshu1); fsj:=' and JMM.MDNO like '''+'%'+Trim(MDNO.Text)+'%'+''''; if cxPageControl1.ActivePageIndex=0 then begin fsj:=fsj+' and isnull(JMM.CKName,'''')='''' '; end else begin fsj:=fsj+' and isnull(JMM.CKName,'''')<>'''' '; end; Parameters.ParamByName('WSql').Value:=fsj; end else if cxPageControl1.ActivePageIndex=2 then begin sql.Add(' select A.*,MDNO=A.SPID,ConName=A.SPName,PSName=''纱线'' '); sql.Add(',orderNo=(select ConNo from Contract_Main CM where CM.MainId=A.CGMainId)'); sql.Add(' from CK_SXPB_CR A'); sql.add(' where A.SPID like '''+'%'+Trim(MDNO.Text)+'%'+''''); sql.Add(' and isnull(CKName,'''')=''纱线'''); SQL.Add(' and CRFlag=''入库'' '); end else if cxPageControl1.ActivePageIndex=3 then begin sql.Add(' select A.*,MDNO=A.SPID,ConName=A.SPName,PSName=''纱线'',orderno='''' '); sql.Add(' from CK_SXPB_CR A'); sql.add(' where A.SPID like '''+'%'+Trim(MDNO.Text)+'%'+''''); SQL.Add(' and CRFlag=''入库'' '); end; Open; end; SCreateCDS20(ADOQuery3,ClientDataSet3); SInitCDSData20(ADOQuery3,ClientDataSet3); finally ADOQuery3.EnableControls; end; end; end; procedure TfrmSCMDList.TBExportClick(Sender: TObject); begin if ClientDataSet3.IsEmpty then Exit; if cxPageControl1.ActivePageIndex=0 then TcxGridToExcel('正常码单',cxGrid3) else if cxPageControl1.ActivePageIndex=1 then TcxGridToExcel('待处理仓库码单',cxGrid1) else if cxPageControl1.ActivePageIndex=2 then TcxGridToExcel('无单纱线码单',cxGrid2) else if cxPageControl1.ActivePageIndex=5 then TcxGridToExcel('无单坯布码单',cxGrid1); end; procedure TfrmSCMDList.FormShow(Sender: TObject); begin READCxGrid('SCTV1',Tv1,'码单管理'); READCxGrid('SCTV2',Tv2,'码单管理'); READCxGrid('SCTV3',Tv3,'码单管理'); READCxGrid('SCTV5',Tv5,'码单管理'); end; procedure TfrmSCMDList.Tv3CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); var fsj:string; begin if ClientDataSet3.IsEmpty then Exit; fsj:='select distinct(PSName) Name, Cast('''' as varchar(20)) code from JYOrder_Process where Mainid='''+Trim(ClientDataSet3.fieldbyname('ORDMainId').AsString)+''''; SInitComBoxBySql(ADOQueryTemp,PSName,False,fsj); end; procedure TfrmSCMDList.Tv2CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin PSName.Clear; end; procedure TfrmSCMDList.Tv5CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin PSName.Clear; end; procedure TfrmSCMDList.Tv1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); var fsj:string; begin if ClientDataSet3.IsEmpty then Exit; fsj:='select distinct(PSName) Name, Cast('''' as varchar(20)) code from JYOrder_Process where Mainid='''+Trim(ClientDataSet3.fieldbyname('ORDMainId').AsString)+''''; SInitComBoxBySql(ADOQueryTemp,PSName,False,fsj); end; end.