📄 unit_frmsaleticket.pas
字号:
sqlstr:='select max(gridrow) as rowcount1,max(gridcol) as colcount1'+
' from tblplanseat where plid='+inttostr(_plid);
if publicinfo.Execsql(sqlstr,false) then
begin
adodm.ADOQRY.First ;
_rowcount:=adodm.ADOQRY.fieldbyname('rowcount1').AsInteger ;
_colcount:=adodm.ADOQRY.fieldbyname('colcount1').AsInteger ;
DrawGrid1.RowCount :=_rowcount;
DrawGrid1.ColCount :=_colcount+1;
end;
sqlstr:='select * from tblplanseat_view where plid='+inttostr(_plid)+' order by gridrow,gridcol ';
seatlist.Clear ;
if publicinfo.Execsql(sqlstr,false) then
begin
with adodm.ADOQRY do
begin
first;
for i:=1 to recordcount do
begin
_rownum:=fieldbyname('rownum').AsInteger ;
_colnum:=fieldbyname('colnum').AsInteger ;
_gridrow:=fieldbyname('gridrow').AsInteger ;
_gridcol:=fieldbyname('gridcol').AsInteger ;
_seattype:=fieldbyname('seattype').AsInteger ;
_Seattypename:=fieldbyname('seatname').AsString ;
_color :=fieldbyname('color').AsInteger ;
_status:=fieldbyname('status').AsString ;
seatlist.Add(_gridrow,_gridcol,_rownum,_colnum,_color,_seattype,_seattypename,_status);
next;
end;
end;
end;
end;
procedure Tfrmsaleticket.ListView1Click(Sender: TObject);
var
selitem:TListItem;
sqlstr:string;
begin
inherited;
selitem:=listview1.Selected ;
if selitem=nil then exit;
plid:=PPlanNode(selitem.Data)^.id;
Refreshcombotickettype(plid);
RefreshPriceList(plid);
RefreshSeat(plid);
refreshgrid;
listview1.Visible :=false;
edtfield.Text :='场次:'+selitem.Caption +' 开始:'+selitem.SubItems[0]+' 结束:'+selitem.SubItems[1]+' 影片:'+selitem.SubItems[2] ;
Lblfilm.Caption :=edtfield.Text;
end;
procedure Tfrmsaleticket.DrawGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
prt:PSeatNode;
i:integer;
begin
inherited;
i:=seatlist.IndexOf_Seat(Arow+1,Acol+1);
if i<0 then exit;
CanSelect:=(prt^.status='0');
end;
procedure Tfrmsaleticket.DrawGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
prt:PSeatNode;
i:integer;
prtticket:PTicketNode;
_price:single;
begin
inherited;
MouseDown:=False;
if Button=mbRight then exit;
//if Shift<>[ssleft,ssCtrl] then exit;
DrawGrid1.MouseToCell(X,Y,CurGridCol,CurGridRow);
i:=seatlist.IndexOf_Seat(CurGridrow+1,CurGridCol);
if i<0 then exit;
prt:=seatlist.Items[i];
CurRow:=prt^.rownum ;
CurCol:=prt^.colnum ;
if prt^.status<>'0' then exit;
if ItemExist(prt^.rownum,prt^.colnum) then
begin
publicinfo.showmsg('此座位已经预选了');
exit;
end;
if Combotickettype.ItemIndex<0 then
begin
publicinfo.showmsg('请选择票类!');
Combotickettype.SetFocus ;
exit;
end;
new(prtticket);
prtticket^.fieldnum:=listview1.Selected.Caption;
prtticket^.rownum :=prt^.rownum ;
prtticket^.colnum :=prt^.colnum ;
prtticket^.seattype:=prt^.seattype;
prtticket^.seattypename:=prt^.seattypename;
prtticket^.tickettype :=integer(Combotickettype.Items.Objects[Combotickettype.ItemIndex]);
prtticket^.tickettypename :=Combotickettype.Text;
_price:=pricelist.IndexOf_price(prtticket^.tickettype,prtticket^.seattype);
if _price<0 then
begin
publicinfo.showmsg('此类座位不售此类票,请重新选择票类!');
Combotickettype.SetFocus ;
exit;
end;
prtticket^.price :=_price;
AddItem(prtticket);
end;
procedure Tfrmsaleticket.DrawGrid1MouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
prt:PSeatNode;
rect1:Trect;
i:integer;
txt:string;
prtticket:PTicketNode;
_price:single;
begin
{inherited;
if not MouseDown then exit;
try
i:=seatlist.IndexOf_Seat(Currow+1,CurCol+1);
if i<0 then exit;
prt:=seatlist.Items[i];
if Combotickettype.ItemIndex<0 then
begin
publicinfo.showmsg('请选择票类!');
exit;
end;
new(prtticket);
prtticket^.fieldnum:=listview1.Selected.Caption;
prtticket^.rownum :=prt^.rownum ;
prtticket^.colnum :=prt^.colnum ;
prtticket^.seattype:=prt^.seattype;
prtticket^.seattypename:=prt^.seattypename;
prtticket^.tickettype :=integer(Combotickettype.Items.Objects[Combotickettype.ItemIndex]);
prtticket^.tickettypename :=Combotickettype.Text;
_price:=pricelist.IndexOf_price(prtticket^.tickettype,prtticket^.seattype);
if _price<0 then
begin
publicinfo.showmsg('此类座位不售此类票,请重新选择票类!');
exit;
end;
prtticket^.price :=_price;
AddItem(prtticket);
{rect1:=DrawGrid1.CellRect(Curcol,Currow);
rect1.Left :=rect1.Left+5;
rect1.Top :=rect1.Top +5;
DrawGrid1.canvas.Brush.Color :=clwhite ;
DrawGrid1.canvas.Rectangle(rect1);
DrawGrid1.Canvas.Font.Size:=9;
DrawGrid1.Canvas.Font.Color:=clblack;
txt:=inttostr(prt^.rownum)+'排'+inttostr(prt^.colnum)+'号';
DrawGrid1.Canvas.TextOut(Rect1.Left+2 ,Rect1.Top+5,txt); }
{finally
MouseDown:=false;
end; }
end;
procedure Tfrmsaleticket.Timer1Timer(Sender: TObject);
begin
inherited;
Refreshstatus(plid);
RefreshGrid;
end;
procedure Tfrmsaleticket.RefreshGrid;
var
i,j,k:integer;
rect:Trect;
prt:PSeatNode;
txt:string;
tmpcolor:integer;
begin
for i:=0 to DrawGrid1.RowCount-1 do
for j:=0 to DrawGrid1.ColCount do
begin
rect:=DrawGrid1.CellRect(j,i);
if j=0 then
begin
with DrawGrid1 do
begin
Canvas.Brush.Color:=clBtnFace ;
canvas.Rectangle(rect);
Canvas.Font.Size:=10;
Canvas.Font.Style:=[fsBold];
Canvas.Font.Color:=clblack;
Canvas.TextOut(Rect.Left+2 ,Rect.Top+2,inttostr(i+1));
end;
Continue;
end;
k:=seatlist.IndexOf_Seat(i+1,j);
if k<0 then
begin
DrawGrid1.Canvas.Brush.Color:=clwhite ;
DrawGrid1.canvas.FillRect(rect);
Continue;
end;
prt:=seatlist.Items[k];
txt:=inttostr(prt^.colnum)+'号';
rect.Left :=rect.Left+3;
rect.Top :=rect.Top+3;
rect.Right :=rect.Right-3;
rect.Bottom :=rect.Bottom-3;
with DrawGrid1 do
begin
case strtoint(prt^.status) of
0:
tmpcolor:=prt^.color;
1:
tmpcolor:=selledcolor.Color ;
2:
tmpcolor:=bookcolor.Color;
4:
tmpcolor:=clwhite;
else
tmpcolor:=clblack;
end;
canvas.Brush.Color :=tmpcolor;//prt^.color ;
canvas.Rectangle(rect);
Canvas.Font.Size:=10;
Canvas.Font.Style:=[fsBold];
Canvas.Font.Color:=clblack;//tmpcolor;
Canvas.TextOut(Rect.Left+3 ,Rect.Top+1,txt);
{canvas.Brush.Color :=tmpcolor ;
rect.Left :=rect.left+15;
rect.top :=rect.top+1;
rect.Right:=rect.Right-1;
rect.Bottom :=rect.Bottom-15;
canvas.FillRect(rect); }
end;
end;
end;
procedure Tfrmsaleticket.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
seatlist.Free ;
pricelist.Free ;
end;
procedure Tfrmsaleticket.Refreshcombotickettype(_seattype: integer);
var
i,_id:integer;
sqlstr:string;
_name:string;
begin
Combotickettype.Clear ;
sqlstr:='select distinct tickettype,ticketname from tblplanticketprice_view where seattype='+inttostr(_seattype);
if publicinfo.Execsql(sqlstr,false) then
begin
with adodm.ADOQRY do
begin
if recordcount<=0 then exit;
first;
for i:=1 to recordcount do
begin
_id:=fieldbyname('tickettype').AsInteger ;
_name:=fieldbyname('ticketname').AsString ;
Combotickettype.Items.AddObject(_name,TObject(_ID));
next;
end;
Combotickettype.ItemIndex :=0;
TicketType:=integer(Combotickettype.Items.Objects[0]);
end;
end;
end;
procedure Tfrmsaleticket.RefreshPriceList(_plid: integer);
var
i:integer;
sqlstr:string;
_tickettype,_seattype:integer;
_price :single;
begin
pricelist.Clear ;
sqlstr:='select tickettype,seattype,price from tblplanticketprice where plid='+inttostr(_plid);
if publicinfo.Execsql(sqlstr,false) then
begin
with adodm.ADOQRY do
begin
if recordcount<=0 then exit;
first;
for i:=1 to recordcount do
begin
_seattype:=fieldbyname('seattype').AsInteger ;
_tickettype:=fieldbyname('tickettype').AsInteger ;
_price:=fieldbyname('price').AsFloat ;
pricelist.Add(_tickettype,_seattype,_price);
next;
end;
end;
end;
end;
procedure Tfrmsaleticket.AddItem(prt: PTicketNode);
var
Item0:TListItem;
begin
item0:=listview2.Items.Add ;
item0.Caption :=prt^.fieldnum;
item0.SubItems.Add(inttostr(prt^.rownum));
item0.SubItems.Add(inttostr(prt^.colnum));
item0.SubItems.Add (prt^.seattypename);
item0.SubItems.Add (prt^.tickettypename);
item0.SubItems.Add (format('%.2f',[prt^.price]));
item0.Data :=prt;
end;
procedure Tfrmsaleticket.DrawGrid1MouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
var
prt:PSeatNode;
i:integer;
_row,_col:integer;
_status:string;
begin
inherited;
//if shift<>[ssCtrl] then exit;
DrawGrid1.MouseToCell(X,Y,_col,_row);
i:=seatlist.IndexOf_Seat(_row+1,_col);
if i<0 then exit;
prt:=seatlist.Items[i];
CurRow:=prt^.rownum ;
CurCol:=prt^.colnum ;
seattype:=prt^.seattype ;
case strtoint(prt^.status) of
0:
_status:='可售';
1:
_status:='已售' ;
2:
_status:='预订';
end;
edtseat.Text :=inttostr(prt^.rownum)+'排'+inttostr(prt^.colnum)+'号'+' '+prt^.seattypename+' '+_status;
DrawGrid1.Hint :=inttostr(prt^.rownum)+'排'+inttostr(prt^.colnum)+'号'+prt^.seattypename;
end;
procedure Tfrmsaleticket.ListView2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
selitem:TListItem;
begin
inherited;
selitem:=listview2.Selected ;
if selitem=nil then exit;
if key=46 then selitem.Delete ;
end;
procedure Tfrmsaleticket.ToolButton3Click(Sender: TObject);
begin
{inherited;
with Adodm.ADOProc do
begin
Close;
ProcedureName := 'My_Update_plan';
Parameters.Refresh;
Parameters.Items[1].Value :=id;
Parameters.Items[2].Value :=cinemaid;
Parameters.Items[3].Value :=hallid;
Parameters.Items[4].Value :=datetostr(dtpplandate.Date) ;
Parameters.Items[5].Value :=strtoint(edtfieldnum.Text);
Parameters.Items[6].Value :=dtpstarttime.DateTime;
Parameters.Items[7].Value :=dtpendtime.DateTime;
Parameters.Items[8].Value :=filmid;
Parameters.Items[9].Value :=-1;
ExecProc;
if Parameters.ParamByName('@retcode').Value =1 then SavePrice;
end; }
end;
procedure Tfrmsaleticket.EdtfieldButtonClick(Sender: TObject);
var
i:integer;
sqlstr:string;
begin
inherited;
i:=Combohall.ItemIndex ;
if i<0 then exit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -