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.

306 lines
11 KiB
Plaintext

11 months ago
unit u_ch_invoice_addone;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, bsSkinCtrls, Grids, DBGridEh, StdCtrls, Mask, bsSkinBoxCtrls,
DB, ADODB, kbmMemTable, kbmMemBinaryStreamFormat;
type
Tfrmch_invoice_addone = class(TForm)
bsSkinPanel1: TbsSkinPanel;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinGroupBox1: TbsSkinGroupBox;
DBGridEh1: TDBGridEh;
bsSkinRadioGroup1: TbsSkinRadioGroup;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
bsSkinEdit1: TbsSkinEdit;
Label1: TLabel;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
ADOQuery2: TADOQuery;
t_ch_fee_do: TADOQuery;
bsSkinGroupBox2: TbsSkinGroupBox;
DBGridEh2: TDBGridEh;
t_fee_obj: TADOQuery;
t_fee_obj1: TDataSource;
memtblDetail: TkbmMemTable;
memtblDetailCH_ID: TIntegerField;
memtblDetailField: TStringField;
memtblDetailField2: TStringField;
memtblDetailField3: TFloatField;
memtblDetailField4: TFloatField;
memtblDetailField5: TFloatField;
memtblDetailField6: TStringField;
memtblDetailField7: TFloatField;
memtblDetailField8: TStringField;
memtblDetailField9: TFloatField;
memtblDetailField10: TFloatField;
memtblDetailField11: TStringField;
kbmBinaryStreamFormat1: TkbmBinaryStreamFormat;
memtblDetailField12: TBooleanField;
memtblDetailField13: TFloatField;
memtblDetailField14: TStringField;
procedure FormShow(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
procedure t_fee_objAfterScroll(DataSet: TDataSet);
private
{ Private declarations }
public
MblNo:Boolean;
{ Public declarations }
end;
var
frmch_invoice_addone: Tfrmch_invoice_addone;
implementation
uses u_main, u_data_share, u_ch_invoice, my_sys_function;
{$R *.dfm}
procedure Tfrmch_invoice_addone.FormShow(Sender: TObject);
begin
IF frm_data_share.t_code_currency.Locate('<27>ұ<EFBFBD>','USD',[])THEN
bsSkinEdit1.Text:=frm_data_share.t_code_currency.fieldbyname('<27><><EFBFBD><EFBFBD>').AsString;
memtblDetail.LoadFromDataSet(ADOQuery1,[]);
memtblDetail.open;
memtblDetail.filtered:=false;
memtblDetail.First;
while not memtblDetail.Eof do begin
memtbldetail.Edit;
memtbldetail.fieldbyname('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=memtbldetail.fieldbyname('<27><><EFBFBD><EFBFBD>').AsFloat-memtbldetail.fieldbyname('<27><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat-memtbldetail.fieldbyname('<27><><EFBFBD>뿪Ʊ').AsFloat;
memtbldetail.fieldbyname('ѡ<><D1A1>').Asboolean:=true;
memtbldetail.post;
memtblDetail.Next;
end;
memtblDetail.filter:='<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='+''''+t_fee_obj.fieldbyname('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').asstring+'''';
memtblDetail.filtered:=true;
end;
procedure Tfrmch_invoice_addone.bsSkinButton1Click(Sender: TObject);
var
FeeStr,NameStr,FeeList,AmtList:TStringList;
jine:Double;
str,str1:String;
aQuery,bQuery,aAdoQuery:TADOQuery;
i,in_id:Integer;
Amt :Double;
begin
FeeStr:=TStringList.Create;
NameStr:=TStringList.Create;
try
frm_ch_invoice.t_ch_invoice.Edit;
if not ADOQuery2.IsEmpty then begin
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=ADOQuery2['<27><><EFBFBD><EFBFBD>']+'/'+ADOQuery2['<27><><EFBFBD><EFBFBD>'];
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD>˸<EFBFBD>']:=ADOQuery2['<27><><EFBFBD>˸<EFBFBD>'];
frm_ch_invoice.t_ch_invoice['ж<><D0B6><EFBFBD><EFBFBD>']:=ADOQuery2['ж<><D0B6><EFBFBD><EFBFBD>'];
frm_ch_invoice.t_ch_invoice['Ŀ<>ĸ<EFBFBD>']:=ADOQuery2['Ŀ<>ĵ<EFBFBD>'];
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=ADOQuery2['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'];
if Mblno then
frm_ch_invoice.t_ch_invoice['ί<>б<EFBFBD><D0B1><EFBFBD>']:=ADOQuery2['ί<>б<EFBFBD><D0B1><EFBFBD>']
else
frm_ch_invoice.t_ch_invoice['<27><EFBFBD><E1B5A5>']:=ADOQuery2['<27><><EFBFBD><EFBFBD><E1B5A5>'];
if (frm_ch_invoice.t_ch_invoice.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull) or (frm_ch_invoice.t_ch_invoice.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='') then begin
Str:=get_no(date,'IA');
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=Str;
end else
Str:=frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'];
end;
if bsSkinRadioGroup1.ItemIndex=1 then
frm_ch_invoice.t_ch_invoice['<27>ұ<EFBFBD>']:='USD'
else
frm_ch_invoice.t_ch_invoice['<27>ұ<EFBFBD>']:='RMB';
if (frm_ch_invoice.t_ch_invoice.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').IsNull) or (frm_ch_invoice.t_ch_invoice['<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>']='') then begin
frm_ch_invoice.t_ch_invoice['<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>']:=t_fee_obj.fieldbyName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString;
end;
if not frm_data_share.t_crm_client_all.IsEmpty then
if frm_data_share.t_crm_client_all.locate('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>',t_fee_obj.fieldbyName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString,[]) then
begin
if trim(frm_data_share.t_crm_client_all.fieldbyname('<27><>Ʊ̧ͷ').asstring)<>''then
frm_ch_invoice.t_ch_invoice['<27><>Ʊ̧ͷ']:=frm_data_share.t_crm_client_all.fieldbyname('<27><>Ʊ̧ͷ').asstring;
end;
jine:=0;
memtblDetail.First;
t_ch_fee_do.Open;
while not memtblDetail.Eof do begin
if (memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat<>0) and (memtblDetail.FieldByNAME('ѡ<><D1A1>').Asboolean) then begin
if memtblDetail['<27>ұ<EFBFBD>']='USD' then begin
if bsSkinRadioGroup1.ItemIndex=1 then begin
if bsSkinCheckRadioBox1.Checked then begin
FeeStr.Add(FloatToStr(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat));
NameStr.Add(memtblDetail['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']);
jine:=jine+(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
end else begin
jine:=jine+(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
end;
t_ch_fee_do.Insert;
t_ch_fee_do['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=Str;
t_ch_fee_do['ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblDetail['<27><><EFBFBD><EFBFBD>'];
t_ch_fee_do['CH_ID']:=memtblDetail['CH_ID'];
t_ch_fee_do['<27>ұ<EFBFBD>']:='USD';
t_ch_fee_do['<27><><EFBFBD><EFBFBD>']:=memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
t_ch_fee_do['ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>']:=memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
t_ch_fee_do['<27><><EFBFBD><EFBFBD>']:=1;
t_ch_fee_do.Post;
end else begin
IF bsSkinCheckRadioBox2.Checked then begin
if bsSkinCheckRadioBox1.Checked then begin
FeeStr.Add(FloatToStr((memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat)*strtofloatdef(bsSkinEdit1.Text,7.0)));
NameStr.Add(memtblDetail['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']);
jine:=jine+(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat)*strtofloatdef(bsSkinEdit1.Text,7.0);
end else begin
jine:=jine+(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat)*strtofloatdef(bsSkinEdit1.Text,7.0);
end;
t_ch_fee_do.Insert;
t_ch_fee_do['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=Str;
t_ch_fee_do['ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblDetail['<27><><EFBFBD><EFBFBD>'];
t_ch_fee_do['CH_ID']:=memtblDetail['CH_ID'];
t_ch_fee_do['<27>ұ<EFBFBD>']:='RMB';
t_ch_fee_do['<27><><EFBFBD><EFBFBD>']:=(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat)*strtofloatdef(bsSkinEdit1.Text,7.0);
t_ch_fee_do['ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>']:=memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
t_ch_fee_do['<27><><EFBFBD><EFBFBD>']:=1;
t_ch_fee_do.Post;
end;
end;
end else begin
if bsSkinRadioGroup1.ItemIndex=1 then begin
end else begin
if bsSkinCheckRadioBox1.Checked then begin
FeeStr.Add(FloatToStr(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat));
NameStr.Add(memtblDetail['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']);
jine:=jine+(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
end else begin
jine:=jine+(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
end;
t_ch_fee_do.Insert;
t_ch_fee_do['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=Str;
t_ch_fee_do['ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblDetail['<27><><EFBFBD><EFBFBD>'];
t_ch_fee_do['CH_ID']:=memtblDetail['CH_ID'];
t_ch_fee_do['<27>ұ<EFBFBD>']:='RMB';
t_ch_fee_do['<27><><EFBFBD><EFBFBD>']:=(memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
t_ch_fee_do['ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>']:=memtblDetail.FieldByNAME('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
t_ch_fee_do['<27><><EFBFBD><EFBFBD>']:=1;
t_ch_fee_do.Post;
end;
end;
end;
memtblDetail.Next;
end;
if bsSkinCheckRadioBox1.Checked then begin
if frm_ch_invoice.t_ch_invoice['<27>ϼƽ<CFBC><C6BD><EFBFBD>']=0 then begin
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']:=NameStr.Text;
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']:=FeeStr.Text;
frm_ch_invoice.t_ch_invoice['<27>ϼƽ<CFBC><C6BD><EFBFBD>']:=jine;
frm_ch_invoice.t_ch_invoice['ʵ<>ʽ<EFBFBD><CABD><EFBFBD>']:=jine;
end else begin
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']:=frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']+#10#13+NameStr.Text;
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']:=frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']+#10#13+FeeStr.Text;
frm_ch_invoice.t_ch_invoice['<27>ϼƽ<CFBC><C6BD><EFBFBD>']:=frm_ch_invoice.t_ch_invoice['<27>ϼƽ<CFBC><C6BD><EFBFBD>']+jine;
frm_ch_invoice.t_ch_invoice['ʵ<>ʽ<EFBFBD><CABD><EFBFBD>']:=frm_ch_invoice.t_ch_invoice['ʵ<>ʽ<EFBFBD><CABD><EFBFBD>']+jine;
end;
end else begin
if frm_ch_invoice.t_ch_invoice['<27>ұ<EFBFBD>']='USD' then
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']:=get_parameters_value(7,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD>')
else
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']:=get_parameters_value(147,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD>');
if frm_ch_invoice.t_ch_invoice['<27>ϼƽ<CFBC><C6BD><EFBFBD>']=0 then begin
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']:=FloatToStr(jine);
frm_ch_invoice.t_ch_invoice['<27>ϼƽ<CFBC><C6BD><EFBFBD>']:=jine;
frm_ch_invoice.t_ch_invoice['ʵ<>ʽ<EFBFBD><CABD><EFBFBD>']:=jine;
end else begin
frm_ch_invoice.t_ch_invoice['<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>']:=FloatToStr(frm_ch_invoice.t_ch_invoice['<27>ϼƽ<CFBC><C6BD><EFBFBD>']+jine);
frm_ch_invoice.t_ch_invoice['<27>ϼƽ<CFBC><C6BD><EFBFBD>']:=frm_ch_invoice.t_ch_invoice['<27>ϼƽ<CFBC><C6BD><EFBFBD>']+jine;
frm_ch_invoice.t_ch_invoice['ʵ<>ʽ<EFBFBD><CABD><EFBFBD>']:=frm_ch_invoice.t_ch_invoice['ʵ<>ʽ<EFBFBD><CABD><EFBFBD>']+jine;
end;
end;
frm_ch_invoice.t_ch_invoice.Post;
aQuery:=CreateAdoQuery;
bQuery:=CreateAdoQuery;
in_id:=frm_ch_invoice.t_ch_invoice.fieldbyname('IN_ID').AsInteger;
str1:=frm_ch_invoice.t_ch_invoice.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>').asstring;
try
with aQuery do
begin
Close;sql.Clear;
SQL.Add('delete from t_ch_invoice_item');
SQL.Add('where IN_ID=:IN_ID');
Parameters.ParamByName('IN_ID').Value:=in_id;
ExecSQL;
Close;sql.Clear;
SQL.Add('Insert into t_ch_invoice_item ( IN_ID, <20><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ, <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> ,<2C><>˰<EFBFBD><CBB0><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>, ˰<><CBB0><><CBB0> ,<2C>ۿ<EFBFBD>,<2C><>ע,<2C><>˰<EFBFBD>۱<EFBFBD>־ )');
SQL.Add('values (:IN_ID,:<3A><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>,:<3A><><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>,:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ,:<3A><><EFBFBD><EFBFBD>,:<3A><><EFBFBD><EFBFBD>,:<3A><>˰<EFBFBD><CBB0><EFBFBD><EFBFBD>,:<3A><><EFBFBD><EFBFBD>, :˰<><CBB0>,:˰<><CBB0>,:<3A>ۿ<EFBFBD>,:<3A><>ע,:<3A><>˰<EFBFBD>۱<EFBFBD>־)');
Parameters.ParamByName('IN_ID').Value:=in_id;
if pos('<27><><EFBFBD><EFBFBD>',str1)>0 then
Parameters.ParamByName('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>').Value:=str1
else Parameters.ParamByName('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>').Value:='<27><><EFBFBD><EFBFBD>'+str1;
Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>').Value:='0';
Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ').Value:='Ʊ';
Parameters.ParamByName('<27><><EFBFBD><EFBFBD>').Value:=1;
Parameters.ParamByName('˰<><CBB0>').Value:=(jine/(1+frm_data_share.t_sys_company.fieldbyname('˰<><CBB0>').AsFloat/100))*frm_data_share.t_sys_company.fieldbyname('˰<><CBB0>').AsFloat/100;
Parameters.ParamByName('<27><>˰<EFBFBD><CBB0><EFBFBD><EFBFBD>').Value:=jine;
Parameters.ParamByName('<27><><EFBFBD><EFBFBD>').Value:=jine-Parameters.ParamByName('˰<><CBB0>').Value;
Parameters.ParamByName('<27><><EFBFBD><EFBFBD>').Value:=jine-Parameters.ParamByName('˰<><CBB0>').Value;
Parameters.ParamByName('˰<><CBB0>').Value:=frm_data_share.t_sys_company.fieldbyname('˰<><CBB0>').AsFloat/100;
Parameters.ParamByName('<27>ۿ<EFBFBD>').Value:=0;
Parameters.ParamByName('<27><>ע').Value:='';
Parameters.ParamByName('<27><>˰<EFBFBD>۱<EFBFBD>־').Value:=0;
ExecSQL;
end;
finally
FreeAndNil(aQuery);
FreeAndNil(bQuery);
end;
finally
FreeAndNil(FeeStr);
FreeAndNil(NameStr);
end;
close;
end;
procedure Tfrmch_invoice_addone.t_fee_objAfterScroll(DataSet: TDataSet);
begin
memtblDetail.filtered:=false;
memtblDetail.filter:='<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='+''''+t_fee_obj.fieldbyname('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').asstring+'''';
memtblDetail.filtered:=true;
end;
end.