unit u_op_seae_paper_print_submitinfo;
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,
ComCtrls, bsSkinTabs, dxDBTLCl, dxGrClms, cxDBLabel, cxControls,
cxContainer, cxEdit, cxLabel;
type
Tfrm_op_seae_paper_print_submitinfo = class(TForm)
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;
bsSkinPanel3: TbsSkinPanel;
btn6_notify_exit: TbsSkinButton;
btn1_notify_search: TbsSkinButton;
btn2_notify_clear: TbsSkinButton;
bsSkinPanel4: TbsSkinPanel;
Label13: TLabel;
Label14: TLabel;
wdbdtmpckr1_kc: TwwDBDateTimePicker;
wdbdtmpckr2_kc: TwwDBDateTimePicker;
kbmMemTable1Field17: TStringField;
kbmMemTable1Field18: TStringField;
kbmMemTable1Field19: TStringField;
kbmMemTable1Field20: TStringField;
kbmMemTable1Field21: TStringField;
kbmMemTable1Field22: TBooleanField;
kbmMemTable1Field23: TStringField;
kbmMemTable1Field24_xuanxiang: TBooleanField;
edt1_tdh: TEdit;
lbl14: TLabel;
lbl15_searchqdthm: TLabel;
bsknpnl1_m: TbsSkinPanel;
dxdbgrd3_notify: TdxDBGrid;
dxdbgrdclmns: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column2: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column4: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column5: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1_SColumn9: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column3: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column6: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1_SColumn11: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column13: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1xdbgrdclmndxdbgrd1Column19: TdxDBGridColumn;
dxdbgrdclmndxdbgrd1_SColumn10: TdxDBGridColumn;
dxdbgrdchckclmndxdbgrd1_SColumn12: TdxDBGridCheckColumn;
dxdbgrdmclmndxdbgrdclmndxdbgrd1_SColumn13: TdxDBGridMemoColumn;
dxdbgrdclmndxdbgrd1_SColumn14: TdxDBGridColumn;
ds1: TDataSource;
qry1_paper_printlist: TADOQuery;
btn5_submit: TbsSkinButton;
btn6_cancelSubmit: TbsSkinButton;
dxdbgrdclmndxdbgrd3_notifyColumn15: TdxDBGridColumn;
procedure btn4_exitClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure N1Click(Sender: TObject);
procedure btn1_notify_searchClick(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure btn6_notify_exitClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure searchqdt(bh:string);
procedure edt1_tdhKeyPress(Sender: TObject; var Key: Char);
procedure dxdbgrd3_notifyDblClick(Sender: TObject);
procedure btn3_notifyClick(Sender: TObject);
procedure btn2_notify_clearClick(Sender: TObject);
procedure Edit6_searchkhmchKeyPress(Sender: TObject; var Key: Char);
procedure btn5_submitClick(Sender: TObject);
procedure btn6_cancelSubmitClick(Sender: TObject);
private
{ Private declarations }
employeePhone:string;
procedure UpateSeaeState(bsno,billstate:string);
public
{ Public declarations }
op:integer;
function GetmblState(bsno:string):Boolean;
function GetmblStateOut(bsno:string):Boolean;
function GetSeaeStateDate(bsno,billstate:string):string;
function _GetmblStateout(bsno,bsstatus:string):string;
procedure Initsql_ts(AdoQuery:TAdoQuery);
procedure initialEmployeePhone();
procedure seachPrintList();
procedure show_qdtxx(qdtbh:string;iway:Integer);
end;
var
frm_op_seae_paper_print_submitinfo: Tfrm_op_seae_paper_print_submitinfo;
implementation
uses u_main,my_sys_function, u_op_seae_teshufandan,u_sys_progress,u_op_seae_sign_info,
u_op_seae_sign;
{$R *.dfm}
const stateNewQD = '生成签单条';
//
function Tfrm_op_seae_paper_print_submitinfo._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_paper_print_submitinfo.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;
function Tfrm_op_seae_paper_print_submitinfo.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_paper_print_submitinfo.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_paper_print_submitinfo.btn4_exitClick(Sender: TObject);
begin
Close;
end;
procedure Tfrm_op_seae_paper_print_submitinfo.FormShow(Sender: TObject);
var str,mblstatus:string;
begin
wdbdtmpckr1_kc.Date:=Date-1 ;
wdbdtmpckr2_kc.Date:=Date ;
Width :=width-1;
dxdbgrd3_notify.Width :=dxdbgrd3_notify.width-1;
bsSkinPanel3.Height :=34;
loadreggrid(dxdbgrd3_notify,false,caption);
seachPrintList();
end;
procedure Tfrm_op_seae_paper_print_submitinfo.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
savereggrid(dxdbgrd3_notify,caption);
frm_op_seae_paper_print_submitinfo.Hide;
frm_op_seae_paper_print_submitinfo.ManualFloat(frm_op_seae_paper_print_submitinfo.BoundsRect );
frm_main.freeTabs('frm_op_seae_paper_print_submitinfo');
action:=cafree;
frm_op_seae_paper_print_submitinfo:=nil;
end;
procedure Tfrm_op_seae_paper_print_submitinfo.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;
procedure Tfrm_op_seae_paper_print_submitinfo.N1Click(Sender: TObject);
begin
//grid_save_xls(dxdbgrd2);
end;
procedure Tfrm_op_seae_paper_print_submitinfo.btn1_notify_searchClick(Sender: TObject);
begin
seachPrintList();
end;
///
///
///
procedure Tfrm_op_seae_paper_print_submitinfo.seachPrintList();
var
str:string;
begin
//
str:='';
if(edt1_tdh.Text<>'') then
str:= str + ' AND 主提单号 like ''%' + Trim(edt1_tdh.Text) + '%'' ';
{ if(cbb1_cgsh.DisplayValues[1]<>'') then
str:= str + ' AND 船公司 =''' + Trim(cbb1_cgsh.DisplayValues[1]) + ''' ';
if(cbb3_qdfsh.DisplayValues[1]<>'') then
str:= str + ' AND 签单方式 =''' + Trim(cbb3_qdfsh.DisplayValues[1]) + ''' ';
if(cbb4_dyzht.Text<>'<无>') then
str:= str + ' AND 打印状态 =''' + Trim(cbb4_dyzht.Text) + ''' ';
if(cxchckbx1_shfhq.State=cbsChecked) then
str:= str + ' AND isnull([是否换签],''false'')=1 '
else if(cxchckbx1_shfhq.State=cbsUnchecked) then
str:= str + ' AND isnull([是否换签],''false'')=0 ' ;
}
if(wdbdtmpckr1_kc.Text<>'') then
str:= str + ' AND 提交日期>=''' + Trim(wdbdtmpckr1_kc.Text) + ''' ';
//
if(wdbdtmpckr2_kc.Text<>'') then
str:= str + ' AND 提交日期<=''' + Trim(wdbdtmpckr2_kc.Text) + ' 23:59:59'' ';
str:='select *, cast(提单份数 as varchar)+''正''+ CAST( 副本提单份数 as varchar) +''副'' as 签单要求 '
+ ' from ('
+ ' SELECT p.*,s.业务状态 as 签回状态 '
+ ' FROM [t_op_seae_paper_print_list] p left join (select 编号,业务状态,录入日期 as 签回日期 '
+ ' from t_op_state where 业务状态=''提单签回'') s '
+ ' on p.编号=s.编号 '
+') plst where 1=1 and 提交状态=''已提交'''
+ str+' order by 提交编号 ';
with qry1_paper_printlist do begin
//
Close;
SQL.Clear;
SQL.Add(str) ;
Open;
end;
end;
procedure Tfrm_op_seae_paper_print_submitinfo.MenuItem1Click(Sender: TObject);
begin
grid_save_xls(dxdbgrd3_notify);
end;
procedure Tfrm_op_seae_paper_print_submitinfo.btn6_notify_exitClick(Sender: TObject);
begin
Close();
end;
procedure Tfrm_op_seae_paper_print_submitinfo.show_qdtxx (qdtbh:string;iway:Integer);
var
str:string;
begin
end;
procedure Tfrm_op_seae_paper_print_submitinfo.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_paper_print_submitinfo.searchqdt(bh:string);
begin
//
if bh<>'' then
begin
//
show_qdtxx(bh,1);
end;
end;
procedure Tfrm_op_seae_paper_print_submitinfo.edt1_tdhKeyPress(Sender: TObject;
var Key: Char);
var
str:string;
begin
//
if key=#13 then
begin
end;
end;
procedure Tfrm_op_seae_paper_print_submitinfo.dxdbgrd3_notifyDblClick(Sender: TObject);
var
str:string;
begin
//
// str:=qry1_qdtm.FieldByName('签单条编号').AsString;
end;
procedure Tfrm_op_seae_paper_print_submitinfo.btn3_notifyClick(Sender: TObject);
var
qdtzht,str:string;
i,noticecount:integer;
aQuery:TADOQuery;
DatabaseDateTime:TDatetime;
begin
//
{ if (dxdbgrd3_notify.SelectedCount<1) and (qry1_qdtm.Recordset.RecordCount<1) then
Exit;
str:=qry1_qdtm.FieldByName('签单条编号').AsString;
show_qdtxx(str,2);
qry1_qdtm.Requery();
Exit;
}
end;
procedure Tfrm_op_seae_paper_print_submitinfo.btn2_notify_clearClick(Sender: TObject);
begin
wdbdtmpckr1_kc.Date:=Date-1 ;
wdbdtmpckr2_kc.Date:=Date ;
edt1_tdh.Text:='';
end;
procedure Tfrm_op_seae_paper_print_submitinfo.Edit6_searchkhmchKeyPress(
Sender: TObject; var Key: Char);
begin
//回车查询执行
if key=#13 then
begin
btn1_notify_searchClick(Self.btn1_notify_search);
end;
end;
///
/// 更改海运出口状态
///
procedure Tfrm_op_seae_paper_print_submitinfo.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;
Parameters.ParamByName('签回日期').value:=Date;
execsql;
finally
aAdoQuery.Free;
end;
end;
procedure Tfrm_op_seae_paper_print_submitinfo.btn5_submitClick(
Sender: TObject);
var
str,bid,strinfo:string;
i,icount:Integer;
aQuery:TADOQuery;
begin
// 获取提交的批ID
if(qry1_paper_printlist.Recordset.RecordCount<1) then
begin
Application.messagebox(pchar('请选择要签入的提单'),'信息提醒',MB_ICONINFORMATION );
Exit;
end;
//
aQuery:=CreateAdoQuery;
icount:=0;
//
bid:= qry1_paper_printlist.fieldbyname('提交编号').AsString;
str:='SELECT TOP 1000 [编号],[序号],[主提单号] FROM [t_op_seae_paper_print_list] '
+' where 提交编号=' + bid +' ;';
with aQuery do begin
Close;
SQL.Clear;
SQL.Add(str);
open;
icount:=Recordset.RecordCount;
end;
strinfo:='是否要批量签入所选提交编号为'+ bid+ '的'+inttostr(icount)+'票提单';
if(Application.MessageBox(pchar(strinfo),'信息提示', MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
try
frm_main.db.BeginTrans;
//提交编号='';
with aQuery do
begin
First;
while not Eof do begin
InsertSeaeStatus(FieldByName('编号').AsString,'提单签入',employee
,FormatDateTime('YYYY-MM-DD hh:mm:ss',now));
UpateSeaeState(FieldByName('编号').AsString,'提单签入');
Next;
end;
end;
//
aQuery.close;
aQuery.sql.Clear;
str:='UPDATE [t_op_seae_paper_print_list] '
+ 'SET [是否签入] = 1,[提交状态]=''提单签入'',[签入人] = '''
+ employee
+''' ,[签入日期] = '''+ FormatDateTime('YYYY-MM-DD hh:mm:ss',now)
+''' WHERE [提交编号] = ' + bid ;
aQuery.SQL.Add(str);
aQuery.ExecSQL;
frm_main.db.CommitTrans;
seachPrintList();
except
on ex: Exception do
begin
frm_main.db.RollbackTrans;
Application.messagebox(pchar('提交发生异常:'+ex.Message),'信息提醒',MB_ICONWARNING );
end;
end;
//
end;
procedure Tfrm_op_seae_paper_print_submitinfo.btn6_cancelSubmitClick(
Sender: TObject);
var
str,bid,strinfo:string;
i,icount:Integer;
aQuery:TADOQuery;
begin
// 获取提交的批ID
if(qry1_paper_printlist.Recordset.RecordCount<1) then
begin
Application.messagebox(pchar('请选择要驳回的提单'),'信息提醒',MB_ICONINFORMATION );
Exit;
end;
//
aQuery:=CreateAdoQuery;
icount:=0;
//
bid:= qry1_paper_printlist.fieldbyname('提交编号').AsString;
str:='SELECT [编号],[序号],[主提单号] FROM [t_op_seae_paper_print_list] '
+' where 提交编号=' + bid +' ;';
with aQuery do begin
Close;
SQL.Clear;
SQL.Add(str);
open;
icount:=Recordset.RecordCount;
end;
strinfo:='是否要批量驳回所选提交编号为'+ bid+ '的'+inttostr(icount)+'票提单';
if(Application.MessageBox(pchar(strinfo),'信息提示', MB_ICONQUESTION+MB_YESNO) <> ID_YES) then
Exit;
try
//* frm_main.db.BeginTrans;
//
aQuery.close;
aQuery.sql.Clear;
str:='UPDATE [t_op_seae_paper_print_list] '
+ 'SET 提交人=null,提交日期=null,[提交状态]=''已驳回'',[驳回人] = '''
+ employee
+''' ,[驳回日期] = '''+ FormatDateTime('YYYY-MM-DD hh:mm:ss',DatabaseDateTime)
+''' WHERE [提交编号] = ' + bid ;
aQuery.SQL.Add(str);
aQuery.ExecSQL;
//* frm_main.db.CommitTrans;
seachPrintList();
except
on ex: Exception do
begin
//*frm_main.db.RollbackTrans;
Application.messagebox(pchar('驳回发生异常:'+ex.Message),'信息提醒',MB_ICONWARNING );
end;
end;
end;
end.