⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pawnmodify.pas

📁 一个典当行的业务管理系统程序
💻 PAS
📖 第 1 页 / 共 5 页
字号:
procedure TfrmPawnModify.cmbCerNameKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
     if key=VK_RETURN then
     begin
          if CertiEnterTimes=0 then
          begin
               CertiEnterTimes:=CertiEnterTimes+1;
               if SendMessage((Sender as TComBoBox).handle,CB_GetDroppedState,0,0)
                  =0 then
                  PostMessage((Sender as TComBoBox).handle,CB_SHOWDROPDOWN,1,0);
          end
          else
          begin
               CertiEnterTimes:=0;
               txtCerCode.SetFocus ;
          end;
     end;
end;

procedure TfrmPawnModify.txtCerCodeKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
     if key=VK_RETURN then
        txtPhone.SetFocus ;
end;

procedure TfrmPawnModify.txtPhoneKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
     if key=VK_RETURN then
     begin
          if txtCerCode.Text='' then
          begin
               messagedlg(Msg.MsgPawnerCode,mtWarning,[mbYes],0);
               txtCerCode.SetFocus;
               exit;
          end;
        txtZip.SetFocus ;
     end;
end;

procedure TfrmPawnModify.txtZipKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
     if key=VK_RETURN then
        txtLinkman.SetFocus ;
end;

procedure TfrmPawnModify.txtLinkmanKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
     if key=VK_RETURN then
        txtAddress.SetFocus ;
end;

procedure TfrmPawnModify.txtAddressKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
     if key=VK_RETURN then
        cmbPawnLimit.SetFocus ;
end;

procedure TfrmPawnModify.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]);
         txtMonthRateExit(Sender);
         cmdSave.SetFocus ;
      end;

end;

procedure TfrmPawnModify.txtFeeRateKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
     if key=VK_RETURN then
     begin
        txtFeeRateExit(Sender);
        cmdSave.SetFocus ;
     end;
end;

procedure TfrmPawnModify.txtTotalPawnMoneyKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
     if key=VK_RETURN then
        txtServiceFee.SetFocus ;
end;

procedure TfrmPawnModify.txtServiceFeeKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
     if key=VK_RETURN then
        txtRealPayMoney.SetFocus ;
end;

procedure TfrmPawnModify.txtRealPayMoneyKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
     if key=VK_RETURN then
        cmdSave.SetFocus ;
end;

procedure TfrmPawnModify.FormShow(Sender: TObject);

var
   Present: TDateTime;
   Year, Month, Day: Word;
{begin
  Present:= Now;
  DecodeDate(Present, Year, Month, Day);
  txtsysdate.text := IntToStr(Year) + '年'
    + IntToStr(Month) + '月' + IntToStr(Day)+'日';
  txtPawnBeginYear.text:=IntToStr(Year);
  txtPawnBeginMonth.text:=InttoStr(Month);
  txtPawnBeginDay.text:=InttoStr(Day);    }
begin
     Present:= Now;
     DecodeDate(Present, Year, Month, Day);
     txtSysYear.Value:=Year;
     txtSysMonth.Value:=Month;
     txtSysDay.Value:=Day;
     with dmPawnFrm do
     begin
       tblHead.Open;
       tblDetailTemp.open;
       tblCertificate.open;
       tblCategory.Open;
     end;
     DBookMarkExist:=False;
     IniDBCombox;
     IniControlBox;
     IniCategoryInDg;
     IniPawnLimit;
end;

procedure TfrmPawnModify.cmdCancelClick(Sender: TObject);
begin
     if DBookMarkExist=True then
     begin
          DBookMarkExist:=False;
     end;
     ClearForm;
end;

{procedure TfrmPawnModify.dbgDetailColEnter(Sender: TObject);
begin
     selMark:=True;
     selValue:=dbgDetail.SelectedField.Value ;
end; }

{当光标从网格的估价和折当率中退出时,将他们的值记下,已备计算金额 }
{procedure TfrmPawnModify.dbgDetailColExit(Sender: TObject);
var
   selDiscountRate,DiscountRate,selAppriseValue:Double;
begin
     with dbgDetail do
     begin
          with dmPawnFrm do
          begin
          //若选中的列中的值与原来的值不同则:
          if selMark=True then
          begin
               selMark:=False;
               if selectedField.Value<>selValue then
               begin
                    //再判断选中的列是折当率的话,计算典当金额
                    if SelectedField.FieldName='DiscountRate' then
                    begin
                         if selectedField.AsFloat=0 then
                            selDiscountRate:=1
                         else
                             selDiscountRate:=selectedField.AsFloat/100 ;
                         with dmPawnFrm do
                         begin
                              tblModifyDetail.DisableControls ;
                              tblModifyDetail.Edit;
                              tblModifyDetail.FieldByName('PawnMoney').Value:=selDiscountRate
                                          *tblModifyDetail.fieldByName('AppriseValue').value;
                              tblModifyDetail.Post;
                              tblModifyDetail.EnableControls ;
                         end;
                         exit;
                    end;
                    // 再判断选中的列是估价的话,计算典当金额
                    if selectedField.FieldName='AppriseValue' then
                    begin
                         selAppriseValue:=selectedField.AsFloat;
                         with dmPawnFrm do
                         begin
                              DiscountRate:=tblModifyDetail.fieldByName('DiscountRate').Value;
                              if DiscountRate=0 then
                                 DiscountRate:=100;
                              tblModifyDetail.DisableControls ;
                              tblModifyDetail.Edit ;
                              tblModifyDetail.FieldByName('PawnMoney').Value:=selAppriseValue
                              *(DiscountRate/100);
                              tblModifyDetail.Post;
                              tblModifyDetail.EnableControls ;
                         end;
                         exit;
                    end;
                    //若值改变的列是折当率或估价以外的列,则不须计算
                    if selectedField.FieldName='PawnMoney'then
                       exit;    //若典当金额的值改变,则不必放入历史记录表中
                    tblModifyDetail.DisableControls;
                    tblModifyDetail.Edit;
                    tblModifyDetail.FieldByName(selectedField.FieldName).Value:=selectedField.Value;
                    tblModifyDetail.Post;
                    tblModifyDetail.EnableControls ;
               end;
          end;//end slemark=true
          end;//end with dmParnFrm
     end;  //end with dbgDetail

end;}

procedure TfrmPawnModify.cmdSaveClick(Sender: TObject);
var
   I:integer;    //用于for 语句
   Limit:integer;   //计算典当期限
   DayWuCha:integer; //选择的典当期限与输入的典当日期的时间间隔的误差
   DayObject:TDayClass;  //自定义的类 in GlobalVar
   BeginMonth:integer;
   BeginDay:integer;
begin
     //如姓名和证件名称未输,则提示并退出
     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='')or
        (txtPawnBeginYear.Text='')or
        (txtPawnBeginMonth.Text='')or
        (txtPawnBeginDay.Text='')then
     begin
          messagedlg(Msg.MsgDateInfo,mtWarning,[mbYes],0);
          exit;
     end;
     //比较选择的典当期限与输入的典当日期的时间间隔是否误差太大
     //计算典当的期限
     //取出此月的天数
     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;
     if (DayWuCha>5) or (DayWuCha<0) then
     begin
          messagedlg(Msg.MsgInputDateError,mtWarning,[mbYes],0);
          exit;
     end;
     //----------------------

     with dmPawnFrm do
     begin
          staModify.Caption:=Msg.StatusMsgSaveIn ;
          //取得查询到的记录的标签
          tblHead.GotoBookmark (HeadBookMark);
          //在历史记录头表中添加此条修改前的记录
          tblHeadHistory.Open;
          tblHeadHistory.Insert ;
          tblHeadHistoryPawnTicketCode.Value :=tblHeadPawnTicketCode.Value ;
          tblHeadHistoryPrePawnTicketCode.Value :=tblHeadPrePawnTicketCode.Value ;
          tblHeadHistoryPawnerName.Value :=tblHeadPawnerName.Value ;
          tblHeadHistoryPawnerAddress.Value :=tblHeadPawnerAddress.Value ;
          tblHeadHistoryPostCode.Value :=tblHeadPostCode.Value ;
          tblHeadHistoryCertificateName.Value :=tblHeadCertificateName.Value ;
          tblHeadHistoryCertificateCode.Value :=tblHeadCertificateCode.Value ;
          tblHeadHistoryTelephoneCode.Value :=tblHeadTelephoneCode.Value ;
          tblHeadHistoryLinkman.Value :=tblHeadLinkman.Value ;
          tblHeadHistoryMonthRate.Value :=tblHeadMonthRate.Value ;
          tblHeadHistoryFeeRate.Value :=tblHeadFeeRate.Value ;
          tblHeadHistoryMonthRateFee.Value:=tblHeadMonthRateFee.Value;
          tblHeadHistoryTotalPawnMoney.Value :=tblHeadTotalPawnMoney.Value ;
          tblHeadHistorySynthesizeFee.Value :=tblHeadSynthesizeFee.Value ;
          tblHeadHistoryRealPayMoney.Value :=tblHeadRealPayMoney.Value ;
          tblHeadHistoryPawnBeginDate.Value :=tblHeadPawnBeginDate.Value ;
          tblHeadHistoryPawnEndDate.Value :=tblHeadPawnEndDate.Value ;
          tblHeadHistoryStatus.Value :='修改';
          tblHeadHistoryCreateDate.Value :=tblHeadCreateDate.Value ;
          tblHeadHistoryLastUpdateDate.Value :=tblHeadLastUpdateDate.Value ;
          tblHeadHistoryUpdateDate.Value :=tblHeadUpdateDate.Value ;
          tblHeadHistoryOperatorCode.Value :=tblHeadOperatorCode.Value ;
          tblHeadHistoryModifyDateTime.Value :=Now;
          tblHeadHistory.Post ;
          tblHeadHistory.Close;
          //修改原头表中的相应的记录
          tblHead.Edit;
          tblHeadPawnTicketCode.Value :=trim(txtPawnCode.Text);
          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);
          tblHeadMonthRate.Value :=strtofloat(trim(txtMonthRate.text));
          tblHeadFeeRate.Value :=strtofloat(trim(txtFeeRate.text));
          tblHeadTotalPawnMoney.Value :=strtofloat(trim(txtTotalPawnMoney.text));
          tblHeadSynthesizeFee.Value :=strtofloat(trim(txtServiceFee.text));
          tblHeadRealPayMoney.Value :=strtofloat(trim(txtRealPayMoney.text));
          tblHeadPawnBeginDate.Value :=EncodeDate(txtPawnBeginYear.Value,
                                     txtPawnBeginMonth.Value,
                                     txtPawnBeginDay.Value);
          tblHeadPawnEndDate.Value :=Encodedate(txtPawnEndYear.Value,
                                   txtPawnEndMonth.Value,
                                   txtPawnEndDay.Value);
          tblHead.Post;
          //tblHead.FreeBookmark (HeadBookMark);
          //将典当金额数据表PawnMoney_Tbl中的金额修改
          tblPawnMoney.Open;
          tblPawnMoney.IndexFieldNames:='PawnTicketCode';
          tblPawnMoney.SetKey ;
          tblPawnMoney.FieldByName('PawnTicketCode').AsString:=txtPawnCode.text;
          if tblPawnMoney.GotoKey then
          begin
               tblPawnMoney.Edit;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -