399 lines
11 KiB
ObjectPascal
399 lines
11 KiB
ObjectPascal
|
unit U_LabelMapSet;
|
|||
|
|
|||
|
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, cxCheckComboBox, cxDropDownEdit, Menus, RM_e_Xls,
|
|||
|
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
|
|||
|
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, System.ImageList,
|
|||
|
Vcl.ImgList, U_BaseHelp, Vcl.Clipbrd;
|
|||
|
|
|||
|
type
|
|||
|
TfrmLabelMapSet = class(Tform)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
DS_1: TDataSource;
|
|||
|
CDS_1: TClientDataSet;
|
|||
|
Panel1: TPanel;
|
|||
|
LMName: TEdit;
|
|||
|
v2Column8: TcxGridDBColumn;
|
|||
|
Label1: TLabel;
|
|||
|
v2Column12: TcxGridDBColumn;
|
|||
|
ToolButton4: TToolButton;
|
|||
|
ToolButton5: TToolButton;
|
|||
|
Label2: TLabel;
|
|||
|
LMType: TEdit;
|
|||
|
v2Column1: TcxGridDBColumn;
|
|||
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
ADOConnection1: TADOConnection;
|
|||
|
ImageList1: TImageList;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
TV2: TcxGridDBTableView;
|
|||
|
cxGridLevel2: TcxGridLevel;
|
|||
|
DS_2: TDataSource;
|
|||
|
ToolBar2: TToolBar;
|
|||
|
ToolButton12: TToolButton;
|
|||
|
ToolButton6: TToolButton;
|
|||
|
ToolButton7: TToolButton;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
ADO_2: TADOQuery;
|
|||
|
PM_2: TPopupMenu;
|
|||
|
N3: TMenuItem;
|
|||
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
procedure CustomerChange(Sender: TObject);
|
|||
|
procedure v2Column8PropertiesEditValueChanged(Sender: TObject);
|
|||
|
procedure ToolButton4Click(Sender: TObject);
|
|||
|
procedure ToolButton5Click(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure ToolButton12Click(Sender: TObject);
|
|||
|
procedure ToolButton6Click(Sender: TObject);
|
|||
|
procedure ToolButton7Click(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
procedure N3Click(Sender: TObject);
|
|||
|
procedure TextEdit(Sender: TObject);
|
|||
|
private
|
|||
|
{ Private declarations }
|
|||
|
procedure InitGrid();
|
|||
|
procedure Getfields(MSql: Integer);
|
|||
|
public
|
|||
|
IsSql1: Boolean;
|
|||
|
FLMType: string;
|
|||
|
FFiltration1, FFiltration2, FFiltration3: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmLabelMapSet: TfrmLabelMapSet;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.Getfields(MSql: Integer);
|
|||
|
begin
|
|||
|
|
|||
|
case MSql of
|
|||
|
1:
|
|||
|
begin
|
|||
|
if IsSql1 then
|
|||
|
begin
|
|||
|
with ADO_2 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.add('exec ' + trim(CDS_1.fieldbyname('LMSql1').AsString));
|
|||
|
sql.add(FFiltration1);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
if trim(CDS_1.fieldbyname('LMSql1').AsString) <> '' then
|
|||
|
begin
|
|||
|
with ADO_2 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.add('exec ' + trim(CDS_1.fieldbyname('LMSql1').AsString) + ' @Filtration=' + quotedstr(Trim(FFiltration1)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
TV2.ClearItems; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
(TV2.DataController as IcxCustomGridDataController).DeleteAllItems; //ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
(TV2.DataController as IcxCustomGridDataController).CreateAllItems(false); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
TV2.ApplyBestFit; //<2F><><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>Ӧ .BestFitMaxWidth;
|
|||
|
end;
|
|||
|
2:
|
|||
|
begin
|
|||
|
if trim(CDS_1.fieldbyname('LMSql2').AsString) <> '' then
|
|||
|
begin
|
|||
|
with ADO_2 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.add('exec ' + trim(CDS_1.fieldbyname('LMSql2').AsString) + ' @Filtration=' + quotedstr(Trim(FFiltration2)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
TV2.ClearItems; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
(TV2.DataController as IcxCustomGridDataController).DeleteAllItems; //ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
(TV2.DataController as IcxCustomGridDataController).CreateAllItems(False); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
TV2.ApplyBestFit; //<2F><><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>Ӧ .BestFitMaxWidth;
|
|||
|
end;
|
|||
|
3:
|
|||
|
begin
|
|||
|
if trim(CDS_1.fieldbyname('LMSql3').AsString) <> '' then
|
|||
|
begin
|
|||
|
with ADO_2 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.add('exec ' + trim(CDS_1.fieldbyname('LMSql3').AsString) + ' @Filtration=' + quotedstr(Trim(FFiltration3)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
TV2.ClearItems; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
(TV2.DataController as IcxCustomGridDataController).DeleteAllItems; //ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
(TV2.DataController as IcxCustomGridDataController).CreateAllItems(false); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
TV2.ApplyBestFit; //<2F><><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>Ӧ .BestFitMaxWidth;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' select A.* from BS_Label_Map A ');
|
|||
|
sql.Add(' where LMType=' + quotedstr(FLMType));
|
|||
|
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
ToolButton2.Click;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.N3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
Clipboard.SetTextBuf(PChar(TV2.Controller.FocusedColumn.DataBinding.FilterFieldName));
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
frmLabelMapSet := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
with ADOConnection1 do
|
|||
|
begin
|
|||
|
Connected := false;
|
|||
|
ConnectionString := DConString;
|
|||
|
Connected := true;
|
|||
|
end;
|
|||
|
// ADOQueryBaseCmd.Connection := ADOConnection1;
|
|||
|
// ADOQueryBaseTemp.Connection := ADOConnection1;
|
|||
|
except
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
ModalResult := 1;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
ReadCxGrid(Trim(Self.Caption), Tv1, '<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>');
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.ToolButton12Click(Sender: TObject);
|
|||
|
begin
|
|||
|
Getfields(1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(Trim(Self.Caption), Tv1, '<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>');
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.ToolButton2Click(Sender: TObject);
|
|||
|
var
|
|||
|
sql: string;
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
sql := SGetFilters(Panel1, 1, 2);
|
|||
|
SDofilter(ADOQueryMain, sql);
|
|||
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.ToolButton3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
TcxGridToExcel('sql<71>ֶ<EFBFBD>', cxgrid2);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.CustomerChange(Sender: TObject);
|
|||
|
begin
|
|||
|
ToolButton2.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.v2Column8PropertiesEditValueChanged(Sender: TObject);
|
|||
|
var
|
|||
|
mvalue, FFieldName: string;
|
|||
|
begin
|
|||
|
mvalue := TcxTextEdit(Sender).EditingText;
|
|||
|
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
with CDS_1 do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName(FFieldName).Value := Trim(mvalue);
|
|||
|
Post;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('UPdate BS_Label_Map ');
|
|||
|
sql.Add(' Set ' + FFieldName + '=''' + Trim(mvalue) + '''');
|
|||
|
sql.Add(' , Editer=''' + Trim(DName) + '''');
|
|||
|
sql.Add(' , Edittime=getdate()');
|
|||
|
sql.Add(' where LMID=' + quotedstr(CDS_1.fieldbyname('LMID').AsString));
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
tv1.Controller.EditingController.ShowEdit();
|
|||
|
except
|
|||
|
tv1.Controller.EditingController.ShowEdit();
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
|||
|
end
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.ToolButton4Click(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('insert into BS_Label_Map(LMType,Filler) values(' + quotedstr(Trim(FLMType)) + ',' + quotedstr(Trim(dname)) + ')');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.ToolButton5Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_1.IsEmpty then
|
|||
|
Exit;
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('delete BS_Label_Map where LMID=' + QuotedStr(CDS_1.FieldByName('LMID').AsString));
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
CDS_1.Delete;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.ToolButton6Click(Sender: TObject);
|
|||
|
begin
|
|||
|
Getfields(2);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.ToolButton7Click(Sender: TObject);
|
|||
|
begin
|
|||
|
Getfields(3);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmLabelMapSet.TextEdit(Sender: TObject);
|
|||
|
var
|
|||
|
mvalue, FFieldName: string;
|
|||
|
begin
|
|||
|
mvalue := TcxTextEdit(Sender).EditingText;
|
|||
|
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
with CDS_1 do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName(FFieldName).Value := Trim(mvalue);
|
|||
|
Post;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('UPdate BS_Label_Map ');
|
|||
|
sql.Add(' Set ' + FFieldName + '=' + Trim(mvalue));
|
|||
|
sql.Add(' , Editer=''' + Trim(DName) + '''');
|
|||
|
sql.Add(' , Edittime=getdate()');
|
|||
|
sql.Add(' where LMID=' + quotedstr(CDS_1.fieldbyname('LMID').AsString));
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
tv1.Controller.EditingController.ShowEdit();
|
|||
|
except
|
|||
|
tv1.Controller.EditingController.ShowEdit();
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
|||
|
end
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|