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

📄 main.~pas

📁 程序示例自动创建配置文件
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
    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 + -