RTFormwork/public10/ThreeFun/Form/U_ColumnBandSet.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

469 lines
13 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_ColumnBandSet;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxCheckBox, ADODB, DBClient,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel,
cxClasses, cxControls, cxGridCustomView, cxGrid, ComCtrls, ToolWin,
ImgList, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore,
dxSkinsDefaultPainters, cxNavigator, dxDateRanges, System.ImageList;
type
TfrmColumnBandSet = class(TForm)
ToolBar1: TToolBar;
TBTP: TToolButton;
TBClose: TToolButton;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
v1Column1: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
v2Column1: TcxGridDBColumn;
ClientDataSet1: TClientDataSet;
ClientDataSet2: TClientDataSet;
DataSource1: TDataSource;
DataSource2: TDataSource;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOQuery3: TADOQuery;
ADOQuery4: TADOQuery;
ADOLink: TADOConnection;
ThreeImgList: TImageList;
ThreeColorBase: TcxStyleRepository;
SHuangSe: TcxStyle;
SkyBlue: TcxStyle;
Default: TcxStyle;
QHuangSe: TcxStyle;
Red: TcxStyle;
FontBlue: TcxStyle;
TextSHuangSe: TcxStyle;
FonePurple: TcxStyle;
FoneClMaroon: TcxStyle;
FoneRed: TcxStyle;
RowColor: TcxStyle;
handBlack: TcxStyle;
cxBlue: TcxStyle;
FenHongS: TcxStyle;
cxGrid3: TcxGrid;
Tv3: TcxGridDBTableView;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
cxGridLevel2: TcxGridLevel;
DSName: TDataSource;
CDSName: TClientDataSet;
ADOQuery5: TADOQuery;
v2Column2: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure TBTPClick(Sender: TObject);
procedure Tv1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure SCreateCDS200(SADOQry:TADOQuery; mClientDataset:TclientDataSet );
procedure SInitCDSData200(fromADO:TADOQuery;toCDS:TclientDataSet);
function GetLSNo200(ADOQueryTmp:TADOQuery;
var mMaxNo:string;
mFlag:string;
mTable:string;
mlen:integer;
mtype:integer=0):Boolean;
public
MKName:String;
{ Public declarations }
end;
var
frmColumnBandSet: TfrmColumnBandSet;
implementation
uses
U_DataLink;
{$R *.dfm}
procedure TfrmColumnBandSet.FormDestroy(Sender: TObject);
begin
frmColumnBandSet:=nil;
end;
procedure TfrmColumnBandSet.SCreateCDS200(SADOQry:TADOQuery; mClientDataset:TclientDataSet );
var
i:integer;
mfieldName:string;
mSize:integer;
begin
mfieldName:='';
mClientDataset.FieldDefs.Clear;
with SADOQry do
begin
for i:=0 to fieldCount-1 do //
begin
if (Fields[i].DataType=ftString) and (Fields[i].Size=0) then
begin
msize:=1;
end
else
msize:=Fields[i].Size;
mfieldName:=trim(fields[i].FieldName);
mClientDataset.FieldDefs.Add(mfieldName,
Fields[i].DataType,msize);
end;
end;
mClientDataset.FieldDefs.Add('Sflag',ftString,1);
mClientDataset.FieldDefs.Add('Sindex',ftInteger,0);
mClientDataset.FieldDefs.Add('Ssel',ftBoolean,0);
mClientDataset.FieldDefs.Add('SDefNote',ftString,10);
mClientDataset.Close;
mClientDataset.CreateDataSet;
end;
procedure TfrmColumnBandSet.SInitCDSData200(fromADO:TADOQuery;toCDS:TclientDataSet);
var
i:integer;
k:integer;
begin
if fromADO.IsEmpty then exit;
fromADO.first;
K:=1;
try
toCDS.DisableControls;
toCDS.Filtered:=false;
while not fromADO.Eof do
begin
with toCDS do
begin
Append;
for i:=0 to fromADO.FieldCount-1 do
begin
fields[i].value:=fromADO.Fields[i].Value ;
end;
fieldByName('Sflag').AsString :='1';
fieldByName('Sindex').value :=k;
fieldByName('Ssel').value :=false;
inc(k);
Post;
end;
fromADO.Next;
end;
if not toCDS.IsEmpty then
begin
toCDS.First ;
end;
finally
toCDS.EnableControls;
end;
end;
procedure TfrmColumnBandSet.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmColumnBandSet.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmColumnBandSet.FormShow(Sender: TObject);
begin
try
ADOQuery1.DisableControls;
with ADOQuery1 do
begin
Close;
sql.Clear;
SQL.Add('select * from SY_User where UserId<>''Admin'' ');
Open;
end;
SCreateCDS200(ADOQuery1,ClientDataSet1);
SInitCDSData200(ADOQuery1,ClientDataSet1);
finally
ADOQuery1.EnableControls;
end;
end;
procedure TfrmColumnBandSet.TBTPClick(Sender: TObject);
var
MaxNo:String;
begin
if ClientDataSet1.IsEmpty then Exit;
if ClientDataSet1.Locate('SSel',True,[])=False then Exit;
try
ADOQuery3.Connection.BeginTrans;
if ClientDataSet1.Locate('SSel',True,[])=True then
begin
with ClientDataSet1 do
begin
First;
while not eof do
begin
if ClientDataSet1.FieldByName('SSel').AsBoolean=True then
begin
with ADOQuery3 do
begin
Close;
sql.Clear;
sql.Add('Delete Table_Column where ');
sql.Add(' Owner='''+Trim(ClientDataSet1.fieldbyname('UserId').AsString)+'''');
ExecSQL;
end;
with ADOQuery3 do
begin
Close;
sql.Clear;
sql.Add('select * from Table_Column where 1<>1 ');
open;
end;
ClientDataSet2.DisableControls;
with ClientDataSet2 do
begin
first;
while not Eof do
begin
with ADOQuery3 do
begin
Append;
if GetLSNo200(ADOQuery4,MaxNo,'CL','Table_Column',4,1)=False then
begin
ADOQuery3.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
FieldByName('TCID').Value:=Trim(MaxNo);
FieldByName('Owner').Value:=Trim(ClientDataSet1.fieldbyname('UserId').AsString);
//SSetSaveDataCDSNew(ADOQuery3,Tv2,ClientDataSet2,'Table_Column',0);
FieldByName('CxTabName').Value:=Trim(ClientDataSet2.fieldbyname('CxTabName').AsString);
FieldByName('CxColName').Value:=Trim(ClientDataSet2.fieldbyname('CxColName').AsString);
if ClientDataSet2.fieldbyname('TCNotVisble').AsBoolean=True then
FieldByName('TCNotVisble').Value:=1
else
FieldByName('TCNotVisble').Value:=0;
FieldByName('ColName').Value:=Trim(ClientDataSet2.fieldbyname('ColName').AsString);
FieldByName('OrderNo').Value:=ClientDataSet2.fieldbyname('OrderNo').Value;
FieldByName('FillTime').Value:=Now;
Post;
end;
Next;
end;
end;
ClientDataSet2.EnableControls;
end;
Next;
end;
end;
if ClientDataSet1.Locate('SSel',True,[])=True then
begin
with ClientDataSet1 do
begin
First;
while not eof do
begin
if ClientDataSet1.FieldByName('SSel').AsBoolean=True then
begin
with ADOQuery3 do
begin
Close;
sql.Clear;
sql.Add(' Delete Table_Name where');
sql.Add(' Owner='''+Trim(ClientDataSet1.fieldbyname('UserId').AsString)+'''');
ExecSQL;
end;
with ADOQuery3 do
begin
Close;
sql.Clear;
sql.Add('select * from Table_Name where 1<>1 ');
open;
end;
CDSName.DisableControls;
with CDSName do
begin
First;
while not eof do
begin
with ADOQuery3 do
begin
Append;
FieldByName('Owner').Value:=Trim(ClientDataSet1.fieldbyname('UserId').AsString);
FieldByName('CxTabName').Value:=Trim(CDSName.fieldbyname('CxTabName').AsString);
if CDSName.fieldbyname('TCNotVisble').AsBoolean=True then
FieldByName('TCNotVisble').Value:=1
else
FieldByName('TCNotVisble').Value:=0;
if CDSName.fieldbyname('InPut').AsBoolean=True then
FieldByName('InPut').Value:=1
else
FieldByName('InPut').Value:=0;
FieldByName('FillTime').Value:=Now;
FieldByName('OrderNo').Value:=CDSName.fieldbyname('OrderNo').Value;
Post;
end;
next;
end;
end;
CDSName.EnableControls;
end;
Next;
end;
end;
end;
end;
ADOQuery3.Connection.CommitTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
except
ADOQuery3.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
end;
end;
function TfrmColumnBandSet.GetLSNo200(ADOQueryTmp:TADOQuery;
var mMaxNo:string;
mFlag:string;
mTable:string;
mlen:integer;
mtype:integer=0):Boolean;
begin
try
with ADOQueryTmp do
begin
Close;
sql.Clear ;
sql.Add('exec Get_SY_MaxBH ');
sql.Add(' '+quotedStr(mFlag));
sql.Add(','+quotedStr(mTable));
sql.Add(','+intTostr(mlen));
sql.Add(','+intTostr(mtype));
//ShowMessage(SQL.Text);
Open;
if RecordCount>0 then
begin
mMaxNo:=trim(fieldByName('MaxBH').AsString) ;
if mMaxNo<>'' then
result:=true
else
Result:=false;
end
else
begin
result:=false;
end;
end;
if not Result then
application.MessageBox(Pchar('<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>('+mflag+')'),'<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONINFORMATION);
Except
result:=false;
application.MessageBox(Pchar('<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>('+mflag+')'),'<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONINFORMATION);
end;
end;
procedure TfrmColumnBandSet.Tv1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
ADOQuery2.DisableControls;
with ADOQuery2 do
begin
Close;
sql.Clear;
sql.Add('select * from Table_Column where ');
sql.Add(' Owner='''+Trim(ClientDataSet1.fieldbyname('UserId').AsString)+'''');
Open;
end;
if ADOQuery2.IsEmpty=False then
begin
with ADOQuery2 do
begin
Close;
sql.Clear;
sql.Add('select * from Table_Column where ');
sql.Add(' Owner='''+Trim(ClientDataSet1.fieldbyname('UserId').AsString)+'''');
sql.Add(' order by OrderNo ');
Open;
end;
SCreateCDS200(ADOQuery2,ClientDataSet2);
SInitCDSData200(ADOQuery2,ClientDataSet2);
end else
begin
while ClientDataSet2.Locate('TCNotVisble',True,[]) do
begin
with ClientDataSet2 do
begin
Edit;
FieldByName('TCNotVisble').Value:=0;
Post;
end;
end;
end;
ADOQuery2.EnableControls;
ADOQuery5.DisableControls;
with ADOQuery5 do
begin
Close;
sql.Clear;
sql.Add('select * from Table_Name where ');
sql.Add(' Owner='''+Trim(ClientDataSet1.fieldbyname('UserId').AsString)+'''');
Open;
end;
if ADOQuery5.IsEmpty=False then
begin
with ADOQuery5 do
begin
Close;
sql.Clear;
sql.Add('select * from Table_Name where ');
sql.Add(' Owner='''+Trim(ClientDataSet1.fieldbyname('UserId').AsString)+'''');
sql.Add(' order by OrderNo ');
Open;
end;
SCreateCDS200(ADOQuery5,CDSName);
SInitCDSData200(ADOQuery5,CDSName);
end else
begin
while CDSName.Locate('TCNotVisble',True,[]) do
begin
with CDSName do
begin
Edit;
FieldByName('TCNotVisble').Value:=0;
FieldByName('InPut').Value:=0;
Post;
end;
end;
end;
ADOQuery5.EnableControls;
end;
procedure TfrmColumnBandSet.FormCreate(Sender: TObject);
begin
with ADOLink do
begin
if not Connected then
begin
Connected:=false;
ConnectionString:=DConString;
//LoginPrompt:=false;
Connected:=true;
end;
end;
end;
end.