RTFormwork/项目代码/RTBasicsV1/T01贸易生产计划/U_LabelInput.pas

191 lines
4.5 KiB
ObjectPascal
Raw Normal View History

2024-07-07 09:35:27 +08:00
unit U_LabelInput;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, ExtCtrls, DB, ADODB, RM_System,
RM_Common, RM_Class, RM_GridReport, Buttons, RTComboBox, RM_Preview, RM_e_Xls,
RM_e_Graphic, RM_e_bmp, RM_BarCode, RM_DsgGridReport, RM_Dataset, cxStyles,
cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData,
cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxClasses, cxControls, cxGridCustomView, cxGrid;
type
TfrmLabelInput = class(TForm)
Panel1: TPanel;
Label3: TLabel;
note: TMemo;
ToolBar1: TToolBar;
Tsave: TToolButton;
Tclose: TToolButton;
ADOQueryCmd: TADOQuery;
Label9: TLabel;
LabelCaption: TEdit;
Label10: TLabel;
ADOQueryTmp: TADOQuery;
LabelType: TComboBox;
procedure TcloseClick(Sender: TObject);
procedure TsaveClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
function SaveData(): Boolean;
procedure InitWinData();
procedure IintLabelType();
public
FLabelId: string;
end;
var
frmLabelInput: TfrmLabelInput;
implementation
uses
U_DataLink, U_RTFun;
{$R *.dfm}
procedure TfrmLabelInput.IintLabelType();
var
mSql: string;
begin
mSql := 'select Name=ZDYName from KH_ZDY where Type=''BQLX'' ';
SInitComBoxBySql(ADOQueryTmp, LabelType, true, mSql);
end;
procedure TfrmLabelInput.TcloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmLabelInput.TsaveClick(Sender: TObject);
begin
if trim(labelCaption.Text) = '' then
begin
application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ');
labelCaption.SetFocus;
exit;
end;
if trim(LabelCaption.Text) = '' then
begin
application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ');
exit;
end;
if SaveData() then
begin
ModalResult := 1;
end;
end;
/////////////////////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/////////////////////////////////////////////////////////////////////
function TfrmLabelInput.SaveData(): Boolean;
var
maxno: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(FLabelId) = '' then
begin
if GetLSNo(ADOQueryCmd, maxno, 'LB', 'Trade_Label', 3, 1) = False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
end
else
begin
maxno := Trim(FLabelId);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.Add('select * from Trade_Label where LabelId=''' + Trim(FLabelId) + '''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(FLabelId) = '' then
begin
Append;
FieldByName('FillId').Value := Trim(DCode);
FieldByName('Filler').Value := Trim(DName);
FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTmp);
FieldByName('EditId').Value := Trim(DCode);
FieldByName('Editer').Value := Trim(DName);
FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTmp);
end
else
begin
Edit;
FieldByName('EditId').Value := Trim(DCode);
FieldByName('Editer').Value := Trim(DName);
FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTmp);
end;
RTSetsavedata(ADOQueryCmd, 'Trade_Label', Panel1, 1);
FieldByName('LabelId').Value := Trim(maxno);
Post;
end;
with ADOQueryTmp do
begin
Close;
sql.Clear;
sql.Add('select * from Trade_Label where LabelCaption=''' + Trim(LabelCaption.text) + '''');
Open;
end;
if ADOQueryTmp.RecordCount > 1 then
begin
ADOQueryCmd.Connection.RollbackTrans;
Result := False;
Application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
ADOQueryCmd.Connection.CommitTrans;
FLabelId := maxno;
result := true;
except
ADOQueryCmd.Connection.RollbackTrans;
Result := false;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩģ<C7A9><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ', 0);
end;
end;
////////////////////////////////////////////////////////////
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
////////////////////////////////////////////////////////////
procedure TfrmLabelInput.InitWinData();
begin
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select A.*');
sql.Add('from Trade_Label A');
sql.Add('WHERE LabelId=' + QuotedStr(FLabelId));
Open;
SCSHData(ADOQueryTmp, panel1, 1);
end;
end;
procedure TfrmLabelInput.FormShow(Sender: TObject);
begin
IintLabelType();
InitWinData();
end;
end.