📄 pensonallqfrm.pas
字号:
unit PensonalLQFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BaseFrm, StdCtrls, ExtCtrls;
type
TFrmPersonalLQ = class(TFormBase)
Panel1: TPanel;
GroupBox1: TGroupBox;
Label4: TLabel;
Label2: TLabel;
Label1: TLabel;
Label5: TLabel;
Label3: TLabel;
EdtStartTicketNo: TEdit;
EdtLQName: TEdit;
EdtLQDate: TEdit;
EdtCount: TEdit;
BtnLQ: TButton;
cbArea: TComboBox;
lblStoreCount: TLabel;
procedure FormCreate(Sender: TObject);
procedure cbAreaChange(Sender: TObject);
procedure BtnLQClick(Sender: TObject);
procedure EdtCountKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
function GetPrintCode: string;
function GetExistInvalidTicketCount: Integer;
procedure WriteDisTicketHistory(AStartTicketNo: string; ATicketCount: Integer);
function isExistPrintCode(APrintCode: string): Boolean;
procedure UpdateStoreCountCaption(AStorCount: Integer);
public
{ Public declarations }
procedure SetPensonalFormActive;
end;
var
FrmPersonalLQ: TFrmPersonalLQ;
implementation
uses SystemDM, IniOptions, CommonFuncLib, LQTicketHintFrm, systemPH;
{$R *.dfm}
procedure TFrmPersonalLQ.FormCreate(Sender: TObject);
begin
inherited;
cbArea.ItemIndex := 0;
end;
function TFrmPersonalLQ.GetPrintCode: string;
var
sSqlStr: string;
begin
Result := '';
sSqlStr := 'SELECT TOP 1 PRINTCODE FROM TICKET_NUMBER WHERE ISUSED = 0' +
' AND USERAREA = ' + IntToStr(cbArea.ItemIndex) + 'ORDER BY PRINTCODE';
if DMSystem.SQL_Querys(DMSystem.Qry_Temp, sSqlStr)then
Result := DMSystem.Qry_Temp.FieldByName('PRINTCODE').AsString;
end;
procedure TFrmPersonalLQ.cbAreaChange(Sender: TObject);
begin
inherited;
EdtStartTicketNo.Text := GetPrintCode;
end;
procedure TFrmPersonalLQ.SetPensonalFormActive;
begin
Self.BringToFront;
cbAreaChange(nil);
EdtLQDate.Text := FormatDateTime('YYYY-MM-DD hh:nn:ss', Now);
UpdateStoreCountCaption(GlobalStoreCount);
end;
procedure TFrmPersonalLQ.BtnLQClick(Sender: TObject);
var
sSqlStr: string;
nDisTicket, I, CurDisTicketCount: Integer;
PrintTicketNo, CurStartTicketNo: Double;
bNoTicket: Boolean;
LQTickerList: TStrings;
begin
inherited;
CurDisTicketCount := 0;
if not DMSystem.isConnectionDB then Exit;
if StrToIntDef(EdtCount.Text, 0) = 0 then
begin
ShowMessage('领取的票数不能为零!');
Exit;
end;
if (GetExistInvalidTicketCount - GLOBALYLTICKETCOUNT) < StrToIntDef(EdtCount.Text, 0) then
begin
ShowMessage('票号不足,不能进行领取!');
Exit;
end;
try
LQTickerList := TStringList.Create;
LQTickerList.Add('领取人姓名:' + EdtLQName.Text);
nDisTicket := StrToIntDef(EdtCount.Text, 0);
PrintTicketNo := StrToFloatDef(Trim(EdtStartTicketNo.Text), 0);
CurStartTicketNo := PrintTicketNo;
SendMessage(Application.MainForm.Handle, WM_STATUS_MSG, DEF_START_UPDATE, nDisTicket + 1);
for I := 0 to nDisTicket-1 do
try
Inc(CurDisTicketCount);
if isExistPrintCode(FloatToStr(PrintTicketNo)) then
begin
sSqlStr := 'UPDATE TICKET_NUMBER SET ISUSED = 1 WHERE PRINTCODE = ' + #39 + FloatToStr(PrintTicketNo) + #39;
DMSystem.SQL_Exec(DMSystem.Qry_Temp, sSqlStr);
PrintTicketNo := 1 + PrintTicketNo;
end
else
begin //跳号
sSqlStr := 'SELECT TOP 1 PRINTCODE FROM TICKET_NUMBER WHERE ISUSED = 0' +
' AND USERAREA = ' + IntToStr(cbArea.ItemIndex) + ' ORDER BY PRINTCODE';
if DMSystem.SQL_Querys(DMSystem.Qry_Temp, sSqlStr) then
begin
LQTickerList.Add(Format(DEF_LQTICKETHINT, [FloatToStr(CurStartTicketNo), FloatToStr(PrintTicketNo-1), IntToStr(CurDisTicketCount-1)]));
PrintTicketNo := StrToFloatDef(DMSystem.Qry_Temp.FieldByName('PRINTCODE').AsString, 0);
WriteDisTicketHistory(FloatToStr(CurStartTicketNo), CurDisTicketCount-1);
CurStartTicketNo := PrintTicketNo;
CurDisTicketCount := 1;
sSqlStr := 'UPDATE TICKET_NUMBER SET ISUSED = 1 WHERE PRINTCODE = ' + #39 + FloatToStr(PrintTicketNo) + #39;
if not DMSystem.SQL_Exec(DMSystem.Qry_Temp, sSqlStr) then Exit;
PrintTicketNo := 1 + PrintTicketNo;
end;
end;
SendMessage(Application.MainForm.Handle, WM_STATUS_MSG, DEF_PLAYING_UPDATE, I);
Application.ProcessMessages;
except
DMSystem.Qry_Temp.SQL.SaveToFile('UPDATE_TICKET_NUMBER_SQL.TXT');
end;
LQTickerList.Add(Format(DEF_LQTICKETHINT, [FloatToStr(CurStartTicketNo), FloatToStr(PrintTicketNo-1), IntToStr(CurDisTicketCount)]));
LQTickerList.Add('总共领取票数:' + EdtCount.Text);
WriteDisTicketHistory(FloatToStr(CurStartTicketNo), CurDisTicketCount);
finally
SendMessage(Application.MainForm.Handle, WM_STATUS_MSG, DEF_FINISHED_UPDATE, 0);
TFrmLQTicketHint.ShowLQTicketHintForm(LQTickerList);
LQTickerList.Free;
EdtCount.Text := '0';
EdtStartTicketNo.Text := GetPrintCode;
EdtLQName.Text := '';
EdtLQDate.Text := FormatDateTime('YYYY-MM-DD hh:nn:ss', Now);
GlobalStoreCount := GlobalStoreCount - nDisTicket;
UpdateStoreCountCaption(GlobalStoreCount);
end;
end;
procedure TFrmPersonalLQ.EdtCountKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if not (key in ['0'..'9', #8]) then Key := #0;
end;
function TFrmPersonalLQ.GetExistInvalidTicketCount: Integer;
var
sSqlStr: string;
begin
Result := 0;
sSqlStr := 'SELECT COUNT(ID) AS TOTALTICKETCOUNT FROM TICKET_NUMBER WHERE ISUSED = 0' +
' AND USERAREA = ' + IntToStr(cbArea.ItemIndex);
if DMSystem.SQL_Querys(DMSystem.Qry_Temp, sSqlStr) then
Result := DMSystem.Qry_Temp.FieldByName('TOTALTICKETCOUNT').AsInteger;
end;
function TFrmPersonalLQ.isExistPrintCode(APrintCode: string): Boolean;
var
sSqlStr: string;
begin
sSqlStr := 'SELECT PRINTCODE FROM TICKET_NUMBER WHERE ISUSED = 0 AND PRINTCODE = ' + #39 + APrintCode + #39;
Result := DMSystem.SQL_Querys(DMSystem.Qry_Temp, sSqlStr);
end;
procedure TFrmPersonalLQ.WriteDisTicketHistory(AStartTicketNo: string;
ATicketCount: Integer);
var
sSqlStr: string;
begin
sSqlStr := 'INSERT INTO TICKET_NUMBER_HISTORY(AGENTID, LQName, STARTPRINTCODE, TICKETCOUNT, OPERATEDATE, USERAREA)' +
'VALUES(' + IntToStr(PERSONALID) + ','
+ #39 + Trim(EdtLQName.Text) + #39 + ','
+ #39 + AStartTicketNo + #39 + ','
+ IntToStr(ATicketCount) + ','
+ #39 + FormatDateTime('YYYY-MM-DD hh:nn:ss', Now) + #39 + ','
+ IntToStr(cbArea.ItemIndex) + ')';
if not DMSystem.SQL_Exec(DMSystem.Qry_Temp, sSqlStr) then
DMSystem.Qry_Temp.SQL.SaveToFile('TICKET_NUMBER_HISTORY_SQL.TXT');
end;
procedure TFrmPersonalLQ.UpdateStoreCountCaption(AStorCount: Integer);
begin
lblStoreCount.AutoSize := True;
lblStoreCount.Caption := '(目前库存票数:' + IntToStr(AStorCount) + '张)';
lblStoreCount.AutoSize := False;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -