RTFormwork/项目代码/RTBasicsV1/A01基础公司管理/U_CustomerInput.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

278 lines
6.8 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_CustomerInput;
interface
uses
Windows, Messages, StrUtils, 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, BtnEdit, cxLookAndFeels, cxLookAndFeelPainters,
cxNavigator, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges,
dxBarBuiltInMenu, U_BaseList, cxContainer, dxCore, cxDateUtils, cxImage,
cxDBEdit, IdExplicitTLSClientServerBase, cxMemo, U_BaseInput, System.ImageList,
Vcl.ImgList;
type
TfrmCustomerInput = class(TfrmBaseInput)
ToolBar1: TToolBar;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ToolButton3: TToolButton;
ScrollBox1: TScrollBox;
Label2: TLabel;
Label6: TLabel;
Label39: TLabel;
CoName: TcxTextEdit;
CoCode: TcxTextEdit;
CoAddress: TcxTextEdit;
Label7: TLabel;
CoAbbrName: TcxTextEdit;
Label3: TLabel;
CoNote: TcxMemo;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure CoareaBtnDnClick(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
function SaveData(): Boolean;
public
fFlileFlag: string;
fkhType: string;
{ Public declarations }
FCOID: string;
end;
var
frmCustomerInput: TfrmCustomerInput;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp, getpic, U_YWYSel;
{$R *.dfm}
procedure TfrmCustomerInput.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
SQL.Clear;
sql.Add(' select * from BS_Company where CoType=''<27><>˾'' and COID=''' + Trim(FCOID) + '''');
Open;
end;
SCSHData(ADOQueryMain, ScrollBox1, 2);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmCustomerInput.FormDestroy(Sender: TObject);
begin
inherited;
frmCustomerInput := nil;
end;
procedure TfrmCustomerInput.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmCustomerInput.TBCloseClick(Sender: TObject);
begin
ModalResult := 1;
end;
procedure TfrmCustomerInput.FormShow(Sender: TObject);
begin
inherited;
InitGrid();
if CoCode.Text <> '' then
exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add(' exec P_BS_Com_Get_No @Str=''W'' ');
Open;
end;
CoCode.Text := trim(ADOQueryTemp.FieldByName('NewCoCode').asstring);
end;
procedure TfrmCustomerInput.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
function TfrmCustomerInput.SaveData(): Boolean;
var
MaxId, MaxSubId, FCoCode, FCCID, MaxCFID: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(FCOID) = '' then
begin
if GetLSNo(ADOQueryCmd, MaxId, 'CO', 'BS_Company', 4, 1) = False then
begin
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
if trim(CoCode.Text) = '' then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add(' exec P_BS_Com_Get_No @Str=''W'' ');
Open;
end;
CoCode.Text := trim(ADOQueryTemp.FieldByName('NewCoCode').asstring);
end;
end
else
begin
MaxId := Trim(FCOID);
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from BS_Company where COID=''' + Trim(FCOID) + '''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(FCOID) = '' then
begin
Append;
FieldByName('Filler').Value := Trim(DName);
end
else
begin
Edit;
FieldByName('Editer').Value := Trim(DName);
FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp);
end;
FieldByName('COID').Value := Trim(MaxId);
RTSetsavedata(ADOQueryCmd, 'BS_Company', ScrollBox1, 2);
FieldByName('CoType').Value := '<27><>˾';
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from BS_Company where CoCode=' + quotedstr(trim(CoCode.Text)));
Open;
end;
if ADOQueryCmd.RecordCount > 1 then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from BS_Company where CoName=' + quotedstr(trim(CoName.Text)));
sql.Add(' and CoType=''<27><>˾'' ');
Open;
end;
if ADOQueryCmd.RecordCount > 1 then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from BS_Company where CoAbbrName=' + quotedstr(trim(CoAbbrName.Text)));
sql.Add(' and CoType=''<27><>˾'' ');
Open;
end;
if ADOQueryCmd.RecordCount > 1 then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ////////////////////////
// with ADOQueryCmd do
// begin
// Close;
// sql.Clear;
// sql.Add('exec P_Com_Up_Code @COID=' + quotedstr(Trim(MaxId)));
// ExecSQL;
// end;
//////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ////////////////////////
ADOQueryCmd.Connection.CommitTrans;
FCCID := Trim(MaxSubId);
Result := True;
except
Result := false;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
end;
end;
procedure TfrmCustomerInput.ToolButton3Click(Sender: TObject);
begin
if Trim(CoAbbrName.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if Trim(CoName.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
end;
end;
procedure TfrmCustomerInput.CoareaBtnDnClick(Sender: TObject);
begin
TBtnEditC(Sender).Text := '';
TBtnEditC(Sender).TxtCode := '';
end;
end.