delphi 强制退出死循环,要设置label标签
delphi 强制退出死循环,要设置label标签
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls;
type
TForm2 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery_select: TADOQuery;
ADOQuery_yezhu_insert: TADOQuery;
Button1: TButton;
ADOQuery_insert: TADOQuery;
ADOQuery_dengjicx: TADOQuery;
ADOQuery_kehucx: TADOQuery;
ADOQuery_cx: TADOQuery;
ADOQuery_insert_kehudengji: TADOQuery;
ADOQuery_yezhutianjia: TADOQuery;
ADOQuery_insert_xiaoshoujibenyixiang: TADOQuery;
ADOQuery_insert_xiaoshoushoukuan: TADOQuery;
ADOQuery_temp: TADOQuery;
ADOQuery_ruzhu_insert: TADOQuery;
Button2: TButton;
ADOQuery_select_daikuan: TADOQuery;
ADOQuery_update_daikuan: TADOQuery;
Button3: TButton;
procedure Button1Click(Sender: TObject);
Procedure tianjiafangyuan(Sender: TObject); //添加房源
Procedure tianjiaxiaoshoujibenyixiang(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject); //添加销售基本意向
private
kehubianhao:string;
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
var py: array[216..247] of string = (
{216}'CJWGNSPGCGNESYPB' + 'TYYZDXYKYGTDJNMJ' + 'QMBSGZSCYJSYYZPG' +
{216}'KBZGYCYWYKGKLJSW' + 'KPJQHYZWDDZLSGMR' + 'YPYWWCCKZNKYDG',
{217}'TTNJJEYKKZYTCJNM' + 'CYLQLYPYQFQRPZSL' + 'WBTGKJFYXJWZLTBN' +
{217}'CXJJJJZXDTTSQZYC' + 'DXXHGCKBPHFFSSYY' + 'BGMXLPBYLLLHLX',
{218}'SPZMYJHSOJNGHDZQ' + 'YKLGJHXGQZHXQGKE' + 'ZZWYSCSCJXYEYXAD' +
{218}'ZPMDSSMZJZQJYZCD' + 'JEWQJBDZBXGZNZCP' + 'WHKXHQKMWFBPBY',
{219}'DTJZZKQHYLYGXFPT' + 'YJYYZPSZLFCHMQSH' + 'GMXXSXJJSDCSBBQB' +
{219}'EFSJYHXWGZKPYLQB' + 'GLDLCCTNMAYDDKSS' + 'NGYCSGXLYZAYBN',
{220}'PTSDKDYLHGYMYLCX' + 'PYCJNDQJWXQXFYYF' + 'JLEJBZRXCCQWQQSB' +
{220}'ZKYMGPLBMJRQCFLN' + 'YMYQMSQYRBCJTHZT' + 'QFRXQHXMJJCJLX',
{221}'QGJMSHZKBSWYEMYL' + 'TXFSYDSGLYCJQXSJ' + 'NQBSCTYHBFTDCYZD' +
{221}'JWYGHQFRXWCKQKXE' + 'BPTLPXJZSRMEBWHJ' + 'LBJSLYYSMDXLCL',
{222}'QKXLHXJRZJMFQHXH' + 'WYWSBHTRXXGLHQHF' + 'NMCYKLDYXZPWLGGS' +
{222}'MTCFPAJJZYLJTYAN' + 'JGBJPLQGDZYQYAXB' + 'KYSECJSZNSLYZH',
{223}'ZXLZCGHPXZHZNYTD' + 'SBCJKDLZAYFMYDLE' + 'BBGQYZKXGLDNDNYS' +
{223}'KJSHDLYXBCGHXYPK' + 'DQMMZNGMMCLGWZSZ' + 'XZJFZNMLZZTHCS',
{224}'YDBDLLSCDDNLKJYK' + 'JSYCJLKOHQASDKNH' + 'CSGANHDAASHTCPLC' +
{224}'PQYBSDMPJLPCJOQL' + 'CDHJJYSPRCHNKNNL' + 'HLYYQYHWZPTCZG',
{225}'WWMZFFJQQQQYXACL' + 'BHKDJXDGMMYDJXZL' + 'LSYGXGKJRYWZWYCL' +
{225}'ZMSSJZLDBYDCPCXY' + 'HLXCHYZJQSQQAGMN' + 'YXPFRKSSBJLYXY',
{226}'SYGLNSCMHCWWMNZJ' + 'JLXXHCHSYD CTXRY' + 'CYXBYHCSMXJSZNPW' +
{226}'GPXXTAYBGAJCXLYS' + 'DCCWZOCWKCCSBNHC' + 'PDYZNFCYYTYCKX',
{227}'KYBSQKKYTQQXFCWC' + 'HCYKELZQBSQYJQCC' + 'LMTHSYWHMKTLKJLY' +
{227}'CXWHEQQHTQHZPQSQ' + 'SCFYMMDMGBWHWLGS' + 'LLYSDLMLXPTHMJ',
{228}'HWLJZYHZJXHTXJLH' + 'XRSWLWZJCBXMHZQX' + 'SDZPMGFCSGLSXYMJ' +
{228}'SHXPJXWMYQKSMYPL' + 'RTHBXFTPMHYXLCHL' + 'HLZYLXGSSSSTCL',
{229}'SLDCLRPBHZHXYYFH' + 'BBGDMYCNQQWLQHJJ' + 'ZYWJZYEJJDHPBLQX' +
{229}'TQKWHLCHQXAGTLXL' + 'JXMSLXHTZKZJECXJ' + 'CJNMFBYCSFYWYB',
{230}'JZGNYSDZSQYRSLJP' + 'CLPWXSDWEJBJCBCN' + 'AYTWGMPABCLYQPCL' +
{230}'ZXSBNMSGGFNZJJBZ' + 'SFZYNDXHPLQKZCZW' + 'ALSBCCJXJYZHWK',
{231}'YPSGXFZFCDKHJGXD' + 'LQFSGDSLQWZKXTMH' + 'SBGZMJZRGLYJBPML' +
{231}'MSXLZJQQHZSJCZYD' + 'JWBMJKLDDPMJEGXY' + 'HYLXHLQYQHKYCW',
{232}'CJMYYXNATJHYCCXZ' + 'PCQLBZWWYTWBQCML' + 'PMYRJCCCXFPZNZZL' +
{232}'JPLXXYZTZLGDLDCK' + 'LYRLZGQTGJHHGJLJ' + 'AXFGFJZSLCFDQZ',
{233}'LCLGJDJCSNCLLJPJ' + 'QDCCLCJXMYZFTSXG' + 'CGSBRZXJQQCTZHGY' +
{233}'QTJQQLZXJYLYLBCY' + 'AMCSTYLPDJBYREGK' + 'JZYZHLYSZQLZNW',
{234}'CZCLLWJQJJJKDGJZ' + 'OLBBZPPGLGHTGZXY' + 'GHZMYCNQSYCYHBHG' +
{234}'XKAMTXYXNBSKYZZG' + 'JZLQJDFCJXDYGJQJ' + 'JPMGWGJJJPKQSB',
{235}'GBMMCJSSCLPQPDXC' + 'DYYKYWCJDDYYGYWR' + 'HJRTGZNYQLDKLJSZ' +
{235}'ZGZQZJGDYKSHPZMT' + 'LCPWNJAFYZDJCNMW' + 'ESCYGLBTZCGMSS',
{236}'LLYXQSXSBSJSBBGG' + 'GHFJLYPMZJNLYYWD' + 'QSHZXTYYWHMCYHYW' +
{236}'DBXBTLMSYYYFSXJC' + 'SDXXLHJHF SXZQHF' + 'ZMZCZTQCXZXRTT',
{237}'DJHNNYZQQMNQDMMG' + 'LYDXMJGDHCDYZBFF' + 'ALLZTDLTFXMXQZDN' +
{237}'GWQDBDCZJDXBZGSQ' + 'QDDJCMBKZFFXMKDM' + 'DSYYSZCMLJDSYN',
{238}'SPRSKMKMPCKLGDBQ' + 'TFZSWTFGGLYPLLJZ' + 'HGJJGYPZLTCSMCNB' +
{238}'TJBQFKTHBYZGKPBB' + 'YMTDSSXTBNPDKLEY' + 'CJNYCDYKZDDHQH',
{239}'SDZSCTARLLTKZLGE' + 'CLLKJLQJAQNBDKKG' + 'HPJTZQKSECSHALQF' +
{239}'MMGJNLYJBBTMLYZX' + 'DCJPLDLPCQDHZYCB' + 'ZSCZBZMSLJFLKR',
{240}'ZJSNFRGJHXPDHYJY' + 'BZGDLJCSEZGXLBLH' + 'YXTWMABCHECMWYJY' +
{240}'ZLLJJYHLGBDJLSLY' + 'GKDZPZXJYYZLWCXS' + 'ZFGWYYDLYHCLJS',
{241}'CMBJHBLYZLYCBLYD' + 'PDQYSXQZBYTDKYYJ' + 'YYCNRJMPDJGKLCLJ' +
{241}'BCTBJDDBBLBLCZQR' + 'PPXJCGLZCSHLTOLJ' + 'NMDDDLNGKAQHQH',
{242}'JHYKHEZNMSHRP QQ' + 'JCHGMFPRXHJGDYCH' + 'GHLYRZQLCYQJNZSQ' +
{242}'TKQJYMSZSWLCFQQQ' + 'XYFGGYPTQWLMCRNF' + 'KKFSYYLQBMQAMM',
{243}'MYXCTPSHCPTXXZZS' + 'MPHPSHMCLMLDQFYQ' + 'XSZYJDJJZZHQPDSZ' +
{243}'GLSTJBCKBXYQZJSG' + 'PSXQZQZRQTBDKYXZ' + 'KHHGFLBCSMDLDG',
{244}'DZDBLZYYCXNNCSYB' + 'ZBFGLZZXSWMSCCMQ' + 'NJQSBDQSJTXXMBLT' +
{244}'XZCLZSHZCXRQJGJY' + 'LXZFJPHYXZQQYDFQ' + 'JJLZZNZJCDGZYG',
{245}'CTXMZYSCTLKPHTXH' + 'TLBJXJLXSCDQXCBB' + 'TJFQZFSLTJBTKQBX' +
{245}'XJJLJCHCZDBZJDCZ' + 'JDCPRNPQCJPFCZLC' + 'LZXBDMXMPHJSGZ',
{246}'GSZZQLYLWTJPFSYA' + 'SMCJBTZYYCWMYTCS' + 'JJLQCQLWZMALBXYF' +
{246}'BPNLSFHTGJWEJJXX' + 'GLLJSTGSHJQLZFKC' + 'GNNDSZFDEQFHBS',
{247}'AQTGYLBXMMYGSZLD' + 'YDQMJJRGBJTKGDHG' + 'KBLQKBDMBYLXWCXY' +
{247}'TTYBKMRTJZXQJBHL' + 'MHMJJZMQASLDCYXY' + 'QDLQCAFYWYXQHZ'
);
function ChnPy(Value: array of char): Char;
begin
Result := #0;
case Byte(Value[0]) of
176:
case Byte(Value[1]) of
161..196: Result := 'A';
197..254: Result := 'B';
end; {case}
177:
Result := 'B';
178:
case Byte(Value[1]) of
161..192: Result := 'B';
193..205: Result := 'C';
206: Result := 'S'; //参
207..254: Result := 'C';
end; {case}
179:
Result := 'C';
180:
case Byte(Value[1]) of
161..237: Result := 'C';
238..254: Result := 'D';
end; {case}
181:
Result := 'D';
182:
case Byte(Value[1]) of
161..233: Result := 'D';
234..254: Result := 'E';
end; {case}
183:
case Byte(Value[1]) of
161: Result := 'E';
162..254: Result := 'F';
end; {case}
184:
case Byte(Value[1]) of
161..192: Result := 'F';
193..254: Result := 'G';
end; {case}
185:
case Byte(Value[1]) of
161..253: Result := 'G';
254: Result := 'H';
end; {case}
186:
Result := 'H';
187:
case Byte(Value[1]) of
161..246: Result := 'H';
247..254: Result := 'J';
end; {case}
188..190:
Result := 'J';
191:
case Byte(Value[1]) of
161..165: Result := 'J';
166..254: Result := 'K';
end; {case}
192:
case Byte(Value[1]) of
161..171: Result := 'K';
172..254: Result := 'L';
end; {case}
193:
Result := 'L';
194:
case Byte(Value[1]) of
161..231: Result := 'L';
232..254: Result := 'M';
end; {case}
195:
Result := 'M';
196:
case Byte(Value[1]) of
161..194: Result := 'M';
195..254: Result := 'N';
end; {case}
197:
case Byte(Value[1]) of
161..181: Result := 'N';
182..189: Result := 'O';
190..254: Result := 'P';
end; {case}
198:
case Byte(Value[1]) of
161..217: Result := 'P';
218..254: Result := 'Q';
end; {case}
199:
Result := 'Q';
200:
case Byte(Value[1]) of
161..186: Result := 'Q';
187..245: Result := 'R';
246..254: Result := 'S';
end; {case}
201..202:
Result := 'S';
203:
case Byte(Value[1]) of
161..249: Result := 'S';
250..254: Result := 'T';
end; {case}
204:
Result := 'T';
205:
case Byte(Value[1]) of
161..217: Result := 'T';
218..254: Result := 'W';
end; {case}
206:
case Byte(Value[1]) of
161..243: Result := 'W';
244..254: Result := 'X';
end; {case}
207..208:
Result := 'X';
209:
case Byte(Value[1]) of
161..184: Result := 'X';
185..254: Result := 'Y';
end; {case}
210..211:
Result := 'Y';
212:
case Byte(Value[1]) of
161..208: Result := 'Y';
209..254: Result := 'Z';
end; {case}
213..215:
Result := 'Z';
216..247:
Result := py[Byte(Value[0])][Byte(Value[1]) - 160];
end; {case}
end;
function ChnToPY(Value: string): string;
var
I, L: Integer;
C: array[0..1] of char;
R: Char;
begin
Result := '';
L := Length(Value);
I := 1;
while I <= (L - 1) do
begin
if Value[I] < #160 then
begin
Result := Result + Value[I];
Inc(I);
end
else
begin
C[0] := Value[I];
C[1] := Value[I + 1];
R := ChnPY(C);
if r <> #0 then
Result := Result + R;
Inc(I, 2);
end;
end;
if I = L then
Result := Result + Value[L];
end;
procedure TForm2.Button1Click(Sender: TObject);
var
i:integer;
label
first_start;
begin
with ADOQuery_Select do
begin
Close;
SQL.Clear;
//SQL.Add('select * from [00台账] WHERE 付款方式 = ''按揭'' ');
SQL.Add('select * from [00台账] order by id');
Open;
end;
if ADOQuery_Select.RecordCount>0 then
begin
with ADOQuery_Select do
begin
ADOQuery_Select.First;
for i:=1 to ADOQuery_Select.RecordCount do
begin
first_start:
//添加房源信息
tianjiafangyuan(Sender);
if (Trim(ADOQuery_Select.FieldValues['状态'])='售出') or (Trim(ADOQuery_Select.FieldValues['状态'])='抵账') then
begin
//添加成交客户登记
//根据客户名称与电话号码查询客户登记中是否有该客户信息
with ADOQuery_kehucx do
begin
Close;
SQL.Clear;
SQL.Add('select * from S_kehudengji where kehumingcheng=:kehumingcheng and dianhua=:dianhua');
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Open;
end;
//如果不存在该客户信息,添加该客户信息
if ADOQuery_kehucx.RecordCount<1 then
begin
with ADOQuery_cx do
begin
Close;
SQL.Clear;
SQL.Add('select max(kehubianhao) as maxcard from s_kehudengji');
Open;
end;
if ADOQuery_cx.FieldValues['maxcard']=null then
begin
kehubianhao:='000001';
end
else
begin
kehubianhao:=Format('%.6d', [strtoint(Trim(ADOQuery_cx.FieldValues['maxcard']))+1]);
end;
with ADOQuery_insert_kehudengji do
begin
Close;
Parameters.ParamByName('zhuangtai').Value:='成交';
Parameters.ParamByName('kehubianhao').Value:=Trim(kehubianhao);
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('pinyinma').Value:=ChnToPY(Trim(ADOQuery_Select.FieldValues['姓名']));
if ADOQuery_Select.FieldValues['性别']=null then
begin
Parameters.ParamByName('xingbie').Value:='';
end
else
begin
Parameters.ParamByName('xingbie').Value:=Trim(ADOQuery_Select.FieldValues['性别']);
end;
if ADOQuery_Select.FieldValues['身份证号']=null then
begin
Parameters.ParamByName('zhengjianhao').Value:='';
end
else
begin
Parameters.ParamByName('zhengjianhao').Value:=Trim(ADOQuery_Select.FieldValues['身份证号']);
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('youbian').Value:='';
if ADOQuery_Select.FieldValues['居住地']=null then
begin
Parameters.ParamByName('tongxundizhi').Value:='';
end
else
begin
Parameters.ParamByName('tongxundizhi').Value:=Trim(ADOQuery_Select.FieldValues['居住地']);
end;
Parameters.ParamByName('guishuloupan').Value:='御海龙湾小区';
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('yewuyuan').Value:='';
end
else
begin
Parameters.ParamByName('yewuyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
//添加物业业主信息 W_yezhuxinxi
with ADOQuery_yezhutianjia do
begin
Close;
SQL.Clear;
SQL.Add('insert into W_yezhuxinxi (loupan,donghao,fangjianhao,xingming,shifouyezhu,zhengjianhaoma,xingbie,dianhua,shoujihao,czy) '+
'values(:loupan,:donghao,:fangjianhao,:xingming,:shifouyezhu,:zhengjianhaoma,:xingbie,:dianhua,:shoujihao,:czy) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#'; end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('xingming').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('shifouyezhu').Value:='是';
if ADOQuery_Select.FieldValues['身份证号']=null then
begin
Parameters.ParamByName('zhengjianhaoma').Value:='';
end
else
begin
Parameters.ParamByName('zhengjianhaoma').Value:=Trim(ADOQuery_Select.FieldValues['身份证号']);
end;
if ADOQuery_Select.FieldValues['性别']=null then
begin
Parameters.ParamByName('xingbie').Value:='';
end
else
begin
Parameters.ParamByName('xingbie').Value:=Trim(ADOQuery_Select.FieldValues['性别']);
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shoujihao').Value:='';
Parameters.ParamByName('czy').Value:='001';
ExecSQL;
end;
//添加入住登记信息
if ADOQuery_Select.FieldValues['入住时间']<>null then
begin
with ADOQuery_ruzhu_insert do
begin
Close;
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('banliren').Value:='001';
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('tuoshouyinhang').Value:='';
Parameters.ParamByName('yinhangzhanghao').Value:='';
Parameters.ParamByName('hetonghao').Value:='';
Parameters.ParamByName('shouloushuhao').Value:='';
Parameters.ParamByName('ruzhutongzhishu').Value:='';
Parameters.ParamByName('cunfangweizhi').Value:='';
Parameters.ParamByName('chanquanzhenghao').Value:='';
Parameters.ParamByName('tudizhenghao').Value:='';
if ADOQuery_Select.FieldValues['入住时间']=null then
begin
Parameters.ParamByName('ruzhuriqi').Value:='';
end
else
begin
Parameters.ParamByName('ruzhuriqi').Value:=Trim(ADOQuery_Select.FieldValues['入住时间']);
end;
if ADOQuery_Select.FieldValues['起征月日']=null then
begin
Parameters.ParamByName('qiyue').Value:='';
Parameters.ParamByName('qiri').Value:='';
end
else
begin
Parameters.ParamByName('qiyue').Value:=copy(Trim(ADOQuery_Select.FieldValues['起征月日']),1,pos('-',Trim(ADOQuery_Select.FieldValues['起征月日']))-1);
Parameters.ParamByName('qiri').Value:=copy(Trim(ADOQuery_Select.FieldValues['起征月日']),pos('-',Trim(ADOQuery_Select.FieldValues['起征月日']))+1,length(Trim(ADOQuery_Select.FieldValues['起征月日']))-pos('-',Trim(ADOQuery_Select.FieldValues['起征月日'])));
end;
if ADOQuery_Select.FieldValues['止付月日']=null then
begin
Parameters.ParamByName('zhiyue').Value:='';
Parameters.ParamByName('zhiri').Value:='';
end
else
begin
Parameters.ParamByName('zhiyue').Value:=copy(Trim(ADOQuery_Select.FieldValues['止付月日']),1,pos('-',Trim(ADOQuery_Select.FieldValues['止付月日']))-1);
Parameters.ParamByName('zhiri').Value:=copy(Trim(ADOQuery_Select.FieldValues['止付月日']),pos('-',Trim(ADOQuery_Select.FieldValues['止付月日']))+1,length(Trim(ADOQuery_Select.FieldValues['止付月日']))-pos('-',Trim(ADOQuery_Select.FieldValues['止付月日'])));
end;
Parameters.ParamByName('jiedairen').Value:='';
Parameters.ParamByName('beizhu').Value:='';
Parameters.ParamByName('ziliaofafang').Value:='是';
Parameters.ParamByName('yaoshifafang').Value:='是';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
//更新房源资料入住信息
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('update S_fangyuanxinxi set fangchanzhuangtai=:fangchanzhuangtai '+
'where loupanmingcheng=:loupan and donghao=:donghao and fangjianhao=:fangjianhao');
Parameters.ParamByName('fangchanzhuangtai').Value:='入住';
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
ExecSQL();
end;
end;
end;
end;
//已存在客户信息
if ADOQuery_kehucx.RecordCount>0 then
begin
kehubianhao:=Trim(ADOQuery_kehucx.FieldValues['kehubianhao']);
//添加物业业主信息 W_yezhuxinxi
with ADOQuery_yezhutianjia do
begin
Close;
SQL.Clear;
SQL.Add('insert into W_yezhuxinxi (loupan,donghao,fangjianhao,xingming,shifouyezhu,zhengjianhaoma,xingbie,dianhua,shoujihao,czy) '+
'values(:loupan,:donghao,:fangjianhao,:xingming,:shifouyezhu,:zhengjianhaoma,:xingbie,:dianhua,:shoujihao,:czy) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('xingming').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('shifouyezhu').Value:='是';
if ADOQuery_Select.FieldValues['身份证号']=null then
begin
Parameters.ParamByName('zhengjianhaoma').Value:='';
end
else
begin
Parameters.ParamByName('zhengjianhaoma').Value:=Trim(ADOQuery_Select.FieldValues['身份证号']);
end;
if ADOQuery_Select.FieldValues['性别']=null then
begin
Parameters.ParamByName('xingbie').Value:='';
end
else
begin
Parameters.ParamByName('xingbie').Value:=Trim(ADOQuery_Select.FieldValues['性别']);
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shoujihao').Value:='';
Parameters.ParamByName('czy').Value:='001';
ExecSQL;
end;
//添加入住登记信息
if ADOQuery_Select.FieldValues['入住时间']<>null then
begin
with ADOQuery_ruzhu_insert do
begin
Close;
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('banliren').Value:='001';
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('tuoshouyinhang').Value:='';
Parameters.ParamByName('yinhangzhanghao').Value:='';
Parameters.ParamByName('hetonghao').Value:='';
Parameters.ParamByName('shouloushuhao').Value:='';
Parameters.ParamByName('ruzhutongzhishu').Value:='';
Parameters.ParamByName('cunfangweizhi').Value:='';
Parameters.ParamByName('chanquanzhenghao').Value:='';
Parameters.ParamByName('tudizhenghao').Value:='';
if ADOQuery_Select.FieldValues['入住时间']=null then
begin
Parameters.ParamByName('ruzhuriqi').Value:='';
end
else
begin
Parameters.ParamByName('ruzhuriqi').Value:=Trim(ADOQuery_Select.FieldValues['入住时间']);
end;
if ADOQuery_Select.FieldValues['起征月日']=null then
begin
Parameters.ParamByName('qiyue').Value:='';
Parameters.ParamByName('qiri').Value:='';
end
else
begin
Parameters.ParamByName('qiyue').Value:=copy(Trim(ADOQuery_Select.FieldValues['起征月日']),1,pos('-',Trim(ADOQuery_Select.FieldValues['起征月日']))-1);
Parameters.ParamByName('qiri').Value:=copy(Trim(ADOQuery_Select.FieldValues['起征月日']),pos('-',Trim(ADOQuery_Select.FieldValues['起征月日']))+1,length(Trim(ADOQuery_Select.FieldValues['起征月日']))-pos('-',Trim(ADOQuery_Select.FieldValues['起征月日'])));
end;
if ADOQuery_Select.FieldValues['止付月日']=null then
begin
Parameters.ParamByName('zhiyue').Value:='';
Parameters.ParamByName('zhiri').Value:='';
end
else
begin
Parameters.ParamByName('zhiyue').Value:=copy(Trim(ADOQuery_Select.FieldValues['止付月日']),1,pos('-',Trim(ADOQuery_Select.FieldValues['止付月日']))-1);
Parameters.ParamByName('zhiri').Value:=copy(Trim(ADOQuery_Select.FieldValues['止付月日']),pos('-',Trim(ADOQuery_Select.FieldValues['止付月日']))+1,length(Trim(ADOQuery_Select.FieldValues['止付月日']))-pos('-',Trim(ADOQuery_Select.FieldValues['止付月日'])));
end;
Parameters.ParamByName('jiedairen').Value:='';
Parameters.ParamByName('beizhu').Value:='';
Parameters.ParamByName('ziliaofafang').Value:='是';
Parameters.ParamByName('yaoshifafang').Value:='是';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
//更新房源资料入住信息
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('update S_fangyuanxinxi set fangchanzhuangtai=:fangchanzhuangtai '+
'where loupanmingcheng=:loupan and donghao=:donghao and fangjianhao=:fangjianhao');
Parameters.ParamByName('fangchanzhuangtai').Value:='入住';
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
ExecSQL();
end;
end;
end;
end;
//添加销售基本意向
tianjiaxiaoshoujibenyixiang(Sender);
//添加销售收款
if (Trim(ADOQuery_Select.FieldValues['状态'])<>'待售') and (Trim(ADOQuery_Select.FieldValues['状态'])<>'公司贷款') then
begin
//按揭情况:1.公司垫款(交垫款,交首付款) 2.交首付款
if Trim(ADOQuery_Select.FieldValues['付款方式'])='按揭' then
begin
//公司垫款
if (ADOQuery_Select.FieldValues['公司垫款']<>null) and (ADOQuery_Select.FieldValues['公司垫款']>0) then
begin
//1.添加公司垫款
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
//公司垫款日期以签约日期为准
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['签约日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['签约日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['签约日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='按揭';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['签约日期'])));
Parameters.ParamByName('zhaiyao').Value:='公司垫款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=-ADOQuery_Select.FieldValues['公司垫款'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
//2.添加首付款
if (ADOQuery_Select.FieldValues['已交首付']<>null) and (ADOQuery_Select.FieldValues['已交首付']>0) then
begin
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='按揭';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['首付日期'])));
Parameters.ParamByName('zhaiyao').Value:='交付首期房款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['已交首付'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
ADOQuery_Select.Next;
goto first_start;
end;
//交首付款
if (ADOQuery_Select.FieldValues['公司垫款']=null) or (ADOQuery_Select.FieldValues['公司垫款']=0) then
begin
//只交首付房款
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='按揭';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['首付日期'])));
Parameters.ParamByName('zhaiyao').Value:='交付首期房款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['已交首付'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
ADOQuery_Select.Next;
goto first_start;
end;
end;
//低首付情况: 公司垫款--> 1.公司垫款 2.交定金 3.交首付款 4.第一次还款 不是公司垫款--> 2.交定金 3.交首付款 4.第一次还款
if Trim(ADOQuery_Select.FieldValues['付款方式'])='低首付' then
begin
//公司垫款
if (ADOQuery_Select.FieldValues['公司垫款']<>null) and (ADOQuery_Select.FieldValues['公司垫款']>0) then
begin
//1.添加公司垫款
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['签约日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['签约日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['签约日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='低首付';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['签约日期'])));
Parameters.ParamByName('zhaiyao').Value:='公司垫款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=-ADOQuery_Select.FieldValues['公司垫款'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
//2.添加定金
if (ADOQuery_Select.FieldValues['定金金额']<>null) and (ADOQuery_Select.FieldValues['定金金额']>0) then
begin
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['定金时间']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['定金时间']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['定金时间']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='低首付';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['定金时间'])));
Parameters.ParamByName('zhaiyao').Value:='交付定金';
Parameters.ParamByName('feiyongmingcheng').Value:='定金';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['定金金额'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
//3.添加首付款
if (ADOQuery_Select.FieldValues['已交首付']<>null) and (ADOQuery_Select.FieldValues['已交首付']>0) then
begin
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='低首付';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['首付日期'])));
Parameters.ParamByName('zhaiyao').Value:='交付首期房款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['已交首付'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
//4.添加第一次还款
if (ADOQuery_Select.FieldValues['一次还款金额']<>null) and (ADOQuery_Select.FieldValues['一次还款金额']>0) then
begin
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['一次还款日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['一次还款日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['一次还款日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='低首付';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['一次还款日期'])));
Parameters.ParamByName('zhaiyao').Value:='缴付第一次房款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['一次还款金额'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
ADOQuery_Select.Next;
goto first_start;
end;
//不是公司垫款情况
if (ADOQuery_Select.FieldValues['公司垫款']=null) or (ADOQuery_Select.FieldValues['公司垫款']=0) then
begin
//2.添加定金
if (ADOQuery_Select.FieldValues['定金金额']<>null) and (ADOQuery_Select.FieldValues['定金金额']>0) then
begin
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['定金时间']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['定金时间']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['定金时间']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='低首付';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['定金时间'])));
Parameters.ParamByName('zhaiyao').Value:='交付定金';
Parameters.ParamByName('feiyongmingcheng').Value:='定金';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['定金金额'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
//3.添加首付款
if (ADOQuery_Select.FieldValues['已交首付']<>null) and (ADOQuery_Select.FieldValues['已交首付']>0) then
begin
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='低首付';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['首付日期'])));
Parameters.ParamByName('zhaiyao').Value:='交付首期房款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['已交首付'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
//4.添加第一次还款
if (ADOQuery_Select.FieldValues['一次还款金额']<>null) and (ADOQuery_Select.FieldValues['一次还款金额']>0) then
begin
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['一次还款日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['一次还款日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['一次还款日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='低首付';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['一次还款日期'])));
Parameters.ParamByName('zhaiyao').Value:='缴付第一次房款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['一次还款金额'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
ADOQuery_Select.Next;
goto first_start;
end;
end;
//抵账情况:1.已交首付不为空或0,进行收款。 2.抵账金额,抵账日期
if Trim(ADOQuery_Select.FieldValues['付款方式'])='抵账' then
begin
//抵账收款
if (ADOQuery_Select.FieldValues['抵账金额']<>null) and (ADOQuery_Select.FieldValues['抵账金额']>0) then
begin
//1.添加抵账
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['抵账日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['抵账日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['抵账日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='抵账';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['抵账日期'])));
Parameters.ParamByName('zhaiyao').Value:='公司抵账';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['抵账金额'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
//2.添加首付款
if (ADOQuery_Select.FieldValues['已交首付']<>null) and (ADOQuery_Select.FieldValues['已交首付']>0) then
begin
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='抵账';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['首付日期'])));
Parameters.ParamByName('zhaiyao').Value:='交付首期房款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['已交首付'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
ADOQuery_Select.Next;
goto first_start;
end
//只有优惠金额,没有抵账金额,所以没有添加
else
begin
ADOQuery_Select.Next;
goto first_start;
end;
end;
//一次性情况 :1.已交首付
if Trim(ADOQuery_Select.FieldValues['付款方式'])='一次性' then
begin
//首付收款,定金已转到首付中,不考虑定金添加
if (ADOQuery_Select.FieldValues['已交首付']<>null) and (ADOQuery_Select.FieldValues['已交首付']>0) then
begin
//1.添加首付
with ADOQuery_insert_xiaoshoushoukuan do
begin
Close;
//选取年度最大开头为'SK'的单据号
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('SELECT MAX(SUBSTRING(shoujuhao, 3, 9)) AS shoujuhao FROM S_xiaoshoushoukuan '+
'WHERE loupan=:loupan and (SUBSTRING(shoujuhao, 1, 2) = ''SK'') and (SUBSTRING(shoujuhao, 3, 4) =:niandu) ');
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('niandu').Value:=FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']));
Open;
end;
if ADOQuery_temp.FieldValues['shoujuhao']=null then
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+'00001';
end
else
begin
Parameters.ParamByName('shoujuhao').Value:='SK'+FormatDateTime('yyyy',StrToDate(ADOQuery_Select.FieldValues['首付日期']))+Format('%.5d', [strtoint(copy(ADOQuery_temp.FieldValues['shoujuhao'],5,5))+1]);
end;
Parameters.ParamByName('kehubianhao').Value:=kehubianhao;
Parameters.ParamByName('kehumingcheng').Value:=Trim(ADOQuery_Select.FieldValues['姓名']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
if ADOQuery_Select.FieldValues['联系方式']=null then
begin
Parameters.ParamByName('dianhua').Value:='';
end
else
begin
Parameters.ParamByName('dianhua').Value:=Trim(ADOQuery_Select.FieldValues['联系方式']);
end;
Parameters.ParamByName('shouji').Value:='';
Parameters.ParamByName('fukuanfangshi').Value:='一次性付款';
Parameters.ParamByName('shoukuanriqi').Value:=FormatDateTime('yyyy-mm-dd',StrToDate(Trim(ADOQuery_Select.FieldValues['首付日期'])));
Parameters.ParamByName('zhaiyao').Value:='交付首期房款';
Parameters.ParamByName('feiyongmingcheng').Value:='房款';
Parameters.ParamByName('fukuanjine').Value:=ADOQuery_Select.FieldValues['已交首付'];
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
Parameters.ParamByName('shoukuanren').Value:='001';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
ADOQuery_Select.Next;
goto first_start;
end;
end;
end;
end
//待售或公司贷款
else
begin
if (Trim(ADOQuery_Select.FieldValues['状态'])='公司贷款') then
begin
//更新房源状态
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('update S_fangyuanxinxi set xiaoshouzhuangtai=:xiaoshouzhuangtai,fangchanzhuangtai=:fangchanzhuangtai '+
'where loupanmingcheng=:loupan and donghao=:donghao and fangjianhao=:fangjianhao');
Parameters.ParamByName('xiaoshouzhuangtai').Value:='公司贷款';
Parameters.ParamByName('fangchanzhuangtai').Value:='空置';
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
ExecSQL();
end;
if Trim(ADOQuery_Select.FieldValues['代号'])='4-4-602' then //最一个房源信息
begin
ShowMessage('导入成功!');
Exit;
end;
ADOQuery_Select.Next;
goto first_start;
end;
if (Trim(ADOQuery_Select.FieldValues['状态'])='待售') then
begin
//更新房源状态
with ADOQuery_temp do
begin
Close;
SQL.Clear;
SQL.Add('update S_fangyuanxinxi set xiaoshouzhuangtai=:xiaoshouzhuangtai,fangchanzhuangtai=:fangchanzhuangtai '+
'where loupanmingcheng=:loupan and donghao=:donghao and fangjianhao=:fangjianhao');
Parameters.ParamByName('xiaoshouzhuangtai').Value:='待售';
Parameters.ParamByName('fangchanzhuangtai').Value:='空置';
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
ExecSQL();
end;
ADOQuery_Select.Next;
goto first_start;
end;
end;
//添加业主信息
//添加入住信息
//添加销售基本意向信息
//添加销售收款信息
end;
end;
ShowMessage('导入成功!');
end;
end;
procedure TForm2.tianjiafangyuan(Sender: TObject);
begin
with ADOQuery_insert do
begin
Close;
if Trim(ADOQuery_Select.FieldValues['代号'])='8-2-401' then
begin
showmessage('1111');
end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupanmingcheng').Value:='御海龙湾小区';
if (Trim(ADOQuery_Select.FieldValues['楼栋'])='写字楼') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='门市') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车库') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='车位') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='商铺') or (Trim(ADOQuery_Select.FieldValues['楼栋'])='社区用房') then
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋']);
end
else
begin
Parameters.ParamByName('donghao').Value:=Trim(ADOQuery_Select.FieldValues['楼栋'])+'#';
end;
Parameters.ParamByName('fangyuanbieming').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('danyuan').Value:=Trim(ADOQuery_Select.FieldValues['单元']);
Parameters.ParamByName('louceng').Value:=Trim(ADOQuery_Select.FieldValues['楼层']);
Parameters.ParamByName('fangchanhao').Value:=Trim(ADOQuery_Select.FieldValues['房号']);
if ADOQuery_Select.FieldValues['套型']=null then
begin
Parameters.ParamByName('taoxing').Value:='';
end
else
begin
Parameters.ParamByName('taoxing').Value:=Trim(ADOQuery_Select.FieldValues['套型']);
end;
if ADOQuery_Select.FieldValues['户型']=null then
begin
Parameters.ParamByName('huxing').Value:='';
end
else
begin
Parameters.ParamByName('huxing').Value:=Trim(ADOQuery_Select.FieldValues['户型']);
end;
if ADOQuery_Select.FieldValues['类别']=null then
begin
Parameters.ParamByName('wuyeleixing').Value:='';
end
else
begin
Parameters.ParamByName('wuyeleixing').Value:=Trim(ADOQuery_Select.FieldValues['类别']);
end;
if ADOQuery_Select.FieldValues['面积']=null then
begin
Parameters.ParamByName('taoneimianji').Value:=0;
Parameters.ParamByName('jianzhumianji').Value:=0;
Parameters.ParamByName('shiyongmianji').Value:=0;
Parameters.ParamByName('xiaoshoumianji').Value:=0;
Parameters.ParamByName('chanquanmianji').Value:=0;
end
else
begin
Parameters.ParamByName('taoneimianji').Value:=ADOQuery_Select.FieldValues['面积'];
Parameters.ParamByName('jianzhumianji').Value:=ADOQuery_Select.FieldValues['面积'];
Parameters.ParamByName('shiyongmianji').Value:=ADOQuery_Select.FieldValues['面积'];
Parameters.ParamByName('xiaoshoumianji').Value:=ADOQuery_Select.FieldValues['面积'];
Parameters.ParamByName('chanquanmianji').Value:=ADOQuery_Select.FieldValues['面积'];
end;
if ADOQuery_Select.FieldValues['面积']=null then
begin
Parameters.ParamByName('gongtanmianji').Value:=0;
end
else
begin
Parameters.ParamByName('gongtanmianji').Value:=0; //Excel表中需要添加此数据
end;
if ADOQuery_Select.FieldValues['定价单价']=null then
begin
Parameters.ParamByName('dingjiadanjia').Value:=0;
end
else
begin
Parameters.ParamByName('dingjiadanjia').Value:=ADOQuery_Select.FieldValues['定价单价'];
end;
if ADOQuery_Select.FieldValues['定价总价']=null then
begin
Parameters.ParamByName('dingjiazongjia').Value:=0;
end
else
begin
Parameters.ParamByName('dingjiazongjia').Value:=ADOQuery_Select.FieldValues['定价总价'];
end;
if ADOQuery_Select.FieldValues['精装修是否']=null then
begin
Parameters.ParamByName('shifouzhuangxiu').Value:='否';
end
else
begin
Parameters.ParamByName('shifouzhuangxiu').Value:=Trim(ADOQuery_Select.FieldValues['精装修是否']);
end;
if ADOQuery_Select.FieldValues['装修单价']=null then
begin
Parameters.ParamByName('zhuangxiudanjia').Value:=0;
end
else
begin
Parameters.ParamByName('zhuangxiudanjia').Value:=ADOQuery_Select.FieldValues['装修单价'];
end;
if ADOQuery_Select.FieldValues['装修面积']=null then
begin
Parameters.ParamByName('zhuangxiumianji').Value:=0;
end
else
begin
Parameters.ParamByName('zhuangxiumianji').Value:=ADOQuery_Select.FieldValues['装修面积'];
end;
if ADOQuery_Select.FieldValues['装修款']=null then
begin
Parameters.ParamByName('zhuangxiuzongjia').Value:=0;
end
else
begin
Parameters.ParamByName('zhuangxiuzongjia').Value:=ADOQuery_Select.FieldValues['装修款'];
end;
Parameters.ParamByName('gongtanxishu').Value:=0;
Parameters.ParamByName('fushemingcheng').Value:='';
Parameters.ParamByName('fushemianji').Value:=0;
Parameters.ParamByName('fushedanjia').Value:=0;
Parameters.ParamByName('fushezongjia').Value:=0;
if ADOQuery_Select.FieldValues['状态']=null then
begin
Parameters.ParamByName('xiaoshouzhuangtai').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouzhuangtai').Value:=Trim(ADOQuery_Select.FieldValues['状态']);
end;
Parameters.ParamByName('jiegou').Value:='框架';
Parameters.ParamByName('chaoxiang').Value:='南北';
Parameters.ParamByName('jingguan').Value:='';
Parameters.ParamByName('weizhi').Value:='';
if ADOQuery_Select.FieldValues['类别']=null then
begin
Parameters.ParamByName('quanshuleixing').Value:='';
end
else
begin
Parameters.ParamByName('quanshuleixing').Value:=Trim(ADOQuery_Select.FieldValues['类别']);
end;
Parameters.ParamByName('qitayinsu1').Value:='';
Parameters.ParamByName('qitayinsu2').Value:='';
Parameters.ParamByName('qitayinsu3').Value:='';
Parameters.ParamByName('peibeisheshi').Value:='';
if ADOQuery_Select.FieldValues['精装修是否']=null then
begin
Parameters.ParamByName('zhuangxiuzhuangkuang').Value:='';
Parameters.ParamByName('shifouzhuangxiu').Value:='';
Parameters.ParamByName('zhuangxiudanjia').Value:=0;
Parameters.ParamByName('zhuangxiumianji').Value:=0;
Parameters.ParamByName('zhuangxiuzongjia').Value:=0;
end
else
begin
if Trim(ADOQuery_Select.FieldValues['精装修是否'])='是' then
begin
Parameters.ParamByName('shifouzhuangxiu').Value:='是';
Parameters.ParamByName('zhuangxiuzhuangkuang').Value:='';
if ADOQuery_Select.FieldValues['装修单价']=null then
begin
Parameters.ParamByName('zhuangxiudanjia').Value:=0;
end
else
begin
Parameters.ParamByName('zhuangxiudanjia').Value:=ADOQuery_Select.FieldValues['装修单价'];
end;
if ADOQuery_Select.FieldValues['装修面积']=null then
begin
Parameters.ParamByName('zhuangxiumianji').Value:=0;
end
else
begin
Parameters.ParamByName('zhuangxiumianji').Value:=ADOQuery_Select.FieldValues['装修面积'];
end;
if ADOQuery_Select.FieldValues['装修款']=null then
begin
Parameters.ParamByName('zhuangxiuzongjia').Value:=0;
end
else
begin
Parameters.ParamByName('zhuangxiuzongjia').Value:=ADOQuery_Select.FieldValues['装修款'];
end;
end
else
begin
Parameters.ParamByName('shifouzhuangxiu').Value:='否';
Parameters.ParamByName('zhuangxiuzhuangkuang').Value:='';
Parameters.ParamByName('zhuangxiudanjia').Value:=0;
Parameters.ParamByName('zhuangxiumianji').Value:=0;
Parameters.ParamByName('zhuangxiuzongjia').Value:=0;
end;
end;
Parameters.ParamByName('beizhu').Value:='';
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
procedure TForm2.tianjiaxiaoshoujibenyixiang(Sender: TObject);
begin
with ADOQuery_insert_xiaoshoujibenyixiang do
begin
Close;
Parameters.ParamByName('kehubianhao').Value:=Trim(kehubianhao);
Parameters.ParamByName('chengyibianhao').Value:='';
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select.FieldValues['代号']);
Parameters.ParamByName('loupan').Value:='御海龙湾小区';
Parameters.ParamByName('zhekoufangan').Value:='无';
Parameters.ParamByName('dikoujine').Value:=0;
Parameters.ParamByName('xiaoshouzhuangtai').Value:='签约';
if ADOQuery_Select.FieldValues['付款方式']=null then
begin
Parameters.ParamByName('fukuanfangshi').Value:='';
end
else
begin
Parameters.ParamByName('fukuanfangshi').Value:=Trim(ADOQuery_Select.FieldValues['付款方式']);
end;
if ADOQuery_Select.FieldValues['按揭成数']=null then
begin
Parameters.ParamByName('anjiechengshu').Value:='';
end
else
begin
Parameters.ParamByName('anjiechengshu').Value:=Trim(ADOQuery_Select.FieldValues['按揭成数']);
end;
if ADOQuery_Select.FieldValues['按揭年限']=null then
begin
Parameters.ParamByName('daikuannianxian').Value:='';
end
else
begin
Parameters.ParamByName('daikuannianxian').Value:=Trim(ADOQuery_Select.FieldValues['按揭年限']);
end;
if ADOQuery_Select.FieldValues['签约日期']=null then
begin
Parameters.ParamByName('xiaoshouriqi').Value:='1900-01-01';
end
else
begin
Parameters.ParamByName('xiaoshouriqi').Value:=Trim(ADOQuery_Select.FieldValues['签约日期']);
end;
if ADOQuery_Select.FieldValues['置业顾问']=null then
begin
Parameters.ParamByName('xiaoshouyuan').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshouyuan').Value:=Trim(ADOQuery_Select.FieldValues['置业顾问']);
end;
if ADOQuery_Select.FieldValues['面积']=null then
begin
Parameters.ParamByName('xiaoshoumianji').Value:=0;
end
else
begin
Parameters.ParamByName('xiaoshoumianji').Value:=ADOQuery_Select.FieldValues['面积'];
end;
if ADOQuery_Select.FieldValues['定价单价']=null then
begin
Parameters.ParamByName('dingjiadanjia').Value:=0;
end
else
begin
Parameters.ParamByName('dingjiadanjia').Value:=ADOQuery_Select.FieldValues['定价单价'];
end;
if ADOQuery_Select.FieldValues['定价总价']=null then
begin
Parameters.ParamByName('dingjiazongjia').Value:=0;
end
else
begin
Parameters.ParamByName('dingjiazongjia').Value:=ADOQuery_Select.FieldValues['定价总价'];
end;
if ADOQuery_Select.FieldValues['成交单价']=null then
begin
Parameters.ParamByName('xiaoshoudanjia').Value:=0;
end
else
begin
Parameters.ParamByName('xiaoshoudanjia').Value:=ADOQuery_Select.FieldValues['成交单价'];
end;
if ADOQuery_Select.FieldValues['成交单价']=null then
begin
Parameters.ParamByName('danjiayouhui').Value:=0;
end
else
begin
Parameters.ParamByName('danjiayouhui').Value:=ADOQuery_Select.FieldValues['定价单价']-ADOQuery_Select.FieldValues['成交单价'];
end;
if ADOQuery_Select.FieldValues['优惠金额']=null then
begin
Parameters.ParamByName('danjiayouhui').Value:=0;
end
else
begin
Parameters.ParamByName('danjiayouhui').Value:=ADOQuery_Select.FieldValues['优惠金额'];
end;
{if ADOQuery_Select.FieldValues['精装修是否']=null then
begin
Parameters.ParamByName('shifouzhuangxiu').Value:='';
end
else
begin
Parameters.ParamByName('shifouzhuangxiu').Value:=Trim(ADOQuery_Select.FieldValues['精装修是否']);
end;
if ADOQuery_Select.FieldValues['装修单价']=null then
begin
Parameters.ParamByName('zhuangxiudanjia').Value:=0;
end
else
begin
Parameters.ParamByName('zhuangxiudanjia').Value:=ADOQuery_Select.FieldValues['装修单价'];
end;
if ADOQuery_Select.FieldValues['装修面积']=null then
begin
Parameters.ParamByName('zhuangxiumianji').Value:=0;
end
else
begin
Parameters.ParamByName('zhuangxiumianji').Value:=ADOQuery_Select.FieldValues['装修面积'];
end;
if ADOQuery_Select.FieldValues['装修款']=null then
begin
Parameters.ParamByName('zhuangxiuzongjia').Value:=0;
end
else
begin
Parameters.ParamByName('zhuangxiuzongjia').Value:=ADOQuery_Select.FieldValues['装修款'];
end; }
Parameters.ParamByName('danjiazhekou').Value:=0;
Parameters.ParamByName('zongjiazhekou').Value:=0;
Parameters.ParamByName('fushe').Value:='';
Parameters.ParamByName('fushemianji').Value:=0;
Parameters.ParamByName('fushedingjia').Value:=0;
Parameters.ParamByName('fushedingjiazongjia').Value:=0;
Parameters.ParamByName('fushexiaoshoudanjia').Value:=0;
Parameters.ParamByName('fushexiaoshouzongjia').Value:=0;
if ADOQuery_Select.FieldValues['优惠金额']=null then
begin
Parameters.ParamByName('zongjiayouhui').Value:=0;
end
else
begin
Parameters.ParamByName('zongjiayouhui').Value:=ADOQuery_Select.FieldValues['优惠金额'];
end;
//根据红晟地产农安给出的表,如为待售状态,根据Excel表设定公式,优惠金额即为成交总价,导入为售出或抵账方式,此部分不执行
if ADOQuery_Select.FieldValues['成交总价']=null then
begin
Parameters.ParamByName('xiaoshouzongjia').Value:=ADOQuery_Select.FieldValues['优惠金额'];
Parameters.ParamByName('hejizongjia').Value:=ADOQuery_Select.FieldValues['优惠金额'];
end
else
begin
Parameters.ParamByName('xiaoshouzongjia').Value:=ADOQuery_Select.FieldValues['成交总价'];
Parameters.ParamByName('hejizongjia').Value:=ADOQuery_Select.FieldValues['成交总价'];
end;
Parameters.ParamByName('zhehouzaiyouhui').Value:=0;
Parameters.ParamByName('shuoming').Value:='';
//房屋产权相关费用
if ADOQuery_Select.FieldValues['契税交款金额']=null then
begin
Parameters.ParamByName('qishuijiaokuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('qishuijiaokuanjine').Value:=ADOQuery_Select.FieldValues['契税交款金额'];
end;
if ADOQuery_Select.FieldValues['物维交款金额']=null then
begin
Parameters.ParamByName('weixiujijinjiaokuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('weixiujijinjiaokuanjine').Value:=ADOQuery_Select.FieldValues['物维交款金额'];
end;
if ADOQuery_Select.FieldValues['查档交款金额']=null then
begin
Parameters.ParamByName('chadangjiaokuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('chadangjiaokuanjine').Value:=ADOQuery_Select.FieldValues['查档交款金额'];
end;
if ADOQuery_Select.FieldValues['产权登记交款金额']=null then
begin
Parameters.ParamByName('chanquandengjijiaokuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('chanquandengjijiaokuanjine').Value:=ADOQuery_Select.FieldValues['产权登记交款金额'];
end;
if ADOQuery_Select.FieldValues['印花交款金额']=null then
begin
Parameters.ParamByName('yinhuajiaokuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('yinhuajiaokuanjine').Value:=ADOQuery_Select.FieldValues['印花交款金额'];
end;
if ADOQuery_Select.FieldValues['预告登记交款金额']=null then
begin
Parameters.ParamByName('yugaodengjijiaokuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('yugaodengjijiaokuanjine').Value:=ADOQuery_Select.FieldValues['预告登记交款金额'];
end;
if ADOQuery_Select.FieldValues['预告登记使用时间']=null then
begin
Parameters.ParamByName('yugaodengjishiyongshijian').Value:='';
end
else
begin
Parameters.ParamByName('yugaodengjishiyongshijian').Value:=ADOQuery_Select.FieldValues['预告登记使用时间'];
end;
if ADOQuery_Select.FieldValues['预告登记使用金额']=null then
begin
Parameters.ParamByName('yugaodengjishiyongjine').Value:=0;
end
else
begin
Parameters.ParamByName('yugaodengjishiyongjine').Value:=ADOQuery_Select.FieldValues['预告登记使用金额'];
end;
if ADOQuery_Select.FieldValues['代办交款金额']=null then
begin
Parameters.ParamByName('daibanjiaokuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('daibanjiaokuanjine').Value:=ADOQuery_Select.FieldValues['代办交款金额'];
end;
if ADOQuery_Select.FieldValues['公正交款金额']=null then
begin
Parameters.ParamByName('gongzhengjiaokuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('gongzhengjiaokuanjine').Value:=ADOQuery_Select.FieldValues['公正交款金额'];
end;
if ADOQuery_Select.FieldValues['公正交款金额']=null then
begin
Parameters.ParamByName('diyashouxufeijiaokuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('diyashouxufeijiaokuanjine').Value:=ADOQuery_Select.FieldValues['公正交款金额'];
end;
Parameters.ParamByName('diyashouxufeijiaokuanjine').Value:=0;
//物业入住费用明细
if ADOQuery_Select.FieldValues['入住时间']=null then
begin
Parameters.ParamByName('wuyeruzhushijian').Value:='';
end
else
begin
Parameters.ParamByName('wuyeruzhushijian').Value:=ADOQuery_Select.FieldValues['入住时间'];
end;
if ADOQuery_Select.FieldValues['电费']=null then
begin
Parameters.ParamByName('wuyeruzhudianfei').Value:=0;
end
else
begin
Parameters.ParamByName('wuyeruzhudianfei').Value:=ADOQuery_Select.FieldValues['电费'];
end;
if ADOQuery_Select.FieldValues['取暖费']=null then
begin
Parameters.ParamByName('wuyeruzhuqunuanfei').Value:=0;
end
else
begin
Parameters.ParamByName('wuyeruzhuqunuanfei').Value:=ADOQuery_Select.FieldValues['取暖费'];
end;
//销售方
if ADOQuery_Select.FieldValues['销售方']=null then
begin
Parameters.ParamByName('xiaoshoufang').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshoufang').Value:=Trim(ADOQuery_Select.FieldValues['销售方']);
end;
if ADOQuery_Select.FieldValues['方式']=null then
begin
Parameters.ParamByName('xiaoshoufangshi').Value:='';
end
else
begin
Parameters.ParamByName('xiaoshoufangshi').Value:=Trim(ADOQuery_Select.FieldValues['方式']);
end;
//抵账信息
if ADOQuery_Select.FieldValues['抵账金额']=null then
begin
Parameters.ParamByName('dizhangjine').Value:=0;
end
else
begin
Parameters.ParamByName('dizhangjine').Value:=ADOQuery_Select.FieldValues['抵账金额'];
end;
if ADOQuery_Select.FieldValues['抵账日期']=null then
begin
Parameters.ParamByName('dizhangriqi').Value:='';
end
else
begin
Parameters.ParamByName('dizhangriqi').Value:=Trim(ADOQuery_Select.FieldValues['抵账日期']);
end;
if ADOQuery_Select.FieldValues['抵账人']=null then
begin
Parameters.ParamByName('dizhangren').Value:='';
end
else
begin
Parameters.ParamByName('dizhangren').Value:=Trim(ADOQuery_Select.FieldValues['抵账人']);
end;
if ADOQuery_Select.FieldValues['抵账公司']=null then
begin
Parameters.ParamByName('dizhanggongsi').Value:='';
end
else
begin
Parameters.ParamByName('dizhanggongsi').Value:=Trim(ADOQuery_Select.FieldValues['抵账公司']);
end;
//一次、二次、三次还款信息
if ADOQuery_Select.FieldValues['一次还款金额']=null then
begin
Parameters.ParamByName('yiciyinghuankuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('yiciyinghuankuanjine').Value:=ADOQuery_Select.FieldValues['一次还款金额'];
end;
if ADOQuery_Select.FieldValues['一次还款日期']=null then
begin
Parameters.ParamByName('yicihuankuanriqi').Value:='';
end
else
begin
Parameters.ParamByName('yicihuankuanriqi').Value:=Trim(ADOQuery_Select.FieldValues['一次还款日期']);
end;
if ADOQuery_Select.FieldValues['二次还款金额']=null then
begin
Parameters.ParamByName('erciyinghuankuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('erciyinghuankuanjine').Value:=ADOQuery_Select.FieldValues['二次还款金额'];
end;
if ADOQuery_Select.FieldValues['二次还款日期']=null then
begin
Parameters.ParamByName('ercihuankuanriqi').Value:='';
end
else
begin
Parameters.ParamByName('ercihuankuanriqi').Value:=Trim(ADOQuery_Select.FieldValues['二次还款日期']);
end;
if ADOQuery_Select.FieldValues['三次还款金额']=null then
begin
Parameters.ParamByName('sanciyinghuankuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('sanciyinghuankuanjine').Value:=ADOQuery_Select.FieldValues['三次还款金额'];
end;
if ADOQuery_Select.FieldValues['三次还款日期']=null then
begin
Parameters.ParamByName('sancihuankuanriqi').Value:='';
end
else
begin
Parameters.ParamByName('sancihuankuanriqi').Value:=Trim(ADOQuery_Select.FieldValues['三次还款日期']);
end;
Parameters.ParamByName('czy').Value:='001';
ExecSQL();
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
i:integer;
begin
with ADOQuery_Select_daikuan do
begin
Close;
SQL.Clear;
SQL.Add('select * from [00贷款] order by 代号');
Open;
end;
if ADOQuery_Select_daikuan.RecordCount>0 then
begin
ADOQuery_Select_daikuan.First;
for i:=1 to ADOQuery_Select_daikuan.RecordCount do
begin
with ADOQuery_update_daikuan do
begin
Close;
SQL.Clear;
SQL.Add('update S_xiaoshoujibenyixiang set daikuanjine=:daikuanjine,fangkuanri=:fangkuanri,'+
'fangkuanjine=:fangkuanjine,fangkuanyinhang=:fangkuanyinhang where fangjianhao=:fangjianhao');
if ADOQuery_Select_daikuan.FieldValues['贷款金额']=null then
begin
Parameters.ParamByName('daikuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('daikuanjine').Value:=ADOQuery_Select_daikuan.FieldValues['贷款金额'];
end;
if ADOQuery_Select_daikuan.FieldValues['放款日']=null then
begin
Parameters.ParamByName('fangkuanri').Value:='';
end
else
begin
Parameters.ParamByName('fangkuanri').Value:=Trim(ADOQuery_Select_daikuan.FieldValues['放款日']);
end;
if ADOQuery_Select_daikuan.FieldValues['放款金额']=null then
begin
Parameters.ParamByName('fangkuanjine').Value:=0;
end
else
begin
Parameters.ParamByName('fangkuanjine').Value:=ADOQuery_Select_daikuan.FieldValues['放款金额'];
end;
if ADOQuery_Select_daikuan.FieldValues['银行']=null then
begin
Parameters.ParamByName('fangkuanyinhang').Value:='';
end
else
begin
Parameters.ParamByName('fangkuanyinhang').Value:=Trim(ADOQuery_Select_daikuan.FieldValues['银行']);
end;
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select_daikuan.FieldValues['代号']);
ExecSQL();
ADOQuery_Select_daikuan.Next;
end;
end;
ShowMessage('更新成功!');
end;
end;
procedure TForm2.Button3Click(Sender: TObject);
var
i:integer;
begin
with ADOQuery_Select_daikuan do
begin
Close;
SQL.Clear;
SQL.Add('select * from [00台账] where 首付日期 is not null and 已交首付 is not null order by 代号');
Open;
end;
if ADOQuery_Select_daikuan.RecordCount>0 then
begin
ADOQuery_Select_daikuan.First;
for i:=1 to ADOQuery_Select_daikuan.RecordCount do
begin
with ADOQuery_update_daikuan do
begin
Close;
SQL.Clear;
SQL.Add('update S_xiaoshoujibenyixiang set xiaoshouriqi=:xiaoshouriqi where fangjianhao=:fangjianhao');
Parameters.ParamByName('xiaoshouriqi').Value:=Trim(ADOQuery_Select_daikuan.FieldValues['首付日期']);
Parameters.ParamByName('fangjianhao').Value:=Trim(ADOQuery_Select_daikuan.FieldValues['代号']);
ExecSQL();
ADOQuery_Select_daikuan.Next;
end;
end;
ShowMessage('更新成功!');
end;
end;
end.