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.
DS6JIEFENG/财务管理/u_ch_invoice_addone_jk.~pas

258 lines
9.5 KiB
Plaintext

unit u_ch_invoice_addone_jk;
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_jk = 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_jk: Tfrmch_invoice_addone_jk;
implementation
uses u_main, u_data_share, u_ch_invoice, my_sys_function;
{$R *.dfm}
procedure Tfrmch_invoice_addone_jk.FormShow(Sender: TObject);
begin
IF frm_data_share.t_code_currency.Locate('±Ò±ð','USD',[])THEN
bsSkinEdit1.Text:=frm_data_share.t_code_currency.fieldbyname('»ãÂÊ').AsString;
memtblDetail.LoadFromDataSet(ADOQuery1,[]);
memtblDetail.open;
memtblDetail.filtered:=false;
memtblDetail.First;
while not memtblDetail.Eof do begin
memtbldetail.Edit;
memtbldetail.fieldbyname('ʵ¿ª½ð¶î').AsFloat:=memtbldetail.fieldbyname('½ð¶î').AsFloat-memtbldetail.fieldbyname('¿ªÆ±½ð¶î').AsFloat-memtbldetail.fieldbyname('ÉêÇ뿪Ʊ').AsFloat;
memtbldetail.fieldbyname('Ñ¡Ôñ').Asboolean:=true;
memtbldetail.post;
memtblDetail.Next;
end;
memtblDetail.filter:='¿Í»§Ãû³Æ='+''''+t_fee_obj.fieldbyname('¿Í»§Ãû³Æ').asstring+'''';
memtblDetail.filtered:=true;
end;
procedure Tfrmch_invoice_addone_jk.bsSkinButton1Click(Sender: TObject);
var
FeeStr,NameStr:TStringList;
jine:Double;
str:String;
begin
FeeStr:=TStringList.Create;
NameStr:=TStringList.Create;
try
frm_ch_invoice_jk.t_ch_invoice.Edit;
if not ADOQuery2.IsEmpty then begin
frm_ch_invoice_jk.t_ch_invoice['´¬Ãûº½´Î']:=ADOQuery2['´¬Ãû']+'/'+ADOQuery2['º½´Î'];
frm_ch_invoice_jk.t_ch_invoice['ÆôÔ˸Û']:=ADOQuery2['ÆðÔ˸Û'];
frm_ch_invoice_jk.t_ch_invoice['ж»õ¸Û']:=ADOQuery2['ж»õ¸Û'];
frm_ch_invoice_jk.t_ch_invoice['Ä¿µÄ¸Û']:=ADOQuery2['Ä¿µÄµØ'];
frm_ch_invoice_jk.t_ch_invoice['¿ª´¬ÈÕÆÚ']:=ADOQuery2['¿ª´¬ÈÕÆÚ'];
if Mblno then
frm_ch_invoice_jk.t_ch_invoice['ίÍбàºÅ']:=ADOQuery2['ίÍбàºÅ']
else
frm_ch_invoice_jk.t_ch_invoice['Ìáµ¥ºÅ']:=ADOQuery2['Ö÷Ìáµ¥ºÅ'];
if (frm_ch_invoice_jk.t_ch_invoice.FieldByName('ÉêÇë±àºÅ').IsNull) or (frm_ch_invoice_jk.t_ch_invoice.FieldByName('ÉêÇë±àºÅ').AsString='') then begin
Str:=get_no(date,'IA');
frm_ch_invoice_jk.t_ch_invoice['ÉêÇë±àºÅ']:=Str;
end else
Str:=frm_ch_invoice_jk.t_ch_invoice['ÉêÇë±àºÅ'];
end;
if bsSkinRadioGroup1.ItemIndex=1 then
frm_ch_invoice_jk.t_ch_invoice['±Ò±ð']:='USD'
else
frm_ch_invoice_jk.t_ch_invoice['±Ò±ð']:='RMB';
if (frm_ch_invoice_jk.t_ch_invoice.FieldByName('¿Í»§Ãû³Æ').IsNull) or (frm_ch_invoice_jk.t_ch_invoice['¿Í»§Ãû³Æ']='') then begin
frm_ch_invoice_jk.t_ch_invoice['¿Í»§Ãû³Æ']:=t_fee_obj.fieldbyName('¿Í»§Ãû³Æ').AsString;
end;
if not frm_data_share.t_crm_client_all.IsEmpty then
if frm_data_share.t_crm_client_all.locate('¿Í»§¼ò³Æ',t_fee_obj.fieldbyName('¿Í»§Ãû³Æ').AsString,[]) then
begin
if trim(frm_data_share.t_crm_client_all.fieldbyname('·¢Æ±Ì§Í·').asstring)<>''then
frm_ch_invoice_jk.t_ch_invoice['·¢Æ±Ì§Í·']:=frm_data_share.t_crm_client_all.fieldbyname('·¢Æ±Ì§Í·').asstring;
end;
jine:=0;
memtblDetail.First;
t_ch_fee_do.Open;
while not memtblDetail.Eof do begin
if (memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat<>0) and (memtblDetail.FieldByNAME('Ñ¡Ôñ').Asboolean) then begin
if memtblDetail['±Ò±ð']='USD' then begin
if bsSkinRadioGroup1.ItemIndex=1 then begin
if bsSkinCheckRadioBox1.Checked then begin
FeeStr.Add(FloatToStr(memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat));
NameStr.Add(memtblDetail['·ÑÓÃÃû³Æ']);
jine:=jine+(memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat);
end else begin
jine:=jine+(memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat);
end;
t_ch_fee_do.Insert;
t_ch_fee_do['¹¤×÷±àºÅ']:=Str;
t_ch_fee_do['ÒµÎñ±àºÅ']:=memtblDetail['±àºÅ'];
t_ch_fee_do['CH_ID']:=memtblDetail['CH_ID'];
t_ch_fee_do['±Ò±ð']:='USD';
t_ch_fee_do['½ð¶î']:=memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat;
t_ch_fee_do['ԭʼ½ð¶î']:=memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat;
t_ch_fee_do['ÀàÐÍ']:=1;
t_ch_fee_do.Post;
end else begin
IF bsSkinCheckRadioBox2.Checked then begin
if bsSkinCheckRadioBox1.Checked then begin
FeeStr.Add(FloatToStr((memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat)*strtofloatdef(bsSkinEdit1.Text,7.0)));
NameStr.Add(memtblDetail['·ÑÓÃÃû³Æ']);
jine:=jine+(memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat)*strtofloatdef(bsSkinEdit1.Text,7.0);
end else begin
jine:=jine+(memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat)*strtofloatdef(bsSkinEdit1.Text,7.0);
end;
t_ch_fee_do.Insert;
t_ch_fee_do['¹¤×÷±àºÅ']:=Str;
t_ch_fee_do['ÒµÎñ±àºÅ']:=memtblDetail['±àºÅ'];
t_ch_fee_do['CH_ID']:=memtblDetail['CH_ID'];
t_ch_fee_do['±Ò±ð']:='RMB';
t_ch_fee_do['½ð¶î']:=(memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat)*strtofloatdef(bsSkinEdit1.Text,7.0);
t_ch_fee_do['ԭʼ½ð¶î']:=memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat;
t_ch_fee_do['ÀàÐÍ']:=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('ʵ¿ª½ð¶î').AsFloat));
NameStr.Add(memtblDetail['·ÑÓÃÃû³Æ']);
jine:=jine+(memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat);
end else begin
jine:=jine+(memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat);
end;
t_ch_fee_do.Insert;
t_ch_fee_do['¹¤×÷±àºÅ']:=Str;
t_ch_fee_do['ÒµÎñ±àºÅ']:=memtblDetail['±àºÅ'];
t_ch_fee_do['CH_ID']:=memtblDetail['CH_ID'];
t_ch_fee_do['±Ò±ð']:='RMB';
t_ch_fee_do['½ð¶î']:=(memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat);
t_ch_fee_do['ԭʼ½ð¶î']:=memtblDetail.FieldByNAME('ʵ¿ª½ð¶î').AsFloat;
t_ch_fee_do['ÀàÐÍ']:=1;
t_ch_fee_do.Post;
end;
end;
end;
memtblDetail.Next;
end;
if bsSkinCheckRadioBox1.Checked then begin
if frm_ch_invoice_jk.t_ch_invoice['ºÏ¼Æ½ð¶î']=0 then begin
frm_ch_invoice_jk.t_ch_invoice['·ÑÓÃÁбí']:=NameStr.Text;
frm_ch_invoice_jk.t_ch_invoice['½ð¶îÁбí']:=FeeStr.Text;
frm_ch_invoice_jk.t_ch_invoice['ºÏ¼Æ½ð¶î']:=jine;
frm_ch_invoice_jk.t_ch_invoice['ʵ¼Ê½ð¶î']:=jine;
end else begin
frm_ch_invoice_jk.t_ch_invoice['·ÑÓÃÁбí']:=frm_ch_invoice_jk.t_ch_invoice['·ÑÓÃÁбí']+#10#13+NameStr.Text;
frm_ch_invoice_jk.t_ch_invoice['½ð¶îÁбí']:=frm_ch_invoice_jk.t_ch_invoice['½ð¶îÁбí']+#10#13+FeeStr.Text;
frm_ch_invoice_jk.t_ch_invoice['ºÏ¼Æ½ð¶î']:=frm_ch_invoice_jk.t_ch_invoice['ºÏ¼Æ½ð¶î']+jine;
frm_ch_invoice_jk.t_ch_invoice['ʵ¼Ê½ð¶î']:=frm_ch_invoice_jk.t_ch_invoice['ʵ¼Ê½ð¶î']+jine;
end;
end else begin
if frm_ch_invoice_jk.t_ch_invoice['±Ò±ð']='USD' then
frm_ch_invoice_jk.t_ch_invoice['·ÑÓÃÁбí']:=get_parameters_value(7,'´úÀíº£ÔË·Ñ')
else
frm_ch_invoice_jk.t_ch_invoice['·ÑÓÃÁбí']:=get_parameters_value(147,'´úÀíÔËÔÓ·Ñ');
if frm_ch_invoice_jk.t_ch_invoice['ºÏ¼Æ½ð¶î']=0 then begin
frm_ch_invoice_jk.t_ch_invoice['½ð¶îÁбí']:=FloatToStr(jine);
frm_ch_invoice_jk.t_ch_invoice['ºÏ¼Æ½ð¶î']:=jine;
frm_ch_invoice_jk.t_ch_invoice['ʵ¼Ê½ð¶î']:=jine;
end else begin
frm_ch_invoice_jk.t_ch_invoice['½ð¶îÁбí']:=FloatToStr(frm_ch_invoice_jk.t_ch_invoice['ºÏ¼Æ½ð¶î']+jine);
frm_ch_invoice_jk.t_ch_invoice['ºÏ¼Æ½ð¶î']:=frm_ch_invoice_jk.t_ch_invoice['ºÏ¼Æ½ð¶î']+jine;
frm_ch_invoice_jk.t_ch_invoice['ʵ¼Ê½ð¶î']:=frm_ch_invoice_jk.t_ch_invoice['ʵ¼Ê½ð¶î']+jine;
end;
end;
frm_ch_invoice_jk.t_ch_invoice.Post;
finally
FreeAndNil(FeeStr);
FreeAndNil(NameStr);
end;
close;
end;
procedure Tfrmch_invoice_addone_jk.t_fee_objAfterScroll(DataSet: TDataSet);
begin
memtblDetail.filtered:=false;
memtblDetail.filter:='¿Í»§Ãû³Æ='+''''+t_fee_obj.fieldbyname('¿Í»§Ãû³Æ').asstring+'''';
memtblDetail.filtered:=true;
end;
end.