📄 ufpublish_chmnt.pas
字号:
end; //---1
end;
procedure TfPublish_ChMnt.dgrdBookCellClick(Column: TColumn);
begin
edtcnname.Text:=dmpublish.adsShare.Fieldbyname('cn_name').AsString;
edtprice.Text:=dmpublish.adsShare.fieldbyname('show_price').AsString;
edtinp.Text:=dmpublish.adsShare.fieldbyname('show_price').AsString;
edtmoney.Text:=dmpublish.adsShare.fieldbyname('show_price').AsString;
edtbarcode.Enabled:=false;
edtcnname.Enabled:=false;
edtprice.Enabled:=false;
cbxtype.SetFocus;
end;
procedure TfPublish_ChMnt.dedtCnnameKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_RETURN)
then SelectNext(ActiveControl, True, True);
end;
function TfPublish_ChMnt.check: Boolean;
begin
Result:=true;
if trim(edtBarcode.Text)='' then
result:=false;
if trim(edtCnName.Text)='' then
result:=false;
if trim(edtPrice.Text)='' then
result:=false;
if trim(cbxIsSale.Text)='' then
result:=false;
if trim(edtdis.Text)='' then
result:=false;
if trim(edtInp.Text)='' then
result:=false;
if trim(edtmoney.Text)='' then
result:=false;
if trim(cbxtype.Text)='' then
result:=false;
if strtofloat(trim(edtmoney.Text))=0 then
result:=false;
if trim(cbxtype.Text)=TypeMem then
begin
if (trim(cbxMName.Text)='') or (trim(cbxPinyin.Text)='') then
result:=false;
end
else
if trim(edtgetid.Text)='' then
result:=false;
end;
procedure TfPublish_ChMnt.SaveBtnClick(Sender: TObject);
var
i:integer;
txtid,s:string;
begin
if strtofloat(trim(edtdis.Text))>100.0 then
begin
MSG('折扣不能大于100%,请重新输入!','W');
edtdis.SelectAll;
edtdis.SetFocus;
exit;
end;
//检查输入记录是否完整
if check() then
begin
s:='';
//取数据库时间
with dmpublish.l_store do
begin
procedurename:='geddate;1';
parameters.Clear;
parameters.CreateParameter('@out',ftDatetime,pdoutput,0,Unassigned);
Prepared;
execproc;
if parameters[0].Value<>null then
begin
txtDate.Caption:=FormatDateTime('YYYY-MM-DD HH:MM:SS',parameters[0].Value);
CurrentDate:=FormatDateTime('YYYYMMDD',parameters[0].Value);
end
else
txtDate.Caption:=FormatDateTime('YYYY-MM-DD HH:MM:SS',Now());
CurrentDate:=FormatDateTime('YYYYMMDD',Now());
end;
{ TODO : 取操作流水号 }
with dmpublish.adsShare do
begin
if Active then
Active := False;
CommandText := 'select operate_order from publish_storage_out where (Id in'+
' (select Max(id) from publish_storage_out where '+
' status=''1'' and operate_order like ''CK'''+'+'''+CurrentDate+'''+'+'''%'') )';
Active := True;
end;
if dmpublish.adsShare.RecordCount=0 then
begin
//若是第一条记录
txtope_id.Caption:='CK'+CurrentDate+'001';
txtid:='CK'+CurrentDate+'001';
end
else begin
//若不是,则取出最大,+1
i:=strtoint(copy(dmpublish.adsShare.fieldbyname('operate_order').AsString,11,3))+1;
txtope_id.Caption:='CK'+CurrentDate+copy('000',1,3-length(inttostr(i)))+inttostr(i);
txtid:='CK'+CurrentDate+copy('000',1,3-length(inttostr(i)))+inttostr(i);
end;
{ TODO : 保存记录 }
s:='insert into publish_storage_out (operate_order,book_barcode,cn_name,type,member_id,';
s:=s+'customer_name,handler,show_price,discount,price,quantity,money,note,operate_date,operator,issale,status)';
s:=s+' values('''+txtope_id.Caption+''','''+trim(edtbarcode.Text)+''','''+trim(edtcnname.Text)+''',''';
s:=s+trim(cbxtype.Text)+''','''+trim(dcbxmid.Text)+''','''+trim(edtgetid.Text)+''','''+trim(edtope.Text)+''',';
s:=s+trim(edtprice.Text)+','+trim(edtdis.Text)+','+trim(edtinp.Text)+','+trim(edtqty.Text)+','+trim(edtmoney.Text);
s:=s+','''+trim(edtnote.Text)+''','''+txtdate.Caption+''','''+ txtope.Caption+''','''+trim(cbxissale.Text)+''',''1'')';
try
{ TODO : 修改“库存表(Publish_Book)”的数量,若数量为0,则将该记录置为无效。 }
if dmpublish.adsPubBook.Locate('book_barcode;cn_name;show_price;status',varArrayOF([trim(edtbarcode.Text),trim(edtcnname.Text),StrToFloat(trim(edtprice.Text)),'1']),[loCaseInsensitive]) then
begin
if dmpublish.adspubbook.FieldByName('store_quantity').AsInteger>StrToInt(trim(edtqty.Text)) then
begin
dmpublish.adsPubBook.Edit;
dmpublish.adspubbook.FieldByName('store_quantity').AsInteger:=dmpublish.adspubbook.FieldByName('store_quantity').AsInteger-StrToInt(trim(edtqty.Text));
dmpublish.adsPubBook.Post;
end
else if dmpublish.adspubbook.FieldByName('store_quantity').AsInteger=StrToInt(trim(edtqty.Text)) then
begin
dmpublish.adsPubBook.Edit;
dmpublish.adspubbook.FieldByName('store_quantity').AsInteger:=0;
dmpublish.adsPubBook.FieldByName('status').AsString:='0';
dmpublish.adsPubBook.Post;
end;
end;
with dmpublish.q_share do
begin
close;
sql.Clear;
sql.Add(s);
execsql;
end;
MSG('记录添加成功!当前流水号为'+txtid,'I');
formshow(fPublish_chMnt);
except
MSG('操作出错,记录添加失败!','W');
formshow(fPublish_chMnt);
end;
end
else
begin
MSG('信息录入不全,请检查后再保存!','W');
end;
end;
procedure TfPublish_ChMnt.dedtNoteKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_Return then
savebtn.SetFocus;
end;
function TfPublish_ChMnt.GetQty: Boolean;
var
qty:integer;
begin
qty:=0;
{ TODO : 查馆藏量 }
if dmpublish.adsPubBook.Locate('book_barcode;cn_name;show_price;Status',varArrayof([trim(edtbarcode.Text),trim(edtcnname.Text),trim(edtprice.Text),'1']),[loCaseInsensitive]) then
qty:=dmpublish.adsPubBook.fieldbyname('store_quantity').AsInteger;
if (strtoint(trim(edtQTy.text))>qty) then
Result:=true
else
Result:=false;
end;
procedure TfPublish_ChMnt.OperateMoney;
begin
edtdis.Text:=floattostr(strtofloat(formatfloat('000.0',strtofloat(trim(cbxmdis.Text)))));
edtinp.Text:=floattostr(strtofloat(formatfloat('0.00',strtofloat(trim(edtprice.Text))*strtofloat(edtdis.text)/100)));
if trim(edtqty.Text)='' then
edtqty.text:='0';
edtmoney.Text:=floattostr(strtofloat(formatfloat('0.00',strtofloat(trim(edtinp.Text))*strtoint(trim(edtqty.text)))));
end;
procedure TfPublish_ChMnt.edtdisExit(Sender: TObject);
begin
if trim(edtdis.Text)='' then
exit;
if not IfNum(trim(edtdis.Text)) then
begin
edtdis.SelectAll;
edtdis.SetFocus;
exit;
end;
edtdis.Text:=floattostr(strtofloat(formatfloat('000.0',strtofloat(trim(edtdis.Text)))));
edtinp.Text:=floattostr(strtofloat(formatfloat('0.00',strtofloat(trim(edtprice.Text))*strtofloat(edtdis.text)/100)));
if trim(edtqty.Text)='' then
edtqty.text:='0';
edtmoney.Text:=floattostr(strtofloat(formatfloat('0.00',strtofloat(trim(edtinp.Text))*strtoint(trim(edtqty.text)))));
end;
procedure TfPublish_ChMnt.edtInpExit(Sender: TObject);
var
f:single;
begin
if trim(edtinp.Text)='' then
exit;
if not IfNum(trim(edtinp.Text)) then
begin
edtinp.SelectAll;
edtinp.SetFocus;
exit;
end;
edtinp.Text:=floattostr(strtofloat(formatfloat('0.00',strtofloat(trim(edtinp.Text)))));
f:=strtofloat(trim(edtinp.Text))*100/strtofloat(trim(edtprice.Text));
edtdis.Text:=floattostr(strtofloat(formatfloat('000.0',f)));
if trim(edtqty.Text)='' then
edtqty.text:='0';
edtmoney.Text:=floattostr(strtofloat(formatfloat('0.00',strtofloat(trim(edtinp.Text))*strtoint(trim(edtqty.text)))));
end;
procedure TfPublish_ChMnt.edtqtyExit(Sender: TObject);
begin
if trim(edtqty.Text)='' then
exit;
if not IfINt(trim(edtqty.Text)) then
begin
edtqty.SelectAll;
edtqty.SetFocus;
exit;
end;
if GetQty() then //检查库存数量
begin
MSG('库存数量不足,请重新输入!','W');
edtQty.SelectAll;
edtQty.SetFocus;
exit;
end;
if trim(edtdis.Text)='' then
edtqty.Text:='100.0';
if trim(edtinp.Text)='' then
edtinp.Text:=floattostr(strtofloat(formatfloat('0.00',strtofloat(trim(edtprice.Text))*strtofloat(edtdis.text)/100)));
edtmoney.Text:=floattostr(strtofloat(formatfloat('0.00',strtofloat(trim(edtinp.Text))*strtoint(trim(edtqty.text)))));
end;
procedure TfPublish_ChMnt.ClearStatus;
begin
edtbarcode.text:='';
edtcnname.text:='';
edtprice.text:='';
cbxtype.text:='';
cbxmname.text:='';
cbxpinyin.text:='';
edtgetid.text:='';
edtope.text:='';
edtnote.text:='';
cbxissale.text:='';
txtope_id.Caption:='';
txtdate.Caption:='';
edtdis.text:='';
edtinp.text:='';
edtqty.text:='';
end;
procedure TfPublish_ChMnt.edtBarcodeKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if trim(edtbarcode.Text)<>'' then
begin
if (Key = VK_RETURN) then
begin
SelectNext(activecontrol,true,true);
end;
end;
end;
procedure TfPublish_ChMnt.edtBarcodeExit(Sender: TObject);
begin
if trim(edtbarcode.Text)<>'' then
begin
OperateBarcode;
end;
end;
procedure TfPublish_ChMnt.cbxISsaleExit(Sender: TObject);
begin
if trim(cbxIsSale.Text)<>'' then
begin
if cbxIsSale.Items.IndexOf(trim(cbxIsSale.Text))<>-1 then
else
begin
MSG('输入的出售/退货不存在,请重新输入!','E');
cbxIsSale.SetFocus;
end;
end;
end;
procedure TfPublish_ChMnt.cbxtypeExit(Sender: TObject);
begin
if trim(cbxType.Text)<>'' then
begin
if cbxType.Items.IndexOf(trim(cbxType.Text))<>-1 then
begin
{ TODO :
若服务类型为会员,则把顾客姓名栏置灰
反之,则把会员栏置灰 }
if trim(cbxtype.Text)=TypeMem then
begin
cbxMname.Enabled:=true;
cbxPinyin.Enabled:=true;
edtGetid.Enabled:=false;
edtgetid.Text:='';
end
else
begin
cbxMname.Enabled:=false;
cbxPinyin.Enabled:=false;
edtGetid.Enabled:=true;
cbxMname.ItemIndex:=-1;
cbxpinyin.ItemIndex:=-1;
cbxMdis.ItemIndex:=-1;
dcbxMid.ItemIndex:=-1;
edtDis.Text:='100.0';
edtgetid.SetFocus;
end;
end
else
begin
MSG('输入的服务类型不存在,请重新输入!','E');
cbxType.SetFocus;
end;
end;
end;
procedure TfPublish_ChMnt.edtNoteKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key=VK_Return) then
savebtn.SetFocus;
end;
procedure TfPublish_ChMnt.SearchBtnClick(Sender: TObject);
begin
if (trim(edtbarcode.Text)<>'') and (trim(edtcnname.Text)<>'') and (trim(edtprice.Text)<>'') then
begin
try
if not assigned(fbookinfo_qr) then
fbookinfo_qr:=tfbookinfo_qr.Create(application);
with fbookinfo_qr.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add(' select * from publish_book where status=''1'' and book_barcode='''+trim(edtbarcode.Text)+'''');
sql.Add(' and cn_name='''+trim(edtcnname.Text)+''' and show_price='+trim(edtprice.Text));
open;
end;
fbookinfo_qr.Preview;
except
MSG('打印报表出错!','W');
formshow(fPublish_chMnt);
end;
end
else
MSG('数据为空,不能查看详细信息!','W');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -