unit U_PRTOrderSCList; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, RM_DsgGridReport, RM_Designer; type TfrmPRTOrderSCList = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBEdit: TToolButton; TBClose: TToolButton; Panel1: TPanel; BegDate: TDateTimePicker; EndDate: TDateTimePicker; Label1: TLabel; Tv1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1: TcxGrid; cxGridPopupMenu1: TcxGridPopupMenu; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DataSource1: TDataSource; Label3: TLabel; OrderNo: TEdit; v1OrderNo: TcxGridDBColumn; v1OrdDate: TcxGridDBColumn; v1DeliveryDate: TcxGridDBColumn; v1MPRTSpec: TcxGridDBColumn; Order_Main: TClientDataSet; RM1: TRMGridReport; RMDBMain: TRMDBDataSet; v1CustomerNoName: TcxGridDBColumn; Label4: TLabel; CustomerNoName: TEdit; v1MPRTCodeName: TcxGridDBColumn; v1MPRTMF: TcxGridDBColumn; TBView: TToolButton; Label8: TLabel; MPRTCodeHZ: TEdit; v1MPRTKZ: TcxGridDBColumn; Label10: TLabel; MPRTSpec: TEdit; Label12: TLabel; MPRTKZ: TEdit; Label13: TLabel; MPRTMF: TEdit; ADOQueryPrint: TADOQuery; CDS_Print: TClientDataSet; v1Column2: TcxGridDBColumn; v1Column3: TcxGridDBColumn; Label9: TLabel; Label2: TLabel; ConNo: TEdit; LiDanPerson: TEdit; v1Column1: TcxGridDBColumn; RMDBDataSet1: TRMDBDataSet; RM2: TRMGridReport; ToolButton3: TToolButton; v1Column4: TcxGridDBColumn; v1Column5: TcxGridDBColumn; RMXLSExport2: TRMXLSExport; v1Column6: TcxGridDBColumn; Label5: TLabel; WCStr: TComboBox; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure TBFindClick(Sender: TObject); procedure TBEditClick(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure OrderNoChange(Sender: TObject); procedure FormShow(Sender: TObject); procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure CheckBox1Click(Sender: TObject); procedure Tv1StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); procedure v1DeliveryDateCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); procedure OrderNoKeyPress(Sender: TObject; var Key: Char); procedure ConNoKeyPress(Sender: TObject; var Key: Char); procedure ToolButton3Click(Sender: TObject); procedure TBViewClick(Sender: TObject); procedure WCStrChange(Sender: TObject); private CanShu1,CanShu2:string; DQdate:TDateTime; procedure InitGrid(); procedure InitForm(); { Private declarations } public FFInt,FCloth:Integer; { Public declarations } end; var frmPRTOrderSCList: TfrmPRTOrderSCList; implementation uses U_DataLink,U_OrderInPut,U_RTFun, U_ZDYHelp, U_ZDYHelpSel, U_ModuleNote,U_OrderInPutPrice ,U_MeetingAPNew; {$R *.dfm} procedure TfrmPRTOrderSCList.FormDestroy(Sender: TObject); begin frmPRTOrderSCList:=nil; end; procedure TfrmPRTOrderSCList.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end; procedure TfrmPRTOrderSCList.FormCreate(Sender: TObject); begin cxgrid1.Align:=alClient; CanShu1:=Trim(DParameters1); CanShu2:=Trim(DParameters2); DQdate:=SGetServerDate(ADOQueryTemp); end; procedure TfrmPRTOrderSCList.TBCloseClick(Sender: TObject); begin Close; WriteCxGrid('指示单列表(会议)',Tv1,'生产指示单管理'); end; procedure TfrmPRTOrderSCList.InitGrid(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered:=False; Close; sql.Clear; sql.add('exec P_View_Order :begdate,:enddate,:WSql') ; if Trim(CanShu1)<>'高权限' then begin //Parameters.ParamByName('WSql').Value:=' and Filler='''+Trim(DName)+''''; Parameters.ParamByName('WSql').Value:=' and Filler in(select UserName from SY_User where DPID in'+ '(select DPID from SY_User where UserName='''+Trim(DName)+'''))'; end else begin Parameters.ParamByName('WSql').Value:=''; end; Parameters.ParamByName('begdate').Value:=FormatDateTime('yyyy-MM-dd',BegDate.DateTime); Parameters.ParamByName('enddate').Value:=FormatDateTime('yyyy-MM-dd',enddate.DateTime+1); ExecSQL; Open; end; SCreateCDS20(ADOQueryMain,Order_Main); SInitCDSData20(ADOQueryMain,Order_Main); finally ADOQueryMain.EnableControls; end; end; procedure TfrmPRTOrderSCList.InitForm(); begin ReadCxGrid('指示单列表(会议)',Tv1,'生产指示单管理'); BegDate.DateTime:=SGetServerDate10(ADOQueryTemp)-92; EndDate.DateTime:=SGetServerDate10(ADOQueryTemp); if Trim(CanShu2)='查看' then begin TBEdit.Visible:=False; end; end; procedure TfrmPRTOrderSCList.TBFindClick(Sender: TObject); begin if ADOQueryMain.Active=False then Exit; SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2)); SCreateCDS20(ADOQueryMain,Order_Main); SInitCDSData20(ADOQueryMain,Order_Main); end; procedure TfrmPRTOrderSCList.TBEditClick(Sender: TObject); begin if Order_Main.IsEmpty then Exit; try frmMeetingAPNew:=TfrmMeetingAPNew.Create(Application); with frmMeetingAPNew do begin PState:=1; FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString); frmMeetingAPNew.OrderNo.Text:=Trim(Self.Order_Main.fieldbyname('OrderNo').AsString); frmMeetingAPNew.Align:=alClient; if ShowModal=1 then begin end; end; finally frmMeetingAPNew.Free; end; end; procedure TfrmPRTOrderSCList.TBRafreshClick(Sender: TObject); begin InitGrid(); end; procedure TfrmPRTOrderSCList.OrderNoChange(Sender: TObject); begin if ADOQueryMain.Active=False then Exit; SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2)); SCreateCDS20(ADOQueryMain,Order_Main); SInitCDSData20(ADOQueryMain,Order_Main); end; procedure TfrmPRTOrderSCList.FormShow(Sender: TObject); begin InitForm(); end; procedure TfrmPRTOrderSCList.Tv1CellDblClick( Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin if TBView.Visible=False then Exit; TBView.Click; end; procedure TfrmPRTOrderSCList.CheckBox1Click(Sender: TObject); begin InitGrid(); end; procedure TfrmPRTOrderSCList.Tv1StylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); var id,id10:Integer; begin {try if Tv1.GroupedItemCount=0 then begin Id:=Tv1.GetColumnByFieldName('DeliveryDate').Index-tv1.GroupedItemCount; Id10:=Tv1.GetColumnByFieldName('SubStatus').Index-tv1.GroupedItemCount; if Trim(VarToStr(ARecord.Values[id]))='' then Exit; if Id<0 then Exit; if ARecord.Values[id10]='完成' then exit; if (ARecord.Values[id]-DQdate)>=4 then Exit; if ((ARecord.Values[id]-DQdate)>=0) and ((ARecord.Values[id]-DQdate)<4) then AStyle:=DataLink_.QHuangSe else if ARecord.Values[id]-DQdate<0 then begin AStyle:=DataLink_OrderManage.FenHongS; end; end else begin end; except end; } end; procedure TfrmPRTOrderSCList.v1DeliveryDateCustomDrawCell( Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); begin { Id:=TV1.GetColumnByFieldName('DeliveryDate').Index;//;-TV1.GroupedItemCount; Id10:=TV1.GetColumnByFieldName('SubStatus').Index; if Id<0 then Exit; if AViewInfo.GridRecord.Values[Id10]='完成' then Exit; if AViewInfo.GridRecord.Values[Id]-SGetServerDate(ADOQueryTemp)>=4 then Exit; if ((AViewInfo.GridRecord.Values[id]-SGetServerDate10(ADOQueryTemp))>=0) and ((AViewInfo.GridRecord.Values[id]-SGetServerDate(ADOQueryTemp))<4) then ACanvas.Brush.Color:=clYellow else if (AViewInfo.GridRecord.Values[id])-(SGetServerDate10(ADOQueryTemp)<0) then begin ACanvas.Brush.Color:=clRed; end; begin ACanvas.Brush.Color:=clRed; end else if AViewInfo.GridRecord.Values[Id]='Purple' then begin ACanvas.Brush.Color:=clPurple; end else if AViewInfo.GridRecord.Values[Id]='Olive' then begin ACanvas.Brush.Color:=clOlive; end else if AViewInfo.GridRecord.Values[Id]='Teal' then begin ACanvas.Brush.Color:=clTeal; end else if AViewInfo.GridRecord.Values[Id]='Background' then begin ACanvas.Brush.Color:=clBackground; end; } end; procedure TfrmPRTOrderSCList.OrderNoKeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then begin if Length(OrderNo.Text)<3 then Exit; try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered:=False; Close; sql.Clear; sql.add('exec P_View_Order :begdate,:enddate,:WSql') ; if Trim(CanShu1)<>'高权限' then begin Parameters.ParamByName('WSql').Value:=' and orderno like '''+'%'+Trim(OrderNo.Text)+'%'+''''+ ' and Filler in(select UserName from SY_User where DPID in'+ '(select DPID from SY_User where UserName='''+Trim(DName)+'''))'; end else begin Parameters.ParamByName('WSql').Value:=' and orderno like '''+'%'+Trim(OrderNo.Text)+'%'+''''; end; Parameters.ParamByName('begdate').Value:='1899-01-01'; Parameters.ParamByName('enddate').Value:='2050-01-01'; Open; end; SCreateCDS20(ADOQueryMain,Order_Main); SInitCDSData20(ADOQueryMain,Order_Main); finally ADOQueryMain.EnableControls; end; end; end; procedure TfrmPRTOrderSCList.ConNoKeyPress(Sender: TObject; var Key: Char); begin if Key=#13 then begin if Length(conno.Text)<3 then Exit; try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered:=False; Close; sql.Clear; sql.add('exec P_View_Order :begdate,:enddate,:WSql') ; if Trim(CanShu1)<>'高权限' then begin Parameters.ParamByName('WSql').Value:=' and A.Filler='''+Trim(DName)+''''; end; begin Parameters.ParamByName('WSql').Value:=' and conno like '''+'%'+Trim(conno.Text)+'%'+''''; end; Parameters.ParamByName('begdate').Value:='1899-01-01'; Parameters.ParamByName('enddate').Value:='2050-01-01'; ExecSQL; Open; end; SCreateCDS20(ADOQueryMain,Order_Main); SInitCDSData20(ADOQueryMain,Order_Main); finally ADOQueryMain.EnableControls; end; end; end; procedure TfrmPRTOrderSCList.ToolButton3Click(Sender: TObject); begin try frmModuleNote:=TfrmModuleNote.Create(Application); with frmModuleNote do begin flag:='生产指示单(会议)'; if ShowModal=1 then begin end; end; finally frmModuleNote.Free; end; end; procedure TfrmPRTOrderSCList.TBViewClick(Sender: TObject); begin if Order_Main.IsEmpty then Exit; try frmMeetingAPNew:=TfrmMeetingAPNew.Create(Application); with frmMeetingAPNew do begin PState:=2; FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString); frmMeetingAPNew.OrderNo.Text:=Trim(Self.Order_Main.fieldbyname('OrderNo').AsString); frmMeetingAPNew.Align:=alClient; if ShowModal=1 then begin end; end; finally frmMeetingAPNew.Free; end; end; procedure TfrmPRTOrderSCList.WCStrChange(Sender: TObject); begin TBFind.Click; end; end.