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

📄 unittenancycaseunit.pas

📁 一个售楼系统
💻 PAS
字号:
Unit UnitTenancyCaseUnit;

Interface

Uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, ExtCtrls, StdCtrls, DBCtrls, AAFont, AACtrls, DB, ADODB,
   LbButton, LbSpeedButton, Grids, DBGridEh, DBCtrlsEh, Mask;

Type
   TUnitTenancyCaseForm = Class(TForm)
      AALabel1: TAALabel;
      DBText1: TDBText;
      AALabel2: TAALabel;
      DBText2: TDBText;
      AALabel31: TAALabel;
      DBText3: TDBText;
      AALabel32: TAALabel;
      DBText4: TDBText;
      AALabel3: TAALabel;
      DBText5: TDBText;
      AALabel4: TAALabel;
      DBText6: TDBText;
      Bevel1: TBevel;
      DBText7: TDBText;
      AALabel9: TAALabel;
      DBText8: TDBText;
      AALabel5: TAALabel;
      Panel2: TPanel;
      DBGridEh4: TDBGridEh;
      Panel3: TPanel;
      LbSpeedButton1: TLbSpeedButton;
      LbSpeedButton2: TLbSpeedButton;
      LbSpeedButton3: TLbSpeedButton;
      LbSpeedButton4: TLbSpeedButton;
      LbButton1: TLbButton;
      DataSource1: TDataSource;
      ADOQuery1: TADOQuery;
      DBText9: TDBText;
      AALabel6: TAALabel;
      DBText10: TDBText;
      AALabel7: TAALabel;
      Function GetPriovDate: TDate;
      Procedure FormClose(Sender: TObject; Var Action: TCloseAction);
      Procedure LbButton1Click(Sender: TObject);
      Procedure FormShow(Sender: TObject);
      Procedure LbSpeedButton1Click(Sender: TObject);
      Procedure LbSpeedButton2Click(Sender: TObject);
      Procedure LbSpeedButton3Click(Sender: TObject);
      Procedure LbSpeedButton4Click(Sender: TObject);
      Procedure DBGridEh4DblClick(Sender: TObject);
      Procedure DBGridEh4CellClick(Column: TColumnEh);
      Procedure LbButton4Click(Sender: TObject);
      Procedure LbButton2Click(Sender: TObject);
      Procedure DBNumberEditEh1Change(Sender: TObject);
      Procedure DBNumberEditEh2Change(Sender: TObject);
      Procedure DBNumberEditEh4Change(Sender: TObject);
   Private
    { Private declarations }
   Public
    { Public declarations }
   End;

Var
   UnitTenancyCaseForm: TUnitTenancyCaseForm;
   BADD             : Boolean;
   BendLoadDB       : Boolean;
Implementation
Uses DM, UnitTenancyUnit, ViewUnitUnit, PUBFunction, EDITTenancyCase2Unit;
{$R *.dfm}

Procedure TUnitTenancyCaseForm.FormClose(Sender: TObject;
   Var Action: TCloseAction);
Begin
   Action := cafree;
   UnitTenancyCaseForm := Nil;
End;

Procedure TUnitTenancyCaseForm.LbButton1Click(Sender: TObject);
Var
   adot             : TADOQuery;
   D                : double;
   D1, D2           : TDate;
   i                : integer;
Begin

   adot := TADOQuery.create(self);
   With adot Do Begin
      connection := DM.DataModule2.ADOConnection1;
      sql.Text := 'SELECT SUM(实际交租金)as sum1,sum(实际未交租金)as sum2 ' +
         'from 租赁情况表 WHERE 公司编号=''' +
         DBText1.Caption + ''' and 项目编号=''' +
         DBText3.Caption + ''' and 幢号=''' +
         DBText5.Caption + ''' AND 房号=''' +
         DBText6.Caption + ''' and 租赁合同号=''' +
         DBText7.Caption + '''';

      open;
      UnitTenancyForm.ADOQuery1.edit;
      UnitTenancyForm.ADOQuery1.fieldbyname('已交租金').AsFloat :=
         fieldbyname('sum1').AsFloat;
      UnitTenancyForm.ADOQuery1.fieldbyname('未交租金').AsFloat :=
         fieldbyname('sum2').AsFloat;
      Close;
      sql.Text := 'SELECT 预定交租日期,实际交租日期 ' +
         'from 租赁情况表 WHERE 公司编号=''' +
         DBText1.Caption + ''' and 项目编号=''' +
         DBText3.Caption + ''' and 幢号=''' +
         DBText5.Caption + ''' AND 房号=''' +
         DBText6.Caption + ''' and 租赁合同号=''' +
         DBText7.Caption + '''';
      open;
      If recordcount > 0 Then
         For i := 0 To recordcount - 1 Do Begin
            D1 := StrToDateDef(fieldbyname('预定交租日期').Text, 0);
            D2 := StrToDateDef(fieldbyname('实际交租日期').Text, 0);
            If D2 > D1 Then D := D + (D2 - D1);
            Next;
         End;

      UnitTenancyForm.ADOQuery1.fieldbyname('租房超期').AsFloat := D;
      UnitTenancyForm.ADOQuery1.post;
      Free;
   End;

   Close;
End;

Procedure TUnitTenancyCaseForm.FormShow(Sender: TObject);
Begin
   BendLoadDB := false;
   With ADOQuery1 Do Begin
      sql.Text := 'select * from 租赁情况表 WHERE 公司编号=''' +
         DBText1.Caption + ''' and 项目编号=''' +
         DBText3.Caption + ''' and 幢号=''' +
         DBText5.Caption + ''' AND 房号=''' +
         DBText6.Caption + ''' and 租赁合同号=''' +
         DBText7.Caption + ''' ORDER BY 实际交租日期 DESC';
      open;
   End;
   ADOQuery1.Cancel;
   BendLoadDB := true;
End;

Procedure TUnitTenancyCaseForm.LbSpeedButton1Click(Sender: TObject);
Var
   rdate            : TDate;
Begin
   BADD := true;
   rdate := GetPriovDate;
   ADOQuery1.Append;
   If rdate = 0 Then
      rdate := StrToDate(DBText9.Caption);
   ADOQuery1.fieldbyname('租金重计日期').Text :=
      FormatDateTime('yyyy-mm-dd', rdate);
   EDITTenancyCase2Form := TEDITTenancyCase2Form.create(self);
   EDITTenancyCase2Form.ShowModal;

End;

Procedure TUnitTenancyCaseForm.LbSpeedButton2Click(Sender: TObject);
Begin
   If ADOQuery1.recordcount = 0 Then Exit;
   BADD := false;
   ADOQuery1.edit;
   EDITTenancyCase2Form := TEDITTenancyCase2Form.create(self);
   EDITTenancyCase2Form.ShowModal;
End;

Procedure TUnitTenancyCaseForm.LbSpeedButton3Click(Sender: TObject);
Begin
   If ADOQuery1.recordcount = 0 Then Exit;
   ADOQuery1.Delete;

End;

Procedure TUnitTenancyCaseForm.LbSpeedButton4Click(Sender: TObject);
Begin
   BendLoadDB := false;
   With ADOQuery1 Do Begin
      sql.Text := 'select * from 租赁情况表 WHERE 公司编号=''' +
         DBText1.Caption + ''' and 项目编号=''' +
         DBText3.Caption + ''' and 幢号=''' +
         DBText5.Caption + ''' AND 房号=''' +
         DBText6.Caption + ''' and 租赁合同号=''' +
         DBText7.Caption + ''' ORDER BY 实际交租日期 DESC';
      open;
   End;
   BendLoadDB := true;
End;

Procedure TUnitTenancyCaseForm.DBGridEh4DblClick(Sender: TObject);
Begin
   LbSpeedButton2.click;
End;

Function TUnitTenancyCaseForm.GetPriovDate: TDate;
Var
   adotemp          : TADOQuery;
   rdate            : TDate;
Begin
   rdate := 0;
   adotemp := TADOQuery.create(self);
   With adotemp Do Begin
      connection := DM.DataModule2.ADOConnection1;
      sql.Text := 'select * from 租赁情况表 WHERE 公司编号=''' +
         DBText1.Caption + ''' and 项目编号=''' +
         DBText3.Caption + ''' and 幢号=''' +
         DBText5.Caption + ''' AND 房号=''' +
         DBText6.Caption + ''' and 租赁合同号=''' +
         DBText7.Caption + ''' ORDER BY 实际交租日期 DESC';

      open;
      If recordcount > 0 Then
         rdate := StrToDateDef(fieldbyname('实际交租日期').Text, 0);
      Free;
   End;
   result := rdate;

End;

Procedure TUnitTenancyCaseForm.DBGridEh4CellClick(Column: TColumnEh);
Begin
//  adoquery1.Cancel ;
End;

Procedure TUnitTenancyCaseForm.LbButton4Click(Sender: TObject);
Begin
   ADOQuery1.Cancel;
   Close;
End;

Procedure TUnitTenancyCaseForm.LbButton2Click(Sender: TObject);
Begin
 {	with UnitTenancyCaseForm  do begin

   ADOQuery1.fieldbyname('公司编号').AsString :=
      DBText1.Caption;
   ADOQuery1.fieldbyname('项目编号').AsString :=
      DBText3.Caption;
   ADOQuery1.fieldbyname('幢号').AsString :=
      DBText5.Caption;
   ADOQuery1.fieldbyname('房号').AsString :=
      DBText6.Caption;
   ADOQuery1.fieldbyname('租赁合同号').AsString :=
      DBText7.Caption;
   ADOQuery1.fieldbyname('预定交租日期').AsString :=
      DBText10.Caption;
   ADOQuery1.post;
   end;
  }

End;

Procedure TUnitTenancyCaseForm.DBNumberEditEh1Change(Sender: TObject);
//Var
 //  a                : TDate;
Begin
  {if not BendLoadDB then Exit ;
   a := StrToDateDef(DBDateTimeEditEh3.Text, 0);

   DBText10.Caption := FormatDateTime('yyyy-mm-dd',
      GetNextMonths(a, StrToIntDef(DBNumberEditEh1.Text, 0)));

   DBNumberEditEh2Change(self);
   }
End;

Procedure TUnitTenancyCaseForm.DBNumberEditEh2Change(Sender: TObject);
Begin
{   If Not BendLoadDB Then Exit;
   DBNumberEditEh3.Text := FloatToStr(STRTOFLOATDEF(DBNumberEditEh2.Text, 0) *
       STRTOFLOATDEF(DBNumberEditEh1.Text, 0));
 }
End;

Procedure TUnitTenancyCaseForm.DBNumberEditEh4Change(Sender: TObject);
Begin
{   If Not BendLoadDB Then Exit;
   DBNumberEditEh5.Text := FloatToStr(STRTOFLOATDEF(DBNumberEditEh3.Text, 0) -
      STRTOFLOATDEF(DBNumberEditEh4.Text, 0));
      }
End;

End.

⌨️ 快捷键说明

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