unit U_FtyOrderList; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB, ExtCtrls, BtnEdit, cxCalendar, StrUtils, cxCurrencyEdit, cxImage, cxDBEdit, Menus, RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, cxGridCustomPopupMenu, cxGridPopupMenu, cxPC, cxSplitter, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP, ShellAPI, cxDropDownEdit, cxCheckBox, RM_e_Graphic, RM_e_Jpeg, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, Math, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, IdExplicitTLSClientServerBase, U_BaseList, Vcl.Clipbrd; type TfrmFtyOrderList = class(TfrmBaseList) ToolBar1: TToolBar; TBRafresh: TToolButton; TBAdd: TToolButton; TBEdit: TToolButton; TBDel: TToolButton; TBPrint: TToolButton; TBClose: TToolButton; Panel1: TPanel; BegDate: TDateTimePicker; EndDate: TDateTimePicker; Tv1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1: TcxGrid; cxgrdpmn1: TcxGridPopupMenu; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DataSource1: TDataSource; Label3: TLabel; FONo: TEdit; VC_FONo: TcxGridDBColumn; v1OrdDate: TcxGridDBColumn; v1DeliveryDate: TcxGridDBColumn; Order_Main: TClientDataSet; TBCK: TToolButton; Label12: TLabel; MPRTKZ: TEdit; btnCopy: TToolButton; cxSplitter1: TcxSplitter; ADOQuerySub: TADOQuery; DataSource2: TDataSource; ToolButton4: TToolButton; cxTabControl1: TcxTabControl; Tchk: TToolButton; Tnochk: TToolButton; TWC: TToolButton; TNowc: TToolButton; Panel2: TPanel; ADOQueryImage: TADOQuery; DSImage: TDataSource; IdFTP1: TIdFTP; TBTJ: TToolButton; TBTJCX: TToolButton; v1Column16: TcxGridDBColumn; ORDER_SUB: TClientDataSet; PopupMenu2: TPopupMenu; N3: TMenuItem; N4: TMenuItem; ComboBox1: TComboBox; Label1: TLabel; CustName: TEdit; Tv1Column6: TcxGridDBColumn; cxgrdpmn2: TcxGridPopupMenu; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; v1PRTColor: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; v1Column5: TcxGridDBColumn; VC_PRTPs: TcxGridDBColumn; v1PRTOrderQty: TcxGridDBColumn; v1OrderUnit: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; Tv1Column1: TcxGridDBColumn; Label2: TLabel; C_Name: TEdit; CDS_WXTS: TClientDataSet; Label4: TLabel; ConNo: TEdit; CheckBox1: TCheckBox; ToolButton2: TToolButton; PM_1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; GPM_3: TcxGridPopupMenu; TV2Column1: TcxGridDBColumn; TV2Column2: TcxGridDBColumn; TV2Column3: TcxGridDBColumn; TV2Column4: TcxGridDBColumn; TV2Column5: TcxGridDBColumn; TV2Column6: TcxGridDBColumn; TV2Column7: TcxGridDBColumn; TV2Column8: TcxGridDBColumn; TV2Column9: TcxGridDBColumn; Tv1Column2: TcxGridDBColumn; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure TBEditClick(Sender: TObject); procedure TBDelClick(Sender: TObject); procedure TBPrintClick(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure TBAddClick(Sender: TObject); procedure OrderNoMChange(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBTPClick(Sender: TObject); procedure CheckBox1Click(Sender: TObject); procedure CheckBox2Click(Sender: TObject); procedure TBCKClick(Sender: TObject); procedure btnCopyClick(Sender: TObject); procedure FONoKeyPress(Sender: TObject; var Key: Char); procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); procedure ToolButton4Click(Sender: TObject); procedure cxTabControl1Change(Sender: TObject); procedure TchkClick(Sender: TObject); procedure TnochkClick(Sender: TObject); procedure TWCClick(Sender: TObject); procedure TNowcClick(Sender: TObject); procedure TBTJClick(Sender: TObject); procedure TBTJCXClick(Sender: TObject); procedure N3Click(Sender: TObject); procedure N4Click(Sender: TObject); procedure ComboBox1Change(Sender: TObject); procedure CustomerNoNameKeyPress(Sender: TObject; var Key: Char); procedure JGTypeChange(Sender: TObject); procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure ToolButton2Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); private DQdate: TDateTime; procedure InitGrid(); function DelData(): Boolean; procedure InitGridFH(); procedure InitSub(); procedure SetStatus(); procedure InitImage(fwbid: string); procedure SendMessageQR(MDateId, KeyWord1, KeyWord2, KeyWord3: string); { Private declarations } public FFInt, FCloth: Integer; canshu1, canshu2: string; fFlileFlag: string; FNOTE: string; { Public declarations } end; implementation uses U_DataLink, U_FtyOrderInPut, U_RTFun, U_ZDYHelp, U_LabelPrint, U_AttachmentUpload; {$R *.dfm} procedure TfrmFtyOrderList.InitImage(fwbid: string); begin ADOQueryImage.close; if fwbid = '' then exit; with ADOQueryImage do begin close; sql.Clear; sql.Add('select * from TP_File A'); sql.Add('where WBID=' + quotedstr(trim(fwbid))); open; end; end; procedure TfrmFtyOrderList.SetStatus(); begin btnCopy.Enabled := false; tbadd.Enabled := false; TBEdit.Enabled := False; TBDel.Enabled := False; TBTJ.Enabled := False; TBTJCX.Enabled := False; tchk.Enabled := false; tnochk.Enabled := false; TWC.Enabled := False; TNowc.Enabled := False; TBDel.Enabled := False; case cxTabControl1.TabIndex of 0: begin tbadd.Enabled := True; TBEdit.Enabled := True; TBDel.Enabled := True; TBDel.Enabled := True; TBTJ.Enabled := True; btnCopy.Enabled := True; end; 1: begin TBTJCX.Enabled := True; btnCopy.Enabled := True; TBDel.Enabled := True; tchk.Enabled := True; end; 2: begin TWC.Enabled := True; btnCopy.Enabled := True; tnochk.Enabled := True; end; 3: begin TNowc.Enabled := True; btnCopy.Enabled := True; end; end; end; procedure TfrmFtyOrderList.InitSub(); begin ADOQuerySub.Close; if Order_Main.IsEmpty then exit; ADOQuerySub.DisableControls; with ADOQuerySub do begin close; sql.Clear; sql.Add('select * '); sql.Add(' from Fty_Order_Sub A'); sql.Add('where FOMId =' + quotedstr((Order_Main.fieldbyname('FOMId').AsString))); open; end; SCreateCDS(ADOQuerySub, ORDER_SUB); SInitCDSData(ADOQuerySub, ORDER_SUB); ADOQuerySub.EnableControls; TV2.DataController.Filter.Clear; end; procedure TfrmFtyOrderList.JGTypeChange(Sender: TObject); begin InitGrid(); end; procedure TfrmFtyOrderList.FormDestroy(Sender: TObject); begin inherited; // frmProductOrderList:=nil; end; procedure TfrmFtyOrderList.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := caFree; end; procedure TfrmFtyOrderList.FormCreate(Sender: TObject); begin inherited; cxgrid1.Align := alClient; DQdate := SGetServerDate(ADOQueryTemp); end; procedure TfrmFtyOrderList.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmFtyOrderList.InitGrid(); var STRwhere, Pwhere: string; begin STRwhere := ''; Pwhere := SGetFilters(Panel1, 1, 2); begin if trim(Pwhere) <> '' then STRwhere := STRwhere + ' and ' + trim(Pwhere); end; case cxTabControl1.TabIndex of 0: begin STRwhere := STRwhere + ' and isnull(status,''0'')=''0'' '; end; 1: begin STRwhere := STRwhere + ' and isnull(status,''0'')=''1'' '; end; 2: begin STRwhere := STRwhere + ' and isnull(status,''0'')=''9'' '; end; 3: begin STRwhere := STRwhere + ' and isnull(status,''0'')=''10'' '; end; end; try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered := False; Close; sql.Clear; sql.add(' select A.* from Fty_Order_Main A'); if (ComboBox1.Text = '制单日期') and (CheckBox1.Checked = True) then begin sql.add(' where A.FODate>=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)))); sql.add(' and A.FODate<' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)))); end; if (ComboBox1.Text = '制单日期') and (CheckBox1.Checked = False) then begin sql.add(' where A.FODate>=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime - 39999)))); sql.add(' and A.FODate<' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)))); end; if (ComboBox1.Text = '交货日期') and (CheckBox1.Checked = True) then begin sql.add(' where A.DlyDate>=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)))); sql.add(' and A.DlyDate<' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)))); end; if (ComboBox1.Text = '交货日期') and (CheckBox1.Checked = False) then begin sql.add(' where A.DlyDate>=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime - 39999)))); sql.add(' and A.DlyDate<' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1)))); end; if canshu1 = '录入' then begin sql.add(' and A.Filler= ' + QuotedStr(Trim(DName))); end; sql.add(' ' + STRwhere); sql.add(' order by filltime desc'); // ShowMessage(SQL.Text); Open; end; SCreateCDS(ADOQueryMain, Order_Main); SInitCDSData(ADOQueryMain, Order_Main); finally ADOQueryMain.EnableControls; TV1.DataController.Filter.Clear; end; end; procedure TfrmFtyOrderList.SendMessageQR(MDateId, KeyWord1, KeyWord2, KeyWord3: string); begin with ADOQueryTemp do begin Close; SQL.Clear; sql.Add('select distinct A.* from SY_User A inner join SY_Purview B on A.UserID=B.UserID where A.Valid=''Y'' '); SQL.Add('and isnull(A.wxid,'''')<>'''''); SQL.Add(' and exists(select 1 from SY_ModuleSub X where X.ModuleID=B.ModuleID and X.ModuleSubID=B.ModuleSubID and X.FormName=''生产计划单审核'' )'); // showmessage(sql.text); Open; end; SCreateCDS(ADOQueryTemp, CDS_WXTS); SInitCDSData(ADOQueryTemp, CDS_WXTS); if CDS_WXTS.IsEmpty then begin Application.MessageBox('用户未绑定微信,提交失败!', '提示信息', 0); Exit; end; CDS_WXTS.First; while not CDS_WXTS.eof do begin with ADOQueryCmd do begin Close; SQL.Clear; SQL.Add('select * from WeixinMessage where 1<>1'); Open; Append; FieldByName('MessageType').Value := 'OrderToAudit'; FieldByName('MessageName').Value := '计划单待审核'; FieldByName('Title').Value := '您有新的生产计划单待审核'; FieldByName('URL').Value := 'subpages/plan/view?id=' + Trim(MDateId); FieldByName('OpenId').Value := Trim(CDS_WXTS.FieldByName('wxid').AsString); FieldByName('Status').Value := '0'; FieldByName('CreateDate').Value := FormatDateTime('yyyymmdd', SGetServerDateTime(ADOQueryTemp)); FieldByName('CreateTime').Value := FormatDateTime('HH:mm:ss', SGetServerDateTime(ADOQueryTemp)); FieldByName('BusinessId').Value := Trim(MDateId); FieldByName('KeyWord1').Value := Trim(KeyWord1); FieldByName('KeyWord2').Value := Trim(KeyWord2); FieldByName('KeyWord3').Value := Trim(KeyWord3); FieldByName('Remark').Value := '点击可查询详情!'; Post; end; CDS_WXTS.Next; end; GetHTTP('http://aotang.rightsoft.top/api/message/send/OrderToAudit'); end; procedure TfrmFtyOrderList.InitGridFH(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered := False; Close; sql.Clear; sql.Add('exec Order_QryList :FOMId,:WSql'); Parameters.ParamByName('WSql').Value := ' and FillTime>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + '''' + ' and FillTime<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1)) + ''''; Open; end; SCreateCDS(ADOQueryMain, Order_Main); SInitCDSData(ADOQueryMain, Order_Main); finally ADOQueryMain.EnableControls; end; end; procedure TfrmFtyOrderList.TBEditClick(Sender: TObject); begin if Order_Main.IsEmpty then Exit; if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then begin Application.MessageBox('不能操作他人的数据!', '提示', 0); Exit; end; try frmTradePlanInPut := TfrmTradePlanInPut.Create(Application); with frmTradePlanInPut do begin PState := 1; FFOMId := Trim(Self.Order_Main.fieldbyname('FOMId').AsString); FFONo := Trim(Self.Order_Main.fieldbyname('FONo').AsString); canshu1 := self.canshu1; if ShowModal = 1 then begin end; end; finally frmTradePlanInPut.Free; end; end; procedure TfrmFtyOrderList.TBDelClick(Sender: TObject); begin if Order_Main.IsEmpty then Exit; if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then begin Application.MessageBox('不能操作他人的数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from Trade_Cloth_Inspect where isnull(FOMId,'''')<>'''' and FOMId=''' + Trim(Order_Main.fieldbyname('FOMId').AsString) + ''''); Open; end; if ADOQueryTemp.IsEmpty = False then begin Application.MessageBox('已检验不能删除数据!', '提示', 0); Exit; end; while Order_Main.Locate('SSel', true, []) do begin if Trim(Order_Main.fieldbyname('FOMId').AsString) <> '' then begin DelData() end; Order_Main.Delete; end; end; function TfrmFtyOrderList.DelData(): Boolean; begin try Result := false; ADOQueryCmd.Connection.BeginTrans; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete Fty_Order_Main where FOMId=''' + Trim(Order_Main.fieldbyname('FOMId').AsString) + ''''); sql.Add('delete Fty_Order_Sub where FOMId=''' + Trim(Order_Main.fieldbyname('FOMId').AsString) + ''''); sql.Add('delete Fty_Order_Fty where FOMId=''' + Trim(Order_Main.fieldbyname('FOMId').AsString) + ''''); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('指示单删除'))); sql.Add(',' + quotedstr(trim('指示单号:' + trim(Order_Main.FieldByName('OrderNO').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); ExecSQL; end; ADOQueryCmd.Connection.CommitTrans; Result := True; except ADOQueryCmd.Connection.RollbackTrans; Result := False; Application.MessageBox('数据删除异常!', '提示', 0); end; end; procedure TfrmFtyOrderList.TBPrintClick(Sender: TObject); var WSql: string; begin if Order_Main.IsEmpty then Exit; WSql := QuotedStr(Trim(Order_Main.fieldbyname('FOMId').AsString)); try frmLabelPrint := TfrmLabelPrint.Create(Application); with frmLabelPrint do begin FLMType := 'TradePlanPrint'; FFiltration1 := WSql; if ShowModal = 1 then begin // Self.InitGrid(); end; end; finally frmLabelPrint.Free; end; end; procedure TfrmFtyOrderList.TBRafreshClick(Sender: TObject); begin InitGrid(); end; procedure TfrmFtyOrderList.TBAddClick(Sender: TObject); begin try frmTradePlanInPut := TfrmTradePlanInPut.Create(Application); with frmTradePlanInPut do begin PState := 0; FFOMId := ''; canshu1 := self.canshu1; if ShowModal = 1 then begin InitGrid(); end; end; finally frmTradePlanInPut.Free; end; end; procedure TfrmFtyOrderList.OrderNoMChange(Sender: TObject); begin if ADOQueryMain.Active = False then Exit; SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, Order_Main); SInitCDSData(ADOQueryMain, Order_Main); end; procedure TfrmFtyOrderList.FormShow(Sender: TObject); begin inherited; canshu1 := self.fParameters1; fFlileFlag := UserDataFlag + 'HX'; cxTabControl1.TabIndex := 0; ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, '生产通知单'); ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, '生产通知单'); BegDate.DateTime := SGetServerDate(ADOQueryTemp) - 180; EndDate.DateTime := SGetServerDate(ADOQueryTemp); SetStatus(); InitGrid(); end; procedure TfrmFtyOrderList.TBTPClick(Sender: TObject); var FQty, FQty1, FMxQty, FPQty, FMxQtyS, FPQtyS: string; begin end; procedure TfrmFtyOrderList.CheckBox1Click(Sender: TObject); begin InitGrid(); end; procedure TfrmFtyOrderList.CheckBox2Click(Sender: TObject); begin TBRafresh.Click; end; procedure TfrmFtyOrderList.TBCKClick(Sender: TObject); begin if Order_Main.IsEmpty then Exit; try frmTradePlanInPut := TfrmTradePlanInPut.Create(Application); with frmTradePlanInPut do begin PState := 1; FFOMId := Trim(Self.Order_Main.fieldbyname('FOMId').AsString); ToolBar2.Visible := False; TBSave.Visible := False; ScrollBox1.Enabled := True; N2.Visible := False; if ShowModal = 1 then begin end; end; finally frmTradePlanInPut.Free; end; end; procedure TfrmFtyOrderList.btnCopyClick(Sender: TObject); begin if Order_Main.IsEmpty then Exit; try frmTradePlanInPut := TfrmTradePlanInPut.Create(Application); with frmTradePlanInPut do begin PState := 1; CopyInt := 99; FFOMId := Trim(Self.Order_Main.fieldbyname('FOMId').AsString); canshu1 := self.canshu1; if ShowModal = 1 then begin end; end; finally frmTradePlanInPut.Free; end; end; procedure TfrmFtyOrderList.FONoKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin initgrid(); end; end; procedure TfrmFtyOrderList.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin Clipboard.SetTextBuf(PChar(Trim(Order_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString))); end; procedure TfrmFtyOrderList.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); begin InitSub(); end; procedure TfrmFtyOrderList.ToolButton4Click(Sender: TObject); begin if Order_Main.IsEmpty then Exit; try frmAttachmentUpload := TfrmAttachmentUpload.Create(Application); with frmAttachmentUpload do begin if Trim(canshu1) <> '查询' then FEditAuthority := True; fkeyNO := Trim(Self.Order_Main.fieldbyname('FOMId').AsString); fType := '指示单'; if ShowModal = 1 then begin end; end; finally frmAttachmentUpload.Free; end; end; procedure TfrmFtyOrderList.cxTabControl1Change(Sender: TObject); begin SetStatus(); InitGrid(); end; procedure TfrmFtyOrderList.TchkClick(Sender: TObject); begin if Order_Main.IsEmpty then exit; if cxTabControl1.TabIndex <> 1 then begin Application.MessageBox('只能在待审核状态下进行审核操作!', '提示', 0); Exit; end; if Application.MessageBox('是否核实好数据?', '提示', 32 + 4) <> IDYES then Exit; try with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Fty_Order_Main SET status=''9'',chker=''' + trim(DName) + ''',Chktime=getdate() '); sql.Add('where FOMId=' + quotedstr(trim(Order_Main.fieldbyname('FOMId').AsString))); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('计划单审核'))); sql.Add(',' + quotedstr(trim('计划单号:' + trim(Order_Main.FieldByName('orderNO').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; except application.MessageBox('计划单审核失败!', '提示信息', 0); end; TBRafresh.Click; end; procedure TfrmFtyOrderList.TnochkClick(Sender: TObject); begin if Order_Main.IsEmpty then exit; if cxTabControl1.TabIndex <> 2 then begin Application.MessageBox('只能在已审核状态下进行审核操作!', '提示', 0); Exit; end; try with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Fty_Order_Main SET status=''1'',chker=null,Chktime=null '); sql.Add('where FOMId=' + quotedstr(trim(Order_Main.fieldbyname('FOMId').AsString))); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('计划单撤销审核'))); sql.Add(',' + quotedstr(trim('计划单号:' + trim(Order_Main.FieldByName('orderNO').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; TBRafresh.Click; except application.MessageBox('计划单撤销审核失败!', '提示信息', 0); end; end; procedure TfrmFtyOrderList.TWCClick(Sender: TObject); begin if Order_Main.IsEmpty then exit; if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then begin Application.MessageBox('不能操作他人的数据!', '提示', 0); Exit; end; if Application.MessageBox('是否核实好数据?', '提示', 32 + 4) <> IDYES then Exit; try with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Fty_Order_Main SET status=''10'' '); sql.Add('where FOMId=' + quotedstr(trim(Order_Main.fieldbyname('FOMId').AsString))); sql.Add('exec P_Ord_Up_SuoLv @DataID=' + quotedstr(trim(Order_Main.fieldbyname('FOMId').AsString))); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('计划单完成'))); sql.Add(',' + quotedstr(trim('计划单号:' + trim(Order_Main.FieldByName('orderNO').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; application.MessageBox('计划单完成成功!', '提示信息'); TBRafresh.Click; except application.MessageBox('计划单完成失败!', '提示信息', 0); end; end; procedure TfrmFtyOrderList.TNowcClick(Sender: TObject); begin if Order_Main.IsEmpty then exit; if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then begin Application.MessageBox('不能操作他人的数据!', '提示', 0); Exit; end; if Application.MessageBox('是否核实好数据?', '提示', 32 + 4) <> IDYES then Exit; try with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Fty_Order_Main SET status=''9'' '); sql.Add('where FOMId=' + quotedstr(trim(Order_Main.fieldbyname('FOMId').AsString))); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('计划单撤销完成'))); sql.Add(',' + quotedstr(trim('计划单号:' + trim(Order_Main.FieldByName('orderNO').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; application.MessageBox('计划单撤销完成成功!', '提示信息'); TBRafresh.Click; except application.MessageBox('计划单撤销完成失败!', '提示信息', 0); end; end; procedure TfrmFtyOrderList.TBTJClick(Sender: TObject); begin if Order_Main.IsEmpty then exit; if canshu1 <> '高权限' then begin if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then begin Application.MessageBox('不能操作他人的数据!', '提示', 0); Exit; end; end; if cxTabControl1.TabIndex <> 0 then begin Application.MessageBox('只能在待提交状态下进行提交操作!', '提示', 0); Exit; end; if Application.MessageBox('确定要提交数据吗?', '提示', 32 + 4) <> IDYES then Exit; try with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Fty_Order_Main SET status=''1'' '); sql.Add(' where FOMId=' + quotedstr(trim(Order_Main.fieldbyname('FOMId').AsString))); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('计划单提交'))); sql.Add(',' + quotedstr(trim('计划单号:' + trim(Order_Main.FieldByName('orderNO').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; SendMessageQR(trim(Order_Main.FieldByName('FOMId').AsString), trim(Order_Main.FieldByName('Filler').AsString), trim(Order_Main.FieldByName('orderNO').AsString), Trim(FormatDateTime('yyyy-MM-dd', Order_Main.FieldByName('FODate').asdatetime))); with ADOQueryCmd do begin close; sql.Clear; sql.Add('exec P_MSG_in '); sql.Add(' @MSG=' + QuotedStr(trim('计划单号:' + trim(Order_Main.FieldByName('orderNO').AsString) + ' 需要审核'))); sql.Add(',@FillUserid=' + QuotedStr(trim(DCode))); sql.Add(',@FillUserName=' + QuotedStr(trim(DName))); sql.Add(',@FillType=' + QuotedStr(trim('需要确认'))); sql.Add(',@MegType=' + QuotedStr(trim('计划单提交'))); execsql; end; application.MessageBox('计划单提交成功!', '提示信息'); except application.MessageBox('计划单提交失败!', '提示信息', 0); end; TBRafresh.Click; end; procedure TfrmFtyOrderList.TBTJCXClick(Sender: TObject); begin if Order_Main.IsEmpty then exit; if canshu1 <> '高权限' then begin if Trim(Order_Main.fieldbyname('Filler').AsString) <> Trim(DName) then begin Application.MessageBox('不能操作他人的数据!', '提示', 0); Exit; end; end; if cxTabControl1.TabIndex <> 1 then begin Application.MessageBox('只能在待审核状态下进行提交撤销操作!', '提示', 0); Exit; end; if Application.MessageBox('确定要撤销提交数据吗?', '提示', 32 + 4) <> IDYES then Exit; try with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Fty_Order_Main SET status=''0'' '); sql.Add(' where FOMId=' + quotedstr(trim(Order_Main.fieldbyname('FOMId').AsString))); sql.Add(' and isnull(status,''0'')=''1'' '); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('计划单提交撤销'))); sql.Add(',' + quotedstr(trim('计划单号:' + trim(Order_Main.FieldByName('orderNO').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; application.MessageBox('计划单提交撤销成功!', '提示信息'); TBRafresh.Click; except application.MessageBox('计划单提交撤销失败!', '提示信息', 0); end; end; procedure TfrmFtyOrderList.N1Click(Sender: TObject); begin Clipboard.SetTextBuf(PChar(Trim(Order_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString))); end; procedure TfrmFtyOrderList.N2Click(Sender: TObject); begin Clipboard.SetTextBuf(PChar(Trim(ORDER_SUB.fieldbyname(TV2.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString))); end; procedure TfrmFtyOrderList.N3Click(Sender: TObject); begin SelOKNoFiler(Tv1, True); //全选 end; procedure TfrmFtyOrderList.N4Click(Sender: TObject); begin SelOKNoFiler(Tv1, False); //全弃 end; procedure TfrmFtyOrderList.ComboBox1Change(Sender: TObject); begin InitGrid(); end; procedure TfrmFtyOrderList.CustomerNoNameKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin InitGrid(); end; end; procedure TfrmFtyOrderList.ToolButton2Click(Sender: TObject); begin WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, '生产通知单'); WriteCxGrid(trim(self.Caption) + 'Tv2', Tv2, '生产通知单'); end; end.