?? main.pas
字號:
end;
if recordcount<=0 then
begin
ShowMessage('無此用戶信息,請檢查月份、用戶編號、或用戶名稱是否正確');
exit;
end
else
begin
lid := TStringList.Create;
lrate := TStringList.Create;
llrd := TStringList.Create;
lcrd := TStringList.Create;
lamt := TStringList.Create;
lrpa := TStringList.Create;
lgaa :=TStringList.Create;
first;
while not eof do
begin
lid.Add(fieldbyname('電表編號').asstring);
lrate.Add(fieldbyname('倍率').asstring);
llrd.Add(fieldbyname('起碼').asstring);
lcrd.Add(fieldbyname('止碼').asstring);
lamt.Add(fieldbyname('差數').asstring);
gage_change := '0';
change_a := '0';
lrpa.Add(fieldbyname('有功加度').asstring);
lgaa.Add(fieldbyname('表量').asstring);
next;
end;
end;
except
showmessage('查詢期間出現錯誤,請檢查月份是否正確且數據庫聯接正確。');
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
str:string;
i:integer;
begin
if (qry1.active=false) or (qry1.RecordCount<=0) then
begin
showmessage('請確認已查詢且查詢結果不為空.');
exit;
end;
with qry11 do
try
close;
sql.Clear;
sql.Add('select charge_time from charge_detail where user_id='''+id+''' and fee_month='''+month+''' and fact_fee>0');
open;
if recordcount>0 then
begin
str := '此用戶已在';
for i:=1 to recordcount do
str := str + fieldbyname('charge_time').asstring +' ';
str := str + '交費,請先沖帳再修改。';
exit;
end;
close;
sql.clear;
sql.add('select user_id from user_info where user_id='''+id+''' and fee_month='''+month+'''');
open;
if recordcount>0 then
begin
str := 'update user_info set user_name='''+nam+''',user_name_py='''+namepy+''',charge_id='''+id+''','+
'power_addr='''+addr+''',power_addr_py='''+addrpy+''',line_name='''+lname+''','+
'station_name='''+sname+''',tran_name='''+tname+''',tran_pos='''+pos+''',bank_name='''+bname+''','+
'life_only='''+only+''',item_added1='''+added1+''',item_added2='''+added2+''',item_added3='''+added3+''','+
'item_added4='''+added4+''' '+'where fee_month='''+month+''' and user_id='''+id+'''';
cm1.CommandText := str;
cm1.execute;
end
else
begin
str := 'insert user_info values('''+month+''','''+id+''','''+nam+''','''+namepy+''','''+cid+''','''+addr+''','''+
addrpy+''','''+'null'+''','''+'0'+''','''+lname+''','''+sname+''','''+tname+''','''+'0'+''','''+pos+''','''+
bname+''','''+'0'+''','''+only+''','''+'0'+''','''+added1+''','''+added2+''','''+added3+''','''+added4+''','''+
'null'+''','''+'0'+''','''+'0'+''','''+'0'+''')';
cm1.CommandText := str;
cm1.Execute;
end;
except
showmessage('無法打開數據庫。');
end;
with qry22 do
try
if CheckBox1.Checked then term := formatdatetime('yyyymmdd',dtp2.DateTime);
close;
sql.clear;
sql.add('select user_id from user_dldf where fee_month='''+month+''' and user_id='''+id+'''');
open;
if recordcount>0 then
begin
str := 'update user_dldf set charge_term='''+term+''',sum_a='''+sum_a+''',repair_f='''+repair_f+''','+
'base_fee='''+base_fee+''',cos_fee='''+cos_fee+''',tran_lose_a='''+tran_lose_a+''',tran_lose_f='''+
tran_lose_f+''',life_a='''+life_a+''',life_p='''+life_p+''',life_f='''+life_f+''',ind_a='''+
ind_a+''',ind_p='''+ind_p+''',ind_f='''+ind_f+''',hind_a='''+hind_a+''',hind_p='''+hind_p+''','+
'hind_f='''+hind_f+''',other2_f='''+other2_f+''',sum_f='''+sum_f+''',should_charge='''+should_charge+
''',fact_charge='''+'0'+''',fact_latefee='''+'0'+''',derate_latefee='''+'0'+''' where fee_month='''+
month+''' and user_id='''+id+'''';
cm1.CommandText := str;
cm1.Execute;
end
else
begin
str := 'insert user_dldf values('''+month+''','''+id+''','''+term+''','''+'0'+''','''+sum_a+''','''+'0'+''','''+
repair_f+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+
'0'+''','''+'0'+''','''+base_fee+''','''+'0'+''','''+cos_fee+''','''+tran_lose_a+''','''+
tran_lose_f+''','''+life_a+''','''+life_p+''','''+life_f+''','''+'0'+''','''+'0'+''','''+
'0'+''','''+ind_a+''','''+ind_p+''','''+ind_f+''','''+'0'+''','''+'0'+''','''+'0'+''','''+
'0'+''','''+'0'+''','''+'0'+''','''+hind_a+''','''+hind_p+''','''+hind_f+''','''+'0'+''','''+
'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+
'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+other2_f+''','''+'0'+''','''+
'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+
'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+
'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+sum_f+''','''+
'0'+''','''+'0'+''','''+should_charge+''','''+'0'+''','''+'0'+''','''+'0'+''','''+'0'+''','''+
'0'+''','''+'0'+''','''+'0'+''','''+'0'+''')';
// e.Text :=str;
// e.SelectAll;
// e.CopyToClipboard;
cm1.CommandText := str;
cm1.Execute;
end;
except
showmessage('無法打開數據庫。');
end;
with qry33 do
try
for i:=0 to lid.Count-1 do
begin
close;
sql.clear;
str := 'select gage_id from user_gage_reading where fee_month='''+month+''' and user_id='''+id+''' and gage_id='''+lid[i]+'''';
sql.Text := str;
open;
if recordcount>0 then
begin
str := 'update user_gage_reading set gage_rate='''+lrate[0]+''',last_read='''+llrd[i]+''',cur_read='''+
lcrd[i]+''',read_amount='''+lamt[i]+''',repair_a='''+lrpa[i]+''',gage_a='''+lgaa[i]+''''+
' where fee_month='''+month+''' and user_id='''+id+''' and gage_id='''+lid[i]+'''';
cm1.CommandText := str;
cm1.Execute;
end
else
begin
str := 'insert user_gage_reading values('''+month+''','''+id+''','''+lid[i]+''','''+lrate[i]+''','''+
'0'+''','''+'0'+''','''+llrd[i]+''','''+lcrd[i]+''','''+lamt[i]+''','''+'0'+''','''+'0'+''','''+'0'+''','''+
'0'+''','''+lrpa[i]+''','''+lgaa[i]+''','''+'0'+''')';
cm1.CommandText := str;
cm1.Execute;
end;
end;
except
showmessage('無法打開數據庫。');
end;
str := 'update user_dldf set user_dldf.remain_last=b.remain_cur,fact_charge=case sign(b.remain_cur-user_dldf.should_charge) when -1 '+
'then b.remain_cur when 0 then b.remain_cur when 1 then b.should_charge end,user_dldf.remain_cur=case sign(b.remain_cur-user_dldf.should_charge) '+
'when -1 then 0 when 0 then 0 when 1 then b.remain_cur-user_dldf.should_charge end from user_dldf,user_dldf b '+
'where user_dldf.user_id=b.user_id and b.fee_month='''+caldate(month,-1)+''' and user_dldf.fee_month='''+month+''' and b.remain_cur>0 '+
'and user_dldf.user_id='''+id+'''';
cm1.CommandText := str;
cm1.Execute;
try
except
showmessage('無法更新余額。')
end;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked=true then
dtp2.Visible := true
else
dtp2.Visible := false;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
lid.Free;
lrate.Free;
llrd.Free;
lcrd.Free;
lamt.Free;
lrpa.Free;
lgaa.Free;
action := cafree;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
inif:TInifile;
begin
// if not Fileexists('dsf.ini') then
// createfile(pchar('Dsf.ini'),GENERIC_WRITE,0,nil,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,0);
inif := TInifile.Create(ExtractFilePath(Paramstr(0))+'Dsf.ini');
cmis := inif.ReadString('conndb','connmis','');
repeat
try
connmis.ConnectionString := cmis;
connmis.CommandTimeout := 10;
connmis.Connected := true;
except
if application.MessageBox('無法連接MIS數據庫,是否用向導進行配置?','系統提示',MB_OKCANCEL+MB_ICONQUESTION+ MB_DEFBUTTON1)=idok then
begin
cmis := PromptDataSource(0,'');
inif.WriteString('conndb','connmis',cmis);
end
else
begin
ShowMessage('Plieae set the connect string in Dsf.ini and restart this program.');
inif.Free;
Application.Terminate;
end;
end;
until connmis.Connected = true;
cyd := inif.ReadString('conndb','connyd','');
repeat
try
connyd.ConnectionString := cyd;
connyd.CommandTimeout := 10;
connyd.Connected := true;
except
if application.MessageBox('無法連接聯網收費數據庫,是否用向導進行配置?','系統提示',MB_OKCANCEL+MB_ICONQUESTION+ MB_DEFBUTTON1)=idok then
begin
cyd := PromptDataSource(0,'');
inif.WriteString('conndb','connyd',cmis);
end
else
begin
inif.free;
ShowMessage('Plieae set the connect string in Dsf.ini and restart this program.');
Application.Terminate;
end;
end;
until connyd.Connected = true;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
createfile(pchar('Dsf.ini'),GENERIC_WRITE,0,nil,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,0);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -