351 lines
9.7 KiB
ObjectPascal
351 lines
9.7 KiB
ObjectPascal
|
|
unit U_JYGL;
|
|||
|
|
|
|||
|
|
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, cxDBLookupComboBox, ComObj, cxLookAndFeels, cxLookAndFeelPainters,
|
|||
|
|
cxNavigator, U_BaseList, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges,
|
|||
|
|
dxBarBuiltInMenu, cxPC;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
Tfrmjygl = class(TfrmBaseList)
|
|||
|
|
ToolBar1: TToolBar;
|
|||
|
|
TBRafresh: TToolButton;
|
|||
|
|
btnAdd: TToolButton;
|
|||
|
|
btnEdit: TToolButton;
|
|||
|
|
TBDel: TToolButton;
|
|||
|
|
btnChk: TToolButton;
|
|||
|
|
btnReChk: TToolButton;
|
|||
|
|
ToolButton1: TToolButton;
|
|||
|
|
TBClose: TToolButton;
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
cxTabControl1: TcxTabControl;
|
|||
|
|
GPM_1: TcxGridPopupMenu;
|
|||
|
|
CDS_1: TClientDataSet;
|
|||
|
|
DS_1: TDataSource;
|
|||
|
|
Label3: TLabel;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
Label4: TLabel;
|
|||
|
|
numbering: TEdit;
|
|||
|
|
client: TEdit;
|
|||
|
|
KDNumber: TEdit;
|
|||
|
|
Label5: TLabel;
|
|||
|
|
Edit1: TEdit;
|
|||
|
|
Label6: TLabel;
|
|||
|
|
remark: TEdit;
|
|||
|
|
ToolButton2: TToolButton;
|
|||
|
|
ToolButton3: TToolButton;
|
|||
|
|
BegDate: TDateTimePicker;
|
|||
|
|
EndDate: TDateTimePicker;
|
|||
|
|
Label7: TLabel;
|
|||
|
|
cxGrid1: TcxGrid;
|
|||
|
|
Tv1: TcxGridDBTableView;
|
|||
|
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
|
Tv1Column5: TcxGridDBColumn;
|
|||
|
|
Tv1Column6: TcxGridDBColumn;
|
|||
|
|
Tv1Column7: TcxGridDBColumn;
|
|||
|
|
Tv1Column8: TcxGridDBColumn;
|
|||
|
|
Tv1Column9: TcxGridDBColumn;
|
|||
|
|
Tv1Column10: TcxGridDBColumn;
|
|||
|
|
Tv1Column11: TcxGridDBColumn;
|
|||
|
|
Tv1Column12: TcxGridDBColumn;
|
|||
|
|
Tv1Column13: TcxGridDBColumn;
|
|||
|
|
Tv1Column14: TcxGridDBColumn;
|
|||
|
|
Tv1Column15: TcxGridDBColumn;
|
|||
|
|
cxGridLevel1: TcxGridLevel;
|
|||
|
|
ADOQueryTemp: TADOQuery;
|
|||
|
|
Panel2: TPanel;
|
|||
|
|
CDS_2: TClientDataSet;
|
|||
|
|
DS_2: TDataSource;
|
|||
|
|
GPM_2: TcxGridPopupMenu;
|
|||
|
|
cxGrid2: TcxGrid;
|
|||
|
|
TV2: TcxGridDBTableView;
|
|||
|
|
TV2Column1: TcxGridDBColumn;
|
|||
|
|
TV2Column2: TcxGridDBColumn;
|
|||
|
|
TV2Column3: TcxGridDBColumn;
|
|||
|
|
TV2Column4: TcxGridDBColumn;
|
|||
|
|
TV2Column5: TcxGridDBColumn;
|
|||
|
|
TV2Column6: TcxGridDBColumn;
|
|||
|
|
TV2Column7: TcxGridDBColumn;
|
|||
|
|
TV2Column8: TcxGridDBColumn;
|
|||
|
|
TV2Column9: TcxGridDBColumn;
|
|||
|
|
TV2Column10: TcxGridDBColumn;
|
|||
|
|
TV2Column11: TcxGridDBColumn;
|
|||
|
|
TV2Column12: TcxGridDBColumn;
|
|||
|
|
cxGridLevel2: TcxGridLevel;
|
|||
|
|
ADOQueryMain: TADOQuery;
|
|||
|
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
|
ADOQueryCmd: TADOQuery;
|
|||
|
|
ToolButton4: TToolButton;
|
|||
|
|
procedure btnAddClick(Sender: TObject);
|
|||
|
|
procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
|
procedure btnEditClick(Sender: TObject);
|
|||
|
|
procedure TBDelClick(Sender: TObject);
|
|||
|
|
procedure FormCreate(Sender: TObject);
|
|||
|
|
procedure ToolButton4Click(Sender: TObject);
|
|||
|
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
procedure FormDestroy(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
procedure InitGrid();
|
|||
|
|
procedure InitSub();
|
|||
|
|
{ Private declarations }
|
|||
|
|
public
|
|||
|
|
FAuthority: string;
|
|||
|
|
{ Public declarations }
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frmjygl: Tfrmjygl;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
U_DataLink, U_RTFun, U_ZDYHelp, U_JYXX;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
procedure Tfrmjygl.InitSub();
|
|||
|
|
begin
|
|||
|
|
if CDS_1.IsEmpty then
|
|||
|
|
exit;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from BS_JYGL_sub A ');
|
|||
|
|
sql.Add('where mainid =' + quotedstr((CDS_1.fieldbyname('mainid').AsString)));
|
|||
|
|
open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS(ADOQueryTemp, CDS_2);
|
|||
|
|
SInitCDSData(ADOQueryTemp, CDS_2);
|
|||
|
|
TV2.DataController.Filter.Clear;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.InitGrid();
|
|||
|
|
var
|
|||
|
|
WSql: string;
|
|||
|
|
begin
|
|||
|
|
// WSql := SGetFilters(Panel1, 1, 2);
|
|||
|
|
// if trim(WSql) <> '' then
|
|||
|
|
// begin
|
|||
|
|
// WSql := ' and ' + trim(WSql);
|
|||
|
|
// end;
|
|||
|
|
//
|
|||
|
|
// if IsJYTime.Checked then
|
|||
|
|
// begin
|
|||
|
|
// WSql := WSql + ' and ConDate>' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
|
|||
|
|
// WSql := WSql + ' and ConDate<=' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1));
|
|||
|
|
// end
|
|||
|
|
// else
|
|||
|
|
// begin
|
|||
|
|
// if trim(WSql) <> '' then
|
|||
|
|
// WSql := ' and 1=1' + trim(WSql)
|
|||
|
|
// else
|
|||
|
|
// WSql := WSql + ' and 1=2 ';
|
|||
|
|
// end;
|
|||
|
|
// if trim(WSql) = 'and 1=2' then
|
|||
|
|
// Application.MessageBox('<27><>ѡ<EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
ADOQueryMain.DisableControls;
|
|||
|
|
with ADOQueryMain do
|
|||
|
|
begin
|
|||
|
|
Filtered := False;
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from BS_JYGL_Main');
|
|||
|
|
sql.Add('where CJdate >' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)));
|
|||
|
|
sql.Add('and CJdate <=' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)));
|
|||
|
|
// sql.Add('select AA.* ,row_number() over(order by ConDate) as XH from (select A.*');
|
|||
|
|
// sql.Add(',ISSC=cast((case when (select COUNT(T.WBID) from FJ_File T where T.WBID=A.ConMID)=0 then 0 else 1 end) as bit )');
|
|||
|
|
// sql.Add(',amount=(select sum(C.ConTotalAmount) from BS_Contract_Sub C where C.conmid=A.conmid)');
|
|||
|
|
// sql.Add(',Qty=(select sum(C.ConQty) from BS_Contract_Sub C where C.conmid=A.conmid)');
|
|||
|
|
// sql.Add(' from BS_Contract_Main A ) AA ');
|
|||
|
|
// sql.Add('where 1=1 ' + (WSql));
|
|||
|
|
// sql.Add(' and AA.ConType in (''<27><><EFBFBD><EFBFBD>'',''<27><><EFBFBD><EFBFBD>'') ');
|
|||
|
|
// showmessage(sql.text);
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
|
finally
|
|||
|
|
ADOQueryMain.EnableControls;
|
|||
|
|
TV1.DataController.Filter.Clear;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.btnAddClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// inherited;
|
|||
|
|
try
|
|||
|
|
frmjyxx := Tfrmjyxx.Create(Application);
|
|||
|
|
with frmjyxx do
|
|||
|
|
begin
|
|||
|
|
// FCOID := '';
|
|||
|
|
// fFlileFlag := self.fFlileFlag;
|
|||
|
|
PState := '<27><><EFBFBD><EFBFBD>';
|
|||
|
|
Fmainid := '';
|
|||
|
|
if ShowModal = 1 then
|
|||
|
|
begin
|
|||
|
|
// InitGrid();
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmjyxx.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.btnEditClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// inherited;
|
|||
|
|
if CDS_1.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
// ShowMessage(Trim(CDS_1.fieldbyname('Filler').AsString));
|
|||
|
|
// ShowMessage(Trim(DName));
|
|||
|
|
if Trim(CDS_1.fieldbyname('Filler').AsString) <> Trim(DName) then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
try
|
|||
|
|
frmjyxx := Tfrmjyxx.Create(Application);
|
|||
|
|
with frmjyxx do
|
|||
|
|
begin
|
|||
|
|
PState := '<27><EFBFBD>';
|
|||
|
|
Fmainid := Trim(Self.CDS_1.fieldbyname('mainid').AsString);
|
|||
|
|
// FAuthority := self.FAuthority;
|
|||
|
|
// FGSTT := self.FGSTT;
|
|||
|
|
// fFlileFlag := self.fFlileFlag;
|
|||
|
|
if ShowModal = 1 then
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmjyxx.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Action := caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.FormCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
EndDate.DateTime := SGetServerDate(ADOQueryTemp);
|
|||
|
|
BegDate.DateTime := EndDate.DateTime - 90;
|
|||
|
|
FAuthority := trim(fParameters1);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.FormDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
frmjygl := nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// inherited;
|
|||
|
|
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>');
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// inherited;
|
|||
|
|
Close;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.TBDelClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// inherited;
|
|||
|
|
if CDS_1.IsEmpty then
|
|||
|
|
exit;
|
|||
|
|
if not CDS_1.Locate('SSel', True, []) then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ');
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>ָܻ<DCBB><D6B8><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
|
Exit;
|
|||
|
|
|
|||
|
|
with CDS_1 do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
First;
|
|||
|
|
while not eof do
|
|||
|
|
begin
|
|||
|
|
if fieldbyname('SSel').AsBoolean then
|
|||
|
|
begin
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
// sql.add('insert into Bs_Contract_Main_DEL select * from BS_Contract_Main where ConMid=''' + trim(CDS_1.fieldbyname('ConMid').AsString) + ''' ');
|
|||
|
|
// sql.add('insert into Bs_Contract_sub_DEL select * from BS_Contract_sub where ConMid=''' + trim(CDS_1.fieldbyname('ConMid').AsString) + ''' ');
|
|||
|
|
sql.Add('DELETE from BS_JYGL_Main where mainid=''' + trim(CDS_1.fieldbyname('mainid').AsString) + ''' ');
|
|||
|
|
sql.Add('DELETE from BS_JYGL_sub where mainid=''' + trim(CDS_1.fieldbyname('mainid').AsString) + ''' ');
|
|||
|
|
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
next;
|
|||
|
|
end;
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
TBRafresh.Click;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.TBRafreshClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// inherited;
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.ToolButton1Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// inherited;
|
|||
|
|
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>');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.ToolButton4Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// inherited;
|
|||
|
|
if ADOQueryMain.Active = False then
|
|||
|
|
Exit;
|
|||
|
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure Tfrmjygl.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
|
begin
|
|||
|
|
// inherited;
|
|||
|
|
InitSub();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|
|||
|
|
|