350 lines
7.9 KiB
ObjectPascal
350 lines
7.9 KiB
ObjectPascal
![]() |
unit U_GYSInPutTab;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|||
|
cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
|
|||
|
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
|
|||
|
cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer,
|
|||
|
cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB,
|
|||
|
ExtCtrls, BtnEdit, cxCalendar,StrUtils, cxDropDownEdit,jpeg,
|
|||
|
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP, cxPC,
|
|||
|
cxGridCustomPopupMenu, cxGridPopupMenu;
|
|||
|
|
|||
|
type
|
|||
|
TfrmGYSInPutTab = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBClose: TToolButton;
|
|||
|
ScrollBox1: TScrollBox;
|
|||
|
ADOTemp: TADOQuery;
|
|||
|
ADOCmd: TADOQuery;
|
|||
|
ADOQuery1: TADOQuery;
|
|||
|
TBSave: TToolButton;
|
|||
|
Panel3: TPanel;
|
|||
|
Label1: TLabel;
|
|||
|
Label7: TLabel;
|
|||
|
Label10: TLabel;
|
|||
|
Label11: TLabel;
|
|||
|
Label13: TLabel;
|
|||
|
Label33: TLabel;
|
|||
|
Label34: TLabel;
|
|||
|
KHName: TEdit;
|
|||
|
ZKAddress: TEdit;
|
|||
|
ZKTelNo: TEdit;
|
|||
|
ZKFax: TEdit;
|
|||
|
KHNameJC: TEdit;
|
|||
|
KHCode: TEdit;
|
|||
|
KHType: TBtnEditA;
|
|||
|
Label2: TLabel;
|
|||
|
TJKHName: TEdit;
|
|||
|
Label3: TLabel;
|
|||
|
LXR: TEdit;
|
|||
|
Label4: TLabel;
|
|||
|
LXRTel: TEdit;
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure SYRNameBtnUpClick(Sender: TObject);
|
|||
|
procedure SKBankBtnDnClick(Sender: TObject);
|
|||
|
procedure TBSaveClick(Sender: TObject);
|
|||
|
procedure KHTypeBtnClick(Sender: TObject);
|
|||
|
private
|
|||
|
procedure InitData();
|
|||
|
function SaveData():Boolean;
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
canshu1:String;
|
|||
|
PState,CopyInt:Integer;
|
|||
|
FMainId:String;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmGYSInPutTab: TfrmGYSInPutTab;
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_DataLink,U_ZDYHelp,U_RTFun,U_ZDYHelpSel;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmGYSInPutTab.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmGYSInPutTab.InitData();
|
|||
|
begin
|
|||
|
|
|||
|
with ADOQuery1 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from ZH_KH_Info where ZKId='''+Trim(FMainId)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCSHDataNew(ADOQuery1,Panel3,0);
|
|||
|
KHCode.SetFocus;
|
|||
|
{if Trim(FMainId)<>'' then
|
|||
|
begin
|
|||
|
with ADOTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select Top 1* from JYOrder_Main_MD_DuiZhang ');
|
|||
|
sql.Add(' where FactoryNo='''+Trim(FMainId)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOTemp.IsEmpty=False then
|
|||
|
begin
|
|||
|
KHCode.ReadOnly:=True;
|
|||
|
KHName.ReadOnly:=True;
|
|||
|
KHNameJC.ReadOnly:=True;
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
with ADOTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select Top 1* from YF_Money_PaiKuan ');
|
|||
|
sql.Add(' where FactoryNo='''+Trim(FMainId)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOTemp.IsEmpty=False then
|
|||
|
begin
|
|||
|
KHCode.ReadOnly:=True;
|
|||
|
KHName.ReadOnly:=True;
|
|||
|
KHNameJC.ReadOnly:=True;
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
with ADOTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select Top 1* from JYOrder_Main_MD ');
|
|||
|
sql.Add(' where FactoryNo='''+Trim(FMainId)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOTemp.IsEmpty=False then
|
|||
|
begin
|
|||
|
KHCode.ReadOnly:=True;
|
|||
|
KHName.ReadOnly:=True;
|
|||
|
KHNameJC.ReadOnly:=True;
|
|||
|
exit;
|
|||
|
end;
|
|||
|
with ADOTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select Top 1* from YF_Money_CR ');
|
|||
|
sql.Add(' where FactoryNo='''+Trim(FMainId)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOTemp.IsEmpty=False then
|
|||
|
begin
|
|||
|
KHCode.ReadOnly:=True;
|
|||
|
KHName.ReadOnly:=True;
|
|||
|
KHNameJC.ReadOnly:=True;
|
|||
|
end;
|
|||
|
end; }
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
procedure TfrmGYSInPutTab.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
InitData();
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmGYSInPutTab.SaveData():Boolean;
|
|||
|
var
|
|||
|
maxno:String;
|
|||
|
begin
|
|||
|
Result:=False;
|
|||
|
try
|
|||
|
ADOCmd.Connection.BeginTrans;
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if Trim(FMainId)='' then
|
|||
|
begin
|
|||
|
if GetLSNo(ADOCmd,maxno,'GS','ZH_KH_Info',3,1)=False then
|
|||
|
begin
|
|||
|
ADOCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end else
|
|||
|
begin
|
|||
|
maxno:=Trim(FMainId);
|
|||
|
end;
|
|||
|
with ADOCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
SQL.Add('select * from ZH_KH_Info where ZKId='''+Trim(FMainId)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
with ADOCmd do
|
|||
|
begin
|
|||
|
if Trim(FMainId)='' then
|
|||
|
begin
|
|||
|
Append;
|
|||
|
end
|
|||
|
else begin
|
|||
|
Edit;
|
|||
|
end;
|
|||
|
FieldByName('ZKId').Value:=Trim(maxno);
|
|||
|
if Trim(FMainId)='' then
|
|||
|
begin
|
|||
|
FieldByName('Filler').Value:=Trim(DName);
|
|||
|
end else
|
|||
|
begin
|
|||
|
FieldByName('Editer').Value:=Trim(DName);
|
|||
|
FieldByName('EditTime').Value:=SGetServerDateTime(ADOTemp);
|
|||
|
end;
|
|||
|
RTSetsavedata(ADOCmd,'ZH_KH_Info',Panel3,0);
|
|||
|
FieldByName('Valid').Value:='Y';
|
|||
|
FieldByName('Type').Value:='GYS';
|
|||
|
Post;
|
|||
|
end;
|
|||
|
if Trim(KHName.Text)<>'' then
|
|||
|
begin
|
|||
|
with ADOTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from ZH_KH_Info where KHName='''+Trim(KHName.Text)+'''');
|
|||
|
SQL.Add(' and Type=''GYS'' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOTemp.RecordCount>1 then
|
|||
|
begin
|
|||
|
ADOCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end;
|
|||
|
if Trim(KHCode.Text)<>'' then
|
|||
|
begin
|
|||
|
with ADOTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from ZH_KH_Info where KHCode='''+Trim(KHCode.Text)+'''');
|
|||
|
SQL.Add(' and Type=''GYS'' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOTemp.RecordCount>1 then
|
|||
|
begin
|
|||
|
ADOCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><>Ӧ<EFBFBD>̱<EFBFBD><CCB1><EFBFBD><EFBFBD>ظ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
if Trim(KHNameJC.Text)<>'' then
|
|||
|
begin
|
|||
|
with ADOTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from ZH_KH_Info where KHNameJC='''+Trim(KHNameJC.Text)+'''');
|
|||
|
SQL.Add(' and Type=''GYS'' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOTemp.RecordCount>1 then
|
|||
|
begin
|
|||
|
ADOCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><>Ӧ<EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD>ظ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end;
|
|||
|
ADOCmd.Connection.CommitTrans;
|
|||
|
FMainId:=Trim(maxno);
|
|||
|
Result:=True;
|
|||
|
except
|
|||
|
Result:=False;
|
|||
|
ADOCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmGYSInPutTab.SYRNameBtnUpClick(Sender: TObject);
|
|||
|
var
|
|||
|
fsj:string;
|
|||
|
FWZ:Integer;
|
|||
|
begin
|
|||
|
fsj:=Trim(TEdit(Sender).Hint);
|
|||
|
FWZ:=Pos('/',fsj);
|
|||
|
try
|
|||
|
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag:=Copy(fsj,1,FWZ-1);
|
|||
|
flagname:=Copy(fsj,FWZ+1,Length(fsj)-fwz);
|
|||
|
if ShowModal=1 then
|
|||
|
begin
|
|||
|
TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmGYSInPutTab.SKBankBtnDnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
TBtnEditC(Sender).Text:='';
|
|||
|
TBtnEditC(Sender).TxtCode:='';
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
procedure TfrmGYSInPutTab.TBSaveClick(Sender: TObject);
|
|||
|
begin
|
|||
|
ToolBar1.SetFocus;
|
|||
|
if Trim(KHName.Text)='' then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
if Trim(KHType.Text)='' then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
if Trim(KHCode.Text)='' then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><>Ӧ<EFBFBD>̱<EFBFBD><CCB1>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
if Trim(KHNameJC.Text)='' then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><>Ӧ<EFBFBD>̼<EFBFBD><CCBC>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
if SaveData() then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmGYSInPutTab.KHTypeBtnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
|||
|
with frmZDYHelp do
|
|||
|
begin
|
|||
|
flag:='KHType';
|
|||
|
flagname:='<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
if ShowModal=1 then
|
|||
|
begin
|
|||
|
Self.KHType.Text:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZDYHelp.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|