792 lines
21 KiB
ObjectPascal
792 lines
21 KiB
ObjectPascal
|
|
unit U_BPZdy_LRX;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|||
|
|
cxDataStorage, cxEdit, DB, cxDBData, ToolWin, ComCtrls,
|
|||
|
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel,
|
|||
|
|
cxClasses, cxControls, cxGridCustomView, cxGrid, DBClient, ADODB, ImgList,
|
|||
|
|
StdCtrls, ExtCtrls, cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu,
|
|||
|
|
cxButtonEdit, BtnEdit, cxTL, cxMaskEdit, cxInplaceContainer, cxDBTL,
|
|||
|
|
cxTLData, cxContainer, cxCurrencyEdit, cxCheckBox, cxSplitter;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmBPZDY_LRX = class(TForm)
|
|||
|
|
ToolBar1: TToolBar;
|
|||
|
|
ADOQueryMain: TADOQuery;
|
|||
|
|
ADOQueryTemp: TADOQuery;
|
|||
|
|
ADOQueryCmd: TADOQuery;
|
|||
|
|
DataSource1: TDataSource;
|
|||
|
|
ClientDataSet1: TClientDataSet;
|
|||
|
|
TBClose: TToolButton;
|
|||
|
|
ADOConnection1: TADOConnection;
|
|||
|
|
ThreeImgList: TImageList;
|
|||
|
|
DataSource2: TDataSource;
|
|||
|
|
ML_GYS: TClientDataSet;
|
|||
|
|
DataSource3: TDataSource;
|
|||
|
|
ML_GX: TClientDataSet;
|
|||
|
|
ADOQuery6: TADOQuery;
|
|||
|
|
ADOQuery2: TADOQuery;
|
|||
|
|
ADOQuery3: TADOQuery;
|
|||
|
|
Panel4: TPanel;
|
|||
|
|
Panel5: TPanel;
|
|||
|
|
Label6: TLabel;
|
|||
|
|
Label7: TLabel;
|
|||
|
|
Label8: TLabel;
|
|||
|
|
Label9: TLabel;
|
|||
|
|
Button1: TButton;
|
|||
|
|
DataSource4: TDataSource;
|
|||
|
|
ADOQueryTree: TADOQuery;
|
|||
|
|
Order_Tree: TClientDataSet;
|
|||
|
|
Panel6: TPanel;
|
|||
|
|
cxGrid1: TcxGrid;
|
|||
|
|
TV1: TcxGridDBTableView;
|
|||
|
|
V1BPColNo: TcxGridDBColumn;
|
|||
|
|
V1BPColor: TcxGridDBColumn;
|
|||
|
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
|
ToolBar2: TToolBar;
|
|||
|
|
TBAdd: TToolButton;
|
|||
|
|
TBDel: TToolButton;
|
|||
|
|
ToolButton1: TToolButton;
|
|||
|
|
Panel7: TPanel;
|
|||
|
|
cxDBTreeList1: TcxDBTreeList;
|
|||
|
|
cxDBTreeList1cxDBTreeListColumn2: TcxDBTreeListColumn;
|
|||
|
|
ToolBar3: TToolBar;
|
|||
|
|
ToolPBLE: TToolButton;
|
|||
|
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
|
cxStyle1: TcxStyle;
|
|||
|
|
cxStyleRepository2: TcxStyleRepository;
|
|||
|
|
cxStyle2: TcxStyle;
|
|||
|
|
BPColNo: TEdit;
|
|||
|
|
BPColor: TEdit;
|
|||
|
|
BPName: TEdit;
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
BPNameM: TEdit;
|
|||
|
|
BPCodeM: TEdit;
|
|||
|
|
V1BPNote: TcxGridDBColumn;
|
|||
|
|
Label14: TLabel;
|
|||
|
|
BPNote: TEdit;
|
|||
|
|
V1BPPrice: TcxGridDBColumn;
|
|||
|
|
Label15: TLabel;
|
|||
|
|
BPPrice: TEdit;
|
|||
|
|
Label16: TLabel;
|
|||
|
|
procedure FormCreate(Sender: TObject);
|
|||
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
procedure TBAddClick(Sender: TObject);
|
|||
|
|
procedure TBSaveClick(Sender: TObject);
|
|||
|
|
procedure TBDelClick(Sender: TObject);
|
|||
|
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure TV1CellDblClick(Sender: TcxCustomGridTableView;
|
|||
|
|
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
|||
|
|
AShift: TShiftState; var AHandled: Boolean);
|
|||
|
|
procedure BPNamehange(Sender: TObject);
|
|||
|
|
procedure v1note1PropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
procedure V1BPCodePropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
procedure V1BPNamePropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
procedure ToolButton4Click(Sender: TObject);
|
|||
|
|
procedure BPCodeMChange(Sender: TObject);
|
|||
|
|
procedure Tv3CellDblClick(Sender: TcxCustomGridTableView;
|
|||
|
|
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
|||
|
|
AShift: TShiftState; var AHandled: Boolean);
|
|||
|
|
procedure Button1Click(Sender: TObject);
|
|||
|
|
procedure TPBLBClick(Sender: TObject);
|
|||
|
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
|
procedure Button1KeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
procedure cxDBTreeList1Click(Sender: TObject);
|
|||
|
|
procedure BPNameKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
procedure FormDestroy(Sender: TObject);
|
|||
|
|
procedure TV1FocusedRecordChanged(Sender: TcxCustomGridTableView;
|
|||
|
|
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
|
|||
|
|
ANewItemRecordFocusingChanged: Boolean);
|
|||
|
|
procedure BPPriceKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
procedure BPNoteKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
procedure BPColNoKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
procedure BPColorKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
private
|
|||
|
|
FBPID,FCPID,FCPNo,FCPName:string;
|
|||
|
|
procedure InitGrid();
|
|||
|
|
procedure SaveData();
|
|||
|
|
procedure initTree();
|
|||
|
|
{ Private declarations }
|
|||
|
|
public
|
|||
|
|
flag,flagname,snote,MainType,FGYName,Fint,canshu1:string;
|
|||
|
|
fnote,fnote1,forderno,fZdyFlag,ViewFlag,fHelpType:Boolean;
|
|||
|
|
PPSTE:integer;
|
|||
|
|
{ Public declarations }
|
|||
|
|
end;
|
|||
|
|
var
|
|||
|
|
frmBPZDY_LRX: TfrmBPZDY_LRX;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
uses
|
|||
|
|
U_DataLink,U_Fun10,U_BPZdy_SH, U_BPZdy_HXK,U_CPTypePB,U_CPTypeX;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
procedure TfrmBPZDY_LRX.initTree();
|
|||
|
|
begin
|
|||
|
|
with ADOQueryTree do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
SQL.Add('select *');
|
|||
|
|
sql.Add(', Case when isnull(CPNo,'''')<>'''' then RTrim(CPNo)+''/''+CPName else CPName end as CP ');
|
|||
|
|
SQL.Add('from CP_TypeX order by CPlevel,CPOrder,CPName');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOQueryTree,Order_Tree);
|
|||
|
|
SInitCDSData20(ADOQueryTree,Order_Tree);
|
|||
|
|
cxDBTreeList1.Items[0].Expand(true);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.SaveData();
|
|||
|
|
var maxno:string;
|
|||
|
|
begin
|
|||
|
|
if FGYName<>'' then exit;
|
|||
|
|
try
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
ClientDataSet1.DisableControls;
|
|||
|
|
with ClientDataSet1 do
|
|||
|
|
begin
|
|||
|
|
First;
|
|||
|
|
while not eof do
|
|||
|
|
begin
|
|||
|
|
if Trim(ClientDataSet1.FieldByName('BPID').AsString)='' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOQueryTemp,maxno,'BP','X_ZDY',3,1)=False then
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
ClientDataSet1.EnableControls;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
maxno:=Trim(ClientDataSet1.fieldbyname('BPID').AsString);
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from X_ZDY where BPID='''+Trim(maxno)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryCmd.IsEmpty then
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Append;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Edit;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.FieldByName('BPID').Value:=Trim(maxno);
|
|||
|
|
SSetSaveDataCDSNew(ADOQueryCmd,Tv1,ClientDataSet1,'X_ZDY',3);
|
|||
|
|
ADOQueryCmd.FieldByName('BPType').Value:=flagName;
|
|||
|
|
ADOQueryCmd.FieldByName('BPFlag').Value:=flag;
|
|||
|
|
ADOQueryCmd.FieldByName('valid').Value:='Y';
|
|||
|
|
ADOQueryCmd.Post;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.add('select * from X_ZDY where BPCode='''+Trim(ClientDataSet1.fieldbyname('BPCode').AsString)+'''');
|
|||
|
|
sql.Add(' and BPFlag='''+trim(flag)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty=False then
|
|||
|
|
begin
|
|||
|
|
if ADOQueryTemp.RecordCount>1 then
|
|||
|
|
begin
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
SQL.Add('delete X_ZDY where BPID='''+Trim(ClientDataSet1.fieldbyname('BPID').AsString)+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
ClientDataSet1.EnableControls;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.add('select * from X_ZDY where BPName='''+Trim(ClientDataSet1.fieldbyname('BPName').AsString)+'''');
|
|||
|
|
sql.add(' and isnull(BPColNo,'''')='''+Trim(ClientDataSet1.fieldbyname('BPColNo').AsString)+'''');
|
|||
|
|
sql.add(' and isnull(BPColor,'''')='''+Trim(ClientDataSet1.fieldbyname('BPColor').AsString)+'''');
|
|||
|
|
sql.Add(' and BPFlag='''+trim(flag)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty=False then
|
|||
|
|
begin
|
|||
|
|
if ADOQueryTemp.RecordCount>1 then
|
|||
|
|
begin
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
SQL.Add('delete X_ZDY where BPID='''+Trim(ClientDataSet1.fieldbyname('BPID').AsString)+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
ClientDataSet1.EnableControls;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD>ؾ<EFBFBD>ɴγɴ<CEB3>ظ<EFBFBD><D8B8><EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
ClientDataSet1.Edit;
|
|||
|
|
ClientDataSet1.FieldByName('BPID').Value:=Trim(maxno);
|
|||
|
|
//ClientDataSet1.Post;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
ClientDataSet1.EnableControls;
|
|||
|
|
end;
|
|||
|
|
TV1.OptionsData.Editing:=false;
|
|||
|
|
TV1.OptionsSelection.CellSelect:=false;
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
except;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.FormCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
//cxGrid1.Align:=alClient;
|
|||
|
|
with ADOConnection1 do
|
|||
|
|
begin
|
|||
|
|
Connected:=false;
|
|||
|
|
ConnectionString:=DConString;
|
|||
|
|
//ConnectionString:='';
|
|||
|
|
Connected:=true;
|
|||
|
|
end;
|
|||
|
|
except;
|
|||
|
|
frmBPZDY_LRX.Free;
|
|||
|
|
end;
|
|||
|
|
canshu1:=Trim(DParameters1);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.FormClose(Sender: TObject;
|
|||
|
|
var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
ToolBar1.SetFocus;
|
|||
|
|
Action:=caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.InitGrid();
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
ADOQueryMain.DisableControls;
|
|||
|
|
with ADOQueryMain do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add(' exec P_Select_X :Code,:PState,:CYType,:Stats ');
|
|||
|
|
Parameters.ParamByName('Code').Value:='';
|
|||
|
|
Parameters.ParamByName('PState').Value:=0;
|
|||
|
|
Parameters.ParamByName('CYType').Value:=Trim(Order_Tree.fieldbyname('CPID').AsString);
|
|||
|
|
Parameters.ParamByName('Stats').Value:='';
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOQueryMain,ClientDataSet1);
|
|||
|
|
SInitCDSData20(ADOQueryMain,ClientDataSet1);
|
|||
|
|
finally
|
|||
|
|
ADOQueryMain.EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.TBAddClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
i:Integer;
|
|||
|
|
begin
|
|||
|
|
if Order_Tree.FieldByName('CPLevel').AsInteger<2 then
|
|||
|
|
begin
|
|||
|
|
Panel5.Visible:=False;
|
|||
|
|
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
Panel5.Visible:=True;
|
|||
|
|
SClearData(Panel5,2);
|
|||
|
|
BPName.Text:='<27><>';//trim(FCPName);
|
|||
|
|
FBPID:='';
|
|||
|
|
Button1.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.TBSaveClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
maxno:string;
|
|||
|
|
begin
|
|||
|
|
if ClientDataSet1.IsEmpty then Exit;
|
|||
|
|
Toolbar1.SetFocus;
|
|||
|
|
if ClientDataSet1.Locate('BPCode',null,[]) then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if ClientDataSet1.Locate('BPCode','',[]) then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if ClientDataSet1.Locate('BPName',null,[]) then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if ClientDataSet1.Locate('BPName','',[]) then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
SaveData();
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.TBDelClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
panel1.SetFocus;
|
|||
|
|
if ClientDataSet1.IsEmpty then Exit;
|
|||
|
|
if Trim(ClientDataSet1.FieldByName('BPID').AsString)<>'' then
|
|||
|
|
begin
|
|||
|
|
if application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD>?','<27><>ʾ<EFBFBD><CABE>Ϣ',1)=2 then exit;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('delete X_ZDY where BPID='''+Trim(ClientDataSet1.fieldbyname('BPID').AsString)+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
ClientDataSet1.Delete;
|
|||
|
|
SClearData(Panel5,2);
|
|||
|
|
FBPID:='';
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
panel1.SetFocus;
|
|||
|
|
WriteCxGrid('<27>Զ<EFBFBD><D4B6><EFBFBD>'+Trim(flag)+'1YX1',TV1,'<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
Close;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
initTree();
|
|||
|
|
InitGrid();
|
|||
|
|
ReadCxGrid('<27>Զ<EFBFBD><D4B6><EFBFBD>'+Trim(flag)+'1YX1',TV1,'<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
frmBPZDY_LRX.Caption:=Trim(flagname);
|
|||
|
|
if ViewFlag=True then
|
|||
|
|
begin
|
|||
|
|
TBAdd.Visible:=False;
|
|||
|
|
TBDel.Visible:=False;
|
|||
|
|
ToolButton1.Visible:=true;
|
|||
|
|
end;
|
|||
|
|
if canshu1='<27><>ѯ' then
|
|||
|
|
begin
|
|||
|
|
ToolBar3.Visible:=False;
|
|||
|
|
ToolBar2.Visible:=false;
|
|||
|
|
Button1.Visible:=false;
|
|||
|
|
Panel4.Align:=alClient;
|
|||
|
|
V1BPNote.Visible:=False;
|
|||
|
|
V1BPPrice.Visible:=false;
|
|||
|
|
Label15.Visible:=false;
|
|||
|
|
BPPrice.Visible:=false;
|
|||
|
|
Label14.Visible:=false;
|
|||
|
|
BPNote.Visible:=false;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
ToolBar3.Visible:=true;
|
|||
|
|
ToolBar2.Visible:=true;
|
|||
|
|
Button1.Visible:=true;
|
|||
|
|
Panel4.Align:=alLeft;
|
|||
|
|
V1BPNote.Visible:=true;
|
|||
|
|
V1BPPrice.Visible:=true;
|
|||
|
|
Label15.Visible:=true;
|
|||
|
|
BPPrice.Visible:=true;
|
|||
|
|
Label14.Visible:=true;
|
|||
|
|
BPNote.Visible:=true;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.TV1CellDblClick(Sender: TcxCustomGridTableView;
|
|||
|
|
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
|||
|
|
AShift: TShiftState; var AHandled: Boolean);
|
|||
|
|
var i:integer;
|
|||
|
|
begin
|
|||
|
|
if ToolButton1.Visible=true then
|
|||
|
|
begin
|
|||
|
|
Fint:='1';
|
|||
|
|
ModalResult:=1;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
ToolBar1.SetFocus;
|
|||
|
|
if ClientDataSet1.IsEmpty then exit;
|
|||
|
|
BPColNO.Text:=Trim(ClientDataSet1.fieldbyname('BPColNO').AsString);
|
|||
|
|
BPColor.Text:=Trim(ClientDataSet1.fieldbyname('BPColor').AsString);
|
|||
|
|
BPPrice.Text:=Trim(ClientDataSet1.FieldByName('BPPrice').AsString);
|
|||
|
|
BPNote.Text:=Trim(ClientDataSet1.FieldByName('BPNote').AsString);
|
|||
|
|
BPName.Text:=Trim(ClientDataSet1.FieldByName('BPName').AsString);
|
|||
|
|
FBPID:=Trim(ClientDataSet1.fieldbyname('BPID').AsString);
|
|||
|
|
FCPID:=Trim(ClientDataSet1.fieldbyname('CPID').AsString);
|
|||
|
|
Panel5.Visible:=True;
|
|||
|
|
Button1.Caption:='<27>ı<DEB8><C4B1><EFBFBD>';
|
|||
|
|
TBDel.Visible:=True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.BPNamehange(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
fsj:String;
|
|||
|
|
begin
|
|||
|
|
if Trim(BPNameM.Text)<>'' then
|
|||
|
|
begin
|
|||
|
|
fsj:=' BPName like '''+'%'+Trim(BPNameM.Text)+'%'+'''';
|
|||
|
|
end;
|
|||
|
|
if ADOQueryMain.Active then
|
|||
|
|
begin
|
|||
|
|
SDofilter(ADOQueryMain,fsj);
|
|||
|
|
SCreateCDS20(ADOQueryMain,ClientDataSet1);
|
|||
|
|
SInitCDSData20(ADOQueryMain,ClientDataSet1);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.v1note1PropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
mvalue:string;
|
|||
|
|
begin
|
|||
|
|
mvalue:=TcxTextEdit(Sender).EditingText;
|
|||
|
|
with ClientDataSet1 do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('BPMiDu').Value:=mvalue;
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.V1BPCodePropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
mvalue:string;
|
|||
|
|
begin
|
|||
|
|
mvalue:=TcxTextEdit(Sender).EditingText;
|
|||
|
|
with ClientDataSet1 do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('BPCode').Value:=mvalue;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.V1BPNamePropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
mvalue:string;
|
|||
|
|
begin
|
|||
|
|
mvalue:=TcxTextEdit(Sender).EditingText;
|
|||
|
|
with ClientDataSet1 do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('BPName').Value:=mvalue;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.ToolButton4Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
ToolBar1.SetFocus;
|
|||
|
|
if ClientDataSet1.IsEmpty then exit;
|
|||
|
|
if ClientDataSet1.FieldByName('BPID').AsString='' then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27>뱣<EFBFBD><EBB1A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ','<27><>ʾ');
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
with ML_GYS do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.BPCodeMChange(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
fsj:String;
|
|||
|
|
begin
|
|||
|
|
if Trim(BPCodeM.Text)<>'' then
|
|||
|
|
begin
|
|||
|
|
fsj:=' BPCode like '''+'%'+Trim(BPCodeM.Text)+'%'+'''';
|
|||
|
|
end;
|
|||
|
|
if ADOQueryMain.Active then
|
|||
|
|
begin
|
|||
|
|
SDofilter(ADOQueryMain,fsj);
|
|||
|
|
SCreateCDS20(ADOQueryMain,ClientDataSet1);
|
|||
|
|
SInitCDSData20(ADOQueryMain,ClientDataSet1);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.Tv3CellDblClick(Sender: TcxCustomGridTableView;
|
|||
|
|
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
|||
|
|
AShift: TShiftState; var AHandled: Boolean);
|
|||
|
|
var i:Integer;
|
|||
|
|
begin
|
|||
|
|
if ML_GX.IsEmpty then exit;
|
|||
|
|
ML_GX.Delete;
|
|||
|
|
i:=1;
|
|||
|
|
ML_GX.DisableControls;
|
|||
|
|
with ML_GX do
|
|||
|
|
begin
|
|||
|
|
first;
|
|||
|
|
while not eof do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('BPMiDu').Value:=i;
|
|||
|
|
i:=i+1;
|
|||
|
|
next;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
ML_GX.EnableControls;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.Button1Click(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
maxno,FCPMiDu,FDXNO:string;
|
|||
|
|
FInt:Integer;
|
|||
|
|
FReal:Double;
|
|||
|
|
begin
|
|||
|
|
if Button1.Caption='<27>ı<DEB8><C4B1><EFBFBD>' then
|
|||
|
|
begin
|
|||
|
|
if Application.MessageBox('ȷ<><C8B7>Ҫ<EFBFBD>ı<DEB8><C4B1><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',1)=2 then exit;
|
|||
|
|
end;
|
|||
|
|
{if Button1.Caption='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
|||
|
|
begin
|
|||
|
|
if Label16.Caption='' then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ');
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
end;}
|
|||
|
|
if Trim(BPPrice.Text)<>'' then
|
|||
|
|
begin
|
|||
|
|
if TryStrToFloat(BPPrice.Text,FReal)=False then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD>۷Ƿ<DBB7><C7B7><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
if Trim(Button1.Caption)<>'<27>ı<DEB8><C4B1><EFBFBD>' then
|
|||
|
|
begin
|
|||
|
|
if Order_Tree.FieldByName('CPLevel').AsInteger=1 then
|
|||
|
|
begin
|
|||
|
|
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ');
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
try
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
if FBPID='' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOQueryTemp,FBPID,'BP','X_ZDY',3,1)=False then
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if GetLSNo(ADOQueryTemp,FDXNO,'','X_ZDY',4,0)=False then
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from X_ZDY where BPID='''+Trim(FBPID)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryCmd.IsEmpty then
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Append;
|
|||
|
|
ADOQueryCmd.FieldByName('BPCode').Value:=trim(FDXNO);
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Edit;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.FieldByName('BPID').Value:=Trim(FBPID);
|
|||
|
|
RTSetsavedata(ADOQueryCmd,'X_ZDY',panel5,2);
|
|||
|
|
ADOQueryCmd.FieldByName('BPType').Value:=flagName;
|
|||
|
|
ADOQueryCmd.FieldByName('BPFlag').Value:=flag;
|
|||
|
|
ADOQueryCmd.FieldByName('valid').Value:='Y';
|
|||
|
|
ADOQueryCmd.FieldByName('CPID').Value:=trim(FCPID);
|
|||
|
|
if Trim(BPPrice.Text)<>'' then
|
|||
|
|
ADOQueryCmd.FieldByName('BPPrice').Value:=BPPrice.Text
|
|||
|
|
else
|
|||
|
|
ADOQueryCmd.FieldByName('BPPrice').Value:=Null;
|
|||
|
|
ADOQueryCmd.FieldByName('BPNote').Value:=Trim(BPNote.Text);
|
|||
|
|
ADOQueryCmd.FieldByName('BPName').Value:=trim(BPName.Text);
|
|||
|
|
ADOQueryCmd.Post;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.add('select * from X_ZDY where BPName='''+trim(BPName.Text)+'''');
|
|||
|
|
sql.add(' and isnull(BPColor,'''')='''+Trim(BPColor.Text)+'''');
|
|||
|
|
sql.add(' and isnull(BPColNo,'''')='''+Trim(BPColNo.Text)+'''');
|
|||
|
|
sql.Add(' and BPFlag='''+trim(flag)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.RecordCount>1 then
|
|||
|
|
begin
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><>Ϣ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
with ClientDataSet1 do
|
|||
|
|
begin
|
|||
|
|
if Button1.Caption<>'<27>ı<DEB8><C4B1><EFBFBD>' then
|
|||
|
|
Append
|
|||
|
|
else
|
|||
|
|
edit;
|
|||
|
|
FieldByName('BPID').Value:=Trim(FBPID);
|
|||
|
|
FieldByName('BPName').Value:=trim(BPName.Text);
|
|||
|
|
FieldByName('BPColor').Value:=Trim(BPColor.Text);
|
|||
|
|
FieldByName('BPColNo').Value:=Trim(BPColNo.Text);
|
|||
|
|
if Trim(BPPrice.Text)<>'' then
|
|||
|
|
FieldByName('BPPrice').Value:=BPPrice.Text
|
|||
|
|
else
|
|||
|
|
FieldByName('BPPrice').Value:=Null;
|
|||
|
|
FieldByName('BPNote').Value:=Trim(BPNote.Text);
|
|||
|
|
post;
|
|||
|
|
end;
|
|||
|
|
SClearData(Panel5,2);
|
|||
|
|
FBPID:='';
|
|||
|
|
Button1.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
|
Panel5.Visible:=false;
|
|||
|
|
TBDel.Visible:=False;
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
except;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
|
end;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>','<27><>ʾ');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.TPBLBClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
frmCPTypeX:=TfrmCPTypeX.Create(self);
|
|||
|
|
with frmCPTypeX do
|
|||
|
|
begin
|
|||
|
|
if ShowModal=1 then
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
free;
|
|||
|
|
end;
|
|||
|
|
initTree();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.ToolButton1Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
ToolBar1.SetFocus;
|
|||
|
|
Fint:='1';
|
|||
|
|
ModalResult:=1;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.Button1KeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
var maxno:string;
|
|||
|
|
begin
|
|||
|
|
if key=#13 then
|
|||
|
|
begin
|
|||
|
|
button1.Click;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.cxDBTreeList1Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
InitGrid();
|
|||
|
|
TBDel.Visible:=False;
|
|||
|
|
Panel5.Visible:=False;
|
|||
|
|
if Order_Tree.FieldByName('CPLevel').AsInteger<2 then
|
|||
|
|
begin
|
|||
|
|
TBAdd.Visible:=False;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
FBPID:='';
|
|||
|
|
FCPID:=Trim(Order_Tree.fieldbyname('CPID').AsString);
|
|||
|
|
FCPNo:=Trim(Order_Tree.fieldbyname('CPNo').AsString);
|
|||
|
|
FCPName:=Trim(Order_Tree.fieldbyname('CPName').AsString);
|
|||
|
|
TBAdd.Visible:=True;
|
|||
|
|
end;
|
|||
|
|
Label16.Caption:=Trim(Order_Tree.fieldbyname('CPNo').AsString);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.BPNameKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
begin
|
|||
|
|
if Key=#13 then
|
|||
|
|
begin
|
|||
|
|
BPColNo.SetFocus;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.FormDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
frmBPZDY_LRX:=nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.TV1FocusedRecordChanged(
|
|||
|
|
Sender: TcxCustomGridTableView; APrevFocusedRecord,
|
|||
|
|
AFocusedRecord: TcxCustomGridRecord;
|
|||
|
|
ANewItemRecordFocusingChanged: Boolean);
|
|||
|
|
begin
|
|||
|
|
Panel5.Visible:=False;
|
|||
|
|
TBAdd.Visible:=False;
|
|||
|
|
TBDel.Visible:=False;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.BPPriceKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
begin
|
|||
|
|
if Key=#13 then
|
|||
|
|
begin
|
|||
|
|
BPNote.SetFocus;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.BPNoteKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
begin
|
|||
|
|
if Key=#13 then
|
|||
|
|
begin
|
|||
|
|
Button1.SetFocus;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.BPColNoKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
begin
|
|||
|
|
if Key=#13 then
|
|||
|
|
begin
|
|||
|
|
BPColor.SetFocus;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmBPZDY_LRX.BPColorKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
begin
|
|||
|
|
if Key=#13 then
|
|||
|
|
begin
|
|||
|
|
BPPrice.SetFocus;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|