423 lines
10 KiB
ObjectPascal
423 lines
10 KiB
ObjectPascal
unit U_CostCR;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
|
||
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin,
|
||
StdCtrls, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
|
||
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
|
||
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
|
||
IdTCPClient, IdFTP,ShellAPI,IniFiles, cxCheckBox, cxCalendar,
|
||
cxButtonEdit, cxTextEdit, cxPC, cxDropDownEdit, cxLookAndFeels,
|
||
cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu;
|
||
|
||
type
|
||
TfrmCostCR = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
Panel1: TPanel;
|
||
ToolButton2: TToolButton;
|
||
Label1: TLabel;
|
||
YFName: TEdit;
|
||
ADOQueryMain: TADOQuery;
|
||
ToolButton1: TToolButton;
|
||
RM1: TRMGridReport;
|
||
RMDB_Main: TRMDBDataSet;
|
||
Label3: TLabel;
|
||
FactoryName: TEdit;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
cxGridDBColumn1: TcxGridDBColumn;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
Label2: TLabel;
|
||
Label6: TLabel;
|
||
begdate: TDateTimePicker;
|
||
Enddate: TDateTimePicker;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
DS_HZ: TDataSource;
|
||
CDS_HZ: TClientDataSet;
|
||
TBADD: TToolButton;
|
||
VHL: TcxGridDBColumn;
|
||
VBZ: TcxGridDBColumn;
|
||
VYB: TcxGridDBColumn;
|
||
VBB: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
tchk: TToolButton;
|
||
tnochk: TToolButton;
|
||
cxTabControl1: TcxTabControl;
|
||
v2Ssel: TcxGridDBColumn;
|
||
v2Column2: TcxGridDBColumn;
|
||
v2Column5: TcxGridDBColumn;
|
||
Label7: TLabel;
|
||
bankNo: TEdit;
|
||
CDS_YFS: TClientDataSet;
|
||
DS_YFS: TDataSource;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Qty: TcxGridDBColumn;
|
||
v1QtyUnit: TcxGridDBColumn;
|
||
v1Price: TcxGridDBColumn;
|
||
v1Money: TcxGridDBColumn;
|
||
v1note: TcxGridDBColumn;
|
||
cxGridLevel2: TcxGridLevel;
|
||
ToolButton3: TToolButton;
|
||
v2Column3: TcxGridDBColumn;
|
||
Label4: TLabel;
|
||
SYRName: TEdit;
|
||
Label5: TLabel;
|
||
PayMent: TEdit;
|
||
v2Column4: TcxGridDBColumn;
|
||
cxStyleRepository1: TcxStyleRepository;
|
||
cxStyle1: TcxStyle;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure FactoryNameChange(Sender: TObject);
|
||
procedure TBADDClick(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure tchkClick(Sender: TObject);
|
||
procedure tnochkClick(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView;
|
||
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
|
||
ANewItemRecordFocusingChanged: Boolean);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
|
||
|
||
procedure InitGrid();
|
||
Procedure SetStatus();
|
||
public
|
||
fflag:integer;
|
||
{ Public declarations }
|
||
FCYID,fmanage:String;
|
||
|
||
end;
|
||
|
||
var
|
||
frmCostCR: TfrmCostCR;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun,U_CostInput;
|
||
|
||
{$R *.dfm}
|
||
|
||
Procedure TfrmCostCR.SetStatus();
|
||
var
|
||
i:integer;
|
||
begin
|
||
|
||
Tchk.Visible:=false;
|
||
TNochk.Visible:=false;
|
||
TBDel.Visible:=false;
|
||
TBADd.Visible:=false;
|
||
ToolButton3.Visible:=false;
|
||
IF fmanage<>'<27><><EFBFBD>ò<EFBFBD>ѯ' then
|
||
begin
|
||
TBADd.Visible:=true;
|
||
|
||
case cxTabControl1.TabIndex of
|
||
0:begin
|
||
Tchk.Visible:=true;
|
||
TBDel.Visible:=true;
|
||
ToolButton3.Visible:=true;
|
||
end;
|
||
1:begin
|
||
TNochk.Visible:=true;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCostCR.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select A.* ');
|
||
sql.Add(' from YF_Money_CR A');
|
||
sql.Add('where A.CRTime>='''+FormatDateTime('yyyy-MM-dd',begdate.DateTime)+''' ');
|
||
sql.Add(' and CRTime<'''+FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1)+''' ');
|
||
sql.Add(' and A.CRType=''<27><><EFBFBD>õǼ<C3B5>'' ');
|
||
IF cxTabControl1.TabIndex<2 then
|
||
sql.Add(' and A.status='''+inttostr(cxTabControl1.TabIndex)+''' ');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
ToolButton2.Click;
|
||
end;
|
||
end;
|
||
|
||
|
||
procedure TfrmCostCR.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmCostCR:=nil;
|
||
end;
|
||
|
||
procedure TfrmCostCR.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmCostCR.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(self.Caption)+'Tv1',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
WriteCxGrid(trim(self.Caption)+'Tv2',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
procedure TfrmCostCR.TBDelClick(Sender: TObject);
|
||
var
|
||
FBBMoney,CRID:string;
|
||
begin
|
||
if CDS_HZ.IsEmpty then Exit;
|
||
|
||
|
||
if CDS_HZ.Locate('ssel',true,[])=false then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_HZ do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
IF Fieldbyname('ssel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('delete YF_Money_CR where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
|
||
sql.Add('delete YF_Money_CR_Sub where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
InitGrid();
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCostCR.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid(trim(self.Caption)+'Tv1',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
ReadCxGrid(trim(self.Caption)+'Tv2',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
Enddate.DateTime:=SGetServerDate(ADOQueryTemp);
|
||
begdate.DateTime:=Enddate.DateTime-90;
|
||
if trim(self.Caption)='<27><><EFBFBD>ò<EFBFBD>ѯ' then
|
||
begin
|
||
fmanage:='<27><>ѯ';
|
||
end;
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCostCR.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCostCR.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCostCR.FactoryNameChange(Sender: TObject);
|
||
begin
|
||
ToolButton2.Click;
|
||
end;
|
||
|
||
procedure TfrmCostCR.TBADDClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmCostInput:=TfrmCostInput.Create(self);
|
||
with frmCostInput do
|
||
begin
|
||
FYFID:='';
|
||
if showmodal=1 then
|
||
begin
|
||
initGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmCostInput.free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCostCR.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then Exit;
|
||
SelExportData(Tv2,ADOQueryMain,'<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmCostCR.tchkClick(Sender: TObject);
|
||
begin
|
||
IF CDS_HZ.IsEmpty then exit;
|
||
|
||
if CDS_HZ.Locate('ssel',true,[])=false then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_HZ do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
IF Fieldbyname('ssel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update YF_Money_CR SET status=''1'' ');
|
||
sql.Add(' ,Chker='''+Trim(DName)+'''');
|
||
sql.Add(' ,Chktime='''+formatdateTIme('yyyy-MM-dd',CDS_HZ.fieldbyname('CRTime').AsDateTime)+'''');
|
||
sql.Add('where YFID ='+quotedstr(trim(CDS_HZ.fieldbyname('YFID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
InitGrid();
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCostCR.tnochkClick(Sender: TObject);
|
||
begin
|
||
IF CDS_HZ.IsEmpty then exit;
|
||
|
||
if CDS_HZ.Locate('ssel',true,[])=false then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_HZ do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not eof do
|
||
begin
|
||
IF Fieldbyname('ssel').AsBoolean then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('update YF_Money_CR SET status=''0'',Chker=null,Chktime=null ');
|
||
sql.Add('where YFID ='+quotedstr(trim(CDS_HZ.fieldbyname('YFID').AsString)));
|
||
execsql;
|
||
end;
|
||
end;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
InitGrid();
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCostCR.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCostCR.Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView;
|
||
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
|
||
ANewItemRecordFocusingChanged: Boolean);
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select * from YF_Money_CR_SUB A');
|
||
sql.Add('where YFID='+Quotedstr(Trim(CDS_HZ.fieldbyname('YFID').AsString)));
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp,CDS_YFS);
|
||
SInitCDSData20(ADOQueryTemp,CDS_YFS);
|
||
end;
|
||
|
||
procedure TfrmCostCR.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmCostInput:=TfrmCostInput.Create(self);
|
||
with frmCostInput do
|
||
begin
|
||
FYFID:=Trim(CDS_HZ.fieldbyname('YFID').AsString);
|
||
if showmodal=1 then
|
||
begin
|
||
initGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmCostInput.free;
|
||
end;
|
||
end;
|
||
|
||
end.
|