📄 unit_frontcheck.pas
字号:
unit Unit_FrontCheck;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, ExtCtrls, StdCtrls, ComCtrls, Buttons,DateUtils;
type
Tfrm_frontcheck = class(TForm)
Panel1: TPanel;
sg_CostList: TStringGrid;
Splitter1: TSplitter;
Panel2: TPanel;
GroupBox1: TGroupBox;
s: TGroupBox;
PageControl1: TPageControl;
sht_Item: TTabSheet;
TabSheet2: TTabSheet;
Label5: TLabel;
edt_CusNo: TEdit;
sbtn_Sure: TSpeedButton;
SpeedButton2: TSpeedButton;
sbtn_Other: TSpeedButton;
Label6: TLabel;
edt_CusName: TEdit;
Label7: TLabel;
edt_CusType: TEdit;
Label8: TLabel;
edt_Curcurrency: TEdit;
Label9: TLabel;
edt_TotalCost: TEdit;
Label10: TLabel;
edt_CostScore: TEdit;
sg_Item: TStringGrid;
Panel4: TPanel;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
sg_Meal: TStringGrid;
Panel5: TPanel;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
Label11: TLabel;
edt_Discount: TEdit;
Label12: TLabel;
edt_CusNo1: TEdit;
RadioGroup1: TRadioGroup;
StatusBar1: TStatusBar;
Panel3: TPanel;
sbtn_Card: TSpeedButton;
SpeedButton9: TSpeedButton;
sbtn_Attend: TSpeedButton;
Label1: TLabel;
lbl_today: TLabel;
lbl_dayofweek: TLabel;
sbtn_print: TSpeedButton;
sbtn_addEmp1: TSpeedButton;
sbtn_addEmp2: TSpeedButton;
GroupBox4: TGroupBox;
Label13: TLabel;
Label15: TLabel;
sbtn_save: TSpeedButton;
Label18: TLabel;
edt_CostSum: TEdit;
edt_DiscountSum: TEdit;
pnlCard: TPanel;
Label17: TLabel;
Label4: TLabel;
Label2: TLabel;
Label3: TLabel;
edt_CardMoney: TEdit;
edt_LatestMoney: TEdit;
edt_Password: TEdit;
edt_CostMoney: TEdit;
pnlCash: TPanel;
Label14: TLabel;
Label16: TLabel;
edt_Payment: TEdit;
edt_change: TEdit;
Label19: TLabel;
edt_EmpNo: TEdit;
edt_CardNo: TEdit;
procedure sbtn_SureClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure edt_CusNoKeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
procedure sbtn_saveClick(Sender: TObject);
procedure edt_PaymentExit(Sender: TObject);
procedure edt_PaymentKeyPress(Sender: TObject; var Key: Char);
procedure edt_changeKeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton9Click(Sender: TObject);
procedure sbtn_addEmp1Click(Sender: TObject);
procedure sbtn_addEmp2Click(Sender: TObject);
procedure sbtn_OtherClick(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure sbtn_CardClick(Sender: TObject);
procedure sbtn_AttendClick(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure sbtn_printClick(Sender: TObject);
private
{ Private declarations }
procedure RefreshCustomerCost;
procedure ClearCustomerCost;
procedure SearchCustomerCost;
public
{ Public declarations }
procedure frontcheck_ref;
procedure ComputeCostsum;
end;
var
frm_frontcheck: Tfrm_frontcheck;
implementation
uses unit_DataModule,unit_TotalPublic,PublicFunOrPro;
{$R *.dfm}
{***********************************************}
procedure Tfrm_frontcheck.frontcheck_ref ;
begin
pagecontrol1.ActivePage := sht_Item;
edt_Empno.Text := SysUserId;
with sg_Item do
begin
cells[0,0]:='项目编号';
cells[1,0]:='项目名称';
cells[2,0]:='项目价格';
cells[3,0]:='服务员工';
end;
with sg_Meal do
begin
cells[0,0]:='套餐编号';
cells[1,0]:='套餐名称';
cells[2,0]:='套餐价格';
cells[3,0]:='服务员工';
end;
with sg_CostList do
begin
cells[0,0]:='消费编号';
cells[1,0]:='顾客编号';
cells[2,0]:='顾客姓名';
cells[3,0]:='消费总计';
cells[4,0]:='打折合计';
cells[5,0]:='总计共收';
cells[6,0]:='应该找零';
cells[7,0]:='结算方式';
end;
lbl_today.Caption := DateToStr(Date);
case DayOfTheWeek(Date) of
1: lbl_dayofweek.Caption :='星期一';
2: lbl_dayofweek.Caption :='星期二';
3: lbl_dayofweek.Caption :='星期三';
4: lbl_dayofweek.Caption :='星期四';
5: lbl_dayofweek.Caption :='星期五';
6: lbl_dayofweek.Caption :='星期六';
7: lbl_dayofweek.Caption :='星期天';
end;
SearchCustomerCost;
RefreshCustomerCost;
sbtn_save.Enabled := GetPower(SysUserId,'前台收营','修改权');
sbtn_print.Enabled := GetPower(SysUserId,'前台收营','打印权');
sbtn_card.Enabled := GetPower(SysUserId,'顾客卡管理','浏览权');
sbtn_Attend.Enabled:= GetPower(SysUserId,'正常考勤','浏览权');
end;
procedure Tfrm_frontcheck.ComputeCostsum ;
var
i:integer;
costsum:double;
begin
if edt_Discount.text='' then
begin
MessageBox(handle,'无法获取客户信息,请先输入客户编号或者点击[散客消费]','提示',mb_ok+mb_iconinformation);
StringGridClear(sg_Item);
StringGridClear(sg_Meal);
sbtn_addEmp1.Enabled :=false;
sbtn_addEmp2.Enabled :=false;
exit;
end;
costsum:=0.0;
for i:=1 to sg_Item.RowCount-2 do
begin
costsum:=costsum+ StrToFloat(sg_Item.cells[2,i])
end;
for i:=1 to sg_Meal.RowCount-2 do
begin
costsum:=costsum+ StrToFloat(sg_Meal.Cells[2,i]);
end;
edt_CostSum.Text := FloatToStr(costsum);
edt_DiscountSum.Text := FloatToStr( StrToFloat(edt_Discount.Text) * costsum * 0.01 );
end;
procedure Tfrm_frontcheck.RefreshCustomerCost ;
var
i,totalconsumer,member,notmember:integer;
totalsum:double;
begin
totalconsumer:=sg_CostList.RowCount-2;
member:=0;
notmember:=0;
totalsum:=0.0;
for i:=1 to sg_CostList.RowCount-2 do
begin
if sg_CostList.cells[0,i]<>'散客' then
member:=member+1
else
notmember:=notmember+1;
totalsum:=totalsum+StrToFloat(sg_CostList.cells[4,i]);
end;
StatusBar1.Panels[0].Text :='消费总人数:'+IntToStr(totalconsumer);
StatusBar1.Panels[1].Text :='会员人数:'+IntToStr(member);
StatusBar1.Panels[2].Text :='散客人数:'+IntToStr(notmember);
StatusBar1.Panels[3].Text :='营业总额:'+FloatToStr(totalsum);
end;
procedure Tfrm_frontcheck.ClearCustomerCost ;
begin
edt_CusNo1.Text :='';
edt_CardNo.Text :='';
edt_CusName.Text :='';
edt_CusType.Text :='';
edt_Discount.Text :='';
edt_Curcurrency.Text :='';
edt_TotalCost.Text :='';
edt_CostScore.Text :='';
StringGridClear(sg_Item);
StringGridClear(sg_Meal);
edt_CostSum.Text :='';
edt_DiscountSum.Text :='';
edt_Payment.Text :='';
edt_Change.Text :='';
edt_CostMoney.Text :='';
edt_LatestMoney.Text :='';
edt_Password.Text :='';
edt_CardMoney.Text :='';
edt_CusNo.SetFocus ;
end;
procedure Tfrm_frontcheck.SearchCustomerCost;
var
i:integer;
begin
with dmod.qrydata do
begin
Close;
SQL.Text :='select cost_no,cc.cus_no,cus_name,cost_sum,discount_sum,payment,change,check_type from CustomerCost cc,Customer c '+
'where cc.cus_no=c.cus_no and cc.cost_date='+#39+DateToString(Date)+#39;
Open;
i:=1;
while not eof do
begin
with sg_CostList do
begin
cells[0,i]:=FieldByName('cost_no').AsString ;
cells[1,i]:=FieldByName('cus_no').AsString;
cells[2,i]:=FieldByName('cus_name').AsString;
cells[3,i]:=FloatToStr(FieldByName('cost_sum').AsFloat);
cells[4,i]:=FloatToStr(FieldByName('discount_sum').AsFloat);
cells[5,i]:=FloatToStr(FieldByName('payment').AsFloat);
cells[6,i]:=FloatToStr(FieldByName('change').AsFloat);
if FieldByName('check_type').AsString='0' then
cells[7,i]:='现金结算'
else
cells[7,i]:='顾客卡结算';
end;
inc(i);
next;
end;
end;
if i<>1 then sg_CostList.RowCount :=i+1;
end;
{***********************************************}
procedure Tfrm_frontcheck.sbtn_SureClick(Sender: TObject);
begin
if trim(edt_CusNo.Text )='' then
begin
MessageBox(handle,'请客户编号不能为空,请重试!','提示',mb_ok+mb_iconinformation);
exit;
end;
with dmod.qrydata do
begin
Close;
SQL.Text :='select cus_name,card_no,type_name,discount,cur_currency,total_cost,cost_score '+
' from customer c,customercard cc,membercardtype mct where c.cus_no=cc.cus_no'+
' and cc.card_type=mct.type_id and c.cus_no='+#39+trim(edt_CusNo.Text)+#39;
Open;
if not eof then
begin
edt_CusNo1.Text :=trim(edt_CusNo.Text );
edt_CardNo.Text :=FieldByName('card_no').AsString ;
edt_CusName.Text :=FieldByName('cus_name').AsString ;
edt_CusType.Text :=FieldByname('type_name').AsString ;
edt_Discount.Text:=FloatToStr(FieldByName('discount').AsFloat) ;
edt_Curcurrency.Text :=FloatToStr(FieldByName('cur_currency').AsFloat) ;
edt_TotalCost.Text :=FloatToStr(FieldByName('total_cost').AsFloat) ;
edt_CostScore.Text :=FloatToStr(FieldByName('cost_score').AsFloat) ;
edt_CusNo.Text :='';
end else
begin
MessageBox(self.handle,'该客户编号不存在,请重试!','提示',mb_ok+mb_iconinformation);
edt_CusNo1.Text :='';
edt_CardNo.Text :='';
edt_CusName.Text :='';
edt_CusType.Text :='';
edt_Discount.Text :='';
edt_Curcurrency.Text :='';
edt_TotalCost.Text :='';
edt_CostScore.Text :='';
edt_CusNo.SetFocus ;
exit;
end;
end;
end;
procedure Tfrm_frontcheck.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
action:=cafree;
frm_frontcheck:=nil;
end;
procedure Tfrm_frontcheck.edt_CusNoKeyPress(Sender: TObject;
var Key: Char);
begin
if key=#13 then
sbtn_SureClick(nil);
end;
procedure Tfrm_frontcheck.SpeedButton4Click(Sender: TObject);
begin
DoServiceItem;
if sg_Item.RowCount >=2 then sbtn_addEmp1.Enabled :=true;
end;
procedure Tfrm_frontcheck.SpeedButton5Click(Sender: TObject);
begin
if sg_Item.Cells[0,sg_Item.Row ]='' then exit;
if (MessageBox(handle,'你确认删除该服务项目吗?','询问',mb_yesno+mb_iconinformation))<>IDYes then exit;
StringGridDelete(sg_Item,sg_Item.Row );
if sg_Item.RowCount <=2 then sbtn_addEmp1.Enabled :=false;
ComputeCostsum;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -