D7myYunxiang/云翔基础资料(BaseInfoYX.dll)/U_KHInPutMainNX.pas

375 lines
10 KiB
ObjectPascal
Raw Permalink Normal View History

2025-01-20 13:04:03 +08:00
unit U_KHInPutMainNX;
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, cxDropDownEdit, cxPC, BtnEdit;
type
TfrmKHInPutMainNX = class(TForm)
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
Panel2: TPanel;
KHNo: TEdit;
Label15: TLabel;
Label16: TLabel;
Label13: TLabel;
Label17: TLabel;
Label18: TLabel;
LabKHName: TLabel;
Label20: TLabel;
KHAdd: TMemo;
KHSJAdd: TMemo;
KHLXR: TEdit;
KHTel: TEdit;
KHName: TEdit;
KHNameJC: TEdit;
Note: TEdit;
Label1: TLabel;
KHWX: TEdit;
Label2: TLabel;
KHEmail: TEdit;
Label3: TLabel;
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
DS_HZ3: TDataSource;
CDS_HZ3: TClientDataSet;
LabKHType: TLabel;
KHType: TComboBox;
KHSHAdd: TMemo;
Label4: TLabel;
KHQuYu: TBtnEditC;
Label22: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure KHQuYuBtnUpClick(Sender: TObject);
procedure KHQuYuBtnDnClick(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
function SaveData(): Boolean;
procedure initBtnColor(panel12: TPanel);
public
{ Public declarations }
FKHMainid, FTSFlag, FKHFlag, FYWY, FLiDan: string;
end;
var
frmKHInPutMainNX: TfrmKHInPutMainNX;
implementation
uses
U_DataLink, U_Fun, U_ZDYHelp, U_FjList_RZ, U_SCPerson;
{$R *.dfm}
procedure TfrmKHInPutMainNX.InitGrid();
begin
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select * from KH_Main where KHMainID=''' + Trim(FKHMainid) + '''');
Open;
end;
//<2F><><EFBFBD><EFBFBD>
if ADOQueryTemp.IsEmpty = false then
SCSHDataNew(ADOQueryTemp, Panel2, 2);
end;
procedure TfrmKHInPutMainNX.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfrmKHInPutMainNX.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmKHInPutMainNX.FormShow(Sender: TObject);
begin
KHName.SetFocus;
InitGrid();
if TBSave.Visible = False then
begin
initBtnColor(Panel2);
end;
end;
procedure TfrmKHInPutMainNX.initBtnColor(panel12: TPanel);
var
i: Integer;
begin
with panel12 do
begin
for i := 0 to panel12.ControlCount - 1 do
begin
if Controls[i] is TEdit then
begin
TEdit(Controls[i]).Color := clMenu;
TEdit(Controls[i]).ReadOnly := True;
end
else if Controls[i] is TMemo then
begin
TMemo(Controls[i]).Color := clMenu;
TMemo(Controls[i]).ReadOnly := True;
end
else if Controls[i] is TComboBox then
begin
TComboBox(Controls[i]).Color := clMenu;
TComboBox(Controls[i]).Enabled := False;
end;
end;
end;
end;
function TfrmKHInPutMainNX.SaveData(): Boolean;
var
maxno, FGYSNO, maxnoYWY: string;
begin
result := false;
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(FKHMainid) = '' then
begin
if GetLSNo(ADOQueryCmd, maxno, 'KH', 'KH_Main', 4, 1) = False then
begin
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD>IDʧ<44><CAA7>GYSKH<4B><48>', '<27><>ʾ', 0);
Exit;
end;
if GetLSNo(ADOQueryCmd, FGYSNO, 'KH', 'KH_Main', 4, 0) = False then
begin
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
KHNo.Text := Trim(FGYSNO);
end
else
begin
maxno := Trim(FKHMainid);
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from KH_Main where KHMainID=''' + Trim(FKHMainid) + '''');
Open;
end;
with ADOQueryCmd do
begin
if IsEmpty then
begin
Append;
FieldByName('Filler').Value := Trim(DName);
FieldByName('Fillercode').Value := Trim(DCode);
FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp);
FieldByName('YWY').Value := Trim(FYWY);
FieldByName('LIDan').Value := Trim(FLiDan);
end
else
begin
Edit;
FieldByName('Editer').Value := Trim(DName);
FieldByName('EditerCode').Value := Trim(DCode);
FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp);
end;
FieldByName('KHMainID').Value := Trim(maxno);
FieldByName('KHFlag').Value := FKHFlag;
RTSetsavedata(ADOQueryCmd, 'KH_Main', Panel2, 2);
FieldByName('Valid').Value := 'Y';
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from KH_Main where KHName=''' + Trim(KHName.Text) + '''');
sql.Add(' and KHFlag=''' + Trim(FKHFlag) + ''' and Valid=''Y'' ');
Open;
end;
if ADOQueryCmd.RecordCount > 1 then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8AB><EFBFBD>ظ<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from KH_Main where KHNameJC=''' + Trim(KHNameJC.Text) + '''');
sql.Add(' and KHFlag=''' + Trim(FKHFlag) + ''' and Valid=''Y'' ');
Open;
end;
if ADOQueryCmd.RecordCount > 1 then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
if Trim(FKHMainid) = '' then
begin
if GetLSNo(ADOQueryCmd, maxnoYWY, 'ZD', 'KH_Owner', 3, 1) = False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('ȡָ<C8A1><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from KH_Owner where 1=2');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('KHMainId').Value := Trim(maxno);
FieldByName('KOID').Value := Trim(maxnoYWY);
FieldByName('UserName').Value := Trim(FYWY);
FieldByName('KOType').Value := <><D2B5>Ա';
FieldByName('FillerCode').Value := Trim(DCode);
FieldByName('Filler').Value := Trim(DName);
FieldByName('Valid').Value := 'Y';
Post;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('KHMainId').Value := Trim(maxno);
FieldByName('KOID').Value := Trim(maxnoYWY) + '-1';
FieldByName('UserName').Value := Trim(FLiDan);
FieldByName('KOType').Value := '<27><><EFBFBD><EFBFBD>Ա';
FieldByName('FillerCode').Value := Trim(DCode);
FieldByName('Filler').Value := Trim(DName);
FieldByName('Valid').Value := 'Y';
Post;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('KHMainId').Value := Trim(maxno);
FieldByName('KOID').Value := Trim(maxnoYWY) + '-2';
FieldByName('UserName').Value := Trim(FLiDan);
FieldByName('KOType').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('FillerCode').Value := Trim(DCode);
FieldByName('Filler').Value := Trim(DName);
FieldByName('Valid').Value := 'Y';
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update KH_Owner Set UserId=(select USERID from SY_User A where A.USERName=KH_Owner.UserName)');
sql.Add(' where KOID=''' + Trim(maxnoYWY) + '''');
sql.Add('Update KH_Owner Set UserId=(select USERID from SY_User A where A.USERName=KH_Owner.UserName)');
sql.Add(' where KOID=''' + Trim(Trim(maxnoYWY) + '-1') + '''');
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update KH_Main Set FZR=dbo.F_Get_HZStr(KH_Main.KHMainId,''FZR'')');
sql.Add(' where KHMainId=''' + Trim(maxno) + '''');
ExecSQL;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
FKHMainid := maxno;
result := true;
except
ADOQueryCmd.Connection.RollbackTrans;
Result := false;
Application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
end;
procedure TfrmKHInPutMainNX.TBSaveClick(Sender: TObject);
begin
Panel2.SetFocus;
if trim(KHName.Text) = '' then
begin
application.MessageBox(<>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
if Trim(KHNameJC.Text) = '' then
begin
application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
if Trim(KHType.Text) = '' then
begin
application.MessageBox('<27><><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
if Trim(KHLXR.Text) = '' then
begin
application.MessageBox('<27><>ϵ<EFBFBD>˲<EFBFBD><CBB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
if Trim(KHTel.Text) = '' then
begin
application.MessageBox('<27>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
ModalResult := 1;
end;
end;
procedure TfrmKHInPutMainNX.KHQuYuBtnUpClick(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'KHQuYuNX';
flagname := '<27><><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
KHQuYu.Text := Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmKHInPutMainNX.KHQuYuBtnDnClick(Sender: TObject);
begin
KHQuYu.Text := '';
end;
end.