ListView 读取和写入

//两个函数系项目中直接截取,自己对变量进行理解

procedure TFrmMenu2wz.btnSelectClick(Sender: TObject);//查询数据库后写入listview
var
  sqlSelect: string;
  wzInfoList: ArrayOfDcBean;
  wzInfo: ArrayOfDcObj;
  i, j: Integer;
  tmpListItem: TListItem;
begin
  inherited;

  sqlSelect := 'select pwz.checkdate as ckrq,10000 as ckdw,' //0 ckrq 1 ckdw
    + ' pwz.checkplace as ckdd,  pwz.holdinfo as zkzj,  pwz.endcasetype dqzt, '
    + ' 10000 as cljg,' // 2 ckdd  3 zkzj 4  dqzt 5 cljg 6 ah 7 cphm 8 cpys  9 yhmc 10 cllxxl 11 cljxxl 12 cljyfwxl
    + ' pwz.id as ah, bcl.vehnumcode as cphm,getDtrinfo(bcl.vehnumcolor) as cpys,byh.CoName as yhmc,'
    + ' getDtrinfo(bcl.vehtype) as cllxxl, getDtrinfo(bcl.vehlevel) cljxxl,'
    + ' getDtrinfo(bcl.workrange2) as cljyfwxl,acyry.name as cyryxm,acyry.certcardid as cyzgzh ,'
    + ' acyry.idcard as sfzh,acyry.telno as lxfs,pwz.peccinfo as wzyy, ec.remark as bz '
    + ' from Tbl_pecc_peccinfo pwz' // 13 cyryxm 14 cyzgzh 15 sfzh 16 lxfs 17 wzyy 18 bz
    + ' left join Tbl_veh_baseinfo bcl on pwz.vehid=bcl.id and pwz.vehid is not null and bcl.id is not null  '
//    + ' left join Tbl_pecc_peccaction pwzxw on pwz.id=pwzxw.peccid and pwz.id is not null and pwzxw.peccid is not null   '
  + ' left join tbl_co_BaseInfo byh on bcl.coid=byh.id and bcl.coid is not null and bcl.coid is not null '
    + ' left join tbl_Train_Archives acyry on acyry.certcardid=pwz.cyrycard and acyry.certcardid is not null and pwz.cyrycard is not null'
    + ' left join  tbl_Pecc_EndCase ec on ec.id=pwz.id and ec.id is not null where 1=1 ';

  lv1.Clear;
  wzInfoList := WebService.GetWebServiceWzxx(sqlSelect);//获取数据集
  lblSum.Caption := IntToStr(Length(wzInfoList));
  if wzInfoList = nil then
  begin
    ShowMessage('查无违章信息!');
    Exit;
  end;
  for i := 0 to Length(wzInfoList) - 1 do //遍历对象中的多有行
  begin
    wzInfo := wzInfoList[i].objArray;//取出一行记录
//    ShowMessage(IntToStr(Length(wzInfo))); //目前为20列信息
    tmpListItem := lv1.Items.Add;//定位行的关键
    tmpListItem.Caption := Trim(wzInfo[7].value); //7 cphm 车牌号码
    tmpListItem.SubItems.Add(Trim(wzInfo[8].value)); //8 cpys 车牌颜色
    tmpListItem.SubItems.Add(Trim(wzInfo[9].value)); //9 yhmc业户名称
    tmpListItem.SubItems.Add(Trim(wzInfo[0].value)); //0 ckrq 查扣日期
    tmpListItem.SubItems.Add(Trim(wzInfo[17].value)); //17 wzyy违章原因


    //当前状态显示       4  dqzt 当前状态
    if Trim(wzInfo[4].value) = '0' then
    begin
      tmpListItem.SubItems.Add(Trim('未结案'));
    end else if Trim(wzInfo[4].value) = '1' then
    begin
      tmpListItem.SubItems.Add(Trim('正常结案'));
    end else if Trim(wzInfo[4].value) = '2' then
    begin
      tmpListItem.SubItems.Add(Trim('免交罚款'));
    end else
    begin
      tmpListItem.SubItems.Add(Trim(wzInfo[4].value));
    end;
    tmpListItem.SubItems.Add(Trim(wzInfo[5].value)); //5 cljg 处理结果
    tmpListItem.SubItems.Add(Trim(wzInfo[1].value)); //1 ckdw 查扣单位
    tmpListItem.SubItems.Add(Trim(wzInfo[2].value)); //2 ckdd 查扣地点
    tmpListItem.SubItems.Add(Trim(wzInfo[3].value)); //3 zkzj 暂扣证件
    tmpListItem.SubItems.Add(Trim(wzInfo[6].value)); //6 ah 案件编号
    tmpListItem.SubItems.Add(Trim(wzInfo[10].value)); //10 cllxxl 车辆类型小类
    tmpListItem.SubItems.Add(Trim(wzInfo[11].value)); // 11 cljxxl 车辆级型小类
    tmpListItem.SubItems.Add(Trim(wzInfo[12].value)); //12 cljyfwxl 车辆经营范围小类
    tmpListItem.SubItems.Add(Trim(wzInfo[13].value)); //13 cyryxm 从业人员姓名
    tmpListItem.SubItems.Add(Trim(wzInfo[14].value)); //14 cyzgzh 从业资格证号
    tmpListItem.SubItems.Add(Trim(wzInfo[15].value)); // 15 sfzh 身份证号
    tmpListItem.SubItems.Add(Trim(wzInfo[16].value)); //16 lxfs 联系方式
    tmpListItem.SubItems.Add(Trim(wzInfo[18].value)); // 18 bz 备注
//    tmpListItem.SubItems.Add(Trim(wzInfo[19].value));
//        tmpListItem.SubItems.Add(Trim(wzInfo[20].value));
    //Application.ProcessMessages;
  end;
end;

 

//listview中信息读取 此处是用于双击显示

procedure TFrmMenu2wz.lv1DblClick(Sender: TObject);
begin
  FrmMenu2wzXq := TFrmMenu2wzXq.Create(Self);
  try
    if lv1.Selected<>nil then //判断记录是否选中
    begin
      with FrmMenu2wzXq do
      begin
        edtCpxx.Text := lv1.Selected.Caption + Trim(lv1.Selected.SubItems[0]);
        edtCllxxl.Text := Trim(lv1.Selected.SubItems[10]);
        edtCljxxl.Text := Trim(lv1.Selected.SubItems[11]);
        edtJyfwxl.Text := Trim(lv1.Selected.SubItems[12]);
        edtYhmc.Text := Trim(lv1.Selected.SubItems[1]);
        edtDsrxm.Text := Trim(lv1.Selected.SubItems[13]);
        edtZgzh.Text := Trim(lv1.Selected.SubItems[14]);
        edtSfzh.Text := Trim(lv1.Selected.SubItems[15]);
        edtLxfs.Text := Trim(lv1.Selected.SubItems[16]);
        edtAh.Text := Trim(lv1.Selected.SubItems[9]);
        edtWzyy.Text := Trim(lv1.Selected.SubItems[3]);
        edtZkzj.Text := Trim(lv1.Selected.SubItems[8]);
        edtCkrq.Text := Trim(lv1.Selected.SubItems[2]);
        edtCkdw.Text := Trim(lv1.Selected.SubItems[6]);
        edtCkdd.Text := Trim(lv1.Selected.SubItems[7]);
        edtDqzt.Text := Trim(lv1.Selected.SubItems[4]);
        edtCljg.Text := Trim(lv1.Selected.SubItems[5]);
        mmoBz.Text := Trim(lv1.Selected.SubItems[17]);

      end;
    end else
    begin
      ShowMessage('请先选中记录!');
      Exit;
    end;

    FrmMenu2wzXq.ShowModal;
  finally
    FrmMenu2wzXq.Free;
  end;
end;


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值