📄 editunitnit.pas
字号:
Unit EditUnitnit;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, LbButton, ExtCtrls, StdCtrls, DBCtrls, AAFont, AACtrls, Mask,
DBCtrlsEh, DB, ADODB;
Type
TEditUnitForm = Class(TForm)
AALabel1: TAALabel;
DBText1: TDBText;
AALabel2: TAALabel;
DBText2: TDBText;
Bevel1: TBevel;
AALabel31: TAALabel;
DBText3: TDBText;
AALabel32: TAALabel;
DBText4: TDBText;
LbButton1: TLbButton;
LbButton2: TLbButton;
AALabel3: TAALabel;
DBText5: TDBText;
AALabel4: TAALabel;
AALabel5: TAALabel;
DBEdit1: TDBEdit;
AALabel9: TAALabel;
AALabel6: TAALabel;
DBEdit2: TDBEdit;
AALabel7: TAALabel;
AALabel8: TAALabel;
DBEdit3: TDBEdit;
AALabel10: TAALabel;
DBText6: TDBText;
AALabel11: TAALabel;
DBNumberEditEh1: TDBNumberEditEh;
AALabel12: TAALabel;
DBNumberEditEh2: TDBNumberEditEh;
DBComboBox1: TDBComboBox;
AALabel13: TAALabel;
AALabel14: TAALabel;
DBEdit4: TDBEdit;
Panel1: TPanel;
AALabel15: TAALabel;
AALabel16: TAALabel;
AALabel17: TAALabel;
combobox1: TComboBox;
ComboBox3: TComboBox;
ComboBox2: TComboBox;
DBComboBox2: TDBComboBox;
AALabel18: TAALabel;
AALabel19: TAALabel;
DBComboBox4: TDBComboBox;
AALabel21: TAALabel;
AALabel22: TAALabel;
DBText7: TDBText;
AALabel23: TAALabel;
DBComboBox5: TDBComboBox;
AALabel24: TAALabel;
AALabel25: TAALabel;
AALabel26: TAALabel;
DBNumberEditEh3: TDBNumberEditEh;
AALabel27: TAALabel;
DBNumberEditEh4: TDBNumberEditEh;
Bevel2: TBevel;
AALabel28: TAALabel;
DBNumberEditEh5: TDBNumberEditEh;
AALabel29: TAALabel;
DBNumberEditEh6: TDBNumberEditEh;
AALabel30: TAALabel;
DBNumberEditEh7: TDBNumberEditEh;
AALabel33: TAALabel;
DBNumberEditEh8: TDBNumberEditEh;
AALabel34: TAALabel;
LbButton3: TLbButton;
AALabel20: TAALabel;
DBText8: TDBText;
AALabel35: TAALabel;
DBCheckBox1: TDBCheckBox;
DBCheckBox2: TDBCheckBox;
DBCheckBox3: TDBCheckBox;
Procedure DelRecordByType(sComID, SItemID, sHourceID, sRoomID, stype:
String);
Procedure EditTypeFlags(sComID, SItemID, sHourceID, sRoomID, stype:
String);
Procedure FormClose(Sender: TObject; Var Action: TCloseAction);
Procedure LbButton1Click(Sender: TObject);
Procedure LbButton2Click(Sender: TObject);
Procedure ComboBox1Change(Sender: TObject);
Procedure DBEdit4Change(Sender: TObject);
Procedure LbButton3Click(Sender: TObject);
Procedure FormCreate(Sender: TObject);
Procedure DBEdit1Change(Sender: TObject);
Procedure DBComboBox4Change(Sender: TObject);
Private
{ Private declarations }
Public
{ Public declarations }
End;
Var
EditUnitForm : TEditUnitForm;
BADD : Boolean;
strTempRoomID, sOldType: String;
Implementation
Uses DM, ViewUnitUnit, PUBFunction;
{$R *.dfm}
Procedure TEditUnitForm.FormClose(Sender: TObject;
Var Action: TCloseAction);
Begin
Action := cafree;
EditUnitForm := Nil;
End;
Procedure TEditUnitForm.LbButton1Click(Sender: TObject);
Begin
ViewUnitForm.ADOQuery4.Cancel;
Close;
End;
Procedure TEditUnitForm.LbButton2Click(Sender: TObject);
Function IsInputNil: Boolean;
Begin
result := true;
If (Trim(DBEdit1.Text) = '') Then Begin
Application.MessageBox('记录添加失败!房号不能为空!请修改房号!',
'出错信息', MB_ICONERROR);
DBEdit1.SetFocus;
result := false;
End;
End;
Function ExtRec: Boolean;
Var
ADOQ : TADOQuery;
Begin
ADOQ := TADOQuery.create(self);
With ADOQ Do Begin
connection := DM.DataModule2.ADOConnection1;
sql.Text := 'SELECT 房号 FROM 单元信息表' +
' WHERE 公司编号=''' + DBText1.Caption +
''' and 项目编号=''' + DBText3.Caption +
''' AND 幢号=''' + DBText5.Caption +
''' and 房号=''' + DBEdit1.Text + '''';
open;
result := (recordcount > 0);
Free;
End;
End;
Procedure ModifyRecAboutGD(sTablename: String);
Var
ADOX : TADOQuery;
Begin
ADOX := TADOQuery.create(self);
ADOX.connection := DM.DataModule2.ADOConnection1;
ADOX.sql.Text := 'UPDATE ' + sTablename + ' SET 房号=''' +
DBEdit1.Text + ''' WHERE 公司编号=''' + DBText1.Caption +
''' and 项目编号=''' + DBText3.Caption +
''' AND 幢号=''' + DBText5.Caption +
''' and 房号=''' + strTempRoomID + '''';
ADOX.ExecSQL;
ADOX.Free;
End;
Var
i : integer;
Begin
If Not IsInputNil Then Exit;
If BADD Then Begin
If ExtRec Then Begin
Application.MessageBox('记录添加失败,记录已存在!请修改房号',
'出错信息', MB_ICONERROR);
DBEdit1.SetFocus;
Exit;
End;
End Else Begin
If DBEdit1.Text <> strTempRoomID Then Begin
If ExtRec Then Begin
Application.MessageBox('记录修改失败,记录已存在!请修改房号',
'出错信息', MB_ICONERROR);
DBEdit1.Text := '';
DBEdit1.SetFocus;
Exit;
End;
End;
End;
If (StrToIntDef(DBNumberEditEh2.Text, 0) > StrToInt(DBText6.Caption)) Then Begin
Application.MessageBox('所在楼层不得大于楼房总楼层!请修改所在楼层。',
'出错信息', MB_ICONERROR);
DBNumberEditEh2.SetFocus;
Exit;
End;
//修改其他相关表中编号
For i := 0 To sTnames.Count - 1 Do
If (ExtFieldInTable(sTnames[i], '房号')) Then
If Not (sTnames[i] = '单元信息表') Then
ModifyRecAboutGD(sTnames[i]);
ViewUnitForm.ADOQuery4.fieldbyname('公司编号').AsString :=
DBText1.Caption;
ViewUnitForm.ADOQuery4.fieldbyname('项目编号').AsString :=
DBText3.Caption;
ViewUnitForm.ADOQuery4.fieldbyname('幢号').AsString :=
DBText5.Caption;
ViewUnitForm.ADOQuery4.fieldbyname('总层数').AsInteger :=
StrToIntDef(DBText6.Caption, 0);
ViewUnitForm.ADOQuery4.fieldbyname('可销售房屋状态').AsString :=
DBText7.Caption;
ViewUnitForm.ADOQuery4.fieldbyname('产权范围').AsString := DBText8.Caption;
If BADD Then
ViewUnitForm.ADOQuery4.fieldbyname('销售类型').AsString :=
DBComboBox4.Text;
ViewUnitForm.ADOQuery4.post;
If (Not (BADD)) And (sOldType <> DBComboBox4.Text) Then Begin
EditTypeFlags(DBText1.Caption, DBText3.Caption, DBText5.Caption,
DBEdit1.Text, sOldType);
//标记或者删除
// DelRecordByType(DBText1.Caption, DBText3.Caption, DBText5.Caption,
// DBEdit1.Text, sOldType);
End;
Close;
End;
Procedure TEditUnitForm.ComboBox1Change(Sender: TObject);
Begin
DBEdit4.Text := combobox1.Text + '房' + ComboBox2.Text + '厅' +
ComboBox3.Text + '卫';
End;
Procedure TEditUnitForm.DBEdit4Change(Sender: TObject);
Var
shx : String;
Begin
shx := Trim(DBEdit4.Text);
If shx <> '' Then Begin
combobox1.Text := Copy(shx, 0, 2);
ComboBox2.Text := Copy(shx, 5, 2);
ComboBox3.Text := Copy(shx, 9, 2);
End;
End;
Procedure TEditUnitForm.LbButton3Click(Sender: TObject);
Var
sum, s1, s2 : double;
Begin
s1 := STRTOFLOATDEF(DBNumberEditEh3.Text, 0);
s2 := STRTOFLOATDEF(DBNumberEditEh4.Text, 0);
sum := s1 + s2;
DBNumberEditEh7.Text := FloatToStr(sum);
s1 := STRTOFLOATDEF(DBNumberEditEh5.Text, 0);
s2 := STRTOFLOATDEF(DBNumberEditEh6.Text, 0);
sum := s1 + s2;
DBNumberEditEh8.Text := FloatToStr(sum);
End;
Procedure TEditUnitForm.FormCreate(Sender: TObject);
Var
GHYT : String;
SL : TStringlist;
i : integer;
Begin
strTempRoomID := ViewUnitForm.ADOQuery4.fieldbyname('房号').Text;
GHYT := ViewUnitForm.ADOQuery3.fieldbyname('设计用途').Text;
If BADD Then Begin
DBComboBox4.Text := ViewUnitForm.combobox1.Text;
DBText7.Caption := DBComboBox4.Text;
DBCheckBox1.Checked := false;
DBCheckBox2.Checked := false;
DBCheckBox3.Checked := false;
End;
SL := TStringlist.create;
SL := Split(GHYT, '_');
For i := 0 To SL.Count - 1 Do
DBComboBox1.Items.Add(SL[i]);
SL.Free;
DBEdit4Change(self);
sOldType := DBComboBox4.Text;
End;
Procedure TEditUnitForm.DBEdit1Change(Sender: TObject);
Begin
DBText8.Caption := DBEdit1.Text;
End;
Procedure TEditUnitForm.DBComboBox4Change(Sender: TObject);
Begin
DBText7.Caption := DBComboBox4.Text;
End;
Procedure TEditUnitForm.EditTypeFlags(sComID, SItemID, sHourceID, sRoomID,
stype: String);
Var
adotemp : TADOQuery;
sTname, stname2 : String;
Begin
stname2 := '';
If stype = '未售' Then Begin
sTname := '单元未售表';
stname2 := '客户意向表';
End;
If stype = '预(销)售' Then sTname := '单元预售表';
If stype = '拆迁还建' Then sTname := '单元拆迁还建表';
If stype = '抵押' Then sTname := '单元抵押表';
If stype = '预定' Then sTname := '单元预定表';
If stype = '预留' Then sTname := '单元预留表';
If stype = '租赁' Then Begin
sTname := '单元租赁表';
stname2 := '租赁情况表';
End;
adotemp := TADOQuery.create(self);
With adotemp Do Begin
connection := DM.DataModule2.ADOConnection1;
sql.Text := 'update ' + sTname + ' set 是否过期=TRUE,过期日期=#' + DateToStr(Now) + '#' +
' where 公司编号=''' + sComID +
''' AND 项目编号=''' + SItemID + ''' and 幢号=''' + sHourceID +
''' AND 房号=''' + sRoomID + '''';
ExecSQL;
{ If stname2 <> '' Then Begin
sql.Text := 'delete from ' + stname2 + ' where 公司编号=''' + sComID +
''' AND 项目编号=''' + SItemID + ''' and 幢号=''' + sHourceID +
''' AND 房号=''' + sRoomID + '''';
ExecSQL;
End;}
Free;
End;
End;
Procedure TEditUnitForm.DelRecordByType(sComID, SItemID, sHourceID,
sRoomID, stype: String);
Var
adotemp : TADOQuery;
sTname, stname2 : String;
Begin
stname2 := '';
If stype = '未售' Then Begin
sTname := '单元未售表';
stname2 := '客户意向表';
End;
If stype = '预(销)售' Then sTname := '单元预售表';
If stype = '拆迁还建' Then sTname := '单元拆迁还建表';
If stype = '抵押' Then sTname := '单元抵押表';
If stype = '预定' Then sTname := '单元预定表';
If stype = '预留' Then sTname := '单元预留表';
If stype = '租赁' Then Begin
sTname := '单元租赁表';
stname2 := '租赁情况表';
End;
adotemp := TADOQuery.create(self);
With adotemp Do Begin
connection := DM.DataModule2.ADOConnection1;
sql.Text := 'delete from ' + sTname + ' where 公司编号=''' + sComID +
''' AND 项目编号=''' + SItemID + ''' and 幢号=''' + sHourceID +
''' AND 房号=''' + sRoomID + '''';
ExecSQL;
Application.ProcessMessages;
If stname2 <> '' Then Begin
sql.Text := 'delete from ' + stname2 + ' where 公司编号=''' + sComID +
''' AND 项目编号=''' + SItemID + ''' and 幢号=''' + sHourceID +
''' AND 房号=''' + sRoomID + '''';
ExecSQL;
End;
Free;
End;
End;
End.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -