unit U_DyePlanCardList; 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, cxCheckBox, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, IdExplicitTLSClientServerBase, U_BaseList, dxScrollbarAnnotations; type TfrmDyePlanCardList = class(TfrmBaseList) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBAdd: TToolButton; TBDel: TToolButton; TBPrint: TToolButton; TBClose: TToolButton; Panel1: TPanel; BegDate: TDateTimePicker; EndDate: TDateTimePicker; Label1: TLabel; Tv1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1: TcxGrid; GPM_1: TcxGridPopupMenu; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DS_1: TDataSource; Label3: TLabel; OrderNo: TEdit; TBExport: TToolButton; v1OrderNo: TcxGridDBColumn; v1OrdDate: TcxGridDBColumn; v1DeliveryDate: TcxGridDBColumn; v1ConNo: TcxGridDBColumn; v1MPRTSpec: TcxGridDBColumn; CDS_1: TClientDataSet; RM1: TRMGridReport; RMDB_1: TRMDBDataSet; v1CustomerNoName: TcxGridDBColumn; Label4: TLabel; CustName: TEdit; v1MPRTCodeName: TcxGridDBColumn; v1MPRTMF: TcxGridDBColumn; Label8: TLabel; C_Name: TEdit; Label9: TLabel; ConNo: TEdit; v1MPRTKZ: TcxGridDBColumn; Label10: TLabel; C_Spec: TEdit; Label12: TLabel; MPRTKZ: TEdit; ADOQueryPrint: TADOQuery; v1Column1: TcxGridDBColumn; v1Column2: TcxGridDBColumn; v1Column3: TcxGridDBColumn; Tchk: TToolButton; Tnochk: TToolButton; v1Column6: TcxGridDBColumn; v1Column4: TcxGridDBColumn; v1Column5: TcxGridDBColumn; v1Column9: TcxGridDBColumn; v1Column10: TcxGridDBColumn; v1Column11: TcxGridDBColumn; ThreeColorBase: TcxStyleRepository; SHuangSe: TcxStyle; SkyBlue: TcxStyle; Default: TcxStyle; QHuangSe: TcxStyle; Red: TcxStyle; FontBlue: TcxStyle; TextSHuangSe: TcxStyle; FonePurple: TcxStyle; FoneClMaroon: TcxStyle; FoneRed: TcxStyle; RowColor: TcxStyle; handBlack: TcxStyle; cxBlue: TcxStyle; cxStyle1: TcxStyle; v1Column12: TcxGridDBColumn; PCID: TEdit; Label2: TLabel; v1Column13: TcxGridDBColumn; v1Column14: TcxGridDBColumn; C_ColorNo: TEdit; Label5: TLabel; C_Color: TEdit; Label6: TLabel; Tv1Column3: TcxGridDBColumn; Tv1Column6: TcxGridDBColumn; Tv1Column13: TcxGridDBColumn; Tv1Column19: TcxGridDBColumn; Tv1Column20: TcxGridDBColumn; ToolButton6: TToolButton; cxTabControl1: TcxTabControl; PM_1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; tbedit: TToolButton; btnWC: TToolButton; btnnowc: TToolButton; Tv1Column1: TcxGridDBColumn; Tv1Column4: TcxGridDBColumn; Tv1Column5: TcxGridDBColumn; Tv1Column7: TcxGridDBColumn; Tv1Filltime: TcxGridDBColumn; Tv1Chker: TcxGridDBColumn; Tv1Chktime: TcxGridDBColumn; Tv1TotalPCID: TcxGridDBColumn; Tv1TotalPCIDNum: TcxGridDBColumn; TbDetailGY: TToolButton; Tv1KaZu: TcxGridDBColumn; Tv1C_description: TcxGridDBColumn; TbUpdateGY: TToolButton; TbSimpleGY: TToolButton; Tv1CINote: TcxGridDBColumn; Tv1C_Color: TcxGridDBColumn; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure TBFindClick(Sender: TObject); procedure TBDelClick(Sender: TObject); procedure TBExportClick(Sender: TObject); procedure TBPrintClick(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure TBAddClick(Sender: TObject); procedure OrderNoChange(Sender: TObject); procedure FormShow(Sender: TObject); procedure CheckBox2Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure cxTabControl1Change(Sender: TObject); procedure TchkClick(Sender: TObject); procedure TnochkClick(Sender: TObject); procedure Label2DblClick(Sender: TObject); procedure ToolButton6Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure tbeditClick(Sender: TObject); procedure btnWCClick(Sender: TObject); procedure btnnowcClick(Sender: TObject); procedure TbDetailGYClick(Sender: TObject); procedure TbUpdateGYClick(Sender: TObject); procedure TbSimpleGYClick(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private DQdate: TDateTime; procedure InitGrid(); procedure SetStatus(); procedure InitForm(); // procedure SetStatus(); procedure PrintCar(MPCID: string); function UpdateQRCodeWithPrtCount(ADOQuery: TADOQuery; const PCID: string): Boolean; { Private declarations } public FFInt, FCloth: Integer; canshu1, canshu2, FWorkshop: string; fFlileFlag: string; { Public declarations } end; var frmDyePlanCardList: TfrmDyePlanCardList; implementation uses U_DataLink, U_RTFun, U_DyePlanCardInput, U_LabelPrint, U_DyeTechnicsinputKaika, U_DyeSimpleTechnicsKaiKa; {$R *.dfm} procedure TfrmDyePlanCardList.PrintCar(MPCID: string); var fPrintFile: string; begin with ADOQueryPrint do begin Close; SQL.Clear; sql.Add('exec P_Dye_Card_Prt '); sql.Add(' @Filtration=' + quotedstr(trim(MPCID))); Open; end; ExportFtErpFile('流程卡.rmf', ADOQueryTemp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\流程卡.rmf'; if FileExists(fPrintFile) then begin RM1.LoadFromFile(fPrintFile); RM1.PrintReport; sleep(200); with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Dye_Plan_Card SET status=''9'' '); sql.Add('where PCID=' + quotedstr(trim(CDS_1.fieldbyname('PCID').AsString))); execsql; end; end else Application.MessageBox(PChar('没有找到' + trim(fPrintFile)), '提示信息', 0); end; procedure TfrmDyePlanCardList.SetStatus(); begin tchk.Enabled := false; tnochk.Enabled := false; tbadd.Enabled := false; tbedit.Enabled := false; tbdel.Enabled := false; btnWC.Enabled := false; btnnowc.Enabled := false; tbadd.Enabled := true; if Trim(canshu1) = '录入' then begin tchk.Visible := False; tnochk.Visible := False; case cxTabControl1.TabIndex of 0: begin tbedit.Enabled := true; tbdel.Enabled := true; end; 1: begin btnWC.Enabled := true; end; 2: begin btnnowc.Enabled := true; end; 3: begin end; end; end; if Trim(canshu1) = '管理' then begin case cxTabControl1.TabIndex of 0: begin tbedit.Enabled := true; tbdel.Enabled := true; tchk.Enabled := true; end; 1: begin btnWC.Enabled := true; tnochk.Enabled := true; end; 2: begin btnnowc.Enabled := true; end; 3: begin end; end; end; end; procedure TfrmDyePlanCardList.FormDestroy(Sender: TObject); begin inherited; frmDyePlanCardList := nil; end; procedure TfrmDyePlanCardList.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_ESCAPE then // VK_ESCAPE 是 ESC 键的常量 begin Key := 0; // 清除按键,防止继续传递 Close; // 或者 ModalResult := mrCancel; end; end; procedure TfrmDyePlanCardList.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := caFree; end; procedure TfrmDyePlanCardList.FormCreate(Sender: TObject); begin inherited; cxgrid1.Align := alClient; DQdate := SGetServerDate(ADOQueryTemp); canshu1 := trim(Self.fParameters1); canshu2 := trim(Self.fParameters2); FWorkshop := trim(Self.fParameters3); end; procedure TfrmDyePlanCardList.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmDyePlanCardList.InitGrid(); var strwhere: string; begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; Filtered := False; sql.Clear; sql.Add('select A.*,ConNo,OrdType,Salestype ,OrdDate,DlyDate'); sql.Add(',GlideList=[dbo].[F_Dye_Card_GlideList](A.PCID) '); sql.Add('from Dye_Plan_Card A '); sql.Add('left join Dye_Plan_sub B on B.subID=A.subID '); sql.Add('left join Dye_Plan_Main C on C.mainID=A.mainID '); sql.Add('where A.PCTime>=''' + formatdateTime('yyyy-MM-dd', begdate.Date) + ''' '); sql.Add('and A.PCTime<''' + formatdateTime('yyyy-MM-dd', enddate.Date + 1) + ''' '); case cxTabControl1.TabIndex of 0: begin sql.Add(' and isnull(A.status,''0'')= ''0'' '); end; 1: begin sql.Add(' and isnull(A.status,''0'')=''9'' '); end; 2: begin sql.Add(' and isnull(A.status,''0'')=''10'' '); end; end; // if trim(FWorkshop) <> '' then // sql.Add(' and C.Workshop=''' + trim(FWorkshop) + ''' '); if Trim(canshu1) = '' then sql.Add(' and A.Filler=''' + trim(DName) + ''' '); Open; end; SCreateCDS(ADOQueryMain, CDS_1); SInitCDSData(ADOQueryMain, CDS_1); finally ADOQueryMain.EnableControls; TBFind.Click; end; end; procedure TfrmDyePlanCardList.Label2DblClick(Sender: TObject); var I: Integer; Column: TcxGridDBColumn; FieldNames: TStringList; begin FieldNames := TStringList.Create; try for I := 0 to Tv1.ColumnCount - 1 do begin Column := Tv1.Columns[I]; FieldNames.Add(Column.Caption + ':' + Column.DataBinding.FieldName); end; ShowMessage(FieldNames.Text); finally FieldNames.Free; end; end; procedure TfrmDyePlanCardList.InitForm(); begin ReadCxGrid(self.Caption + 'TV1', Tv1, '生产指示单管理'); BegDate.DateTime := SGetServerDate(ADOQueryTemp) - 3; EndDate.DateTime := SGetServerDate(ADOQueryTemp); SetStatus(); InitGrid() end; procedure TfrmDyePlanCardList.TBFindClick(Sender: TObject); begin if ADOQueryMain.Active = False then Exit; SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, CDS_1); SInitCDSData(ADOQueryMain, CDS_1); end; procedure TfrmDyePlanCardList.TBDelClick(Sender: TObject); begin if CDS_1.IsEmpty then Exit; // if (Trim(CDS_1.fieldbyname('Filler').AsString) <> Trim(DName)) and (dname <> 'ADMIN') then // begin // Application.MessageBox('不能操作他人的数据!', '提示', 0); // Exit; // end; if CDS_1.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; try with CDS_1 do begin DisableControls; First; while not Eof do begin if Fieldbyname('Ssel').AsBoolean then begin try ADOQueryCmd.Connection.BeginTrans; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_BS_Cloth_Out_Del '); Sql.Add(' @BCIOIDS=' + quotedstr(Trim(CDS_1.fieldbyname('BCIOID').AsString))); Sql.Add(',@DCode=' + quotedstr(Trim(CDS_1.fieldbyname('C_Code').AsString))); Sql.Add(',@DName=' + quotedstr(Trim(CDS_1.fieldbyname('C_Name').AsString))); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Card_Del '); Sql.Add('@PCIDS=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString))); Sql.Add(',@DCode=' + quotedstr(Trim(DCode))); Sql.Add(',@DName=' + quotedstr(Trim(DName))); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('delete from Dye_Plan_glide where PCID = ' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString))); ExecSQL; end; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('delete from Bs_Cloth_GY_Main_Kaika where PCID = ' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString))); ExecSQL; end; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('delete from Bs_Cloth_GY_Sub_Kaika where PCID = ' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString))); ExecSQL; end; if (Trim(CDS_1.fieldbyname('PCType').AsString) = '正常卡') or (Trim(CDS_1.fieldbyname('PCType').AsString) = '前道卡') then begin with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_GreyCloth_Out_Del '); Sql.Add('@PCID=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString))); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); end else begin with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Card_Move_Del '); Sql.Add('@PCID=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString))); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); end; ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; raise Exception.Create(PChar(Exception(ExceptObject).Message)); end; end; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Plan_UpdateOrderNo '); Sql.Add('@OrderNo=' + quotedstr(Trim(CDS_1.FieldByName('OrderNo').asString))); Open; end; Next; end; EnableControls; end; TBRafresh.Click; except CDS_1.EnableControls; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmDyePlanCardList.TBExportClick(Sender: TObject); begin if ADOQueryMain.IsEmpty then Exit; // SelExportData(Tv1,ADOQueryMain,self.Caption); end; function TfrmDyePlanCardList.UpdateQRCodeWithPrtCount(ADOQuery: TADOQuery; const PCID: string): Boolean; var mQRCode: string; mPrtCount: Integer; NewQRCode: string; begin Result := False; try with ADOQuery do begin // 查询数据 Close; SQL.Clear; SQL.Add('SELECT QRCode, PrtCount FROM Dye_Plan_Card WHERE PCID = ' + QuotedStr(Trim(PCID))); Open; if not IsEmpty then begin // 获取字段值 mQRCode := FieldByName('QRCode').AsString; mPrtCount := FieldByName('PrtCount').AsInteger; // 检查QRCode是否为空 if mQRCode <> '' then begin // 将最后一位替换为PrtCount NewQRCode := Copy(mQRCode, 1, Length(mQRCode) - 1) + IntToStr(mPrtCount); // 更新记录 Edit; FieldByName('QRCode').AsString := NewQRCode; Post; Result := True; end; end; end; except on E: Exception do begin // 处理异常 Application.MessageBox(PChar('更新QRCode时发生错误: ' + E.Message), '错误', MB_ICONERROR); Result := False; end; end; end; procedure TfrmDyePlanCardList.TBPrintClick(Sender: TObject); var MPCID: string; begin if CDS_1.IsEmpty then Exit; if CDS_1.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; MPCID := ''; CDS_1.DisableControls; with CDS_1 do begin First; while CDS_1.Locate('SSel', True, []) do begin if MPCID = '' then begin MPCID := Trim(CDS_1.fieldbyname('PCID').AsString); end else begin MPCID := MPCID + ',' + Trim(CDS_1.fieldbyname('PCID').AsString); end; Edit; FieldByName('SSel').Value := False; Post; with Self.ADOQueryCmd do begin Close; SQL.Clear; SQL.Add(' update Dye_Plan_Card set PrtCount = PrtCount + 1 '); sql.add(' where PCID = ' + QuotedStr(Trim(CDS_1.fieldbyname('PCID').AsString))); ExecSQL; end; UpdateQRCodeWithPrtCount(ADOQueryCmd, CDS_1.fieldbyname('PCID').AsString); end; end; CDS_1.EnableControls; try frmLabelPrint := TfrmLabelPrint.Create(Application); with frmLabelPrint do begin FLMType := 'DyePlanCarListPrint1'; FFiltration1 := MPCID; if ShowModal = 1 then begin // Self.InitGrid(); end; end; finally frmLabelPrint.Free; end; end; //var // i: integer; // MPCID: string; //begin // if CDS_1.IsEmpty then // Exit; // if CDS_1.Locate('SSel', True, []) = False then // begin // Application.MessageBox('没有选择数据!', '提示', 0); // Exit; // end; // i := 0; // with CDS_1 do // begin // DisableControls; // First; // while not Eof do // begin // if Fieldbyname('Ssel').AsBoolean then // begin // if i = 0 then // MPCID := trim(CDS_1.fieldbyname('PCID').AsString); // PrintCar(trim(CDS_1.fieldbyname('PCID').AsString)); // i := i + 1; // end; // Next; // end; // EnableControls; // end; // SelOKNoFiler(Tv1, False); // CDS_1.Locate('PCID', MPCID, []); //end; procedure TfrmDyePlanCardList.TBRafreshClick(Sender: TObject); begin InitGrid(); end; procedure TfrmDyePlanCardList.TbSimpleGYClick(Sender: TObject); begin try frmDyeSimpleTechnicsKaiKa := TfrmDyeSimpleTechnicsKaiKa.Create(Application); with frmDyeSimpleTechnicsKaiKa do begin fKaZu := CDS_1.FieldByName('KaZu').AsString; if ShowModal = 1 then begin end; end; finally frmDyeSimpleTechnicsKaiKa.Free; end; end; procedure TfrmDyePlanCardList.TbUpdateGYClick(Sender: TObject); begin if CDS_1.IsEmpty then Exit; if CDS_1.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; CDS_1.DisableControls; with CDS_1 do begin First; while CDS_1.Locate('SSel', True, []) do begin with ADOQueryCmd do begin Close; SQL.Clear; SQL.Add('Delete From Bs_Cloth_GY_Main_Kaika where PCID = ' + quoTedStr(Trim(CDS_1.FieldByName('KaZu').AsString))); SQL.Add('Delete From Bs_Cloth_GY_Sub_Kaika where PCID = ' + quoTedStr(Trim(CDS_1.FieldByName('KaZu').AsString))); ExecSQL; end; with ADOQueryCmd do begin SQL.Clear; SQL.Add('EXEC P_InsertGxToKaika @PCID = ' + quotedstr(trim(CDS_1.FieldByName('KaZu').AsString))); ExecSQL; end; Edit; FieldByName('SSel').Value := False; Post; end; end; Application.MessageBox('更新成功!', '提示信息', MB_OK); CDS_1.EnableControls; end; procedure TfrmDyePlanCardList.TBAddClick(Sender: TObject); begin try frmDyePlanCardInput := TfrmDyePlanCardInput.Create(Application); with frmDyePlanCardInput do begin FPCIDS := ''; FWorkshop := self.FWorkshop; if ShowModal = 1 then begin InitGrid(); end; end; finally frmDyePlanCardInput.Free; end; end; procedure TfrmDyePlanCardList.OrderNoChange(Sender: TObject); begin if ADOQueryMain.Active = False then Exit; SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, CDS_1); SInitCDSData(ADOQueryMain, CDS_1); end; procedure TfrmDyePlanCardList.FormShow(Sender: TObject); begin inherited; fFlileFlag := UserDataFlag + 'HX'; canshu1 := self.fParameters1; canshu2 := self.fParameters3; // canshu1 := '录入'; FWorkshop := self.fParameters3; InitForm(); KeyPreview := True; end; procedure TfrmDyePlanCardList.CheckBox2Click(Sender: TObject); begin TBRafresh.Click; end; procedure TfrmDyePlanCardList.N1Click(Sender: TObject); begin SelOKNo(CDS_1, true); end; procedure TfrmDyePlanCardList.N2Click(Sender: TObject); begin SelOKNo(CDS_1, False); end; procedure TfrmDyePlanCardList.tbeditClick(Sender: TObject); var MPCIDS: string; I, j: Integer; Column: TcxGridDBColumn; firstCurrentValue, CurrentValue: string; begin I := 0; j := 0;//第一个被选中的 with CDS_1 do begin DisableControls; First; Column := Tv1.GetColumnByFieldName('OrderNo'); while not Eof do begin if Fieldbyname('Ssel').AsBoolean then begin MPCIDS := MPCIDS + trim(CDS_1.FieldByName('PCID').AsString) + ';'; if j = 0 then begin firstCurrentValue := VarToStr(Tv1.DataController.Values[I, Column.Index]); j := 1;//第一个选中值执行其余不执行 end; if (Column = nil) or (Tv1.DataController.RecordCount = 0) then begin Exit; end; CurrentValue := VarToStr(Tv1.DataController.Values[I, Column.Index]); if CurrentValue <> firstCurrentValue then begin application.MessageBox('列内容不一致', '提示信息', MB_OK); EnableControls; Exit; end; end; I := I + 1; Next; end; EnableControls; end; try frmDyePlanCardInput := TfrmDyePlanCardInput.Create(Application); with frmDyePlanCardInput do begin FPCIDS := MPCIDS; FWorkshop := self.FWorkshop; fmainID := SELF.CDS_1.fieldbyname('mainID').asstring; if ShowModal = 1 then begin InitGrid(); end; end; finally frmDyePlanCardInput.Free; end; end; procedure TfrmDyePlanCardList.btnWCClick(Sender: TObject); begin if CDS_1.IsEmpty then exit; if CDS_1.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_1 do begin DisableControls; First; while not Eof do begin if Fieldbyname('Ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Dye_Plan_Card SET status=''10'' '); sql.Add('where PCID=' + quotedstr(trim(CDS_1.fieldbyname('PCID').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(CDS_1.FieldByName('PCID').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; end; Next; end; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmDyePlanCardList.btnnowcClick(Sender: TObject); begin if CDS_1.IsEmpty then exit; if CDS_1.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_1 do begin DisableControls; First; while not Eof do begin if Fieldbyname('Ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Dye_Plan_Card SET status=''9'' '); sql.Add('where PCID=' + quotedstr(trim(CDS_1.fieldbyname('PCID').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(CDS_1.FieldByName('PCID').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; end; Next; end; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('操作成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('操作失败!', '提示信息', 0); end; end; procedure TfrmDyePlanCardList.TbDetailGYClick(Sender: TObject); begin try frmDyeTechnicsinputKaika := TfrmDyeTechnicsinputKaika.Create(Application); with frmDyeTechnicsinputKaika do begin PState := '查看'; FPCID := Trim(self.CDS_1.fieldbyname('KaZu').AsString); if ShowModal = 1 then begin end; end; finally frmDyeTechnicsinputKaika.Free; end; end; procedure TfrmDyePlanCardList.ToolButton6Click(Sender: TObject); begin WriteCxGrid(self.Caption + 'TV1', Tv1, '生产指示单管理'); end; procedure TfrmDyePlanCardList.cxTabControl1Change(Sender: TObject); begin SetStatus(); InitGrid(); end; procedure TfrmDyePlanCardList.TchkClick(Sender: TObject); begin if CDS_1.IsEmpty then exit; if CDS_1.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_1 do begin DisableControls; First; while not Eof do begin if Fieldbyname('Ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Dye_Plan_Card SET status=''9'' '); sql.Add(' ,Chker = ' + quotedstr(trim(DName)) + ',Chktime = getdate()'); sql.Add('where PCID=' + quotedstr(trim(CDS_1.fieldbyname('PCID').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(CDS_1.FieldByName('PCID').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; end; Next; end; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('审核成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('审核失败!', '提示信息', 0); end; end; procedure TfrmDyePlanCardList.TnochkClick(Sender: TObject); begin if CDS_1.IsEmpty then exit; if CDS_1.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_1 do begin DisableControls; First; while not Eof do begin if Fieldbyname('Ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update Dye_Plan_Card SET status=''0'' '); sql.Add('where PCID=' + quotedstr(trim(CDS_1.fieldbyname('PCID').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(CDS_1.FieldByName('PCID').AsString)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); execsql; end; end; Next; end; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('撤销审核成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('撤销审核失败!', '提示信息', 0); end; end; end.