RTFormwork/public10/ThreeFun/Form/U_LbaelMap.pas
“ddf” f2a94cb7b0 1
2024-11-15 17:18:34 +08:00

280 lines
6.7 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_LbaelMap;
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,
dxDateRanges, dxBarBuiltInMenu, System.ImageList,
Vcl.ImgList;
type
TfrmLbaelMap = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ToolButton2: TToolButton;
ADOQueryMain: TADOQuery;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
cxGridLevel1: TcxGridLevel;
cxGridPopupMenu2: TcxGridPopupMenu;
DS_HZ: TDataSource;
CDS_HZ: TClientDataSet;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
Panel1: TPanel;
LMName: TEdit;
v2Column8: TcxGridDBColumn;
Label1: TLabel;
v2Column12: TcxGridDBColumn;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
Label2: TLabel;
LMType: TEdit;
v2Column1: TcxGridDBColumn;
Tv2Column1: TcxGridDBColumn;
ADOConnection1: TADOConnection;
ImageList_new32: TImageList;
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 N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure CustomerChange(Sender: TObject);
procedure v2Column8PropertiesEditValueChanged(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
public
FLMType: string;
{ Public declarations }
end;
var
frmLbaelMap: TfrmLbaelMap;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp;
{$R *.dfm}
procedure TfrmLbaelMap.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
SQL.Clear;
sql.Add(' select A.* from Lbael_Map A ');
sql.Add(' where LMType= ' + QuotedStr(trim(FLMType)));
Open;
end;
SCreateCDS(ADOQueryMain, CDS_HZ);
SInitCDSData(ADOQueryMain, CDS_HZ);
finally
ADOQueryMain.EnableControls;
ToolButton2.Click;
end;
end;
procedure TfrmLbaelMap.FormDestroy(Sender: TObject);
begin
frmLbaelMap := nil;
end;
procedure TfrmLbaelMap.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfrmLbaelMap.FormCreate(Sender: TObject);
begin
try
with ADOConnection1 do
begin
Connected := false;
ConnectionString := DConString;
//ConnectionString:='';
Connected := true;
end;
except
frmLbaelMap.Free;
end;
end;
procedure TfrmLbaelMap.TBCloseClick(Sender: TObject);
begin
WriteCxGrid(Trim(Self.Caption), Tv2, '<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>');
Close;
end;
procedure TfrmLbaelMap.FormShow(Sender: TObject);
begin
ReadCxGrid(Trim(Self.Caption), Tv2, '<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>');
InitGrid();
end;
procedure TfrmLbaelMap.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmLbaelMap.ToolButton2Click(Sender: TObject);
var
sql: string;
begin
if ADOQueryMain.Active then
begin
sql := SGetFilters(Panel1, 1, 2);
SDofilter(ADOQueryMain, sql);
SCreateCDS(ADOQueryMain, CDS_HZ);
SInitCDSData(ADOQueryMain, CDS_HZ);
end;
end;
procedure TfrmLbaelMap.cxTabControl1Change(Sender: TObject);
begin
InitGrid;
end;
procedure TfrmLbaelMap.N1Click(Sender: TObject);
begin
if CDS_HZ.IsEmpty then
exit;
with CDS_HZ do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value := true;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmLbaelMap.N2Click(Sender: TObject);
begin
if CDS_HZ.IsEmpty then
exit;
with CDS_HZ do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value := false;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmLbaelMap.CustomerChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmLbaelMap.v2Column8PropertiesEditValueChanged(Sender: TObject);
var
mvalue, FFieldName: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
FFieldName := Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value := Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate Lbael_Map ');
sql.Add(' Set ' + FFieldName + '=''' + Trim(mvalue) + '''');
sql.Add(' , Editer=''' + Trim(DName) + '''');
sql.Add(' , Edittime=getdate()');
sql.Add(' where LMID=' + quotedstr(CDS_HZ.fieldbyname('LMID').AsString));
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
tv2.Controller.EditingController.ShowEdit();
except
tv2.Controller.EditingController.ShowEdit();
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
end
end;
procedure TfrmLbaelMap.ToolButton4Click(Sender: TObject);
var
maxId: string;
begin
if GetLSNo(ADOQueryCmd, maxId, 'M', 'Lbael_Map', 4, 1) = False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into Lbael_Map(LMType,Filler) values(' + quotedstr(Trim(FLMType)) + ',' + quotedstr(Trim(dname)) + ')');
ExecSQL;
end;
InitGrid();
end;
procedure TfrmLbaelMap.ToolButton5Click(Sender: TObject);
begin
if CDS_HZ.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 Lbael_Map where LMID=' + QuotedStr(CDS_HZ.FieldByName('LMID').AsString));
ExecSQL;
end;
CDS_HZ.Delete;
end;
end.