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.

214 lines
7.9 KiB
Plaintext

unit u_ch_invoice_add;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BusinessSkinForm, StdCtrls, wwdblook, RxLookup, bsSkinCtrls, DB,
ADODB;
type
Tfrm_ch_invoice_add = class(TForm)
bsBusinessSkinForm1: TbsBusinessSkinForm;
Label48: TLabel;
wwDBLookupCombo6: TwwDBLookupCombo;
Label63: TLabel;
RxDBLookupCombo3: TRxDBLookupCombo;
Label1: TLabel;
Edit1: TEdit;
bsSkinCheckRadioBox7: TbsSkinCheckRadioBox;
bsSkinCheckRadioBox8: TbsSkinCheckRadioBox;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
p_invoice_no: TADOStoredProc;
Edit2: TEdit;
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_ch_invoice_add: Tfrm_ch_invoice_add;
implementation
uses u_data_share, u_ch_invoice, u_main, my_sys_function, my_sys_chat;
{$R *.dfm}
procedure Tfrm_ch_invoice_add.bsSkinButton1Click(Sender: TObject);
var
afield : variant;
i: Integer;
begin
if trim(Edit1.Text)='' then
begin
showmessage('发票号码不能为空!!');
exit;
end;
if bsSkinCheckRadioBox7.Checked or bsSkinCheckRadioBox8.Checked then
begin
if trim(wwDBLookupCombo6.Text)='' then
begin
showmessage('发票币别不能为空!!');
exit;
end;
if RxDBLookupCombo3.DisplayValue='' then
begin
showmessage('客户名称不能为空!!');
exit;
end;
end;
if bsSkinCheckRadioBox7.Checked then
begin
try
modify_all:=true;
frm_ch_invoice.t_ch_invoice.Insert;
frm_ch_invoice.t_ch_invoice['发票类别']:='自由发票';
frm_ch_invoice.t_ch_invoice['发票号码']:=trim(Edit1.Text);
frm_ch_invoice.t_ch_invoice['币别']:=wwDBLookupCombo6.Text;
frm_ch_invoice.t_ch_invoice['客户名称']:=RxDBLookupCombo3.DisplayValues[1];
frm_ch_invoice.t_ch_invoice['费用列表']:=get_parameters_value(7,'海运费');
if not frm_data_share.t_crm_client_all.IsEmpty then
if frm_data_share.t_crm_client_all.locate('客户简称',RxDBLookupCombo3.DisplayValues[1],[]) then
begin
if trim(frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring)<>''then
frm_ch_invoice.t_ch_invoice['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring;
end;
frm_ch_invoice.t_ch_invoice.post;
modify_all:=false;
except
if frm_ch_invoice.t_ch_invoice.State=dsinsert then
frm_ch_invoice.t_ch_invoice.cancel;
modify_all:=true;
showmessage('发票添加失败!!');
exit;
end;
frm_ch_invoice.bsSkinTabSheet2.show;
close;
exit;
end;
if bsSkinCheckRadioBox8.Checked then
begin
try
modify_all:=true;
afield := vararraycreate([0,frm_ch_invoice.t_ch_invoice.fieldcount-1],varvariant);
for i := 0 to (frm_ch_invoice.t_ch_invoice.fieldcount-1) do
begin
afield[i] :=frm_ch_invoice.t_ch_invoice.fields[i].value ;
end;
frm_ch_invoice.t_ch_invoice.append;
for i := 0 to (frm_ch_invoice.t_ch_invoice.fieldcount-1) do
begin
if frm_ch_invoice.t_ch_invoice.fields[i].FieldName<>'IN_ID'then
frm_ch_invoice.t_ch_invoice.fields[i].value := afield[i] ;
end;
frm_ch_invoice.t_ch_invoice['发票类别']:='自由发票';
frm_ch_invoice.t_ch_invoice['发票号码']:=trim(Edit1.Text);
frm_ch_invoice.t_ch_invoice['币别']:=wwDBLookupCombo6.Text;
frm_ch_invoice.t_ch_invoice['客户名称']:=RxDBLookupCombo3.DisplayValues[1];
if not frm_data_share.t_crm_client_all.IsEmpty then
if frm_data_share.t_crm_client_all.locate('客户简称',RxDBLookupCombo3.DisplayValues[1],[]) then
begin
if trim(frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring)<>''then
frm_ch_invoice.t_ch_invoice['发票抬头']:=frm_data_share.t_crm_client_all.fieldbyname('发票抬头').asstring;
end;
frm_ch_invoice.t_ch_invoice['制单人']:=employee;
frm_ch_invoice.t_ch_invoice['开票日期']:=date;
frm_ch_invoice.t_ch_invoice['是否打印']:=0;
frm_ch_invoice.t_ch_invoice['是否废除']:=0;
frm_ch_invoice.t_ch_invoice['废除原因']:='';
frm_ch_invoice.t_ch_invoice['废除人']:='';
frm_ch_invoice.t_ch_invoice['废除日期']:=null;
frm_ch_invoice.t_ch_invoice['申请人']:='';
frm_ch_invoice.t_ch_invoice['申请日期']:=null;
frm_ch_invoice.t_ch_invoice.post;
modify_all:=false;
except
if frm_ch_invoice.t_ch_invoice.State=dsinsert then
frm_ch_invoice.t_ch_invoice.cancel;
modify_all:=true;
showmessage('发票添加失败!!');
exit;
end;
frm_ch_invoice.bsSkinTabSheet2.show;
close;
exit;
end;
if bsSkinCheckRadioBox1.Checked then
begin
try
modify_all:=true;
frm_ch_invoice.t_ch_invoice.Insert;
frm_ch_invoice.t_ch_invoice['发票类别']:='申请发票';
frm_ch_invoice.t_ch_invoice['发票号码']:=trim(Edit1.Text);
frm_ch_invoice.t_ch_invoice['币别']:=wwDBLookupCombo6.Text;
frm_ch_invoice.t_ch_invoice['客户名称']:=edit2.text;
frm_ch_invoice.t_ch_invoice['申请编号']:=frm_ch_invoice.t_ch_invoice_shen['申请编号'];
frm_ch_invoice.t_ch_invoice['发票抬头']:=frm_ch_invoice.t_ch_invoice_shen['发票抬头'];
frm_ch_invoice.t_ch_invoice['船名航次']:=frm_ch_invoice.t_ch_invoice_shen['船名航次'];
frm_ch_invoice.t_ch_invoice['提单号']:=frm_ch_invoice.t_ch_invoice_shen['提单号'];
frm_ch_invoice.t_ch_invoice['开船日期']:=frm_ch_invoice.t_ch_invoice_shen['开船日期'];
frm_ch_invoice.t_ch_invoice['启运港']:=frm_ch_invoice.t_ch_invoice_shen['启运港'];
frm_ch_invoice.t_ch_invoice['卸货港']:=frm_ch_invoice.t_ch_invoice_shen['卸货港'];
frm_ch_invoice.t_ch_invoice['目的港']:=frm_ch_invoice.t_ch_invoice_shen['目的港'];
frm_ch_invoice.t_ch_invoice['费用列表']:=frm_ch_invoice.t_ch_invoice_shen['费用列表'];
frm_ch_invoice.t_ch_invoice['金额列表']:=frm_ch_invoice.t_ch_invoice_shen['金额列表'];
frm_ch_invoice.t_ch_invoice['备注']:=frm_ch_invoice.t_ch_invoice_shen['备注'];
frm_ch_invoice.t_ch_invoice['合计金额']:=frm_ch_invoice.t_ch_invoice_shen['申请金额'];
frm_ch_invoice.t_ch_invoice['实际金额']:=frm_ch_invoice.t_ch_invoice_shen['实际金额'];
frm_ch_invoice.t_ch_invoice['虚开金额']:=frm_ch_invoice.t_ch_invoice_shen['虚开金额'];
frm_ch_invoice.t_ch_invoice['币别']:=frm_ch_invoice.t_ch_invoice_shen['币别'];
frm_ch_invoice.t_ch_invoice['申请人']:=frm_ch_invoice.t_ch_invoice_shen['申请人'];
frm_ch_invoice.t_ch_invoice['申请日期']:=frm_ch_invoice.t_ch_invoice_shen['申请日期'];
frm_ch_invoice.t_ch_invoice.post;
frm_ch_invoice.t_ch_invoice_shen.Edit;
frm_ch_invoice.t_ch_invoice_shen['申请状态']:='开出发票';
frm_ch_invoice.t_ch_invoice_shen['开出人']:=employee;
frm_ch_invoice.t_ch_invoice_shen['开出日期']:=now;
frm_ch_invoice.t_ch_invoice_shen['发票号码']:=trim(Edit1.Text);
frm_ch_invoice.t_ch_invoice_shen.post;
modify_all:=false;
Send_invocie_check_check('申请发票开出,申请编号:'+frm_ch_invoice.t_ch_invoice_shen.fieldbyname('申请编号').asstring
+',客户:'+frm_ch_invoice.t_ch_invoice_shen.fieldbyname('客户名称').asstring,frm_ch_invoice.t_ch_invoice_shen.fieldbyname('申请人').asstring,'25');
except
if frm_ch_invoice.t_ch_invoice.State=dsinsert then
frm_ch_invoice.t_ch_invoice.cancel;
modify_all:=true;
showmessage('开出发票失败!!');
exit;
end;
frm_ch_invoice.bsSkinTabSheet2.show;
close;
exit;
end;
end;
procedure Tfrm_ch_invoice_add.bsSkinButton2Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_ch_invoice_add.FormShow(Sender: TObject);
var
i:integer;
begin
p_invoice_no.ExecProc;
try
i:=strtoint(p_invoice_no.Parameters[1].value);
Edit1.Text:=inttostr(i+1);
except
;
end;
end;
end.