You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
7.5 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

unit u_op_seae_excel;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
dxExEdtr, DB, dxTL, dxDBCtrl, dxDBGrid, dxCntner, StdCtrls, Mask,
wwdbedit, Wwdotdot, Wwdbcomb, bsSkinCtrls, Dialogs, Excel, ADODB,
BusinessSkinForm, DBCtrls, Excels;
type
Tfrm_op_seae_excel = class(TForm)
bsBusinessSkinForm1: TbsBusinessSkinForm;
t_excel_bill: TADOQuery;
t_excel_bill1: TDataSource;
bsSkinPanel1: TbsSkinPanel;
t_excel_bill_bill: TADOQuery;
t_excel_bill_bill1: TDataSource;
bsSkinPanel8: TbsSkinPanel;
bsSkinButton10: TbsSkinButton;
bsSkinButton11: TbsSkinButton;
bsSkinButton12: TbsSkinButton;
Excel1: TExcel;
t_op_ctn: TADOQuery;
bsSkinOpenDialog1: TOpenDialog;
SaveDialog: TSaveDialog;
bsSkinGroupBox2: TbsSkinGroupBox;
bsSkinPanel6: TbsSkinPanel;
bsSkinPanel7: TbsSkinPanel;
bsSkinButton7: TbsSkinButton;
bsSkinButton8: TbsSkinButton;
bsSkinButton9: TbsSkinButton;
dxDBGrid2: TdxDBGrid;
dxDBGrid2Column1: TdxDBGridMaskColumn;
dxDBGrid2X: TdxDBGridMaskColumn;
dxDBGrid2Y: TdxDBGridMaskColumn;
bsSkinPanel9: TbsSkinPanel;
wwDBComboBox2: TwwDBComboBox;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
dxDBGrid2Column4: TdxDBGridColumn;
DBEdit5: TDBEdit;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinButton4: TbsSkinButton;
bsSkinGroupBox3: TbsSkinGroupBox;
bsSkinPanel2: TbsSkinPanel;
dxDBGrid1: TdxDBGrid;
dxDBGrid1Column1: TdxDBGridMaskColumn;
Memo1: TMemo;
Data1: TDataSource;
t_excel_billEX_ID: TAutoIncField;
t_excel_billDSDesigner: TStringField;
t_excel_billDSDesigner2: TStringField;
t_excel_billDSDesigner3: TBlobField;
procedure FormShow(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure bsSkinButton4Click(Sender: TObject);
procedure t_excel_billPostError(DataSet: TDataSet; E: EDatabaseError;
var Action: TDataAction);
procedure t_excel_bill_billPostError(DataSet: TDataSet;
E: EDatabaseError; var Action: TDataAction);
procedure t_excel_billBeforeDelete(DataSet: TDataSet);
procedure bsSkinButton7Click(Sender: TObject);
procedure bsSkinButton8Click(Sender: TObject);
procedure bsSkinButton9Click(Sender: TObject);
procedure t_excel_bill_ctnBeforeInsert(DataSet: TDataSet);
procedure t_excel_bill_billBeforePost(DataSet: TDataSet);
procedure t_excel_bill_billAfterInsert(DataSet: TDataSet);
procedure bsSkinButton11Click(Sender: TObject);
procedure bsSkinButton12Click(Sender: TObject);
procedure bsSkinButton10Click(Sender: TObject);
procedure bsSkinButton13Click(Sender: TObject);
procedure t_excel_billAfterInsert(DataSet: TDataSet);
private
{ Private declarations }
public
tradetype:string;
{ Public declarations }
end;
var
frm_op_seae_excel: Tfrm_op_seae_excel;
implementation
uses u_main, my_sys_function, u_op_seae;
{$R *.dfm}
procedure Tfrm_op_seae_excel.FormShow(Sender: TObject);
var
i:integer;
begin
wwDBComboBox2.Items.Clear;
wwDBComboBox2.Items.Add('<27>̶<EFBFBD>ֵ');
for i:=0 to Data1.DataSet.FieldCount-1 do begin
wwDBComboBox2.Items.Add(Data1.DataSet.Fields[i].FieldName);
end;
t_excel_bill.Close;
t_excel_bill.SQL.Text:='select * from t_sys_excel where <20><><EFBFBD><EFBFBD>='''+tradetype+'''';
t_excel_bill.open;
t_excel_bill_bill.open;
end;
procedure Tfrm_op_seae_excel.bsSkinButton1Click(Sender: TObject);
begin
t_excel_bill.insert;
end;
procedure Tfrm_op_seae_excel.bsSkinButton2Click(Sender: TObject);
begin
table_post(t_excel_bill);
end;
procedure Tfrm_op_seae_excel.bsSkinButton4Click(Sender: TObject);
begin
table_delete(t_excel_bill);
end;
procedure Tfrm_op_seae_excel.t_excel_billPostError(DataSet: TDataSet;
E: EDatabaseError; var Action: TDataAction);
begin
showmessage('<27><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>');
end;
procedure Tfrm_op_seae_excel.t_excel_bill_billPostError(DataSet: TDataSet;
E: EDatabaseError; var Action: TDataAction);
begin
showmessage('<27>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>');
end;
procedure Tfrm_op_seae_excel.t_excel_billBeforeDelete(DataSet: TDataSet);
begin
table_before_delete(t_excel_bill_bill,'<27>ӱ<EFBFBD>');
end;
procedure Tfrm_op_seae_excel.bsSkinButton7Click(Sender: TObject);
begin
t_excel_bill_bill.insert;
end;
procedure Tfrm_op_seae_excel.bsSkinButton8Click(Sender: TObject);
begin
table_post(t_excel_bill_bill);
end;
procedure Tfrm_op_seae_excel.bsSkinButton9Click(Sender: TObject);
begin
table_delete(t_excel_bill_bill);
end;
procedure Tfrm_op_seae_excel.t_excel_bill_ctnBeforeInsert(
DataSet: TDataSet);
begin
table_before_insert(t_excel_bill);
end;
procedure Tfrm_op_seae_excel.t_excel_bill_billBeforePost(
DataSet: TDataSet);
begin
table_before_post(t_excel_bill_bill,'<27>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>');
table_before_post(t_excel_bill_bill,'<27><><EFBFBD><EFBFBD>X');
table_before_post(t_excel_bill_bill,'<27><><EFBFBD><EFBFBD>Y');
end;
procedure Tfrm_op_seae_excel.t_excel_bill_billAfterInsert(
DataSet: TDataSet);
begin
t_excel_bill_bill['EX_ID']:=t_excel_bill['EX_ID'];
end;
procedure Tfrm_op_seae_excel.bsSkinButton11Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_op_seae_excel.bsSkinButton12Click(Sender: TObject);
begin
if t_excel_bill.IsEmpty then
exit;
if (t_excel_bill.state=dsinsert)or(t_excel_bill.state=dsedit)then
t_excel_bill.Post;
if bsSkinOpenDialog1.Execute then
begin
t_excel_bill.EDIT;
t_excel_billDSDesigner3.LoadFromFile(bsSkinOpenDialog1.FileName);
t_excel_bill.post;
end;
end;
procedure Tfrm_op_seae_excel.bsSkinButton10Click(Sender: TObject);
var
str:Tstringlist;
wide_str:widestring;
i:integer;
Y:INTEGER;
begin
if t_excel_bill.IsEmpty then
exit;
t_excel_billDSDesigner3.SaveToFile(ExtractFilePath(ParamStr(0))+t_excel_bill.fieldbyname('EX_ID').asstring+'.xls');
str:=Tstringlist.Create;
str.Clear;
excel1.Connect;
Excel1.Exec('[open('+'"'+ExtractFilePath(ParamStr(0))+t_excel_bill.fieldbyname('EX_ID').asstring+'.xls'+'"'+')]');
Data1.DataSet.First;
i:=0;
while not Data1.DataSet.Eof do begin
t_excel_bill_bill.First;
while not t_excel_bill_bill.eof do
begin
if trim(t_excel_bill_bill.fieldbyname('<27>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>').asstring)<>'<27>̶<EFBFBD>ֵ'then
begin
excel1.putstr(t_excel_bill_bill.fieldbyname('<27><><EFBFBD><EFBFBD>Y').asinteger+i,
t_excel_bill_bill.fieldbyname('<27><><EFBFBD><EFBFBD>X').asinteger,
Data1.DataSet.fieldbyname(t_excel_bill_bill.fieldbyname('<27>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>').asstring).asstring);
end
else
begin
excel1.putstr(t_excel_bill_bill.fieldbyname('<27><><EFBFBD><EFBFBD>Y').asinteger+i,
t_excel_bill_bill.fieldbyname('<27><><EFBFBD><EFBFBD>X').asinteger,
trim(t_excel_bill_bill.fieldbyname('<27>̶<EFBFBD>ֵ').asstring));
end;
t_excel_bill_bill.next;
end;
i:=i+1;
Data1.DataSet.Next;
end;
SaveDialog.Filter := '(*.xls)|*.xls';
SaveDialog.FileName := t_excel_bill.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring+'.xls';
if SaveDialog.Execute then
begin
Excel1.Exec('[SAVE.AS("'+SaveDialog.FileName+'";1;"";false;"";false)]');
Excel1.Exec('[CLOSE(false)]');
Excel1.Exec('[open("'+SaveDialog.FileName+'")]');
Excel1.Exec('[APP.maxIMIZE()]'); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>excel
end;
deletefile(ExtractFilePath(ParamStr(0))+t_excel_bill.fieldbyname('EX_ID').asstring+'.xls');
end;
procedure Tfrm_op_seae_excel.bsSkinButton13Click(Sender: TObject);
begin
if t_excel_bill.IsEmpty then
exit;
end;
procedure Tfrm_op_seae_excel.t_excel_billAfterInsert(DataSet: TDataSet);
begin
t_excel_bill.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=tradetype;
end;
end.