📄 unitcastpurposeunit.pas
字号:
Unit UnitCastPurposeUnit;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGridEh, StdCtrls, Buttons, DB, ADODB, LbButton, AAFont,
AACtrls, DBCtrls, ExtCtrls;
Type
TUnitCastPurposeForm = Class(TForm)
GroupBox1: TGroupBox;
DBGridEh3: TDBGridEh;
GroupBox6: TGroupBox;
DBGridEH1: TDBGridEh;
LbButton1: TLbButton;
LbButton2: TLbButton;
LbButton3: TLbButton;
LbButton4: TLbButton;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
AALabel2: TAALabel;
DBText1: TDBText;
AALabel3: TAALabel;
DBText2: TDBText;
AALabel4: TAALabel;
DBText3: TDBText;
AALabel5: TAALabel;
DBText4: TDBText;
Bevel1: TBevel;
StaticText3: TStaticText;
Panel1: TPanel;
AALabel1: TAALabel;
combobox1: TComboBox;
Procedure FormClose(Sender: TObject; Var Action: TCloseAction);
Procedure LbButton4Click(Sender: TObject);
Procedure LbButton2Click(Sender: TObject);
Procedure LbButton3Click(Sender: TObject);
Procedure FormCreate(Sender: TObject);
Procedure ComboBox1Change(Sender: TObject);
Procedure LbButton1Click(Sender: TObject);
Private
{ Private declarations }
Public
{ Public declarations }
End;
Var
UnitCastPurposeForm: TUnitCastPurposeForm;
sItemNo : TStringlist;
Implementation
Uses DM, ViewCasterUnit;
{$R *.dfm}
Procedure TUnitCastPurposeForm.FormClose(Sender: TObject;
Var Action: TCloseAction);
Begin
sItemNo.Free;
Action := cafree;
UnitCastPurposeForm := Nil;
End;
Procedure TUnitCastPurposeForm.LbButton4Click(Sender: TObject);
Begin
Close;
End;
Procedure TUnitCastPurposeForm.LbButton2Click(Sender: TObject);
Begin
If ViewCasterForm.ADOQuery3.Active Then
If ViewCasterForm.ADOQuery3.recordcount > 0 Then
ViewCasterForm.ADOQuery3.Delete;
End;
Procedure TUnitCastPurposeForm.LbButton3Click(Sender: TObject);
Begin
ViewCasterForm.ADOQuery3.Close;
ViewCasterForm.ADOQuery3.open;
ADOQuery1.Close;
ADOQuery1.open;
End;
Procedure TUnitCastPurposeForm.FormCreate(Sender: TObject);
Var
adot : TADOQuery;
i : integer;
Begin
With ADOQuery1 Do Begin //单元表
sql.Text :=
'select 单元信息表.公司编号,单元信息表.项目编号,项目名称,幢号,房号,合同约定建筑面积 as 建筑面积,' +
'合同约定套内面积 AS 套内面积,合同约定分摊面积 AS 分摊面积,' +
'可销售房屋状态 from 单元信息表,项目信息表 where 单元信息表.公司编号=''' +
ViewCasterForm.ADOQuery1.fieldbyname('公司编号').Text +
''' and 项目信息表.公司编号=''' +
ViewCasterForm.ADOQuery1.fieldbyname('公司编号').Text +
''' AND (销售类型 =''未售'' or 销售类型=''无'') AND ' +
' 项目信息表.项目编号=单元信息表.项目编号';
open;
End;
sItemNo := TStringlist.create;
adot := TADOQuery.create(self);
With adot Do Begin
connection := DM.DataModule2.ADOConnection1;
sql.Text := ' select * from 项目信息表 where 公司编号=''' + DBText1.Caption
+ '''';
open;
combobox1.Items.Clear;
For i := 0 To recordcount - 1 Do Begin
combobox1.Items.Add(fieldbyname('项目名称').Text);
sItemNo.Add(fieldbyname('项目编号').Text);
Next;
End;
Free;
End;
combobox1.Text := combobox1.Items[0];
ComboBox1Change(self);
End;
Procedure TUnitCastPurposeForm.ComboBox1Change(Sender: TObject);
Begin
With ADOQuery1 Do Begin //单元表
sql.Text :=
'select 单元信息表.公司编号,单元信息表.项目编号,项目名称,幢号,房号,合同约定建筑面积 as 建筑面积,' +
'合同约定套内面积 AS 套内面积,合同约定分摊面积 AS 分摊面积,' +
'可销售房屋状态 from 单元信息表,项目信息表 where 单元信息表.公司编号=''' +
ViewCasterForm.ADOQuery1.fieldbyname('公司编号').Text +
''' AND 项目信息表.公司编号=''' +
ViewCasterForm.ADOQuery1.fieldbyname('公司编号').Text +
''' AND (销售类型 =''未售'' or 销售类型=''无'') AND ' +
'项目信息表.项目编号=单元信息表.项目编号 ' +
' and 单元信息表.项目编号=''' +
sItemNo[combobox1.Items.IndexOf(combobox1.Text)] +
''' and 项目信息表.项目编号=''' +
sItemNo[combobox1.Items.IndexOf(combobox1.Text)] + '''';
open;
End;
End;
Procedure TUnitCastPurposeForm.LbButton1Click(Sender: TObject);
Var
adotemp : TADOQuery;
Begin
If ADOQuery1.recordcount = 0 Then Exit;
adotemp := TADOQuery.create(self);
With adotemp Do Begin
connection := DM.DataModule2.ADOConnection1;
sql.Text := 'select * from 客户意向表 where 公司编号=''' +
ADOQuery1.fieldbyname('公司编号').Text + ''' and 项目编号=''' +
ADOQuery1.fieldbyname('项目编号').Text + ''' and 幢号=''' +
ADOQuery1.fieldbyname('幢号').Text + ''' and 房号=''' +
ADOQuery1.fieldbyname('房号').Text + ''' and 客户编号=''' +
DBText3.Caption + '''';
open;
If recordcount > 0 Then Begin
Application.MessageBox('该房屋已被列入意向表或已被该客户选中!请在未售房屋表中重新选择',
'提示', MB_ICONERROR + mb_OK + MB_SYSTEMMODAL);
Free;
Exit;
End;
Free;
End;
With ViewCasterForm.ADOQuery3 Do Begin
Append;
fieldbyname('公司编号').Text := ADOQuery1.fieldbyname('公司编号').Text;
fieldbyname('项目编号').Text := ADOQuery1.fieldbyname('项目编号').Text;
fieldbyname('幢号').Text := ADOQuery1.fieldbyname('幢号').Text;
fieldbyname('房号').Text := ADOQuery1.fieldbyname('房号').Text;
fieldbyname('客户编号').Text := DBText3.Caption;
post;
End;
End;
End.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -