tradeoutputunit.~pas
来自「公交行业的管理系统」· ~PAS 代码 · 共 1,570 行 · 第 1/5 页
~PAS
1,570 行
if ComboBox2.Text='' then
begin
showmessage('对不起!"终止年份"不能为空!请重新选择条件!');
exit;
end;
if (Length(ComboBox1.Text)<>4) or ((Length(ComboBox2.Text)<>4)) then
begin
showmessage('对不起!您选择的年份非法!请重新选择!');
exit;
end;
try
temp:=StrToInt(ComboBox1.Text);
except
showmessage('起始年份非法!请重新选择!');
exit;
end;
try
temp:=StrToInt(ComboBox2.Text);
except
showmessage('终止年份非法!请重新选择!');
exit;
end;
if (StrToInt(ComboBox1.Text)<1900) or (StrToInt(ComboBox1.Text)>3000) then
begin
showmessage('对不起!您选择的"起始年份"非法!请重新选择!');
exit;
end;
if (StrToInt(ComboBox2.Text)<1900) or (StrToInt(ComboBox2.Text)>3000) then
begin
showmessage('对不起!您选择的"终止年份"非法!请重新选择!');
exit;
end;
if ComboBox3.Text='' then
begin
showmessage('对不起!"起始月份"不能为空!请重新选择条件!');
exit;
end;
if ComboBox4.Text='' then
begin
showmessage('对不起!"终止月份"不能为空!请重新选择条件!');
exit;
end;
{if (not CheckFileSuc) or (Edit1.Text='')then
begin
showmessage('请选择导出文件!');
exit;
end;}
if StrToInt(ComboBox1.Text)>StrToInt(ComboBox2.Text) then
begin
showmessage('对不起!"起始年份"不能大于"终止年份"!请重新选择条件!');
exit;
end;
if StrToInt(ComboBox3.Text)>StrToInt(ComboBox4.Text) then
begin
showmessage('对不起!"起始月份"不能大于"终止月份"!请重新选择条件!');
exit;
end;
try
Screen.Cursor:=crHourGlass;
TableToTableMonth('gjmonth.data','公交企业统计月报表');
if judge=false then StrToInt('sf');
TableToTableMonth('gjmonth_z.data','公交企业统计月报表_z');
if judge=false then StrToInt('sf');
showmessage('公交企业统计月报数据导出成功!');
RichEdit1.Lines.Add('公交企业统计月报表导出成功');
except
showmessage('数据导出失败!');
RichEdit1.Lines.Add('公交企业统计月报表导出失败');
end;
Screen.Cursor:=crDefault;
end;
procedure TTradeOutputFrm.TableToTableMonth(src:string;srcdata:string);
var
SrcQuery:TADOQuery;
curPath:string;
i,j:integer;
begin
if(copy(edit1.text,Length(edit1.text),1)='\')then
curPath:=pchar(edit1.text+src) else
curPath:=pchar(edit1.text+'\'+src);
CopyFile(pchar(extractFilePath(application.ExeName)+'ImOutDir\'+src),pchar(curPath),false);
ClientDataSet1.Close;
ClientDataSet1.LoadFromFile(curPath);
try
ClientDataSet1.Open;
except
MessageBox(self.Handle,PCHAR(srcdata+'不能被导入,请检查导入文件'+src+'是否存在或格式是否正确。'),pchar('消息'),MB_OK);
exit;
end;
SrcQuery:=TADOQuery.create(self);
SrcQuery.Connection:=BusTradeDataModule.ADOConnection1;
if Edit2.Text<>'' then
SrcQuery.SQL.Add('select * from '+srcdata+' where 企业代码 in '+Epr_Select.TotalEpr
+' and 统计年份>='+ComboBox1.text+' and 统计年份<='+ComboBox2.Text
+' and 统计月份>='+ComboBox3.text+' and 统计月份<='+ComboBox4.text)
else
SrcQuery.SQL.Add('select * from '+srcdata+' where 统计年份>='+ComboBox1.text+
' and 统计年份<='+ComboBox2.Text+
' and 统计月份>='+ComboBox3.text+' and 统计月份<='+ComboBox4.text);
SrcQuery.Open;
if (SrcQuery.RecordCount=0) then
begin
showmessage('导出的源数据库没有所需数据!');
judge:=false;
exit;
end;
SrcQuery.First;
while not SrcQuery.Eof do
begin
ClientDataSet1.Append;
for i:=0 to ClientDataSet1.FieldCount-1 do
for j:=0 to SrcQuery.FieldCount-1 do
if(ClientDataSet1.Fields[i].FieldName=SrcQuery.Fields[j].FieldName)then
begin
if(ClientDataSet1.Fields[i].FieldName<>'ID')then
begin
ClientDataSet1.Fields[i].Value:=SrcQuery.Fields[j].Value;
break;
end;
end;
ClientDataSet1.Post;
SrcQuery.Next;
end;
ClientDataSet1.SaveToFile(curPath);
judge:=true;
end;
procedure TTradeOutputFrm.TableToTableEpr(src:string;srcdata:string);
var
SrcQuery,DesQuery:TADOQuery;
i,j:integer;
curPath:string;
begin
if(copy(edit1.text,Length(edit1.text),1)='\')then
curPath:=pchar(edit1.text+src) else
curPath:=pchar(edit1.text+'\'+src);
CopyFile(pchar(extractFilePath(application.ExeName)+'ImOutDir\'+src),pchar(curPath),false);
ClientDataSet1.Close;
ClientDataSet1.LoadFromFile(curPath);
try
ClientDataSet1.Open;
except
MessageBox(self.Handle,PCHAR(srcdata+'不能被导入,请检查导入文件'+src+'是否存在或格式是否正确。'),pchar('消息'),MB_OK);
exit;
end;
SrcQuery:=TADOQuery.create(self);
SrcQuery.Connection:=BusTradeDataModule.ADOConnection1;
if Edit4.Text<>'' then
SrcQuery.SQL.Add('select * from '+srcdata+' where 单位代码 in '+ Epr_Select.TotalEpr+ ' and 统计年份>='+ComboBox7.Text
+' and 统计年份<='+ComboBox8.Text)
else
SrcQuery.SQL.Add('select * from '+srcdata+' where 统计年份>='+ComboBox7.Text
+' and 统计年份<='+ComboBox8.Text);
SrcQuery.Open;
if (SrcQuery.RecordCount=0) then
begin
showmessage('导出的源数据库没有所需数据!');
judge:=false;
exit;
end;
SrcQuery.First;
while not SrcQuery.Eof do
begin
ClientDataSet1.Append;
for i:=0 to ClientDataSet1.FieldCount-1 do
for j:=0 to SrcQuery.FieldCount-1 do
if(ClientDataSet1.Fields[i].FieldName=SrcQuery.Fields[j].FieldName)then
begin
if(ClientDataSet1.Fields[i].FieldName<>'ID')then
begin
ClientDataSet1.Fields[i].Value:=SrcQuery.Fields[j].Value;
break;
end;
end;
ClientDataSet1.Post;
SrcQuery.Next;
end;
ClientDataSet1.SaveToFile(curPath);
judge:=true;
end;
procedure TTradeOutputFrm.BitBtn8Click(Sender: TObject);
begin
judge:=true;
{if(not CheckFileSuc)then
begin
showmessage('请选择导出文件!');
exit;
end; }
if ComboBox5.Text='' then
begin
showmessage('对不起!"起始年份"不能为空!请重新选择条件!');
exit;
end;
if ComboBox6.Text='' then
begin
showmessage('对不起!"终止年份"不能为空!请重新选择条件!');
exit;
end;
if (Length(ComboBox5.Text)<>4) or (Length(ComboBox6.Text)<>4) then
begin
showmessage('对不起!您选择的年份非法!请重新选择!');
exit;
end;
try
temp:=StrToInt(ComboBox5.Text);
except
showmessage('起始年份非法!请重新选择!');
exit;
end;
try
temp:=StrToInt(ComboBox6.Text);
except
showmessage('终止年份非法!请重新选择!');
exit;
end;
if (StrToInt(ComboBox5.Text)<1900) or (StrToInt(ComboBox5.Text)>3000) then
begin
showmessage('对不起!您选择的"起始年份"非法!请重新选择!');
exit;
end;
if (StrToInt(ComboBox6.Text)<1900) or (StrToInt(ComboBox6.Text)>3000) then
begin
showmessage('对不起!您选择的"终止年份"非法!请重新选择!');
exit;
end;
if StrToInt(ComboBox5.Text)>StrToInt(ComboBox6.Text) then
begin
showmessage('对不起!"起始年份"不能大于"终止年份"!请重新选择条件!');
exit;
end;
try
Screen.Cursor:=crHourGlass;
TradeTableToTableYear('gjyear.data','公交企业统计年报表');
if judge=false then StrToInt('sf');
TradeTableToTableYear('gjyear_z.data','公交企业统计年报表_z');
if judge=false then StrToInt('sf');
showmessage('公交企业统计年报数据导出成功!');
RichEdit1.Lines.Add('公交企业统计年报数据导出成功');
except
showmessage('数据导出失败!');
RichEdit1.Lines.Add('公交企业统计年报表导出失败');
end;
Screen.Cursor:=crDefault;
end;
procedure TTradeOutputFrm.BitBtn10Click(Sender: TObject);
begin
if ComboBox5.Text='' then
begin
showmessage('对不起!"起始年份"不能为空!请重新选择条件!');
exit;
end;
if ComboBox6.Text='' then
begin
showmessage('对不起!"终止年份"不能为空!请重新选择条件!');
exit;
end;
if (Length(ComboBox5.Text)<>4) or (Length(ComboBox6.Text)<>4) then
begin
showmessage('对不起!您选择的年份非法!请重新选择!');
exit;
end;
try
temp:=StrToInt(ComboBox5.Text);
except
showmessage('起始年份非法!请重新选择!');
exit;
end;
try
temp:=StrToInt(ComboBox6.Text);
except
showmessage('终止年份非法!请重新选择!');
exit;
end;
if (StrToInt(ComboBox5.Text)<1900) or (StrToInt(ComboBox5.Text)>3000) then
begin
showmessage('对不起!您选择的"起始年份"非法!请重新选择!');
exit;
end;
if (StrToInt(ComboBox6.Text)<1900) or (StrToInt(ComboBox6.Text)>3000) then
begin
showmessage('对不起!您选择的"终止年份"非法!请重新选择!');
exit;
end;
if StrToInt(ComboBox5.Text)>StrToInt(ComboBox6.Text) then
begin
showmessage('对不起!"起始年份"不能大于"终止年份"!请重新选择条件!');
exit;
end;
Application.CreateForm(TLookImportData5, LookImportData5);
LookImportData5.Label1.Caption:='公交企业年报导出数据浏览';
LookImportData5.Edit1.Text:=ComboBox5.Text;
LookImportData5.Edit2.Text:=ComboBox6.Text;
LookImportData5.ADOQuery1.Connection:=BusTradeDataModule.ADOConnection1;
LookImportData5.ADOQuery1.SQL.Clear;
if Edit3.Text<>'' then
LookImportData5.ADOQuery1.SQL.Add('select a.统计年份 as 统计年份,a.企业代码 as 企业代码, b.指标名称 as 指标名称,'
+' b.指标代码 as 指标代码, b.单位 as 单位,a.全年实际 as 全年实际'
+' from 公交企业统计年报表_z as a, 公交企业统计年报指标定义表 as b'
+' where a.企业代码 in ' +Epr_Select.TotalEpr+' and a.统计年份>='
+ ComboBox5.Text+' and a.统计年份<='+ComboBox6.Text
+' and a.指标代码=b.指标代码 ORDER BY a.统计年份, b.指标代码,a.企业代码')
else
LookImportData5.ADOQuery1.SQL.Add('select a.统计年份 as 统计年份,a.企业代码 as 企业代码, b.指标名称 as 指标名称,'
+' b.指标代码 as 指标代码, b.单位 as 单位,a.全年实际 as 全年实际'
+' from 公交企业统计年报表_z as a, 公交企业统计年报指标定义表 as b'
+' where a.统计年份>='+ ComboBox5.Text+' and a.统计年份<='+ComboBox6.Text
+' and a.指标代码=b.指标代码 ORDER BY a.统计年份, b.指标代码,a.企业代码');
LookImportData5.ADOQuery1.Open;
LookImportData5.ShowModal;
end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?