📄 pawninput.~pa
字号:
NewCode:string;
Limit:integer; //计算典当期限
DayWuCha:integer; //选择的典当期限与输入的典当日期的时间间隔的误差
DayObject:TDayClass; //自定义的类 in GlobalVar
BeginMonth:integer;
BeginDay:integer;
begin
if txtPawnCode.Text='' then
begin
messagedlg(Msg.MsgPawnCodeInput,mtWarning,[mbYes],0);
txtPawnCode.SetFocus ;
exit;
end;
//判断当户姓名和证件编号不为空,如为空则退出保存
if txtName.Text='' then
begin
messagedlg(Msg.MsgPawnerName,mtWarning,[mbYes],0);
txtName.SetFocus;
exit;
end;
if txtCerCode.Text='' then
begin
messagedlg(Msg.MsgPawnerCode,mtWarning,[mbYes],0);
txtCerCode.SetFocus;
exit;
end;
//判断典当的终到日期不为空,如为空则退出保存
if (txtPawnEndYear.Text='')or
(txtPawnEndMonth.Text='')or
(txtPawnEndDay.Text='') then
begin
messagedlg(Msg.MsgDateInfo,mtWarning,[mbYes],0);
exit;
end;
//判断此当票编号是否已在数据库中
with dmPawnFrm do
begin
tblHead.Open;
tblHead.IndexFieldNames:='PawnTicketCode';
tblHead.SetKey ;
tblHeadPawnTicketCode.AsString:=trim(txtPawnCode.text);
if tblHead.GotoKey then
begin
//如存在则提示并退出保存操作
//ClearForm;
messagedlg(Msg.MsgPawnCodeExist,mtInformation,[mbYes],0);
txtPawnCode.SetFocus ;
tblHead.Close;
exit;
end;
end;
PawnBeginDate:=EncodeDate(txtPawnBeginYear.Value,
txtPawnBeginMonth.Value,
txtPawnBeginDay.Value);
//trim(txtPawnBeginYear.Text )+'-'+trim(txtPawnBeginMonth.Text)
// +'-'+trim(txtPawnBeginDay.Text );
PawnEndDate:=EncodeDate(txtPawnEndYear.Value,txtPawnEndMonth.Value,
txtPawnEndDay.Value);
//比较选择的典当期限与输入的典当日期的时间间隔是否误差太大
//计算典当的期限
//取出此月的天数
DayObject:=TDayClass.Create;
BeginMonth:=txtPawnBeginMonth.Value; //txtSysMonth.Value; //strtoint(txtPawnBeginMonth.Text);
BeginDay:=txtPawnBeginDay.Value; //txtSysDay.Value;
Limit:=txtPawnEndYear.Value-txtPawnBeginYear.Value;
Limit:=(Limit*12)+(txtPawnEndMonth.Value-txtPawnBeginMonth.Value);
Limit:=Limit*DayObject.GetDays(BeginMonth,BeginDay)+1+((txtPawnEndDay.Value-txtPawnBeginDay.Value));
DayWuCha:=Limit-Round(TimeLimit*DayObject.GetDays(BeginMonth,BeginDay));
//释放对象
DayObject.Free;
//DayWuCha:=Trunc(PawnEndDate-PawnBeginDate);
if (DayWuCha>5) or (DayWuCha<0) then
begin
messagedlg(Msg.MsgInputDateError,mtWarning,[mbYes],0);
exit;
end;
//--------------------------
Present:= Now;
DecodeDate(Present, Year, Month, Day);
//当票产生日期
InputDate:=EncodeDate(txtSysYear.Value,txtSysMonth.Value,txtSysDay.Value);
//取出典当的起始与终到日期的字符串
if txtPawnBeginYear.Text =''then
txtPawnBeginYear.Value :=GlobalVar.SysYear;
if txtPawnBeginMonth.Text =''then
txtPawnBeginMonth.Value :=GlobalVar.SysMonth;
if txtPawnBeginDay.Text =''then
txtPawnBeginDay.Value :=GlobalVar.SysDay;
//if txtPawnEndYear.Text =''then
//txtPawnEndYear.Text :=IntToStr(Year);
//if txtPawnEndMonth.Text =''then
//txtPawnEndMonth.Text :=IntToStr(Month);
//if txtPawnEndDay.Text =''then
//txtPawnEndDay.Text :=IntToStr(Day);
//trim(txtPawnEndYear.Text)+'-'+trim(txtPawnEndMonth.Text)
// +'-'+trim(txtPawnEndDay.Text);
frmNewPay:=TfrmNewPay.Create (nil);
with frmNewPay do
begin
lbPawnMoney.Caption :=format('%8.1f',[TotalPawnMoney]);
lbServiceFee.Caption :=trim(txtServiceFee.text);
lbRealPayMoney.Caption :=trim(txtRealPayMoney.text);
ShowModal;
Free;
end;
if NewPay.SaveMark =True then
begin
staStatus.Caption :=Msg.StatusMsgSaveIn;
//将这些费用写入数据表PawnMoney_Tbl用于打印
with dmPawnFrm do
begin
tblPawnMoney.Open;
tblPawnMoney.IndexFieldNames:='PawnTicketCode';
tblPawnMoney.SetKey;
tblPawnMoney.FieldByName('PawnTicketCode').asstring:=txtPawnCode.Text;
if tblPawnMoney.GotoKey then
begin
tblPawnMoney.Edit;
end
else
begin
tblPawnMoney.Append;
tblPawnMoneyPawnTicketCode.Value:=trim(self.txtPawnCode.Text);
end;
tblPawnMoneyTotalMoney.Value:=format('%8.1f',[TotalPawnMoney]);
tblPawnMoneyServiceMoney.Value:=trim(txtServiceFee.text);
tblPawnMoneyRealpayMoney.Value:=trim(txtRealPayMoney.text);
tblPawnMoneyPawnDate.Value:=InputDate;
tblPawnMoney.Post;
tblPawnMoney.Close;
end;
//将输入的数据存入数据表中
with dmPawnFrm do
begin
//将此当票编号存入库存数据表中
tblStockpile.Open;
tblStockpile.Append;
tblStockpilePawnCode.Value:=trim(txtPawnCode.text);
tblStockpile.Post;
tblStockpile.Close;
//将文本框中的数据存入头数据表中
tblHead.open;
try //head's try...except begin
with tblHead do
begin
gPawnTicketCode:=trim(txtPawnCode.text);
Insert;
if gHeadInsertMark=false then
exit;
tblHeadPawnTicketCode.Value :=trim(txtPawnCode.Text );
tblHeadPrePawnTicketCode.Value:='';
tblHeadPawnerName.Value :=trim(txtName.Text );
tblHeadPawnerAddress.Value :=trim(txtAddress.Text);
tblHeadPostCode.Value :=trim(txtZip.Text );
tblHeadCertificateName.Value :=trim(cmbCerName.Text);
tblHeadCertificateCode.Value :=trim(txtCerCode.Text);
tblHeadTelephoneCode.Value :=trim(txtPhone.Text);
tblHeadLinkman.Value :=trim(txtLinkman.Text);
if txtMonthRate.Text =''then
txtMonthRate.Text :='0';
tblHeadMonthRate.Value :=StrToFloat(trim(txtMonthRate.Text ));
if txtRate.Text='' then
txtRate.Text:='0';
tblHeadMonthRateFee.Value:=strtofloat(trim(txtRate.Text));
if txtFeeRate.Text='' then
txtFeeRate.Text :='0';
tblHeadFeeRate.Value :=StrToFloat(trim(txtFeeRate.Text));
if txtTotalPawnMoney.Text ='' then
txtTotalPawnMoney.Text :='0';
//TempText:=trim(txtTotalPawnMoney.text);
//delete(TempText,1,1);
tblHeadTotalPawnMoney.Value :=StrToFloat(trim(txtTotalPawnMoney.text));
if txtServiceFee.Text ='' then
txtServiceFee.Text :='0';
tblHeadSynthesizeFee.Value :=StrToFloat(trim(txtServiceFee.Text));
if txtRealPayMoney.Text='' then
txtRealPayMoney.Text:='0';
tblHeadRealPayMoney.Value :=strtofloat(txtRealPayMoney.Text);
tblHeadPawnBeginDate.Value :=PawnBeginDate;
tblHeadPawnEndDate.Value :=PawnEndDate;
tblHeadCreateDate.Value :=InputDate;
tblHeadStatus.Value :='未赎';
tblHeadOperatorCode.Value :=Login.gWorkNo;
Post;
end;
//将文本框中的数据存入历史头数据记录表中
tblHeadHistory.Open;
with tblHeadHistory do
begin
gPawnTicketCode:=trim(txtPawnCode.text);
Insert;
if gHeadInsertMark=false then
exit;
tblHeadHistoryPawnTicketCode.Value :=trim(txtPawnCode.Text );
tblHeadHistoryPrePawnTicketCode.Value:='';
tblHeadHistoryPawnerName.Value :=trim(txtName.Text );
tblHeadHistoryPawnerAddress.Value :=trim(txtAddress.Text);
tblHeadHistoryPostCode.Value :=trim(txtZip.Text );
tblHeadHistoryCertificateName.Value :=trim(cmbCerName.Text);
tblHeadHistoryCertificateCode.Value :=trim(txtCerCode.Text);
tblHeadHistoryTelephoneCode.Value :=trim(txtPhone.Text);
tblHeadHistoryLinkman.Value :=trim(txtLinkman.Text);
if txtMonthRate.Text =''then
txtMonthRate.Text :='0';
tblHeadHistoryMonthRate.Value :=StrToFloat(trim(txtMonthRate.Text ));
if txtRate.Text='' then
txtRate.Text:='0';
tblHeadHistoryMonthRateFee.Value:=strtofloat(trim(txtRate.Text));
if txtFeeRate.Text='' then
txtFeeRate.Text :='0';
tblHeadHistoryFeeRate.Value :=StrToFloat(trim(txtFeeRate.Text));
if txtTotalPawnMoney.Text ='' then
txtTotalPawnMoney.Text :='0';
//TempText:=trim(txtTotalPawnMoney.text);
//delete(TempText,1,1);
tblHeadHistoryTotalPawnMoney.Value :=StrToFloat(trim(txtTotalPawnMoney.text));
if txtServiceFee.Text ='' then
txtServiceFee.Text :='0';
tblHeadHistorySynthesizeFee.Value :=StrToFloat(trim(txtServiceFee.Text));
if txtRealPayMoney.Text='' then
txtRealPayMoney.Text:='0';
tblHeadHistoryRealPayMoney.Value :=strtofloat(txtRealPayMoney.Text);
tblHeadHistoryPawnBeginDate.Value :=PawnBeginDate;
tblHeadHistoryPawnEndDate.Value :=PawnEndDate;
tblHeadHistoryCreateDate.Value :=InputDate;
tblHeadHistoryModifyDateTime.Value:=InputDate;
tblHeadHistoryStatus.Value :='未赎';
tblHeadHistoryOperatorCode.Value :=Login.gWorkNo;
Post;
end;
tblHeadHistory.Close;
except
//on ESomething do
end;
tblDetail.open;
tblDetailHistory.Open;
//将临时详细数据表中的数据存入详细数据表和历史细表数据记录表中
tblDetailTemp.DisableControls ;
try //begin try...finally
tblDetailTemp.First;
while not tblDetailTemp.Eof do
begin
with tblDetail do
begin
Append;
tblDetailPawnTicketCode.Value :=trim(txtPawnCode.Text);
tblDetailPawnLineNum.Value:=tblDetailTempPawnLineNum.Value ;
gLineNum:=tblDetailTempPawnLineNum.Value ;
tblDetailPawnName.Value :=tblDetailTempPawnName.Value ;
tblDetailPawnSpec.Value :=tblDetailTempPawnSpec.Value ;
tblDetailPawnCategory.Value :=tblDetailTempPawnCategory.Value ;
tblDetailPawnNumber.Value :=tblDetailTempPawnNumber.Value ;
tblDetailAppriseValue.Value :=tblDetailTempAppriseValue.Value ;
tblDetailDiscountRate.Value :=tblDetailTempDiscountRate.Value ;
tblDetailPawnMoney.Value :=tblDetailTempPawnMoney.Value ;
tblDetailStatus.Value :='';
Post;
end;
with tblDetailHistory do
begin
Append;
tblDetailHistoryPawnTicketCode.Value :=trim(txtPawnCode.Text);
tblDetailHistoryPawnLineNum.Value:=tblDetailTempPawnLineNum.Value ;
tblDetailHistoryPawnName.Value :=tblDetailTempPawnName.Value ;
tblDetailHistoryPawnSpec.Value :=tblDetailTempPawnSpec.Value ;
tblDetailHistoryPawnCategory.Value :=tblDetailTempPawnCategory.Value ;
tblDetailHistoryPawnNumber.Value :=tblDetailTempPawnNumber.Value ;
tblDetailHistoryAppriseValue.Value :=tblDetailTempAppriseValue.Value ;
tblDetailHistoryDiscountRate.Value :=tblDetailTempDiscountRate.Value ;
tblDetailHistoryPawnMoney.Value :=tblDetailTempPawnMoney.Value;
tblDetailHistoryModifyDateTime.Value:=InputDate;
tblDetailHistoryStatus.Value :='';
Post;
end;
tblDetailTemp.Next;
end;
tblDetailHistory.Close;
tblDetailTemp.EnableControls ;
staStatus.Caption :=Msg.StatusMsgSaveOut;
ClearForm;
//将上一当票编号自动加1成为新当票编号
NewCode:=frmMain.CodePlus(trim(txtPawnCode.text));
txtPawnCode.Text:=NewCode;
finally
tblDetailTemp.EnableControls;
staStatus.Caption :=Msg.StatusMsgSaveOut ;
ClearForm;
//将上一当票编号自动加1成为新当票编号
//NewCode:=frmMain.CodePlus(trim(txtPawnCode.text));
//txtPawnCode.Text:=NewCode;
end;//end try...finally
end;// end with
end //结束询问是否保存数据 如果frmNewPay.savemark等于true
else //如未保存,则提示出来
staStatus.Caption:=Msg.StatusMsgUnSave ;
end;
procedure TfrmPawnInput.txtMonthRateKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
MonthR:Double;
begin
if txtMonthRate.Text='' then
MonthR:=0
else
MonthR:=strtofloat(txtMonthRate.text);
if key=VK_RETURN then
begin
txtRate.Text:=Format('%8.1f',[TimeLimit*TotalPawnMoney*
MonthR/100]);
//txtFeeRate.SetFocus ;
cmdSave.SetFocus;
end;
end;
procedure TfrmPawnInput.txtFeeRateKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
FeeRate:Double;
ServiceFee,RealPayMoney:Double;
begin
if key=VK_RETURN then
begin
if txtFeeRate.text='' then
FeeRate:=0
else
FeeRate:=strtofloat(txtFeeRate.text);
ServiceFee:=(FeeRate/100)*TimeLimit*TotalPawnMoney;
RealPayMoney:=TotalPawnMoney-ServiceFee;
txtServiceFee.Text :=format('%8.1f',[ServiceFee]);
txtRealPayMoney.Text :=format('%8.1f',[RealPayMoney]);
cmdSave.SetFocus ;
end;
end;
{procedure TfrmPawnInput.txtPawnBeginYearKeyUp(Sender: TObject;
var Key: Word; Shift: TShiftState);
var
Present: TDateTime;
Year, Month, Day: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
if txtPawnBeginYear.Text =''then
txtPawnBeginYear.Text := IntToStr(Year);
if (length(txtPawnBeginYear.text)=4) then {or
(length(txtPawnBeginYear.text)=2)then
txtPawnBeginMonth.SetFocus ;
end;}
{procedure TfrmPawnInput.txtPawnBeginMonthKeyUp(Sender: TObject;
var Key: Word; Shift: TShiftState);
var
Present: TDateTime;
Year, Month, Day: Word;
InputMonth:integer;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
if txtPawnBeginMonth.Text ='' then
txtPawnBeginMonth.Text:=IntToStr(Month);
if (length(txtPawnBeginMonth.text)=2)then
begin
InputMonth:=strtoint(txtPawnBeginMonth.Text);
if (InputMonth>12)or(InputMonth<1) then
begin
txtPawnBeginMonth.Text :=IntToStr(Month);
end;
txtPawnBeginDay.SetFocus ;
end;
end;}
{procedure TfrmPawnInput.txtPawnBeginDayKeyUp(Sender: TObject;
var Key: Word; Shift: TShiftState);
var
Present: TDateTime;
Year, Month, Day: Word;
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -