D10szXIANGYING/E04梭织坯布仓库/U_KHCompanySel.pas
DESKTOP-E401PHE\Administrator 95fa3bf810 0526
2026-05-26 10:27:37 +08:00

218 lines
5.5 KiB
ObjectPascal
Raw Permalink 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_KHCompanySel;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, ToolWin, ComCtrls, U_BaseHelp, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls,
cxGridCustomView, cxGrid, DBClient, ADODB, ImgList, StdCtrls, ExtCtrls,
cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels,
cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, cxNavigator,
dxDateRanges, dxBarBuiltInMenu, System.ImageList, U_BaseInput,
dxScrollbarAnnotations;
type
TfrmKHCompanySel = class(TfrmBaseHelp)
TV1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
ToolBar1: TToolBar;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
DS_1: TDataSource;
CDS_1: TClientDataSet;
TBSave: TToolButton;
TBClose: TToolButton;
ToolButton1: TToolButton;
ADOConnection1: TADOConnection;
Panel1: TPanel;
Label1: TLabel;
CoName: TEdit;
GPM_1: TcxGridPopupMenu;
ImageList1: TImageList;
TV1Column1: TcxGridDBColumn;
TV1Column2: TcxGridDBColumn;
TV1Column3: TcxGridDBColumn;
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;
SHuangSeCu: TcxStyle;
TV1Saleser: TcxGridDBColumn;
Label2: TLabel;
CoAbbrName: TEdit;
Label3: TLabel;
Saleser: TEdit;
cxGrid2: TcxGrid;
TV2: TcxGridDBTableView;
cxGridLevel1: TcxGridLevel;
TV2address: TcxGridDBColumn;
CDS_2: TClientDataSet;
DS_2: TDataSource;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure CoNameChange(Sender: TObject);
procedure TV1FocusedRecordChanged(Sender: TcxCustomGridTableView;
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
ANewItemRecordFocusingChanged: Boolean);
procedure TV2DblClick(Sender: TObject);
private
procedure InitGrid();
{ Private declarations }
public
FCoType, FAuthority: string;
{ Public declarations }
end;
var
frmKHCompanySel: TfrmKHCompanySel;
implementation
uses
U_DataLink, U_RTFun;
{$R *.dfm}
procedure TfrmKHCompanySel.FormCreate(Sender: TObject);
begin
inherited;
try
with ADOConnection1 do
begin
Connected := false;
ConnectionString := DConString;
Connected := true;
end;
ADOQueryBaseCmd.Connection := ADOConnection1;
ADOQueryBaseTemp.Connection := ADOConnection1;
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
end;
end;
procedure TfrmKHCompanySel.CoNameChange(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
end;
end;
procedure TfrmKHCompanySel.FormClose(Sender: TObject; var Action: TCloseAction);
begin
CoName.SetFocus;
Action := cahide;
end;
procedure TfrmKHCompanySel.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
sql.Clear;
sql.Add('select A.* from BS_Company A where 1=1 and valid=''Y'' ');
if Trim(FCoType) <> '' then
begin
sql.Add(' and A.CoType=''' + Trim(FCoType) + '''');
end;
if Trim(FAuthority) = '<27><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>' then
begin
SQL.Add('and ( filler=' + quotedstr(trim(dname)));
sql.Add('or SalesId=' + quotedstr(trim(DCode)) + ' or exists (select * from [dbo].[F_Tool_SplitString](TallyId,'','') X where X.RTValue =' + quotedstr(trim(DCode)) + '))');
end;
Open;
end;
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmKHCompanySel.FormShow(Sender: TObject);
begin
inherited;
InitGrid();
ReadCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>' + Trim(FCoType), TV1, '<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
ReadCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>' + Trim(FCoType), TV2, '<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmKHCompanySel.TBCloseClick(Sender: TObject);
begin
inherited;
Close;
end;
procedure TfrmKHCompanySel.TBSaveClick(Sender: TObject);
begin
WriteCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>' + Trim(FCoType), TV1, '<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
WriteCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>' + Trim(FCoType), TV2, '<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmKHCompanySel.ToolButton1Click(Sender: TObject);
begin
CoName.SetFocus;
ModalResult := 1;
end;
procedure TfrmKHCompanySel.TV1FocusedRecordChanged(
Sender: TcxCustomGridTableView; APrevFocusedRecord,
AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
begin
with ADOQueryTemp do
begin
Filtered := False;
Close;
SQL.Clear;
sql.Add(' select * from KH_Address where COID=' + quotedstr(Trim(CDS_1.FieldByName('COID').AsString)));
Open;
end;
SCreateCDS(ADOQueryTemp, CDS_2);
SInitCDSData(ADOQueryTemp, CDS_2);
end;
procedure TfrmKHCompanySel.TV2DblClick(Sender: TObject);
begin
ModalResult := 1;
end;
procedure TfrmKHCompanySel.FormDestroy(Sender: TObject);
begin
inherited;
frmKHCompanySel := nil;
end;
end.