D7wmguihua/坯布码单待检(PBMDDJ.dll)/U_WXFPList.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

458 lines
12 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_WXFPList;
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, cxCalendar, cxButtonEdit, cxSplitter,
RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport,
cxTextEdit, cxPC, cxCheckBox;
type
TfrmWXFPList = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBAdd: TToolButton;
TBEdit: TToolButton;
TBDel: TToolButton;
TBClose: TToolButton;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
TBExport: TToolButton;
Order_Main: TClientDataSet;
RM1: TRMGridReport;
RMDBMain: TRMDBDataSet;
RMXLSExport1: TRMXLSExport;
CDS_PRT: TClientDataSet;
ToolButton3: TToolButton;
cxGridPopupMenu2: TcxGridPopupMenu;
Panel1: TPanel;
Label2: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column5: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
ComboBox2: TComboBox;
Label3: TLabel;
Label1: TLabel;
ToolButton1: TToolButton;
ToolButton4: TToolButton;
Label5: TLabel;
FPNO: TEdit;
v1Column1: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
ADOQueryPrint: TADOQuery;
v1Column18: TcxGridDBColumn;
v1Column13: TcxGridDBColumn;
v1Column20: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
Label4: TLabel;
GHDanWei: TEdit;
Label6: TLabel;
XHDanWei: TEdit;
v1Column4: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
ToolButton2: TToolButton;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure TBEditClick(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure TBAddClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure cxPageControl1Change(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure WorkerChange(Sender: TObject);
procedure v1Column15CustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
procedure v1Column9CustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
procedure ToolButton1Click(Sender: TObject);
procedure FPNOKeyPress(Sender: TObject; var Key: Char);
procedure ToolButton2Click(Sender: TObject);
private
FInt,PFInt:Integer;
canshu1,canshu2:string;
FNowDate:TDateTime;
procedure InitGrid();
procedure InitForm();
function DelData():Boolean;
procedure InitGridWsql(fsj:string);
{ Private declarations }
public
{ Public declarations }
end;
var
frmWXFPList: TfrmWXFPList;
implementation
uses
U_DataLink,U_RTFun,U_WXFPInPut,U_ModuleNote, U_ZDYHelp,U_WXFPInPutWGL;
{$R *.dfm}
procedure TfrmWXFPList.FormDestroy(Sender: TObject);
begin
frmWXFPList:=nil;
end;
procedure TfrmWXFPList.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmWXFPList.TBCloseClick(Sender: TObject);
begin
Close;
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD>б<EFBFBD>',Tv1,'<27><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>');
end;
procedure TfrmWXFPList.InitGrid();
var
fsj:String;
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add('select AA.* from (');
sql.Add(' select A.*');
sql.Add(',HZMoney=(select Sum(Money) from FP_XiaoShou_Sub B where B.FXID=A.FXID )');
SQL.Add(' from FP_XiaoShou A');
sql.Add(' ) AA');
sql.Add(' where 1=1 ');
//if cxTabControl1.TabIndex<>0 then
begin
fsj:=TA(ComboBox2.Items.Objects[ComboBox2.Items.IndexOf(Trim(ComboBox2.Text))]).S;
sql.Add(' and AA.'+Trim(fsj)+'>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
sql.Add(' and AA.'+Trim(fsj)+'<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.Date+1))+'''');
end;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmWXFPList.InitForm();
begin
FNowDate:=SGetServerDate(ADOQueryTemp);
EndDate.Date:=FNowDate;
BegDate.Date:=EndDate.Date-7;
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD>б<EFBFBD>',Tv1,'<27><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>');
//InitGrid();
end;
procedure TfrmWXFPList.TBEditClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
{if Trim(DName)<>Trim(Order_Main.fieldbyname('Filler').AsString) then
begin
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ!','<27><>ʾ',0);
Exit;
end;}
try
frmWXFPInPutWGL:=TfrmWXFPInPutWGL.Create(Application);
with frmWXFPInPutWGL do
begin
PState:=1;
FMainId:=Trim(Self.Order_Main.fieldbyname('FXID').AsString);
if ShowModal=1 then
begin
end;
end;
finally
frmWXFPInPutWGL.Free;
end;
end;
procedure TfrmWXFPList.TBDelClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
if Trim(DName)<>Trim(Order_Main.fieldbyname('Filler').AsString) then
begin
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ!','<27><>ʾ',0);
Exit;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select isnull(sum(HXMoney),0) HXMoney from FP_Money_HX where FXID='''+Trim(Order_Main.fieldbyname('FXID').AsString)+'''');
sql.Add(' and isnull(Type,'''')=''<27><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ʊ'' ');
Open;
end;
if ADOQueryTemp.FieldByName('HXMoney').Value<>0 then
begin
Application.MessageBox('<27><><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
if DelData() then
begin
Order_Main.Delete;
end;
end;
function TfrmWXFPList.DelData():Boolean;
begin
try
Result:=false;
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete FP_XiaoShou where FXId='''+Trim(Order_Main.fieldbyname('FXId').AsString)+'''');
sql.Add('delete FP_XiaoShou_Sub where FXId='''+Trim(Order_Main.fieldbyname('FXId').AsString)+'''');
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
Result:=True;
except
ADOQueryCmd.Connection.RollbackTrans;
Result:=False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
procedure TfrmWXFPList.TBExportClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ',cxGrid1);
end;
procedure TfrmWXFPList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmWXFPList.TBAddClick(Sender: TObject);
begin
try
frmWXFPInPutWGL:=TfrmWXFPInPutWGL.Create(Application);
with frmWXFPInPutWGL do
begin
PState:=0;
FMainId:='';
if ShowModal=1 then
begin
end;
end;
finally
frmWXFPInPutWGL.Free;
end;
end;
procedure TfrmWXFPList.FormShow(Sender: TObject);
var
i:Integer;
begin
InitForm();
SInitComBoxByTvColumns(ComboBox2,Tv1,999,True,True);
end;
procedure TfrmWXFPList.cxPageControl1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmWXFPList.ToolButton3Click(Sender: TObject);
begin
try
frmModuleNote:=TfrmModuleNote.Create(Application);
with frmModuleNote do
begin
flag:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ';
if ShowModal=1 then
begin
end;
end;
finally
frmModuleNote.Free;
end;
end;
procedure TfrmWXFPList.FormCreate(Sender: TObject);
begin
canshu1:=Trim(DParameters1);
canshu2:=Trim(DParameters2);
end;
procedure TfrmWXFPList.InitGridWsql(fsj:string);
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add('select AA.* from (');
sql.Add(' select A.*');
sql.Add(',HZMoney=(select Sum(Money) from FP_XiaoShou_Sub B where B.FXID=A.FXID )');
SQL.Add(' from FP_XiaoShou A');
sql.Add(' ) AA');
sql.Add(' where 1=1 ');
sql.Add(fsj);
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmWXFPList.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmWXFPList.WorkerChange(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 TfrmWXFPList.v1Column15CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
Id,Id10:Integer;
begin
Id:=TV1.GetColumnByFieldName('YuJinagDate1').Index;//
Id10:=TV1.GetColumnByFieldName('MoneyKC').Index;
if Id<0 then Exit;
//$008000FF <20>Ⱥ<EFBFBD>ɫ <20><>ɫ $000D55FF $00B9EE9F dz<><C7B3>
if AViewInfo.GridRecord.Values[Id10]>0 then
begin
if AViewInfo.GridRecord.Values[Id]-FNowDate<=0 then
begin
ACanvas.Brush.Color:=clYellow;
end else
if AViewInfo.GridRecord.Values[Id]=null then
begin
// ACanvas.Brush.Color:=clWhite;
end;
end else
begin
//ACanvas.Brush.Color:=clWhite;
end;
end;
procedure TfrmWXFPList.v1Column9CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
Id,Id10:Integer;
begin
Id:=TV1.GetColumnByFieldName('YuJinagDate2').Index;//
Id10:=TV1.GetColumnByFieldName('MoneyKC').Index;
if Id<0 then Exit;
//$008000FF <20>Ⱥ<EFBFBD>ɫ <20><>ɫ $000D55FF $00B9EE9F dz<><C7B3>
if AViewInfo.GridRecord.Values[Id10]>0 then
begin
if AViewInfo.GridRecord.Values[Id]-FNowDate<=0 then
begin
ACanvas.Brush.Color:=clRed;
end else
if AViewInfo.GridRecord.Values[Id]=null then
begin
//ACanvas.Brush.Color:=clWhite;
end;
end else
begin
//ACanvas.Brush.Color:=clWhite;
end;
end;
procedure TfrmWXFPList.ToolButton1Click(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 TfrmWXFPList.FPNOKeyPress(Sender: TObject; var Key: Char);
var
fsj:String;
begin
if Key<>#13 then Exit;
if Length(Trim(FPNO.Text))<3 then Exit;
fsj:=' and AA.FPNO like '''+'%'+Trim(FPNO.Text)+'%'+'''';
InitGridWsql(fsj);
end;
procedure TfrmWXFPList.ToolButton2Click(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
{if Trim(DName)<>Trim(Order_Main.fieldbyname('Filler').AsString) then
begin
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ!','<27><>ʾ',0);
Exit;
end;}
try
frmWXFPInPutWGL:=TfrmWXFPInPutWGL.Create(Application);
with frmWXFPInPutWGL do
begin
PState:=1;
FMainId:=Trim(Self.Order_Main.fieldbyname('FXID').AsString);
TBSave.Visible:=False;
ToolButton3.Visible:=False;
ToolButton4.Visible:=False;
if ShowModal=1 then
begin
end;
end;
finally
frmWXFPInPutWGL.Free;
end;
end;
end.