205 lines
5.2 KiB
ObjectPascal
205 lines
5.2 KiB
ObjectPascal
![]() |
unit U_CustomerCX;
|
|||
|
|
|||
|
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, cxLookAndFeels, cxLookAndFeelPainters,
|
|||
|
cxNavigator;
|
|||
|
|
|||
|
type
|
|||
|
TfrmCustomerCX = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
Panel1: TPanel;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
RM1: TRMGridReport;
|
|||
|
RMDB_Main: TRMDBDataSet;
|
|||
|
Label3: TLabel;
|
|||
|
CoName: TEdit;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
Tv2: TcxGridDBTableView;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
DS_HZ: TDataSource;
|
|||
|
CDS_HZ: TClientDataSet;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v2Column2: TcxGridDBColumn;
|
|||
|
v2Column7: TcxGridDBColumn;
|
|||
|
v2Column10: TcxGridDBColumn;
|
|||
|
v2Column15: TcxGridDBColumn;
|
|||
|
CDS_LXR: TClientDataSet;
|
|||
|
DSLXR: TDataSource;
|
|||
|
Tv2Column1: TcxGridDBColumn;
|
|||
|
CDS_DZ: TClientDataSet;
|
|||
|
DSDZ: TDataSource;
|
|||
|
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 TBuserClick(Sender: TObject);
|
|||
|
procedure Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
procedure CoNameKeyPress(Sender: TObject; var Key: Char);
|
|||
|
private
|
|||
|
|
|||
|
{ Private declarations }
|
|||
|
procedure InitGrid();
|
|||
|
public
|
|||
|
canshu1: string;
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmCustomerCX: TfrmCustomerCX;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_Fun, U_ZDYHelp;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
procedure TfrmCustomerCX.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Filtered := False;
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' select * from Company where CoType=''<27>ͻ<EFBFBD>'' and Valid=''Y'' ');
|
|||
|
if Length(CoName.Text) < 4 then
|
|||
|
begin
|
|||
|
SQL.Add('AND 1=2');
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
SQL.Add('AND CONAME LIKE' + QuotedStr(Trim('%' + CoName.Text + '%')));
|
|||
|
end;
|
|||
|
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryMain, CDS_HZ);
|
|||
|
SInitCDSData20(ADOQueryMain, CDS_HZ);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCustomerCX.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
// frmCustomer:=nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCustomerCX.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCustomerCX.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(trim(self.caption), Tv2, '<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCustomerCX.TBDelClick(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;
|
|||
|
if Trim(CDS_HZ.fieldbyname('COID').AsString) <> '' then
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('update Company set Valid=''N'' where COID=''' + Trim(CDS_HZ.fieldbyname('COID').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
end;
|
|||
|
CDS_HZ.Delete;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCustomerCX.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
ReadCxGrid(trim(self.Caption), Tv2, '<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCustomerCX.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCustomerCX.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 TfrmCustomerCX.TBuserClick(Sender: TObject);
|
|||
|
var
|
|||
|
FuserName: string;
|
|||
|
begin
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCustomerCX.Tv2FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
begin
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Filtered := False;
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' select * from Company_contact where COID=' + quotedstr(Trim(CDS_HZ.FieldByName('COID').AsString)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryTemp, CDS_LXR);
|
|||
|
SInitCDSData20(ADOQueryTemp, CDS_LXR);
|
|||
|
|
|||
|
// with ADOQueryTemp do
|
|||
|
// begin
|
|||
|
// Filtered := False;
|
|||
|
// Close;
|
|||
|
// SQL.Clear;
|
|||
|
// sql.Add(' select * from Company_DZ where COID=' + quotedstr(Trim(CDS_HZ.FieldByName('COID').AsString)));
|
|||
|
// Open;
|
|||
|
// end;
|
|||
|
// SCreateCDS20(ADOQueryTemp, CDS_DZ);
|
|||
|
// SInitCDSData20(ADOQueryTemp, CDS_DZ);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCustomerCX.CoNameKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|