unit u_op_seae_sign;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, bsSkinCtrls, DB,
ADODB, ExtCtrls, RxLookup, StdCtrls, wwdbdatetimepicker, wwdblook, Menus,
Mask, bsSkinBoxCtrls, bsdbctrls,DateUtils, kbmMemTable, DBCtrlsEh,ShellAPI,
ComCtrls, bsSkinTabs, dxDBTLCl, dxGrClms, cxDBLabel, cxControls,
cxContainer, cxEdit, cxLabel;
type
Tfrm_op_seae_sign = class(TForm)
t_op_seae: TADOQuery;
t_op_seae1: TDataSource;
kbmMemTable1: TkbmMemTable;
kbmMemTable1Field: TStringField;
kbmMemTable1Field3: TStringField;
kbmMemTable1Field4: TStringField;
kbmMemTable1Field5: TStringField;
kbmMemTable1Field6: TStringField;
kbmMemTable1Field7: TStringField;
kbmMemTable1Field2: TStringField;
kbmMemTable1Field9: TStringField;
kbmMemTable1Field10: TStringField;
kbmMemTable1Field8: TStringField;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
kbmMemTable1Field11: TStringField;
kbmMemTable1Field12: TStringField;
kbmMemTable1Field13: TStringField;
kbmMemTable1Field14: TStringField;
kbmMemTable1Field15: TStringField;
kbmMemTable1Field16: TStringField;
bsSkinPageControl1: TbsSkinPageControl;
bsSkinTabSheet1: TbsSkinTabSheet;
bsSkinTabSheet2: TbsSkinTabSheet;
bsSkinPanel3: TbsSkinPanel;
bsSkinButton4: TbsSkinButton;
btn6_exit: TbsSkinButton;
btn_seach2: TbsSkinButton;
bsSkinButton14: TbsSkinButton;
bsSkinPanel4: TbsSkinPanel;
Label13: TLabel;
Label14: TLabel;
wwDBDateTimePicker5: TwwDBDateTimePicker;
wwDBDateTimePicker6: TwwDBDateTimePicker;
dxDBGrid1: TdxDBGrid;
dxDBGridColumn2: TdxDBGridColumn;
dxDBGridColumn4: TdxDBGridColumn;
dxDBGridColumn7: TdxDBGridColumn;
dxDBGridColumn8: TdxDBGridColumn;
kbmMemTable3: TkbmMemTable;
StringField1: TStringField;
StringField3: TStringField;
StringField4: TStringField;
StringField5: TStringField;
StringField6: TStringField;
StringField8: TStringField;
PopupMenu2: TPopupMenu;
MenuItem1: TMenuItem;
DataSource1: TDataSource;
kbmMemTable3Field: TStringField;
kbmMemTable3Field2: TStringField;
kbmMemTable3Field3: TStringField;
kbmMemTable3Field4: TStringField;
dxDBGrid1Column6: TdxDBGridColumn;
dxDBGrid1Column7: TdxDBGridColumn;
dxDBGrid1Column8: TdxDBGridColumn;
Edit6_searchkhmch: TEdit;
Label8: TLabel;
ADOQUERY_TZFD: TADOQuery;
ADOQUERY_TDQR: TADOQuery;
ADOQUERY_TDQC: TADOQuery;
ADOQUERY_TDQF: TADOQuery;
ADOQUERY_TSFD: TADOQuery;
kbmMemTable1Field17: TStringField;
kbmMemTable1Field18: TStringField;
kbmMemTable1Field19: TStringField;
kbmMemTable1Field20: TStringField;
kbmMemTable1Field21: TStringField;
kbmMemTable1Field22: TBooleanField;
kbmMemTable1Field23: TStringField;
ADOQUERY_TDQH: TADOQuery;
bsknpnl1: TbsSkinPanel;
btn4_exit: TbsSkinButton;
btn3_clearConditon: TbsSkinButton;
bsknpnl2: TbsSkinPanel;
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
lbl4: TLabel;
lbl5: TLabel;
lbl6: TLabel;
lbl7: TLabel;
lbl8: TLabel;
lbl9: TLabel;
lbl10: TLabel;
lbl11: TLabel;
lbl12: TLabel;
lbl13: TLabel;
Edit1_ywbh: TEdit;
Edit2_wtbh: TEdit;
Edit3_ztdh: TEdit;
wdbdtmpckr1_kc: TwwDBDateTimePicker;
wdbdtmpckr2_kc: TwwDBDateTimePicker;
Edit4_hc: TEdit;
wdblkpcmb1_cm: TwwDBLookupCombo;
wdblkpcmb2_xhg: TwwDBLookupCombo;
wdbdtmpckr3_lr: TwwDBDateTimePicker;
wdbdtmpckr4_lr: TwwDBDateTimePicker;
DBComboBoxEh1: TDBComboBoxEh;
RxDBLookupCombo28: TRxDBLookupCombo;
dxdbgrd1_S: TdxDBGrid;
dxdbgrdclmns: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column2: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column3: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column4: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column5: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column6: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column13: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column19: TdxDBGridColumn;
dxdbgrdclmnDBGrid1Column10: TdxDBGridColumn;
kbmMemTable1Field24_xuanxiang: TBooleanField;
DataSource2: TDataSource;
qry1_qdtm: TADOQuery;
dxdbgrdclmnDBGrid1Column11: TdxDBGridColumn;
dxdbgrdclmnDBGrid1Column12: TdxDBGridColumn;
dxdbgrdclmnDBGrid1Column13: TdxDBGridColumn;
Edit1_qdtbh: TEdit;
lbl14: TLabel;
bsknpnl4_NewQDT: TbsSkinPanel;
lbl15_searchqdthm: TLabel;
Edit15_searchqdthm: TEdit;
ds3_ls_qdtm: TDataSource;
dxdbgrdclmndxdbgrd1_SColumn9: TdxDBGridColumn;
N2: TMenuItem;
btn4_searchNew: TbsSkinButton;
lbl15: TLabel;
dxdbgrdchckclmnDBGrid1Column14_tf: TdxDBGridCheckColumn;
dxdbgrdchckclmnDBGrid1Column13b: TdxDBGridCheckColumn;
RxDBLookupCombo_wtdw: TRxDBLookupCombo;
dxdbgrdclmndxdbgrd1_SColumn10: TdxDBGridColumn;
dxdbgrdclmnDBGrid1Column14: TdxDBGridColumn;
qry_crm_client_weituo: TADOQuery;
btn1_gennerateSign: TbsSkinButton;
ds2_wt: TDataSource;
dxdbgrdclmndxdbgrd1_SColumn6_B: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1_SColumn6_C: TdxDBGridColumn;
dxdbgrdclmnDBGrid1Column15: TdxDBGridColumn;
dxdbgrdclmnDBGrid1Column16: TdxDBGridColumn;
bskntbsht1_pj: TbsSkinTabSheet;
bsknpnl3: TbsSkinPanel;
btn1: TbsSkinButton;
btn4_searchNew_pj: TbsSkinButton;
btn3_clearConditon_pj: TbsSkinButton;
btn1_gennerateSign_pj: TbsSkinButton;
bsknpnl4: TbsSkinPanel;
lbl16: TLabel;
lbl17: TLabel;
lbl18: TLabel;
lbl19: TLabel;
lbl20: TLabel;
lbl21: TLabel;
lbl22: TLabel;
lbl23: TLabel;
lbl24: TLabel;
lbl25: TLabel;
lbl26: TLabel;
lbl27: TLabel;
lbl28: TLabel;
Edit1_ywbh_pj: TEdit;
Edit2_wtbh_pj: TEdit;
Edit3_ztdh_pj: TEdit;
wdbdtmpckr1_kc_pj: TwwDBDateTimePicker;
wdbdtmpckr2_kc_pj: TwwDBDateTimePicker;
Edit4_hc_pj: TEdit;
wdblkpcmb1_cm_pj: TwwDBLookupCombo;
wdblkpcmb2_xhg_pj: TwwDBLookupCombo;
wdbdtmpckr3_lr_pj: TwwDBDateTimePicker;
wdbdtmpckr4_lr_pj: TwwDBDateTimePicker;
DBComboBoxEh1_pj: TDBComboBoxEh;
RxDBLookupCombo_wtdw_pj: TRxDBLookupCombo;
ds2_wt_pj: TDataSource;
qry_crm_client_weituo_pj: TADOQuery;
ds_op_seae1_pj: TDataSource;
qry_op_seae_pj: TADOQuery;
dxdbgrd1_S_pj: TdxDBGrid;
dxdbgrdclmn1: TdxDBGridColumn;
dxdbgrdclmn2: TdxDBGridColumn;
dxdbgrdclmn3: TdxDBGridColumn;
dxdbgrdclmn4: TdxDBGridColumn;
dxdbgrdclmn5: TdxDBGridColumn;
dxdbgrdclmn6: TdxDBGridColumn;
dxdbgrdclmn7: TdxDBGridColumn;
dxdbgrdclmn8: TdxDBGridColumn;
dxdbgrdclmn9: TdxDBGridColumn;
dxdbgrdclmn10: TdxDBGridColumn;
dxdbgrdclmn11: TdxDBGridColumn;
dxdbgrdclmn12: TdxDBGridColumn;
DBComboBoxEh: TDBComboBoxEh;
dxdbgrdclmnDBGrid1Column17: TdxDBGridColumn;
bskntbsht1: TbsSkinTabSheet;
bsknpnl5: TbsSkinPanel;
btn43_exit: TbsSkinButton;
btn41_search_log: TbsSkinButton;
btn3_clearConditon_log: TbsSkinButton;
bsknpnl6: TbsSkinPanel;
lbl29: TLabel;
lbl30: TLabel;
lbl31: TLabel;
lbl32: TLabel;
lbl33: TLabel;
wdbdtmpckr41_start: TwwDBDateTimePicker;
wdbdtmpckr42_end: TwwDBDateTimePicker;
Edit42_zhtdh: TEdit;
Edit41_qdtbh: TEdit;
dxdbgrd41_log: TdxDBGrid;
dxdbgrdclmn41_log_qdtbh: TdxDBGridColumn;
dxdbgrdclmn42_log_zhtdh: TdxDBGridColumn;
dxdbgrdclmn43__log_reason: TdxDBGridColumn;
dxdbgrdclmn44__log_cancelPerson: TdxDBGridColumn;
dxdbgrdclmn45__log_canceldate: TdxDBGridColumn;
ds41_cancellog: TDataSource;
qry41_cancellog: TADOQuery;
procedure btn4_exitClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btn3_clearConditonClick(Sender: TObject);
procedure btn4_searchNewClick(Sender: TObject);
procedure bsknpnl1Resize(Sender: TObject);
procedure dxdbgrd1_SColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
procedure btn1_gennerateSignClick(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure dxdbgrd1_SCustomDraw(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn;
const AText: String; AFont: TFont; var AColor: TColor; ASelected,
AFocused: Boolean; var ADone: Boolean);
procedure Edit3_ztdhKeyPress(Sender: TObject; var Key: Char);
procedure dxdbgrd1_SDblClick(Sender: TObject);
procedure dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column13CustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean;
var ADone: Boolean);
procedure dxDBGrid2Column14CustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean;
var ADone: Boolean);
procedure btn_seach2Click(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure btn6_exitClick(Sender: TObject);
procedure RxDBLookupCombo28Enter(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btn11Click(Sender: TObject);
procedure searchqdt(bh:string);
procedure Edit1_qdtbhKeyPress(Sender: TObject; var Key: Char);
procedure dxDBGrid1DblClick(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure bsSkinPageControl1Change(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure bsSkinButton14Click(Sender: TObject);
procedure Edit1_ywbhKeyPress(Sender: TObject; var Key: Char);
procedure Edit6_searchkhmchKeyPress(Sender: TObject; var Key: Char);
procedure frm__op_seae_sign_new_infomniN3Click(Sender: TObject);
procedure dxDBGrid1CustomDraw(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn;
const AText: String; AFont: TFont; var AColor: TColor; ASelected,
AFocused: Boolean; var ADone: Boolean);
procedure btn4_searchNew_pjClick(Sender: TObject);
procedure btn1_gennerateSign_pjClick(Sender: TObject);
procedure btn3_clearConditon_pjClick(Sender: TObject);
procedure btn3_clearConditon_logClick(Sender: TObject);
procedure btn41_search_logClick(Sender: TObject);
procedure searchCancelLog();
procedure Edit41_qdtbhKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
employeePhone:string;
m_infomation:string;
function CheckBilldue(bsnoes,wtdw:string):Boolean;
function CheckBilldue2(bsnoes,wtdw:string):Boolean;
function getNouseDate(wtdw: string ):TDateTime;
function CheckBilldue_pj(bsnoes,wtdw:string;out blnotifyOk:boolean):Boolean; //票结客户验证
function gettmpzqdate(cust: string ):string;//获得临时账期:dt1~dt2
public
{ Public declarations }
op:integer;
function GetmblState(bsno:string):Boolean;
function GetmblzbState(bsno:string):Boolean;
function GetmblStateOut(bsno:string):Boolean;
procedure UpateSeaeState(bsno,billstate:string);
function GetSeaeStateDate(bsno,billstate:string):string;
function _GetmblStateout(bsno,bsstatus:string):string;
procedure Initsql(AdoQuery:TAdoQuery;str,s:string);
procedure Initsql_ts(AdoQuery:TAdoQuery);
procedure initialEmployeePhone();
procedure show_qdtxx(qdtbh:string;iway:Integer);
end;
var
frm_op_seae_sign: Tfrm_op_seae_sign;
implementation
uses u_main,my_sys_function, u_op_seae_teshufandan,u_sys_progress,u_op_seae_sign_info,
u_op_seae_sign_new_info, u_op_znjyj, u_op_znjpj;
{$R *.dfm}
const stateNewQD = '生成签单条';
//
function Tfrm_op_seae_sign._GetmblStateout(bsno,bsstatus:string):string;
var aAdoQuery:TAdoQuery;
begin
result:='';
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
try
Close;SQL.Clear;
SQL.Add('select 编号,业务状态,录入日期');
SQL.Add('from t_op_state where 编号=:bsNo1 and 业务状态=:bsstatus ');
Parameters.ParamByName('bsNo1').value:=bsno;
Parameters.ParamByName('bsstatus').value:=bsstatus;
Open;
if not IsEmpty then
result:=FieldByName('业务状态').AsString;
finally
aAdoQuery.Free;
end;
end;
function Tfrm_op_seae_sign.GetSeaeStateDate(bsno,billstate:string):string;
var aAdoQuery:TAdoQuery;
begin
Result:='';
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
try
Close;SQL.Clear;
SQL.Add('select 编号,录入日期 处理日期 from t_op_state');
SQL.Add('where 编号=:bsNo and 业务状态=:billstate');
Parameters.ParamByName('bsNo').value:=bsno;
Parameters.ParamByName('billstate').value:=billstate;
open;
if not IsEmpty then
Result:=FormatDateTime('YYYY-MM-DD',FieldByName('处理日期').AsDateTime);
finally
aAdoQuery.Free;
end;
end;
procedure Tfrm_op_seae_sign.UpateSeaeState(bsno,billstate:string);
var aAdoQuery:TAdoQuery;
begin
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
try
Close;SQL.Clear;
SQL.Add('Update t_op_Seae');
SQL.Add('set 提单签发状态=:billstate where 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Parameters.ParamByName('billstate').value:=billstate;
execsql;
finally
aAdoQuery.Free;
end;
end;
function Tfrm_op_seae_sign.GetmblState(bsno:string):Boolean;
var aAdoQuery:TAdoQuery;
b1,b2,b3:Boolean;
begin
result:=false;
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
try
Close;SQL.Clear;
SQL.Add('select 编号,业务状态');
SQL.Add('from t_op_state where 业务状态=''通知放单'' and 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Open;
b1:=RecordCount>=1;
Close;SQL.Clear;
SQL.Add('select 编号,业务状态');
SQL.Add('from t_op_state where 业务状态=''提单签出'' and 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Open;
b2:=RecordCount>=1;
Close;SQL.Clear;
SQL.Add('select 编号,业务状态');
SQL.Add('from t_op_state where 业务状态=''提单签发'' and 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Open;
b3:= isempty or (RecordCount=0);
result:=(b1 or b2) and b3;
finally
aAdoQuery.Free;
end;
end;
function Tfrm_op_seae_sign.GetmblzbState(bsno:string):Boolean; //
var aAdoQuery:TAdoQuery;
b1,b2,b3,b4:Boolean;
begin
result:=false;
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
try
Close;SQL.Clear;
SQL.Add('select 编号,业务状态');
SQL.Add('from t_op_state where 业务状态=''通知放单'' and 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Open;
b1:=RecordCount>=1;
Close;SQL.Clear;
SQL.Add('select 编号,业务状态');
SQL.Add('from t_op_state where 业务状态=''提单签入'' and 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Open;
b2:=RecordCount>=1;
Close;SQL.Clear;
SQL.Add('select 编号,业务状态');
SQL.Add('from t_op_state where 业务状态=''提单签出'' and 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Open;
b3:=RecordCount>=1;
Close;SQL.Clear;
SQL.Add('select 编号,业务状态');
SQL.Add('from t_op_state where 业务状态=''提单签发'' and 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Open;
b4:= isempty or (RecordCount=0);
result:=(b1 or b2 or b3) and b4;
finally
aAdoQuery.Free;
end;
end;
function Tfrm_op_seae_sign.GetmblStateOut(bsno:string):Boolean;
var aAdoQuery:TAdoQuery;
begin
result:=false;
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do
try
Close;SQL.Clear;
SQL.Add('select 编号,业务状态');
SQL.Add('from t_op_state where 业务状态=''提单签出'' and 编号=:bsNo');
Parameters.ParamByName('bsNo').value:=bsno;
Open;
result:=RecordCount=1;
finally
aAdoQuery.Free;
end;
end;
procedure Tfrm_op_seae_sign.btn4_exitClick(Sender: TObject);
begin
Close;
end;
procedure Tfrm_op_seae_sign.FormShow(Sender: TObject);
var str,mblstatus:string;
begin
RxDBLookupCombo28.LookupDisplay:='代码;签单方式';
RxDBLookupCombo28.DisplayValue :='ZB';
//未过期的月结客户 begin
//临时账期客户归入月结客户 程建波 2017-08-15
qry_crm_client_weituo.SQL.Clear;
str:='SELECT t.代码,t.EDI代码,t.客户简称,t.客户全称,t.揽货人,t.快捷代码,'
+ 't.空运快捷代码,t.发货人,t.结费习惯,t.其他要求,t.备注,yjkh.结费类型' + #13#10
+' FROM t_crm_client AS t INNER JOIN ' + #13#10
+' (select 客户简称 AS khjc,''临时账期'' as 结费类型 from t_crm_client_sales_tmp '
+' where 结束日期>=cast(GETDATE()as date) ' + #13#10
+ ' union SELECT DISTINCT 客户简称 AS khjc, 结费类型 FROM t_crm_client_sales '
+ ' WHERE (结费类型 IN (''约定时间'', ''约定天数'') and 结束日期>=cast(GETDATE()as date) ) '
+ ' and 客户简称 not in (select 客户简称 from t_crm_client_sales_tmp where 结束日期>=cast(GETDATE()as date))'
+' ) AS yjkh ' +#13#10
+' ON t.客户简称 = yjkh.khjc ' +#13#10
+' WHERE (t.客户性质 <> ''目标'') AND (t.委托单位 = 1) AND '
+ ' (ISNULL(t.放单不控制, 0) = 0) ORDER BY t.代码';
qry_crm_client_weituo.SQL.Add(str);
//月结客户 end
qry_crm_client_weituo.Close();
qry_crm_client_weituo.Open;
//DBComboBoxEh1.text:='提单签回';
//DBComboBoxEh1.text:='提单签入';
loadreggrid(dxdbgrid1,false,caption );
loadreggrid(dxdbgrd1_S,false,caption+'1');
loadreggrid(dxdbgrd1_S_pj,false,caption+'2');
loadreggrid(dxdbgrd41_log,false,caption+'3');
//提单签出
initialEmployeePhone();
bsSkinPageControl1.ActivePageIndex:=0;
dxdbgrd1_S.Width:=self.ClientWidth;
bsknpnl1.Height :=34;
self.WindowState:= wsMaximized;
wwDBDateTimePicker5.Date:=Date-7; ;//StrToDateTime(Formatdatetime('YYYY-MM-DD',date-7));
wwDBDateTimePicker6.Date:=Date;//StrToDateTime(Formatdatetime('YYYY-MM-DD',date));
// btn4_searchNewClick(btn4_searchNew);
//
if(if_open('449')) then
begin
bskntbsht1_pj.TabVisible:=true;
qry_crm_client_weituo_pj.Close;
qry_crm_client_weituo_pj.Open;
end
else
begin
bskntbsht1_pj.TabVisible:=false;
end;
//
wdbdtmpckr41_start.Date:=Date-7;
wdbdtmpckr42_end.date:=Date;
end;
procedure Tfrm_op_seae_sign.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
savereggrid(dxdbgrid1,caption);
savereggrid(dxdbgrd1_S,caption+'1');
savereggrid(dxdbgrd1_S_pj,caption+'2');
savereggrid(dxdbgrd41_log,caption+'3');
frm_op_seae_sign.Hide;
frm_op_seae_sign.ManualFloat(frm_op_seae_sign.BoundsRect );
frm_main.freeTabs('frm_op_seae_sign');
action:=cafree;
frm_op_seae_sign:=nil;
end;
procedure Tfrm_op_seae_sign.btn3_clearConditonClick(Sender: TObject);
begin
Edit1_ywbh.text:='';
Edit2_wtbh.text:='';
Edit3_ztdh.text:='';
wdbdtmpckr1_kc.text:='';
wdbdtmpckr2_kc.text:='';
wdbdtmpckr3_lr.text:='';
wdbdtmpckr4_lr.text:='';
wdblkpcmb2_xhg.text:='';
wwDBDateTimePicker5.text:='';
wwDBDateTimePicker6.text:='';
Edit6_searchkhmch.text:='';
Edit1_qdtbh.text:='';
end;
procedure Tfrm_op_seae_sign.Initsql(AdoQuery:TAdoQuery;str,s:string);
begin
with AdoQuery do
begin
Close;sql.Clear;
sql.add('select t_op_seae.编号,t_op_state.业务状态,t_op_state.录入日期');
sql.add('from t_op_state');
sql.add('left JOIN t_op_seae on t_op_state.编号 = t_op_seae.编号 ' +str);
sql.add('and t_op_state.业务状态='''+s+'''');
sql.add('order by t_op_seae.编号');
Open;First;
end;
end;
procedure Tfrm_op_seae_sign.Initsql_ts(AdoQuery:TAdoQuery);
begin
with AdoQuery do
begin
Close;Sql.Clear;
SQL.Add('Select 编号,放单状态 from t_op_fangdan');
sql.add('order by 编号');
Open;First;
end;
end;
function replaceSQuotes(txt: string):string;
begin
result:=stringreplace(txt,'''','''''',[rfReplaceAll]);
end;
procedure Tfrm_op_seae_sign.btn4_searchNewClick(Sender: TObject);
var
str,mblstatus:widestring;
begin
str:='where t_op_seae.主提单号<>'''' and t_op_seae.签单方式<>''''';
if RxDBLookupCombo_wtdw.DisplayValues[1]=''then
begin
//八家固定月结客户
// str:=str +' and t_op_seae.委托单位 in (''青岛和川国际'',''浩宏物流'',''澳源达'',''希世物流'',''俊鑫'',''东顺海达'',''泛海华航'',''舜安恒泰'')';
//1.客户账期为月结(账期为约定天数,约定日期)
//2.签单方式为(正本)
//3.并排除放单不控制的客户
//4. 临时账期客户 归入到月结客户 程建波 2017-08-15
str:=str +' and t_op_seae.委托单位 '
+'in (select 客户简称 from t_crm_client_sales_tmp where 结束日期>=cast(GETDATE() as date) '
+' UNION SELECT DISTINCT 客户简称 FROM t_crm_client_sales '
+' WHERE 结费类型 IN (''约定时间'', ''约定天数'') and 结束日期>=cast(GETDATE()as date))'
+' and t_op_seae.委托单位 not in ( select t.客户简称 FROM t_crm_client t where (ISNULL(t.放单不控制, 0) = 1))';
end
else
str:=str+' and t_op_seae.委托单位='+''''+RxDBLookupCombo_wtdw.DisplayValues[1]+'''';
if Edit1_ywbh.text<>''then
str:=str+' and t_op_seae.业务编号 like '+''''+'%'+replaceSQuotes(Edit1_ywbh.text)+'%'+'''';
if Edit2_wtbh.text<>''then
str:=str+' and t_op_seae.委托编号 like '+''''+'%'+replaceSQuotes(Edit2_wtbh.text)+'%'+'''';
if Edit3_ztdh.text<>''then
str:=str+' and t_op_seae.主提单号 like '+''''+'%'+replaceSQuotes(Edit3_ztdh.text)+'%'+'''';
if wdbdtmpckr1_kc.text<>''then
str:=str+' and t_op_seae.开船日期>='+''''+wdbdtmpckr1_kc.text+'''';
if wdbdtmpckr2_kc.text<>''then
str:=str+' and t_op_seae.开船日期<='+''''+wdbdtmpckr2_kc.text+'''';
if wdblkpcmb1_cm.text<>''then
str:=str+' and t_op_seae.船名 like '+''''+'%'+replaceSQuotes(wdblkpcmb1_cm.text)+'%'+'''';
if Edit4_hc.text<>''then
str:=str+' and t_op_seae.航次 like '+''''+'%'+replaceSQuotes(Edit4_hc.text)+'%'+'''';
if wdblkpcmb2_xhg.text<>''then
str:=str+' and t_op_seae.卸货港 like '+''''+'%'+replaceSQuotes(wdblkpcmb2_xhg.text)+'%'+'''';
// //if DBComboBoxEh1.text<>'' then
str:=str+' and ( t_op_state.业务状态 = ''提单签入'')';
if wdbdtmpckr3_lr.text<>''then
str:=str+' and t_op_state.录入日期>='+''''+wdbdtmpckr3_lr.text+'''';
if wdbdtmpckr4_lr.text<>''then
str:=str+' and t_op_state.录入日期<='+''''+wdbdtmpckr4_lr.text+' 23:59:59''';
//
str:=str+' and '+ open_data('0001','t_op_seae.录入人',
't_op_seae.操作员','t_op_seae.客服员','t_op_seae.报关操作','t_op_seae.报检操作');
//
if RxDBLookupCombo28.text<>''then
str:=str+' and t_op_seae.签单方式 like '+''''+'%'+RxDBLookupCombo28.Value+'%'+''''
+' and t_op_state.编号 not in ('
+'select 编号 from t_op_seae_sign_detail t left join t_op_seae_sign_main m on (m.签单条编号=t.签单条编号) where m.状态<>''已作废'' ' // where t.是否签单=1
+' union select 编号 from t_op_state t where t.业务状态=''提单签出'''
+' union select t.编号 from t_op_seae_app t'
+')';
with t_op_seae do
begin
close;sql.clear;
sql.add('select distinct t_op_seae.业务状态,t_op_seae.编号,t_op_seae.业务编号,t_op_seae.委托单位,t_op_seae.船名,t_op_seae.航次');
sql.add(',t_op_seae.主提单号,t_op_seae.签单方式,t_op_seae.开船日期 , t_op_state.录入日期 as [提单签入日期]');
sql.add(',t_op_seae.操作员,t_op_seae.揽货人,t_op_seae.提单签发状态,t_op_seae.结费类型,t_op_seae.装货港,t_op_seae.卸货港');
sql.add('from t_op_state');
sql.add('left JOIN t_op_seae on t_op_state.编号 = t_op_seae.编号 ' +str);
open;First;
end;
if t_op_seae.IsEmpty then
begin
showmessage('没有检索出要查找的提单!!');
exit;
end;
end;
procedure Tfrm_op_seae_sign.bsknpnl1Resize(Sender: TObject);
var
i:integer;
begin
// i:=round(bsSkinPanel1.Width/11);
// bsSkinButton9.Width:=i;
//bsSkinButton1.Width:=i;
end;
procedure Tfrm_op_seae_sign.dxdbgrd1_SColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
begin
Column_sort(Column,t_op_seae,'业务编号');
end;
procedure Tfrm_op_seae_sign.btn1_gennerateSignClick(Sender: TObject);
var
str,bsno:widestring;
i:integer;
aQuery:TAdoQuery;
qdm_Query:TAdoQuery;
qdd_Query:TAdoQuery;
qry_state:TADOQuery;
qdtbh:string;
strwtdw1,strwtdw2,zhtdh,ysstr,znjstr:string;
khlx:string;//客户类型
dbTime,nouseDate:TDateTime;
blNoQF,isznj:Boolean; //是否无欠费
bsnoes:string; //签单条 选中的编号
strsql:string;
bllszq:Boolean;
strlszq:string;//临时账期范围
reasons:string;//临时账期发签单条原因
ttlznj:Double;
begin
blNoQF:=True; //无欠费
bsnoes:='';
if dxdbgrd1_S.SelectedCount<1 then
Exit;
//计算作废日期
nouseDate:=getNouseDate(t_op_seae.FieldByName('委托单位').AsString); //debug
try
//begin check
//初始化提示信息为空
m_infomation:='';
for i:=0 to dxdbgrd1_S.SelectedCount-1 do
begin
t_op_seae.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i]));
if i=0 then
begin
strwtdw1 := t_op_seae.FieldByName('委托单位').AsString;
strwtdw2:=strwtdw1;
bsnoes:=''''+ t_op_seae.FieldByName('编号').AsString +'''';
end
else
begin
strwtdw2 := t_op_seae.FieldByName('委托单位').AsString;
bsnoes:=bsnoes+','''+ t_op_seae.FieldByName('编号').AsString +'''';
end;
if strwtdw1<>strwtdw2 then
begin
showmessage('委托单位不唯一!');
Exit;
end;
end; //end for
//判断临时账期
bllszq:=false;
khlx:= getzqlx(strwtdw1,false);
if(khlx='现结买单')then
begin
strlszq:=gettmpzqdate(strwtdw1);
if( strlszq<>'') then
begin
khlx:='临时账期';
if Application.MessageBox(pchar(strwtdw1+' 临时帐期没有过期:'+ strlszq +#13#10+'确实要生成签单条吗?'),'信息提醒',MB_YESNO+mb_iconquestion)<> ID_YES then
begin
Exit;
end;
bllszq:=True;
end
else
begin
//请确认该客户是否是月结客户??????
ShowMessage('请确认该客户是否是月结客户!');
end;
end;
try
//一个提醒信息,因为每一票的提醒都一样
if(bllszq=False) and (CheckBilldue(bsnoes,strwtdw1 )=False) then
blNoQF:=false; //只标记不退出
except
on ex:Exception do
begin
errorlog(ex.Message) ;
ShowMessage('判断提单状态时发生异常:' + ex.message) ;
Exit;
end;
end;
{
isznj:=getyjzq(bsnoes,strwtdw1,ysstr,znjstr,ttlznj);
if (isznj) then begin
try
if not assigned(frm_op_znjyj) then
frm_op_znjyj:=tfrm_op_znjyj.Create (self);
frm_op_znjyj.lblcust.Caption:=strwtdw1;
frm_op_znjyj.lblmonth.Caption:=FormatDateTime('MM',t_op_seae.fieldbyname('开船日期').AsDateTime);
frm_op_znjyj.lblzq.Caption:=getzq(strwtdw1);
frm_op_znjyj.lbldate.Caption:=FormatDateTime('YYYY-MM-DD',Date);
frm_op_znjyj.lblznj.Caption:=znjstr;
frm_op_znjyj.lblys.Caption:=ysstr;
frm_op_znjyj.lblttlznj.Caption:=FloatToStr(ttlznj);
frm_op_znjyj.Memo1.Clear;
frm_op_znjyj.Memo1.Lines.Add('应收费用:'+ysstr);
frm_op_znjyj.Memo1.Lines.Add('');
frm_op_znjyj.Memo1.Lines.Add('滞纳金:'+znjstr);
frm_op_znjyj.Memo1.Lines.Add('');
frm_op_znjyj.Memo1.Lines.Add('合计:'+FloatToStr(ttlznj));
frm_op_znjyj.ShowModal;
finally
FreeAndNil(frm_op_znjyj);
end;
Exit;
end;
}
if(blNoQF=false) then
begin
//欠费处理
//月结客户欠费不能生成签单条 :需求 张晨源 2017-08-02
//月结客户欠费的情况下,如果有特殊权限可以生成签单条 :需求 张晨源 2017-08-15
if(if_open('450')) then
begin
if Application.MessageBox(pchar('当前要生成签单存在欠费'+#13#10+ m_infomation +#13#10+'是否继续生成签单条?'),'信息提醒'
,mb_yesno+mb_iconquestion)<>id_yes then
exit;
end
else
begin
Application.MessageBox(pchar('当前要生成签单存在欠费'+#13#10+ m_infomation +#13#10+'不能生成签单条!'+#13#10+'请选择其他放单模式:'+#13#10+'1.是否有跨月负数更改单'+#13#10+'2.查账放单'+#13#10+'3.到账本放单'+#13#10+'4.特殊放单'),'信息提醒'
,MB_ICONINFORMATION);
exit;
end;
end;
//end check
aQuery:=CreateAdoQuery();
qdm_Query:=CreateAdoQuery();
qdd_Query:=CreateAdoQuery();
str:= 'INSERT INTO t_sys_signid (mainorderno) VALUES (''222'');';
aQuery.SQL.Add(str) ;
aQuery.ExecSQL();
aQuery.sql.Clear();
str:= 'select MAX(signid) as qdtbh,GETDATE()as FDate from t_sys_signid; ';
aQuery.sql.add(str);
qdm_Query.SQL.Add('SELECT * FROM [t_op_seae_sign_main] where 1=2');
qdd_Query.SQL.Add('SELECT * FROM [t_op_seae_sign_detail] where 1=2');
aQuery.Open;
aQuery.First;
qdtbh:=aQuery.FieldByName('qdtbh').AsString;
dbTime:=aQuery.FieldByName('FDate').AsDateTime;
aQuery.sql.Clear();
aQuery.sql.Add('SELECT * FROM [t_op_state] WHERE 1=2');
aQuery.OPEN;
qdm_Query.Open;
qdd_Query.Open;
try
frm_main.db.BeginTrans;
for i:=0 to dxdbgrd1_S.SelectedCount-1 do
begin
t_op_seae.GoTobookmark(pointer(dxdbgrd1_S.SelectedRows[i]));
if i=0 then
begin
strwtdw1 := t_op_seae.FieldByName('委托单位').AsString;
strwtdw2:=strwtdw1;
with qdm_Query do
begin
Insert;
FieldByName('签单条编号').AsString:=qdtbh;
FieldByName('客户名称').AsString:= strwtdw1;
FieldByName('录入人').AsString:= employee;
FieldByName('录入人电话').AsString:=employeePhone;
FieldByName('录入日期').AsDateTime:= dbTime;
FieldByname('账期').AsString:=getzq(strwtdw1);
//计算作废日期
nouseDate:=getNouseDate(strwtdw1);
if(nouseDate>0) then
FieldByName('作废日期').AsDateTime:= nouseDate
else FieldByName('作废日期').AsDateTime:=date+3;
FieldByname('客户类型').AsString:=khlx;
FieldByName('状态').AsString:= stateNewQD;
FieldByName('是否特放').AsVariant:= 0;
//
FieldByname('签单条类型').AsString:='月结';
FieldByName('状态').AsString:='通知签出签单条';
FieldByName('通知签出时间').AsDateTime:= dbTime;
//月结客户提单签出
FieldByName('状态').AsString:='签出签单条';
FieldByName('签出时间').AsDateTime:=dbTime;
end;
end
else
begin
strwtdw2 := t_op_seae.FieldByName('委托单位').AsString;
end;
qdd_Query.Insert;
qdd_Query.FieldByName('签单条编号').AsString:= qdtbh;
qdd_Query.FieldByName('编号').AsString:= t_op_seae.FieldByName('编号').AsString;
zhtdh:= t_op_seae.FieldByName('主提单号').AsString;
qdd_Query.FieldByName('主提单号').AsString:= zhtdh;
qdd_Query.FieldByName('船名').AsString:= t_op_seae.FieldByName('船名').AsString;
qdd_Query.FieldByName('航次').AsString:= t_op_seae.FieldByName('航次').AsString;
qdd_Query.FieldByName('签单方式').AsString:= t_op_seae.FieldByName('签单方式').AsString;
qdd_Query.FieldByName('状态').AsString:= stateNewQD;
qdd_Query.FieldByName('提单签入日期').AsDateTime:= t_op_seae.FieldByName('提单签入日期').AsDateTime;
with aQuery do
begin
//
Insert;
FieldByName('编号').AsString:= t_op_seae.FieldByName('编号').AsString;
FieldByName('业务状态').AsString:= stateNewQD;
FieldByName('录入人').AsString:= employee;
FieldByName('录入日期').AsDateTime:= dbTime;
end;
end; //end for
if( blNoQF=False) then
begin
//欠费发签出提醒
qdm_Query.FieldByName('状态').AsString:='通知签出签单条';
qdm_Query.FieldByName('通知签出时间').AsDateTime:=dbTime;
end;
qdm_Query.post;
qdd_Query.post;
aQuery.post;
{
qry_state:=CreateAdoQuery;
with qry_state do
begin
Close;SQL.Clear;
//---插入提单签出状态
SQL.Add('insert into t_op_state (编号 ,业务状态 ,录入人 ,录入日期,备注)'
+'select 编号,''提单签出'' as 业务状态,'''+ employee +''' as 录入人,GETDATE() as 录入日期,null as 备注 '
+' from t_op_seae s where s.编号 in (' + bsnoes+ ') '
+' and not exists (select ts.编号 from t_op_state ts where 业务状态=''提单签出'' and ts.编号=s.编号) '
);
//---通知放单
SQL.Add('insert into t_op_state (编号 ,业务状态 ,录入人 ,录入日期,备注)'
+'select 编号,''通知放单'' as 业务状态,'''+ employee +''' as 录入人,GETDATE() as 录入日期,null as 备注 '
+' from t_op_seae s where s.编号 in (' + bsnoes+ ') '
+' and not exists (select ts.编号 from t_op_state ts where 业务状态=''通知放单'' and ts.编号=s.编号) '
);
//---提单签出
SQL.Add('Update t_op_Seae set 提单签发状态=''提单签出'' ,签回日期=getdate() '
+' where 编号 in (' + bsnoes +');' );
i:= ExecSQL();
if(i<0) then
ShowMessage('月结签单条更新签出状态失败!');
end;
}
frm_main.db.CommitTrans;
show_qdtxx(qdtbh,0);
aQuery.close();
qdm_Query.close();
qdd_Query.close();
t_op_seae.Requery();
except
on ex: Exception do
begin
errorlog(ex.Message) ;
ShowMessage(ex.Message);
aQuery.Cancel;
qdm_Query.Cancel;
qdd_Query.Cancel;
frm_main.db.rollbacktrans;
end
end;
except
on ex: Exception do
begin
errorlog(ex.Message) ;
ShowMessage(ex.Message);
end;
end;
end;
function Tfrm_op_seae_sign.getNouseDate( wtdw:string):TDateTime;
var
str:string;
aQuery:TAdoquery;
iday:Integer;
begin
result:=0;
str:='select jfrq0, 结费日期 ,case when DAY( GETDATE()) < = 结费日期 ' +#13#10
+' then DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)+ 结费日期 ' +#13#10
+' else ' +#13#10
+' DATEADD(mm, DATEDIFF(mm,0,getdate())+1, 0)+ case when jfrq0>下月天数 then 下月天数 else jfrq0 end ' +#13#10
+' end as 作废日期,客户简称 from (' +#13#10
+' select 客户简称,结费日期 as jfrq0,当月天数,下月天数, ' +#13#10
+' case when 结费日期> 当月天数 then 当月天数 else 结费日期 end as 结费日期 ' +#13#10
+' from ' +#13#10
+' (' +#13#10
+' select 结费日期,客户简称,day( DATEADD(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate())+1, 0))) as 当月天数,' +#13#10
+' day( DATEADD(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate())+2, 0))) as 下月天数' +#13#10
+' from t_crm_client_sales WITH(NOLOCK) where 日期模式=''固定'' and isnull( 结费日期,0)>0 ' +#13#10
+' and 客户简称='''+ wtdw +'''' +#13#10
+' ) crm ' +#13#10
+' ) crm_sales ';
aquery:=CreateAdoQuery;
with aquery do
begin
close;
sql.clear;
sql.add(str);
open;First;
if IsEmpty then
begin
result:=0;
end
else
result:=aquery.fieldbyname('作废日期').asdatetime;
end;
end;
///
/// 获得临时账期
///
function Tfrm_op_seae_sign.gettmpzqdate(cust: string ):string;
var
aQuery:TAdoQuery;
begin
result:='';
aQuery:=CreateAdoQuery;
try
with aQuery do
begin
close;sql.Clear;
sql.Add('select top 1 t.开始日期,t.结束日期 from t_crm_client_sales_tmp t ');
sql.Add(' where 客户简称='''+cust+''' and 结束日期>=cast(GETDATE() as date) order by 结束日期 desc ');
open;First;
if IsEmpty then
begin
result:='';
end
else
begin
result:= FormatDateTime('YYYY-MM-DD',FieldByName('开始日期').AsDateTime)
+ '~'+FormatDateTime('YYYY-MM-DD',FieldByName('结束日期').AsDateTime) ;
end;
end;
finally
FreeAndNil(aQuery);
end;
end;
procedure Tfrm_op_seae_sign.N1Click(Sender: TObject);
begin
//grid_save_xls(dxdbgrd2);
end;
procedure Tfrm_op_seae_sign.dxdbgrd1_SCustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
begin
{ if ANode.Strings[dxDBGrid2Column10.Index]='副总审核' then begin
AFont.Color:=clGreen;
end
else
if ANode.Strings[dxDBGrid2Column10.Index]='主管审核' then begin
AFont.Color:=clred;
end
else
if ANode.Strings[dxDBGrid2Column10.Index]='销售审核' then begin
AFont.Color:=clred;
end
else
if ANode.Strings[dxDBGrid2Column10.Index]='申请放单' then begin
AFont.Color:=clred;
end
else
AFont.Color:=clblack;
}
end;
procedure Tfrm_op_seae_sign.Edit3_ztdhKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
//bsSkinButton8Click(Sender);
end;
end;
procedure Tfrm_op_seae_sign.dxdbgrd1_SDblClick(Sender: TObject);
begin
//
end;
procedure Tfrm_op_seae_sign.dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column13CustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
begin
{
if Trim(ANode.Strings[dxDBGrid2Column13.Index])<>'' then
AColor:=clred;
AFont.Color:=clblack;
}
end;
procedure Tfrm_op_seae_sign.dxDBGrid2Column14CustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
begin
{if Trim(ANode.Strings[dxDBGrid2Column14.Index])<>'' then
AColor:=clred;
AFont.Color:=clblack;
}
end;
procedure Tfrm_op_seae_sign.btn_seach2Click(Sender: TObject);
begin
//
show_qdtxx('',1);
end;
procedure Tfrm_op_seae_sign.MenuItem1Click(Sender: TObject);
begin
grid_save_xls(dxDBGrid1);
end;
procedure Tfrm_op_seae_sign.btn6_exitClick(Sender: TObject);
begin
Close;
end;
procedure Tfrm_op_seae_sign.RxDBLookupCombo28Enter(Sender: TObject);
begin
RxDBLookupCombo28.LookupDisplay:='代码;签单方式';
RxDBLookupCombo28.DisplayValue:='ZB';
end;
procedure Tfrm_op_seae_sign.btn11Click(Sender: TObject);
begin
bsSkinPageControl1.Pages[0].Visible:=true;
bsSkinPageControl1.Pages[1].Visible:=true;
bsSkinPageControl1.ActivePageIndex:=0;
t_op_seae.Requery();
end;
procedure Tfrm_op_seae_sign.show_qdtxx (qdtbh:string;iway:Integer);
var
str:string;
begin
//初始化窗体
if not assigned(frm__op_seae_sign_new_info) then
frm__op_seae_sign_new_info:=Tfrm__op_seae_sign_new_info.Create (self);
//双击进行显示明细
if iway=2 then
begin
frm__op_seae_sign_new_info.InitialUserinfo(qdtbh,0);
frm__op_seae_sign_new_info.SigninfoShow();
Exit;
end;
if(qdtbh<>'') then
str :=' where 签单条编号 =''' +qdtbh + ''''
else
begin
//
str:=' where 1=1';
if wwDBDateTimePicker5.text<>''then
str:=str+' and t_op_seae_sign_main.录入日期 >='+''''+wwDBDateTimePicker5.text+'''';
if wwDBDateTimePicker6.text<>''then
str:=str+' and t_op_seae_sign_main.录入日期<='+''''+wwDBDateTimePicker6.text+' 23:59:59''';
if Edit6_searchkhmch.text<>''then
str:=str+' and t_op_seae_sign_main.客户名称 like'+'''%'+replaceSQuotes(trim(Edit6_searchkhmch.text))+'%''';
//增加条件本人只能看本人相关的提单
end;
//TODO : 待确认
//if (not if_open('432')) then
// str:= str + ' and 签单条编号 in ( select td.签单条编号 from t_op_seae_sign_detail td,t_op_seae ts '
// +' where td.主提单号=ts.主提单号 and 录入人=''' + employee +''') ';
str:='SELECT * FROM [t_op_seae_sign_main] ' +str;
qry1_qdtm.Close() ;
qry1_qdtm.SQL.Clear;
qry1_qdtm.SQL.Add(str);
qry1_qdtm.open; qry1_qdtm.First;
if qry1_qdtm.IsEmpty then
begin
showmessage('没有检索出要查找的记录!!');
exit;
end;
if (qry1_qdtm.Recordset.RecordCount=1)
and (qdtbh<>'')
and (iway=0) then
begin
frm__op_seae_sign_new_info.InitialUserinfo(qdtbh,iway);
frm__op_seae_sign_new_info.SigninfoShow();
end;
end;
procedure Tfrm_op_seae_sign.initialEmployeePhone();
var
empQuery:TADOQuery;
begin
//
empQuery:=CreateAdoQuery();
with empQuery do
begin
SQL.Add('select [固定电话],[移动电话] from [t_sys_employee] where [姓名]='''+ employee +''' ');
Open;First;
employeePhone :=FieldByName('固定电话').AsString;
close();
end;
end;
procedure Tfrm_op_seae_sign.searchqdt(bh:string);
begin
//
if bh<>'' then
begin
//
show_qdtxx(bh,1);
end;
end;
procedure Tfrm_op_seae_sign.Edit1_qdtbhKeyPress(Sender: TObject;
var Key: Char);
var
str:string;
begin
//
if key=#13 then
begin
str:= Edit1_qdtbh.Text;
Edit1_qdtbh.Clear();
Edit15_searchqdthm.Text:=str;
show_qdtxx(str,0);
end;
end;
procedure Tfrm_op_seae_sign.dxDBGrid1DblClick(Sender: TObject);
var
str:string;
begin
//
str:=qry1_qdtm.FieldByName('签单条编号').AsString;
show_qdtxx(str,2);
qry1_qdtm.Requery();
end;
///
/// 检查客户是否欠费
///
function Tfrm_op_seae_sign.CheckBilldue( bsnoes,wtdw:string):Boolean;
var
FeeItems:string;
amt,usd:Double;
tdh,bh,jflx:string;
begin
Result:=True;
tdh:=t_op_seae.FieldByName('主提单号').AsString;
bh:=t_op_seae.FieldByName('编号').AsString;
jflx:= Trim(t_op_seae.FieldByName('结费类型').AsString);
jflx:='月结';
//月结客户
begin
if GetCrmsales(bh,wtdw,jflx ,amt,usd,FeeItems)then
begin
m_infomation:= wtdw+'客户结费类型为月结人民币金额为:'
+FormatFloat('0.00;-0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;-0.00;0',USD)+' 存在欠费' +#13#10;
Result:=False;
end;
end;
end; //end CheckBilldue
function Tfrm_op_seae_sign.CheckBilldue2( bsnoes,wtdw:string):Boolean;
var
FeeItems:string;
amt,usd:Double;
tdh,bh,jflx:string;
begin
Result:=True;
tdh:=qry_op_seae_pj.FieldByName('主提单号').AsString;
bh:=qry_op_seae_pj.FieldByName('编号').AsString;
jflx:= Trim(qry_op_seae_pj.FieldByName('结费类型').AsString);
jflx:='月结';
//月结客户
begin
if GetCrmsales(bh,wtdw,jflx ,amt,usd,FeeItems,True)then
begin
m_infomation:= wtdw+'客户结费类型为月结人民币金额为:'
+FormatFloat('0.00;-0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;-0.00;0',USD)+' 存在欠费' +#13#10;
Result:=False;
end;
end;
end; //end CheckBilldue
///
/// 全是票结客户
///
function Tfrm_op_seae_sign.CheckBilldue_pj(bsnoes,wtdw:string;out blnotifyOk:Boolean):Boolean;
var
FeeItems,unchkinfo,strtmp:string;
amt,usd,usd_this,rmb_this:Double;
tdh,bh,jflx,khlx:string;
str:string;
aquery:TADOQuery;
begin
Result:=True;
blnotifyOk:=true;//通知放单ok
tdh:='';
bh:='';
usd_this:=0;
rmb_this:=0;
//月结客户 的电放 必须有放单通知:否则不可以生成签单条
aquery:=CreateAdoQuery;
khlx:= getzqlx(wtdw) ;
if(khlx<>'现结买单') then
begin
if GetCrmsales(bh,wtdw,'月结' ,amt,usd,FeeItems,True)then
begin
m_infomation:= wtdw+'客户结费类型为月结人民币金额为:'
+FormatFloat('0.00;-0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;-0.00;0',USD)+' 存在欠费' +#13#10;
Result:=false;
end else begin
Result:=True;
end;
{
//月结客户
with aquery do
begin
Close;
SQL.Clear;
SQL.Add('select 编号,主提单号 from t_op_seae where 编号 in (' + bsnoes +')') ;
SQL.Add(' and not exists ( select 编号 from t_op_state where 业务状态=''通知放单'' and t_op_state.编号=t_op_seae.编号)');
Open;
if(IsEmpty) then
Exit
else
begin
Result:=False;
First;
unchkinfo:='';
while not Eof do
begin
if(unchkinfo='') then
unchkinfo :=fieldbyname('主提单号').AsString
else
unchkinfo:=unchkinfo+','+ fieldbyname('主提单号').AsString;
Next;
end;
//拥有全新的用户可以进行强制生成签单条 cjb 2017-09-01
if(if_open('450')) then
begin
unchkinfo:= '此票为月结客户电放业务,必须做通知放单!以下提单未做"通知放单":'+#13#10 + unchkinfo +#13#10;
//+#13#10+'是否强制放单?' ;
//判断是否欠费
//月结客户
if GetCrmsales(bh,wtdw,'月结' ,amt,usd,FeeItems)then
begin
strtmp:= wtdw +' 客户结费类型为月结,当前欠费人民币金额为:'
+FormatFloat('0.00;0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;0.00;0',USD)+' ,存在超期欠费' +#13#10;
unchkinfo:= unchkinfo+strtmp +#13#10+'是否强制放单?' ;
end;
if( Application.MessageBox(PChar(unchkinfo),'信息提示',MB_ICONQUESTION+MB_YESNO)<>id_yes) then
begin
Result:=false;
blnotifyOk:=false;//含有未做"通知放单"的提单
Close;
Exit;
end;
//强制放行
Result:=True;
blnotifyOk:=True; //强制放行 cjb 2017-09-01
Close;
Exit;
end ;
//无特殊权限
unchkinfo:='此票为月结客户电放业务,必须做通知放单!以下提单未做"通知放单":'+#13#10 + unchkinfo +#13#10+'不能放单!' ;
Application.MessageBox(PChar(unchkinfo),'信息提示',MB_ICONINFORMATION) ;
blnotifyOk:=false;//含有未做"通知放单"的提单
Close;
Exit;
end;
Close;
end;
}
end else begin
jflx:= '现结买单';
// if (jflx='') or (jflx='无帐期') or (jflx='现结买单') or (jflx=null) then
begin
m_infomation:='';
if GetCrmsales(bh,wtdw,jflx,amt,usd,FeeItems,True) then
begin
//客户结费类型为票结
m_infomation:= m_infomation+wtdw+'客户结费类型为票结,人民币金额为:'
+FormatFloat('0.00;-0.00;0',amt) +'美元金额为:'+FormatFloat('0.00;-0.00;0',USD) +' 存在超期欠费' +#13#10;
Result:=False;
end ;
//无论是否欠费都要提示每票货的u欠费情况 ----from 张晨源 2017-08-08
//票结签单条生成时的欠费提示去掉特殊不计算欠费的客户特例:''外代(收费)'' AND''MCCREF'' AND ''兴亚船务(收费)'' AND ''SMTREF''的金额。
{
//无法排除4类特定客户:
str:='select sum(应收USD-已收USD ) as USD,sum(应收RMB-已收RMB) as RMB from t_op_gain where 编号 in (%s);';
with aquery do
begin
Close;
SQL.Clear;
SQL.Add(Format(str,[bsnoes])) ;
open();
if(not isempty) then
begin
usd_this:=fieldbyname('USD').AsFloat;
rmb_this:=fieldbyname('RMB').AsFloat;
end;
end;
}
str:='select sum(应收USD-已收USD ) as USD,sum(应收RMB-已收RMB) as RMB from t_op_gain where 编号 in (%s);';
with aquery do
begin
Close;Sql.Clear;
SQL.Add('select 操作员,');
SQL.Add('SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''USD'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END ) as USD');
SQL.Add(',');
SQL.Add('SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''RMB'' then t_ch_fee.金额-t_ch_fee.结算金额 else 0 end) ELSE 0 END) as RMB');
SQL.Add(',');
SQL.Add('SUM(CASE t_ch_fee.类型 WHEN ''收'' THEN (case t_ch_fee.币别 when ''USD'' then (t_ch_fee.金额-t_ch_fee.结算金额)*t_ch_fee.汇率 else 0 end) ELSE 0 END) as USDTORMB');
SQL.Add('From t_ch_fee');
SQL.Add('Left Join V_op_bscard_All on V_op_bscard_All.编号=t_ch_fee.编号');
SQL.Add('where V_op_bscard_All.委托单位=:客户名称 ');
//
SQL.Add( ' and t_ch_fee.编号 in (' + bsnoes + ' ) and not (V_op_bscard_All.船公司=''进口专用'' and V_op_bscard_All.操作部门=''综合组'') ');
//
SQL.Add(' and t_ch_fee.类型=''收'' and t_ch_fee.金额<>t_ch_fee.结算金额 AND ');
SQL.Add('t_ch_fee.客户名称<>''外代(收费)'' AND t_ch_fee.客户名称<>''MCCREF'' AND t_ch_fee.客户名称<>''兴亚船务(收费)'' AND t_ch_fee.客户名称<>''SMTREF''');
SQL.Add(' and t_ch_fee.客户名称<>''捷丰黄岛收费'' and t_ch_fee.客户名称<>''AUSREF'' AND t_ch_fee.客户名称<>''APLREF'' AND t_ch_fee.客户名称<>''ONEREF'' ');
SQL.Add('and V_op_bscard_All.开船日期>=Getdate()-10000 and ((v_op_bscard_all.业务种类=''普通货'' and V_op_bscard_All.开船日期<=Getdate()-7) or (v_op_bscard_all.业务种类=''更改单'' and V_op_bscard_All.会计期间<=Getdate()-7) ) ');
SQL.Add(' Group by V_op_bscard_All.操作员 ');
Parameters.ParamByName('客户名称').Value:=wtdw;
SQL.Add(Format(str,[bsnoes])) ;
open();
if(not isempty) then
begin
usd_this:=fieldbyname('USD').AsFloat;
rmb_this:=fieldbyname('RMB').AsFloat;
if(rmb_this+ usd_this)>0 then
m_infomation:= m_infomation+'选中业务欠费' + '人民币金额为:' +FormatFloat('0.00;-0.00;0',rmb_this)
+'美元金额为:'+FormatFloat('0.00;-0.00;0',usd_this)+' 责任人:'+FieldByName('操作员').AsString ;
end;
Close;
end;
{
if(rmb_this+ usd_this)>0 then
m_infomation:= m_infomation+'选中业务欠费' + '人民币金额为:' +FormatFloat('0.00;-0.00;0',rmb_this)
+'美元金额为:'+FormatFloat('0.00;-0.00;0',usd_this) ;
}
if (m_infomation<>'') then begin
ShowMessage(m_infomation);
end;
end;
end;
end; //end CheckBilldue
///
/// 查看财务签字
///
procedure Tfrm_op_seae_sign.N2Click(Sender: TObject);
var
tmpfile:string;
begin
//
if qry1_qdtm.IsEmpty then exit;
try
tmpfile:=qry1_qdtm.fieldbyname('财务签字').asstring ;
if(tmpfile='') or (not FileExists(tmpfile)) then
Exit;
ShellExecute(Handle, nil, pchar(tmpfile), nil, nil, SW_NORMAL);
except
showmessage('不能打开文件,请检查!');
end ;
end;
///
/// 查看客户签字
///
procedure Tfrm_op_seae_sign.frm__op_seae_sign_new_infomniN3Click(
Sender: TObject);
var
tmpfile:string;
begin
if qry1_qdtm.IsEmpty then exit;
try
tmpfile:=qry1_qdtm.fieldbyname('客户签字').asstring ;
if(tmpfile='') or (not FileExists(tmpfile)) then
Exit;
ShellExecute(Handle, nil, pchar(tmpfile), nil, nil, SW_NORMAL);
except
showmessage('不能打开文件,请检查!');
end ;
end;
procedure Tfrm_op_seae_sign.bsSkinPageControl1Change(Sender: TObject);
begin
//
if (Self.Visible) and (bsSkinPageControl1.ActivePageIndex=2) and Edit1_qdtbh.Visible then
Edit1_qdtbh.SetFocus();
end;
procedure Tfrm_op_seae_sign.FormResize(Sender: TObject);
begin
//
bsSkinTabSheet1.Width:=self.ClientWidth;
end;
procedure Tfrm_op_seae_sign.bsSkinButton14Click(Sender: TObject);
begin
wwDBDateTimePicker5.text:='';
wwDBDateTimePicker6.text:='';
Edit6_searchkhmch.text:='';
Edit1_qdtbh.text:='';
end;
procedure Tfrm_op_seae_sign.Edit1_ywbhKeyPress(Sender: TObject;
var Key: Char);
begin
// 回车自动查询
if key=#13 then
begin
btn4_searchNewClick(btn4_searchNew);
end;
end;
procedure Tfrm_op_seae_sign.Edit6_searchkhmchKeyPress(Sender: TObject;
var Key: Char);
begin
if key=#13 then
begin
btn_seach2Click(Self.btn_seach2);
end;
end;
procedure Tfrm_op_seae_sign.dxDBGrid1CustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
var
value:string;
begin
value:=ANode.Strings[dxdbgrdchckclmnDBGrid1Column14_tf.Index];
if value ='True' then
begin
AFont.Color:=clgreen;
end
else
AFont.Color:=clblack;
end;
///
///
///
procedure Tfrm_op_seae_sign.btn4_searchNew_pjClick(Sender: TObject);
var
str,mblstatus:widestring;
begin
str:='where t_op_seae.主提单号<>'''' and t_op_seae.签单方式<>''''';
if RxDBLookupCombo_wtdw_pj.DisplayValues[1]=''then
begin
//票结客户
//1.客户账期为月结[(账期为约定天数,约定日期),并且 结束日期>=当天] 或票结 :电放
//2.签单方式为(正本):票结
//3.并排除放单不控制的客户
str:=str+ ' and t_op_seae.委托单位 not in ('
+' select t.客户简称 FROM t_crm_client t where (ISNULL(t.放单不控制, 0) = 1) '
+')';
end
else
str:=str+' and t_op_seae.委托单位='+''''+RxDBLookupCombo_wtdw_pj.DisplayValues[1]+'''';
if Edit1_ywbh_pj.text<>''then
str:=str+' and t_op_seae.业务编号 like '+''''+'%'+replaceSQuotes(Edit1_ywbh_pj.text)+'%'+'''';
if Edit2_wtbh_pj.text<>''then
str:=str+' and t_op_seae.委托编号 like '+''''+'%'+replaceSQuotes(Edit2_wtbh_pj.text)+'%'+'''';
if Edit3_ztdh_pj.text<>''then
str:=str+' and t_op_seae.主提单号 like '+''''+'%'+replaceSQuotes(Edit3_ztdh_pj.text)+'%'+'''';
if wdbdtmpckr1_kc_pj.text<>''then
str:=str+' and t_op_seae.开船日期>='+''''+wdbdtmpckr1_kc_pj.text+'''';
if wdbdtmpckr2_kc_pj.text<>''then
str:=str+' and t_op_seae.开船日期<='+''''+wdbdtmpckr2_kc_pj.text+'''';
if wdblkpcmb1_cm_pj.text<>''then
str:=str+' and t_op_seae.船名 like '+''''+'%'+replaceSQuotes(wdblkpcmb1_cm_pj.text)+'%'+'''';
if Edit4_hc_pj.text<>''then
str:=str+' and t_op_seae.航次 like '+''''+'%'+replaceSQuotes(Edit4_hc_pj.text)+'%'+'''';
if wdblkpcmb2_xhg_pj.text<>''then
str:=str+' and t_op_seae.卸货港 like '+''''+'%'+replaceSQuotes(wdblkpcmb2_xhg_pj.text)+'%'+'''';
// //if DBComboBoxEh1.text<>'' then
str:=str+' and ( t_op_state.业务状态 = ''提单签入'')';
if wdbdtmpckr3_lr_pj.text<>''then
str:=str+' and t_op_state.录入日期>='+''''+wdbdtmpckr3_lr_pj.text+'''';
if wdbdtmpckr4_lr_pj.text<>''then
str:=str+' and t_op_state.录入日期<='+''''+wdbdtmpckr4_lr_pj.text+' 23:59:59''';
//
str:=str+' and '+ open_data('0001','t_op_seae.录入人',
't_op_seae.操作员','t_op_seae.客服员','t_op_seae.报关操作','t_op_seae.报检操作');
//
str:=str+' and t_op_seae.签单方式 in (''电放'',''正本'',''电子提单'')'
+' and t_op_state.编号 not in ('
+'select 编号 from t_op_seae_sign_detail t left join t_op_seae_sign_main m on (m.签单条编号=t.签单条编号) where m.状态<>''已作废'' ' // where t.是否签单=1
+' union select 编号 from t_op_state t where t.业务状态=''提单签出''' +#13#10 //提单签出的排除
+' union select t.编号 from t_op_seae_app t ' +#13#10 //特殊审批中的提单 排除
+'union select 编号 from t_op_seae t_yzb where 委托单位 '
+ ' in (SELECT 客户简称 FROM t_crm_client_sales WHERE 结费类型 IN (''约定时间'', ''约定天数'') and 结束日期>=cast(GETDATE()as date) '
+ ' union select 客户简称 from t_crm_client_sales_tmp t where 结束日期>=cast(GETDATE()as date) ) '
+ ' and (签单方式=''正本'' OR 签单方式=''电子提单'')' //月结客户的正本排除, 临时账期归入月结客户(临时客户的正本排除)
+')';
with qry_op_seae_pj do
begin
close;sql.clear;
sql.add('select distinct t_op_seae.业务状态,t_op_seae.编号,t_op_seae.业务编号,t_op_seae.委托单位,t_op_seae.船名,t_op_seae.航次');
sql.add(',t_op_seae.主提单号,t_op_seae.签单方式,t_op_seae.开船日期 , t_op_state.录入日期 as [提单签入日期]');
sql.add(',t_op_seae.操作员,t_op_seae.揽货人,t_op_seae.提单签发状态,t_op_seae.结费类型,t_op_seae.装货港,t_op_seae.卸货港');
sql.add('from t_op_state');
sql.add('left JOIN t_op_seae on t_op_state.编号 = t_op_seae.编号 ' +str);
open;First;
end;
if qry_op_seae_pj.IsEmpty then
begin
showmessage('没有检索出要查找的提单!!');
exit;
end;
end;
procedure Tfrm_op_seae_sign.btn1_gennerateSign_pjClick(Sender: TObject);
var
str,bsno:widestring;
i:integer;
aQuery:TAdoQuery;
qdm_Query:TAdoQuery;
qdd_Query:TAdoQuery;
qdtbh:string;
strwtdw1,strwtdw2,zhtdh,ysstr,znjstr:string;
dbTime,nouseDate:TDateTime;
blNoQF:Boolean;
khlx:string;
bsnoes,mblnos:string; //签单条 选中的编号
strlszq:string;//临时账期
bllszq:boolean;//是否临时账期
blnotifyOk,isznj:Boolean;//月结或临时账期的票结:是否都做了"通知放单"
etddate:TDate;
ttlznj:Double;
begin
blNoQF:=True;
//计算作废日期
ttlznj:=0;
if dxdbgrd1_S_pj.SelectedCount<1 then
Exit;
//nouseDate:=getNouseDate(t_op_seae_pj.FieldByName('委托单位').AsString); //debug
//票结无作废日期
nouseDate:=0;
bsnoes:='';
mblnos:='';
try
//begin check
//初始化提示信息为空
m_infomation:='';
//票结客户只有一个提醒,:内容???????
for i:=0 to dxdbgrd1_S_pj.SelectedCount-1 do
begin
qry_op_seae_pj.GoTobookmark(pointer(dxdbgrd1_S_pj.SelectedRows[i]));
if i=0 then
begin
strwtdw1 := qry_op_seae_pj.FieldByName('委托单位').AsString;
strwtdw2:=strwtdw1;
bsnoes:=''''+ qry_op_seae_pj.FieldByName('编号').AsString +'''';
mblnos:=qry_op_seae_pj.fieldbyname('主提单号').asstring;
end
else
begin
strwtdw2 := qry_op_seae_pj.FieldByName('委托单位').AsString;
bsnoes:=bsnoes+','''+ qry_op_seae_pj.FieldByName('编号').AsString +'''';
mblnos:=mblnos+','+qry_op_seae_pj.fieldbyname('主提单号').asstring;
end;
if strwtdw1<>strwtdw2 then
begin
showmessage('委托单位不唯一!');
Exit;
end;
end;
//月结客户 的电放 必须有放单通知:否则不可以生成签单条
try
//每一票一个提醒信息,最后一起提醒
khlx:= getzqlx(strwtdw1,false);
if(khlx='现结买单')then
begin
strlszq:=gettmpzqdate(strwtdw1);
if( strlszq<>'') then
begin
khlx:='临时账期';
// if Application.MessageBox(pchar(strwtdw1+' 临时帐期没有过期:'+ strlszq +#13#10+'确实要生成签单条吗?'),'信息提醒',MB_YESNO+mb_iconquestion)<> ID_YES then
// begin
// Exit;
//end;
bllszq:=True;
end;
blNoQF:=CheckBilldue_pj(bsnoes,strwtdw1,blnotifyOk ); //只标记不退出
if(blnotifyOk=False) then
BEGIN
Exit;//月结客户或者临时账期客户的提单 存在未做"放单通知"的不能生成签单条
END;
end else begin
try
//一个提醒信息,因为每一票的提醒都一样
if(CheckBilldue2(bsnoes,strwtdw1 )=False) then
blNoQF:=false; //只标记不退出
except
on ex:Exception do
begin
errorlog(ex.Message) ;
ShowMessage('判断提单状态时发生异常:' + ex.message) ;
Exit;
end;
end;
end;
except
on ex:Exception do
begin
errorlog(ex.Message) ;
ShowMessage('判断提单状态时发生异常:' + ex.message) ;
Exit;
end;
end;
if(khlx='现结买单')then
begin
{
isznj:=getpjzq(bsnoes,strwtdw1,ysstr,znjstr,ttlznj);
if (isznj) then begin
try
if not assigned(frm_op_znjpj) then
frm_op_znjpj:=tfrm_op_znjpj.Create (self);
frm_op_znjpj.lblcust.Caption:=strwtdw1;
frm_op_znjpj.lblmblno.Caption:=mblnos;
frm_op_znjpj.lbletd.Caption:=qry_op_seae_pj.fieldbyname('开船日期').asstring;
frm_op_znjpj.lbldate.Caption:=FormatDateTime('YYYY-MM-DD',Date);
frm_op_znjpj.lblmblno.Caption:=mblnos;
frm_op_znjpj.lblznj.Caption:=znjstr;
frm_op_znjpj.lblysstr.Caption:=ysstr;
if(if_open('450')) then frm_op_znjpj.bsSkinButton2.Visible:=true;
frm_op_znjpj.lblttlznj.Caption:=FloatToStr(ttlznj);
if (frm_op_znjpj.ShowModal<>mrAbort) then Exit;
finally
FreeAndNil(frm_op_znjpj);
end;
end else begin
ShowMessage('此票无滞纳金!');
end;
}
//票结客户有欠费进行提醒
if(blNoQF=false) then
begin
if(if_open('450')) then
begin
if Application.MessageBox(pchar('当前要生成签单存在欠费'+#13#10+ m_infomation +#13#10+'是否继续生成签单条?'),'信息提醒'
,mb_yesno+mb_iconquestion)<>id_yes then
exit;
end
else
begin
Application.MessageBox(pchar('当前要生成签单存在欠费'+#13#10+ m_infomation +#13#10+'不能生成签单条!'+#13#10+'请选择其他放单模式:'+#13#10+'1.是否有跨月负数更改单'+#13#10+'2.查账放单'+#13#10+'3.到账本放单'+#13#10+'4.特殊放单'),'信息提醒'
,MB_ICONINFORMATION);
exit;
end;
end else begin
end;
{
if(Application.MessageBox(pchar('当前要生成签单存在欠费'+#13#10+ m_infomation +#13#10+'是否仍要生成签单条?'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
//二次提醒
if(Application.MessageBox(pchar('该客户目前欠费,生成签单条前必须确认款项已经到账!!'+#13#10+'是否生成签单条?'+#13#10+'请选择其他放单模式:'+#13#10+'1.是否有跨月负数更改单'+#13#10+'2.查账放单'+#13#10+'3.到账本放单'+#13#10+'4.特殊放单'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
}
end;
if (khlx='现结买单') or (khlx='临时账期') then begin
end else begin
{
isznj:=getyjzq(bsnoes,strwtdw1,ysstr,znjstr,ttlznj);
if (isznj) then begin
try
if not assigned(frm_op_znjyj) then
frm_op_znjyj:=tfrm_op_znjyj.Create (self);
frm_op_znjyj.lblcust.Caption:=strwtdw1;
frm_op_znjyj.lblmonth.Caption:=FormatDateTime('MM',qry_op_seae_pj.fieldbyname('开船日期').AsDateTime);
frm_op_znjyj.lblzq.Caption:=getzq(strwtdw1);
frm_op_znjyj.lbldate.Caption:=FormatDateTime('YYYY-MM-DD',Date);
frm_op_znjyj.lblznj.Caption:=znjstr;
frm_op_znjyj.lblys.Caption:=ysstr;
frm_op_znjyj.lblttlznj.Caption:=FloatToStr(ttlznj);
frm_op_znjyj.Memo1.Clear;
frm_op_znjyj.Memo1.Lines.Add('应收费用:'+ysstr);
frm_op_znjyj.Memo1.Lines.Add('');
frm_op_znjyj.Memo1.Lines.Add('滞纳金:'+znjstr);
frm_op_znjyj.Memo1.Lines.Add('');
frm_op_znjyj.Memo1.Lines.Add('合计:'+FloatToStr(ttlznj));
frm_op_znjyj.ShowModal;
finally
FreeAndNil(frm_op_znjyj);
end;
Exit;
end;
}
//票结客户有欠费进行提醒
if(blNoQF=false) then
begin
if(if_open('450')) then
begin
if Application.MessageBox(pchar('当前要生成签单存在欠费'+#13#10+ m_infomation +#13#10+'是否继续生成签单条?'),'信息提醒'
,mb_yesno+mb_iconquestion)<>id_yes then
exit;
end
else
begin
Application.MessageBox(pchar('当前要生成签单存在欠费'+#13#10+ m_infomation +#13#10+'不能生成签单条!'+#13#10+'请选择其他放单模式:'+#13#10+'1.是否有跨月负数更改单'+#13#10+'2.查账放单'+#13#10+'3.到账本放单'+#13#10+'4.特殊放单'),'信息提醒'
,MB_ICONINFORMATION);
exit;
end;
end else begin
end;
end;
{
else if(m_infomation<>'') then
begin
if(Application.MessageBox(pchar(m_infomation +#13#10+'是否仍要生成签单条?'),'信息提醒'
,MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
end;
}
//end check
aQuery:=CreateAdoQuery();
qdm_Query:=CreateAdoQuery();
qdd_Query:=CreateAdoQuery();
str:= 'INSERT INTO t_sys_signid (mainorderno) VALUES (''222'');';
aQuery.SQL.Add(str) ;
aQuery.ExecSQL();
aQuery.sql.Clear();
str:= 'select MAX(signid) as qdtbh,GETDATE()as FDate from t_sys_signid; ';
aQuery.sql.add(str);
qdm_Query.SQL.Add('SELECT * FROM [t_op_seae_sign_main] where 1=2');
qdd_Query.SQL.Add('SELECT * FROM [t_op_seae_sign_detail] where 1=2');
aQuery.Open;
aQuery.First;
qdtbh:=aQuery.FieldByName('qdtbh').AsString;
dbTime:=aQuery.FieldByName('FDate').AsDateTime;
aQuery.sql.Clear();
aQuery.sql.Add('SELECT * FROM [t_op_state] WHERE 1=2');
aQuery.OPEN;
qdm_Query.Open;
qdd_Query.Open;
try
frm_main.db.BeginTrans;
for i:=0 to dxdbgrd1_S_pj.SelectedCount-1 do
begin
qry_op_seae_pj.GoTobookmark(pointer(dxdbgrd1_S_pj.SelectedRows[i]));
if i=0 then
begin
with qdm_Query do
begin
Insert;
FieldByName('签单条编号').AsString:=qdtbh;
FieldByName('客户名称').AsString:= strwtdw1;
FieldByName('录入人').AsString:= employee;
FieldByName('录入人电话').AsString:=employeePhone;
FieldByName('录入日期').AsDateTime:= dbTime;
FieldByname('账期').AsString:=getzq(strwtdw1);
//计算作废日期 , 票结无作废日期
//nouseDate:=getNouseDate(strwtdw1);
//if(nouseDate>0) then
// FieldByName('作废日期').AsDateTime:= nouseDate;
FieldByname('客户类型').AsString:=getzqlx(strwtdw1);
FieldByName('状态').AsString:= stateNewQD;
FieldByName('是否特放').AsVariant:= 0;
//2017-08-02 增加签单条类型
if (FieldByname('客户类型').AsString='现结买单') then begin
FieldByName('签单条类型').AsString:= '票结';
FieldByName('作废日期').AsDateTime:=date+strtoint(pjday);
end else begin
nouseDate:=getNouseDate(strwtdw1);
if(nouseDate>0) then
FieldByName('作废日期').AsDateTime:= nouseDate
else FieldByName('作废日期').AsDateTime:=date+3;
end;
end;
etddate:=qry_op_seae_pj.FieldByName('开船日期').AsDateTime;
end ;
qdd_Query.Insert;
qdd_Query.FieldByName('签单条编号').AsString:= qdtbh;
qdd_Query.FieldByName('编号').AsString := qry_op_seae_pj.FieldByName('编号').AsString;
zhtdh:= qry_op_seae_pj.FieldByName('主提单号').AsString;
qdd_Query.FieldByName('主提单号').AsString:= zhtdh;
qdd_Query.FieldByName('船名').AsString:= qry_op_seae_pj.FieldByName('船名').AsString;
qdd_Query.FieldByName('航次').AsString:= qry_op_seae_pj.FieldByName('航次').AsString;
qdd_Query.FieldByName('签单方式').AsString:= qry_op_seae_pj.FieldByName('签单方式').AsString;
qdd_Query.FieldByName('状态').AsString:= stateNewQD;
qdd_Query.FieldByName('提单签入日期').AsDateTime:= qry_op_seae_pj.FieldByName('提单签入日期').AsDateTime;
if (qry_op_seae_pj.FieldByName('开船日期').AsDateTime>etddate) then etddate:=qry_op_seae_pj.FieldByName('开船日期').AsDateTime;
with aQuery do
begin
//
Insert;
FieldByName('编号').AsString:= qry_op_seae_pj.FieldByName('编号').AsString;
FieldByName('业务状态').AsString:= stateNewQD;
FieldByName('录入人').AsString:= employee;
FieldByName('录入日期').AsDateTime:= dbTime;
end;
end;
if( blNoQF=False) then
begin
//欠费发签出提醒
qdm_Query.FieldByName('状态').AsString:='通知签出签单条';
qdm_Query.FieldByName('通知签出时间').AsDateTime:=dbTime;
end;
if (qdm_Query.FieldByName('签单条类型').AsString= '票结') then
qdm_Query.FieldByName('作废日期').AsDateTime:=etddate+strtoint(pjday);
if(if_open('450')) then
begin
if (etddate+strtoint(pjday)''then
str:=str+' and 签单条编号 like '+''''+'%'+replaceSQuotes(Edit41_qdtbh.text)+'%'+'''';
if Edit42_zhtdh.text<>''then
str:=str+' and 主提单号 like '+''''+'%'+replaceSQuotes(Edit42_zhtdh.text)+'%'+'''';
if wdbdtmpckr41_start.text<>''then
str:=str+' and 取消日期>='+''''+wdbdtmpckr41_start.text+'''';
if wdbdtmpckr42_end.text<>''then
str:=str+' and 取消日期<='+''''+wdbdtmpckr42_end.text+' 23:59:59''';
str:=' select * from t_op_seae_sign_cancel_log ' +str;
with qry41_cancellog do
begin
Close;
SQL.Clear;
SQL.Add(str);
Open;
end;
end;
procedure Tfrm_op_seae_sign.Edit41_qdtbhKeyPress(Sender: TObject;
var Key: Char);
begin
// 回车自动查询
if key=#13 then
begin
searchCancelLog();
end;
end;
end.