unit u_op_seae_teshusales; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, XPMenu, Menus, dxDBTLCl, dxGrClms, dxDBCtrl, dxDBGrid, dxTL, dxCntner, DB, ADODB, Mask, wwdbedit, Wwdotdot, Wwdbcomb, wwdblook, RxLookup, wwdbdatetimepicker, StdCtrls, bsSkinCtrls, ExtCtrls, ComCtrls, bsSkinTabs, DBCtrls,DateUtils; type Tfrm_op_seae_teshusales = class(TForm) bsSkinButton13: TbsSkinButton; bsSkinButton1: TbsSkinButton; PopupMenu2: TPopupMenu; N16: TMenuItem; XPMenu1: TXPMenu; t_op_seaesel: TADOQuery; ds_op_seaesel1: TDataSource; pm1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; bsSkinPanel2: TbsSkinPanel; bsSkinPanel3: TbsSkinPanel; bsSkinButton3: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; t_op_bill: TADOQuery; ds_op_bill1: TDataSource; bsSkinPageControl1: TbsSkinPageControl; bskntbsht1: TbsSkinTabSheet; bskntbsht2: TbsSkinTabSheet; dxDBGrid2: TdxDBGrid; dxDBGrid2Column2: TdxDBGridColumn; dxDBGrid2Column3: TdxDBGridColumn; dxDBGrid2Column4: TdxDBGridColumn; dxDBGrid2Column5: TdxDBGridColumn; dxDBGrid2Column6: TdxDBGridColumn; bsSkinPanel4: TbsSkinPanel; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn7: TdxDBGridMaskColumn; dxDBGridMaskColumn13: TdxDBGridMaskColumn; dxDBGridMaskColumn14: TdxDBGridMaskColumn; dxDBGridMaskColumn15: TdxDBGridMaskColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridMaskColumn17: TdxDBGridMaskColumn; dxDBGridMaskColumn24: TdxDBGridMaskColumn; dxDBGridMaskColumn57: TdxDBGridMaskColumn; dxDBGridMaskColumn58: TdxDBGridMaskColumn; dxDBGridMaskColumn61: TdxDBGridMaskColumn; PopupMenu1: TPopupMenu; MenuItem1: TMenuItem; bsSkinButton5: TbsSkinButton; bsSkinButton9: TbsSkinButton; RxDBLookupCombo4: TRxDBLookupCombo; Label4: TLabel; DBEdit9: TDBEdit; DBEdit10: TDBEdit; Label7: TLabel; Label12: TLabel; wwDBDateTimePicker5: TwwDBDateTimePicker; PopupMenu3: TPopupMenu; MenuItem2: TMenuItem; dxDBGrid2Column7: TdxDBGridColumn; Label13: TLabel; DBEdit1: TDBEdit; Label14: TLabel; bsSkinPanel5: TbsSkinPanel; Panel1: TPanel; bsSkinButton11: TbsSkinButton; Label17: TLabel; wwDBDateTimePicker6: TwwDBDateTimePicker; Label18: TLabel; wwDBDateTimePicker7: TwwDBDateTimePicker; Label19: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; Label20: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; dxDBGrid2Column8: TdxDBGridColumn; dxDBGrid2Column9: TdxDBGridColumn; dxDBGrid3Column12: TdxDBGridColumn; dxDBGrid3Column13: TdxDBGridColumn; dxDBGrid3Column14: TdxDBGridColumn; dxDBGrid3Column15: TdxDBGridColumn; Label22: TLabel; wwDBDateTimePicker8: TwwDBDateTimePicker; Label23: TLabel; Label24: TLabel; RxDBLookupCombo7: TRxDBLookupCombo; wwDBDateTimePicker9: TwwDBDateTimePicker; Label15: TLabel; DBEdit2: TDBEdit; Label25: TLabel; DBEdit3: TDBEdit; Label26: TLabel; RxDBLookupCombo8: TRxDBLookupCombo; dxDBGrid2Column10: TdxDBGridColumn; dxDBGrid2Column11: TdxDBGridColumn; Label27: TLabel; RxDBLookupCombo9: TRxDBLookupCombo; dxDBGrid2Column12: TdxDBGridColumn; bsSkinButton38: TbsSkinButton; dxDBGrid2Column13: TdxDBGridColumn; dxDBGrid2Column14: TdxDBGridColumn; dxDBGrid2Column15: TdxDBGridColumn; Label1: TLabel; DBMemo1: TDBMemo; Label29: TLabel; DBMemo2: TDBMemo; Label2: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; Label3: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; Label5: TLabel; RxDBLookupCombo5: TRxDBLookupCombo; DBMemo3: TDBMemo; DBMemo4: TDBMemo; DBMemo5: TDBMemo; Label6: TLabel; Label8: TLabel; Label9: TLabel; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton5Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton38Click(Sender: TObject); procedure dxDBGrid2Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure t_op_billBeforeEdit(DataSet: TDataSet); procedure RxDBLookupCombo4Change(Sender: TObject); procedure RxDBLookupCombo7Change(Sender: TObject); procedure RxDBLookupCombo2Change(Sender: TObject); procedure RxDBLookupCombo5Change(Sender: TObject); procedure RxDBLookupCombo8Change(Sender: TObject); procedure dxDBGrid3DblClick(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); private { Private declarations } public { Public declarations } function UpdateBillStatus(bsStStatus:string):Boolean; end; var frm_op_seae_teshusales: Tfrm_op_seae_teshusales; implementation uses my_sys_function, u_main, my_sys_chat; {$R *.dfm} function Tfrm_op_seae_teshusales.UpdateBillStatus(bsStStatus:string):Boolean; var aAdoQuery,aAdoQuerySelect:TAdoQuery; begin {var aAdoQuery:TAdoQuery; begin result:=False; aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;Sql.Clear; SQL.Add('select count(编号) c from t_op_fangdan'); SQL.Add('where 编号=:编号'); Parameters.ParamByName('编号').Value:=BsNo; Open; if aAdoQuery.FieldByName('c').AsInteger=0 then begin Close;Sql.Clear; SQL.Add('Insert into t_op_fangdan (编号, 放单状态,申请人,申请日期)'); SQL.Add('values (:编号,:放单状态,:申请人,:申请日期)'); Parameters.ParamByName('编号').Value:=BsNo; Parameters.ParamByName('放单状态').Value:='申请放单'; Parameters.ParamByName('申请人').Value:=employee; Parameters.ParamByName('申请日期').Value:=date; ExecSQL; end; finally aAdoQuery.Free; end; } result:=False; aAdoQuery:=CreateAdoQuery; aAdoQuerySelect:=CreateAdoQuery; with t_op_seaesel do try Open;First; while not eof do begin aAdoQuerySelect.Close;aAdoQuerySelect.Sql.Clear; aAdoQuerySelect.SQL.Add('select count(编号) c from t_op_fangdan'); aAdoQuerySelect.SQL.Add('where 编号=:编号'); aAdoQuerySelect.Parameters.ParamByName('编号').Value:=fieldByName('编号').AsString; aAdoQuerySelect.Open; if aAdoQuerySelect.FieldByName('c').AsInteger=0 then begin aAdoQuery.Close;aAdoQuery.Sql.Clear; aAdoQuery.SQL.Add('Insert into t_op_fangdan (编号, 放单状态)'); aAdoQuery.SQL.Add('values (:编号,:放单状态)'); aAdoQuery.Parameters.ParamByName('编号').Value:=fieldByName('编号').AsString; aAdoQuery.Parameters.ParamByName('放单状态').Value:=bsStStatus; aAdoQuery.ExecSQL; end else begin aAdoQuery.Close;aAdoQuery.Sql.Clear; aAdoQuery.SQL.Add('Update t_op_fangdan set 放单状态=:放单状态'); aAdoQuery.SQL.Add('where 编号=:编号'); aAdoQuery.Parameters.ParamByName('编号').Value:=fieldByName('编号').AsString; aAdoQuery.Parameters.ParamByName('放单状态').Value:=bsStStatus; aAdoQuery.ExecSQL; end; Next; end; finally aAdoQuery.Free; aAdoQuerySelect.Free; end; end; procedure Tfrm_op_seae_teshusales.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid2,caption); savereggrid(dxdbgrid3,caption+'1'); frm_op_seae_teshusales.Hide; frm_op_seae_teshusales.ManualFloat(frm_op_seae_teshusales.BoundsRect ); frm_main.freeTabs('frm_op_seae_teshusales'); action:=cafree; frm_op_seae_teshusales:=nil; end; procedure Tfrm_op_seae_teshusales.bsSkinButton5Click(Sender: TObject); begin if t_op_bill.IsEmpty then exit; if not t_op_bill.FieldByName('业务审核日期').IsNull then begin showmessage('已经审核!!'); end else begin t_op_bill.edit; t_op_bill['状态']:='销售审核'; t_op_bill['业务审核日期']:=Now; t_op_bill['业务审核']:=employee; t_op_bill.post; UpdateBillStatus('销售审核'); with t_op_seaesel do begin First; while not eof do begin InsertSeaeStatus(FieldByName('编号').AsString,'销售审核',employee,FormatDateTime('YYYY-MM-DD',Now)); Next; end; end; t_op_bill.Refresh; end; end; procedure Tfrm_op_seae_teshusales.FormShow(Sender: TObject); begin loadreggrid(dxdbgrid2,true,caption); loadreggrid(dxdbgrid3,true,caption+'1'); t_op_bill.Parameters.ParamByName('业务审核').Value:=employee; t_op_bill.Open; t_op_seaesel.Open; end; procedure Tfrm_op_seae_teshusales.bsSkinButton9Click(Sender: TObject); var str:string; begin if t_op_bill.IsEmpty then exit; if t_op_bill.FieldByName('业务审核日期').IsNull then begin showmessage('没有审核,不用取消审核!!'); end else if (not t_op_bill.FieldByName('业务审核日期').IsNull) and t_op_bill.FieldByName('签单日期').IsNull then begin t_op_bill.edit; t_op_bill.FieldByName('驳回原因').AsString:=t_op_bill.FieldByName('驳回原因').AsString+#13#10+employee+' '+FormatDateTime('YYYY-MM-DD hh:ss',Now); t_op_bill['状态']:='新建签单'; t_op_bill['业务审核日期']:=null; t_op_bill.post; UpdateBillStatus('申请放单'); with t_op_seaesel do begin First; while not eof do begin DelteSeaeStatus(fieldbyname('编号').AsString,'销售审核'); Next; end; end; t_op_bill.Refresh; end else showmessage('主管已经审核不能取消审核,主管取消审核后才可以审核!'); end; procedure Tfrm_op_seae_teshusales.bsSkinButton7Click(Sender: TObject); begin if t_op_bill.IsEmpty then exit; t_op_bill.Cancel; end; procedure Tfrm_op_seae_teshusales.bsSkinButton8Click(Sender: TObject); begin Close; end; procedure Tfrm_op_seae_teshusales.bsSkinButton38Click(Sender: TObject); begin t_op_bill.Refresh; end; procedure Tfrm_op_seae_teshusales.dxDBGrid2Click(Sender: TObject); begin bsSkinPageControl1.ActivePageIndex:=1; end; procedure Tfrm_op_seae_teshusales.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid2); end; procedure Tfrm_op_seae_teshusales.t_op_billBeforeEdit(DataSet: TDataSet); begin { if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage('当前状态'+t_op_bill.FieldByName('状态').AsString+'不能修改'); abort; end; if t_op_bill.FieldByName('操作人').AsString<>employee then begin ShowMessage(t_op_bill.FieldByName('操作人').AsString+'的申请不能修改'); abort; end; } end; procedure Tfrm_op_seae_teshusales.RxDBLookupCombo4Change(Sender: TObject); begin if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage('当前状态'+t_op_bill.FieldByName('状态').AsString+'不能修改'); t_op_bill.Cancel; end; end; procedure Tfrm_op_seae_teshusales.RxDBLookupCombo7Change(Sender: TObject); begin if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage('当前状态'+t_op_bill.FieldByName('状态').AsString+'不能修改'); t_op_bill.Cancel; end; end; procedure Tfrm_op_seae_teshusales.RxDBLookupCombo2Change(Sender: TObject); begin if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage('当前状态'+t_op_bill.FieldByName('状态').AsString+'不能修改'); t_op_bill.Cancel; end; end; procedure Tfrm_op_seae_teshusales.RxDBLookupCombo5Change(Sender: TObject); begin if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage('当前状态'+t_op_bill.FieldByName('状态').AsString+'不能修改'); t_op_bill.Cancel; end; end; procedure Tfrm_op_seae_teshusales.RxDBLookupCombo8Change(Sender: TObject); begin if t_op_bill.FieldByName('状态').AsString<>'新建签单' then begin ShowMessage('当前状态'+t_op_bill.FieldByName('状态').AsString+'不能修改'); t_op_bill.Cancel; end; end; procedure Tfrm_op_seae_teshusales.dxDBGrid3DblClick(Sender: TObject); begin fee_view(t_op_seaesel.fieldbyname('编号').asstring); end; procedure Tfrm_op_seae_teshusales.bsSkinButton11Click(Sender: TObject); begin with t_op_bill do begin Close; sql.Clear; sql.Add('select * from t_op_bill_fangdan'); sql.Add('where 操作日期 between :date1 and :date2 and 业务审核=:业务审核'); sql.Add('order by BILL_ID DESC'); Parameters.ParamByName('date1').Value:=wwDBDateTimePicker6.Date; Parameters.ParamByName('date2').Value:=wwDBDateTimePicker7.Date; Parameters.ParamByName('业务审核').Value:=RxDBLookupCombo1.value; Open; end; end; end.