📄 selectdata.pas
字号:
Form3.DBGrid1.Canvas.Brush.Color:=clmoneygreen ;
end;
Form3.DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
procedure TForm3.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
tmpp:=combobox1.Text;
end;
procedure TForm3.ComboBox2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
tmpp:=combobox2.Text;
end;
procedure TForm3.ComboBox3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
tmpp:=combobox3.Text;
end;
procedure TForm3.ComboBox4KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
tmpp:=combobox4.Text;
end;
procedure TForm3.ComboBox5KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
tmpp:=combobox5.Text;
end;
procedure TForm3.ComboBox6KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
tmpp:=combobox6.Text;
end;
procedure TForm3.SpeedButton3Click(Sender: TObject);
var
bExcelvisible:boolean;
i,j,k:integer;
titlestr,fvalue,dispstr,filedna:string;
ch:char;
count:integer;
A:array of integer; //输出列到excel中
begin
{if (combobox1.Text='上报到法院') then
begin
if application.MessageBox('上报到法院的记录进行司法标志,如果确认,数据将不能更改!','提示',MB_okcancel)=0 then exit;
while not form1.Query1.Eof do
begin
form1.tempquery.Close;
form1.tempquery.SQL.Clear;
form1.tempquery.SQL.Add('update wf_zl_info');
form1.tempquery.SQL.Add('SET SFBZ='''+'Y'+'''');
form1.tempquery.SQL.Add('where TZSHM=:p1 and CFQR=:p2');
form1.tempquery.ParamByName('p1').AsString:=form1.Query1['TZSHM'];
form1.tempquery.ParamByName('p2').AsString:='N';
form1.tempquery.ExecSQL;
form1.Query1.Next;
end;
end; }
if application.MessageBox('是否输出到EXCEL中','提示',MB_OKcancel)<>1 then exit;
// if checkbox1.Checked=true then
if form1.Query1.Active<>true then begin application.MessageBox('未进行查询','错误提示',MB_OK);exit;end;
{if application.MessageBox('启动Excel界面吗?','请回答',MB_YESNO+MB_DEFBUTTON2)<>IDNO then
bExcelvisible:=true
else }
bExcelvisible:=false;
try
Excelapplication1.Connect;
except
application.MessageBox('Excel可能未安装','提示',MB_OK);
abort;
end;
excelapplication1.Caption:='从数据库中导出的数据';
excelapplication1.Workbooks.Add(null,0);
excelworkbook1.ConnectTo(excelapplication1.Workbooks[1]);
if bexcelvisible=true then
excelapplication1.visible[0]:=true;
//add one page
{try
excelworkbook1.Worksheets.Add(null,excelworkbook1.Worksheets[excelworkbook1.Worksheets.Count],null,null,0);
except
application.MessageBox('创建EXCEL新页失败','错误提示',MB_OK);
exit;
end; }
excelworksheet1.ConnectTo(excelworkbook1.Worksheets[1]as _worksheet);
// page modify
excelworksheet1.Range['A1','E1'].Merge(true);
excelworksheet1.Range['A1','D2'].HorizontalAlignment:=$FFFFEFF4;
excelworksheet1.Cells.Item[1,1].value:='长沙市人行道汽车违章停车抄牌数据';
i:=2;
count:=form1.Query1.FieldDefs.Count;
setlength(A,count);//分配动态数给长度
for j:=0 to (count-1) do
begin
A[j]:=0; //初始化数组
///////////////////////////////分配显示列到Excel中
if (OKBottomDlg1.checkbox1.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='WFSJ') then A[j]:=1;
if (OKBottomDlg1.checkbox2.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='ZFBM') then A[j]:=1;
if (OKBottomDlg1.checkbox3.Checked=true) and (form1.Query1.Fields[j].DisplayLabel='ZXR')then A[j]:=1;
if (OKBottomDlg1.checkbox4.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='CFFS') then A[j]:=1;
if (OKBottomDlg1.checkbox5.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='WFSY') then A[j]:=1;
if (OKBottomDlg1.checkbox6.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='WFDD') then A[j]:=1;
if (OKBottomDlg1.checkbox7.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='SFJE') then A[j]:=1;
if (OKBottomDlg1.checkbox8.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='CFSJ') then A[j]:=1;
if (OKBottomDlg1.checkbox9.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='SPR') then A[j]:=1;
if (OKBottomDlg1.checkbox11.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='TZSHM') then A[j]:=1;
if (OKBottomDlg1.checkbox12.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='CPHM')then A[j]:=1;
if (OKBottomDlg1.checkbox13.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='CLLX')then A[j]:=1;
if (OKBottomDlg1.checkbox14.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='ZCCFSJ') then A[j]:=1;
if (OKBottomDlg1.checkbox15.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='CFJE') then A[j]:=1;
if (OKBottomDlg1.checkbox16.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='DSR') then A[j]:=1;
if (OKBottomDlg1.checkbox17.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='ZLBC') then A[j]:=1;
if (OKBottomDlg1.checkbox18.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='CFJDSBM') then A[j]:=1;
if (OKBottomDlg1.checkbox19.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='BZ') then A[j]:=1;
if (OKBottomDlg1.checkbox20.Checked=true)and (form1.Query1.Fields[j].DisplayLabel='CFQR') then A[j]:=1;
end;
////////////////////////////////////
k:=1;
for j:=0 to count-1 do
begin
if A[j]=0 then continue;
if (form1.Query1.Fields[j].DisplayLabel='WFSJ') then filedna:='违章时间';
if (form1.Query1.Fields[j].DisplayLabel='ZFBM') then filedna:='执法中队名称';
if (form1.Query1.Fields[j].DisplayLabel='ZXR') then filedna:='执法队员';
if (form1.Query1.Fields[j].DisplayLabel='CFFS') then filedna:='处罚方式';
if (form1.Query1.Fields[j].DisplayLabel='WFSY') then filedna:='违章事由';
if (form1.Query1.Fields[j].DisplayLabel='WFDD') then filedna:='违章地点';
if (form1.Query1.Fields[j].DisplayLabel='SFJE') then filedna:='实罚金额';
if (form1.Query1.Fields[j].DisplayLabel='CFSJ') then filedna:='处罚时间';
if (form1.Query1.Fields[j].DisplayLabel='SPR') then filedna:='审批领导';
if (form1.Query1.Fields[j].DisplayLabel='TZSHM') then filedna:='陈述通知书编号';
if (form1.Query1.Fields[j].DisplayLabel='CPHM') then filedna:='车牌号码';
if (form1.Query1.Fields[j].DisplayLabel='CLLX') then filedna:='车辆类型';
if (form1.Query1.Fields[j].DisplayLabel='ZCCFSJ') then filedna:='最迟有效时间';
if (form1.Query1.Fields[j].DisplayLabel='CFJE') then filedna:='处罚金额';
if (form1.Query1.Fields[j].DisplayLabel='DSR') then filedna:='当事人';
if (form1.Query1.Fields[j].DisplayLabel='ZLBC') then filedna:='资料完整性';
if (form1.Query1.Fields[j].DisplayLabel='CFJDSBM') then filedna:= '处罚决定书编号';
if (form1.Query1.Fields[j].DisplayLabel='BZ') then filedna:='备注';
if (form1.Query1.Fields[j].DisplayLabel='CFQR') then filedna:='处罚情况';
// 设置标 题字体颜色
excelworksheet1.Cells.Item[i,k].value:=filedna;
excelworksheet1.Cells.Item[i,k].Font.Color:=clblue;
//excelworksheet1.Cells.Item[1,k].Color:=clskyblue;
inc(k);
end;
excelworksheet1.Range['A1','D1'].Font.Color:=clskyblue;
excelworksheet1.Range['A1','D1'].Font.Name:='隶书';
excelworksheet1.Range['A1','D1'].Font.Size:=18;
form1.Query1.First;
i:=0;
while not form1.Query1.Eof do
begin
k:=0;
for j:=0 to form1.Query1.FieldDefs.Count-1 do
begin
if (form1.Query1.Fields[j].FieldKind=fkCalculated) then continue;
if A[j]=0 then continue;
dispstr:=form1.Query1.Fields[j].AsString;
if j=0 then dispstr:='No:'+dispstr;
if dispstr='Y' then dispstr:='已接受处罚';
if dispstr='N' then dispstr:='没有接受处罚';
excelworksheet1.Cells.Item[i+3,k+1].value:=dispstr;
inc(k);
end;
form1.Query1.next;
inc(i);
end;
if bexcelvisible=false then
begin
if savedialog1.Execute then
begin
try
excelworksheet1.SaveAs(savedialog1.FileName);
application.MessageBox('保存成功','提示',MB_OK);
except
application.MessageBox('保存失败','提示',MB_OK);
end;
end;
excelapplication1.Disconnect;
excelapplication1.Quit;
end;
end;
procedure TForm3.DBGrid1DblClick(Sender: TObject);
begin
IF form1.Query1.Active<>true then exit;
{ if combobox1.Text='材料情况' then
begin
if (form1.Query1['zlbc']='不全') then
if application.MessageBox(pchar('是否将此记录置为资料完整状态,陈述通知书编号为:'+trim(form1.Query1['TZSHM'])),'提示',MB_OKCANCEL)=1 then
begin
form1.tempquery.Close;
form1.tempquery.SQL.Clear;
form1.tempquery.SQL.Add('update wf_zl_info');
form1.tempquery.SQL.Add('SET zlbc='''+'完整'+'''');
form1.tempquery.SQL.Add('where TZSHM=:p1 and zlbc=:p2');
form1.tempquery.ParamByName('p1').AsString:=form1.Query1['TZSHM'];
form1.tempquery.ParamByName('p2').AsString:='不全';
form1.tempquery.ExecSQL;
form1.Query1.Active:=false;
form1.Query1.Active:=true;
end;
if (form1.Query1['zlbc']='完整')and (form1.Query1['scbz']='Y') then
begin
application.MessageBox(pchar('此记录以完整的资料,已经上传,此记录不能再修改,陈述通知书编号为:'+trim(form1.Query1['TZSHM'])),'提示',MB_OKCANCEL);
exit;
end;
if (form1.Query1['zlbc']='完整')and (form1.Query1['scbz']='N') then
if application.MessageBox(pchar('是否将此记录置为资料不全状态,陈述通知书编号为:'+trim(form1.Query1['TZSHM'])),'提示',MB_OKCANCEL)=1 then
begin
form1.tempquery.Close;
form1.tempquery.SQL.Clear;
form1.tempquery.SQL.Add('update wf_zl_info');
form1.tempquery.SQL.Add('SET zlbc='''+'不全'+'''');
form1.tempquery.SQL.Add('where TZSHM=:p1 and zlbc=:p2');
form1.tempquery.ParamByName('p1').AsString:=form1.Query1['TZSHM'];
form1.tempquery.ParamByName('p2').AsString:='完整';
form1.tempquery.ExecSQL;
form1.Query1.Active:=false;
form1.Query1.Active:=true;
end;
end; }
{if (form1.Query1['CFQR']='N') and (form1.Query1['SFBZ']='N') then
if application.MessageBox(pchar('是否将此记录置为司法状态,陈述通知书编号为:'+trim(form1.Query1['TZSHM'])),'提示',MB_OKCANCEL)=1 then
begin
form1.tempquery.Close;
form1.tempquery.SQL.Clear;
form1.tempquery.SQL.Add('update wf_zl_info');
form1.tempquery.SQL.Add('SET SFBZ='''+'Y'+'''');
form1.tempquery.SQL.Add('where TZSHM=:p1 and CFQR=:p2');
form1.tempquery.ParamByName('p1').AsString:=form1.Query1['TZSHM'];
form1.tempquery.ParamByName('p2').AsString:='N';
form1.tempquery.ExecSQL;
form1.Query1.Active:=false;
form1.Query1.Active:=true;
end;
if (form1.Query1['CFQR']='N') and (form1.Query1['SFBZ']='Y') then
if application.MessageBox(pchar('是否将此记录解除司法状态,陈述通知书编号为:'+trim(form1.Query1['TZSHM'])),'提示',MB_OKCANCEL)=1 then
begin
form1.tempquery.Close;
form1.tempquery.SQL.Clear;
form1.tempquery.SQL.Add('update wf_zl_info');
form1.tempquery.SQL.Add('SET SFBZ='''+'N'+'''');
form1.tempquery.SQL.Add('where TZSHM=:p1 and CFQR=:p2');
form1.tempquery.ParamByName('p1').AsString:=form1.Query1['TZSHM'];
form1.tempquery.ParamByName('p2').AsString:='N';
form1.tempquery.ExecSQL;
form1.Query1.Active:=false;
form1.Query1.Active:=true;
end; }
end;
procedure TForm3.CheckBox5Click(Sender: TObject);
begin
if checkbox5.Checked then
combobox10.Visible:=true
else
combobox10.visible:=false;
end;
procedure TForm3.combobox10KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
tmpp:=combobox10.Text;
end;
procedure TForm3.combobox10Change(Sender: TObject);
var
i:integer;
begin
i:=0;
while i<combobox10.Items.Count do
begin
if combobox10.Text=combobox10.Items[i] then
break;
inc(i);
end;
if i>=combobox10.Items.Count then begin application.MessageBox('条件选择不对','提示',mb_ok);combobox10.Text:=tmpp;combobox10.SetFocus;exit; end;
end;
procedure TForm3.CheckBox6Click(Sender: TObject);
begin
if form3.CheckBox6.Checked then
form3.GroupBox7.Visible:=true
else
form3.GroupBox7.Visible:=false;
end;
procedure TForm3.ComboBox7KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
tmpp:=combobox7.Text;
end;
procedure TForm3.ComboBox7Change(Sender: TObject);
begin
i:=0;
while i<combobox7.Items.Count do
begin
if combobox7.Text=combobox7.Items[i] then
break;
inc(i);
end;
if i>=combobox7.Items.Count then begin application.MessageBox('属性值选择不对','提示',mb_ok);combobox7.Text:=tmpp;combobox7.SetFocus;exit; end;
end;
procedure TForm3.SpeedButton5Click(Sender: TObject);
begin
OKBottomDlg.show;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -