unit U_DyeCardInput; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, BtnEdit, ComCtrls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ToolWin, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid, ADODB, DBClient, cxCalendar, cxContainer, cxTextEdit, cxCurrencyEdit, cxDropDownEdit, cxCheckBox, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, U_BaseInput, System.ImageList, Vcl.ImgList, dxBarBuiltInMenu, cxGridCustomPopupMenu, cxGridPopupMenu, cxButtonEdit, Vcl.Menus, cxPC; type TfrmDyeCardInput = class(TfrmBaseInput) CDS_1: TClientDataSet; DS_1: TDataSource; ADO_Car: TADOQuery; ADOQueryCmd: TADOQuery; ADOQueryTmp: TADOQuery; GPM_1: TcxGridPopupMenu; Panel3: TPanel; Panel5: TPanel; Panel4: TPanel; cxGrid1: TcxGrid; TV1: TcxGridDBTableView; V1SSel: TcxGridDBColumn; V1Column1: TcxGridDBColumn; V1Column5: TcxGridDBColumn; TV1Column1: TcxGridDBColumn; TV1Column5: TcxGridDBColumn; TV1Column6: TcxGridDBColumn; TV1Column7: TcxGridDBColumn; V1Column2: TcxGridDBColumn; V1Column3: TcxGridDBColumn; TV1Column4: TcxGridDBColumn; TV1Column3: TcxGridDBColumn; V1Column6: TcxGridDBColumn; V1Column4: TcxGridDBColumn; TV1Column2: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; ToolBar1: TToolBar; ToolButton4: TToolButton; ADOQueryMain: TADOQuery; DS_2: TDataSource; CDS_2: TClientDataSet; PM_2: TPopupMenu; N1: TMenuItem; N2: TMenuItem; PM_1: TPopupMenu; MenuItem1: TMenuItem; MenuItem2: TMenuItem; GPM_2: TcxGridPopupMenu; TV1Column10: TcxGridDBColumn; ToolButton5: TToolButton; ToolButton1: TToolButton; ToolButton2: TToolButton; ToolButton3: TToolButton; cxPageControl1: TcxPageControl; cxTabSheet3: TcxTabSheet; cxTabSheet4: TcxTabSheet; Panel2: TPanel; Label3: TLabel; Label2: TLabel; Label8: TLabel; Label5: TLabel; Label6: TLabel; C_Name: TEdit; FromCoName: TEdit; C_Spec: TEdit; BatchNo: TEdit; FromCoNo: TEdit; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; v1Column17: TcxGridDBColumn; v1Column14: TcxGridDBColumn; v1Column10: TcxGridDBColumn; cxGridDBColumn5: TcxGridDBColumn; v2Column6: TcxGridDBColumn; cxGridDBColumn6: TcxGridDBColumn; Tv1Column9: TcxGridDBColumn; v2Column1: TcxGridDBColumn; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn1: TcxGridDBColumn; v1Column8: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; v1Column7: TcxGridDBColumn; v1Column9: TcxGridDBColumn; Tv1Column8: TcxGridDBColumn; Tv1Column11: TcxGridDBColumn; cxGrid2Level1: TcxGridLevel; cxGrid3: TcxGrid; TV3: TcxGridDBTableView; cxGridDBColumn8: TcxGridDBColumn; cxGridDBColumn9: TcxGridDBColumn; cxGridDBColumn10: TcxGridDBColumn; cxGridDBColumn11: TcxGridDBColumn; cxGridDBColumn12: TcxGridDBColumn; cxGridDBColumn13: TcxGridDBColumn; cxGridDBColumn14: TcxGridDBColumn; cxGridDBColumn15: TcxGridDBColumn; cxGridDBColumn16: TcxGridDBColumn; cxGridDBColumn17: TcxGridDBColumn; cxGridDBColumn18: TcxGridDBColumn; cxGridDBColumn19: TcxGridDBColumn; cxGridDBColumn20: TcxGridDBColumn; cxGridDBColumn21: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; Panel6: TPanel; Label20: TLabel; PCID: TEdit; GPM_3: TcxGridPopupMenu; CDS_3: TClientDataSet; DS_3: TDataSource; Panel1: TPanel; Label1: TLabel; Label7: TLabel; Label15: TLabel; Label16: TLabel; Label17: TLabel; Label4: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; PCTime: TDateTimePicker; carnum: TcxCurrencyEdit; PCPiece: TcxCurrencyEdit; PCType: TComboBox; PCQty: TEdit; edt_Width: TEdit; edt_GramWeight: TEdit; edt_Color: TEdit; edt_ColorNo: TEdit; Button2: TButton; PCUnit: TComboBox; TV3Column1: TcxGridDBColumn; TV3Column2: TcxGridDBColumn; Button1: TButton; TV1Column12: TcxGridDBColumn; TV1Column13: TcxGridDBColumn; TV1Column14: TcxGridDBColumn; TV1Column15: TcxGridDBColumn; TV1Column16: TcxGridDBColumn; TV1Column17: TcxGridDBColumn; TV3Column3: TcxGridDBColumn; TV3Column4: TcxGridDBColumn; TV3Column5: TcxGridDBColumn; TV3Column6: TcxGridDBColumn; TV3Column7: TcxGridDBColumn; TV3Column8: TcxGridDBColumn; Label13: TLabel; Label14: TLabel; Label18: TLabel; Label19: TLabel; Re_Width: TEdit; Re_GramWeight: TEdit; Re_Color: TEdit; Re_ColorNo: TEdit; Label21: TLabel; REUnit: TComboBox; Label22: TLabel; RePCType: TComboBox; TV1Column18: TcxGridDBColumn; TV1Column19: TcxGridDBColumn; Label23: TLabel; processRequirements: TEdit; TV1Column20: TcxGridDBColumn; TV1Column21: TcxGridDBColumn; TV1Column22: TcxGridDBColumn; TV1Column23: TcxGridDBColumn; Label24: TLabel; OrderNo: TEdit; TV1Column24: TcxGridDBColumn; TV2Column1: TcxGridDBColumn; Label25: TLabel; SPR1: TEdit; Label26: TLabel; SPR2: TEdit; TV1Column25: TcxGridDBColumn; TV1Column26: TcxGridDBColumn; ToolButton6: TToolButton; ToolButton7: TToolButton; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure FromCoNoChange(Sender: TObject); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure MenuItem1Click(Sender: TObject); procedure MenuItem2Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure TV2DblClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure PCIDKeyPress(Sender: TObject; var Key: Char); procedure Button1Click(Sender: TObject); procedure TV3DblClick(Sender: TObject); procedure TextEdit(Sender: TObject); procedure ToolButton7Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); private FRollNum: integer; FGC_BatchNo, FGC_Piece, FGC_STKID, FGC_Position: string; FFromCoNo, FFromCoName, FSaleser, FC_Name, FNote: string; procedure InitCard(); procedure InitGreyClothStk(); function GetGreyClothStk(): Boolean; function GetCard(): Boolean; procedure InitRepairCard(PPCID: string); { Private declarations } public FWorkshop, FPCIDS: string; { Public declarations } end; var frmDyeCardInput: TfrmDyeCardInput; implementation uses U_DataLink, U_ZDYHelp, U_RTFun, U_DyePlanForCardSel, U_DyeProcessSel, U_DyeTechnicsSel, U_DyePlanCardSel, U_DyeGreyClothStkSel, U_DyeCardGlideEdit, U_DyeCardOrdSel; {$R *.dfm} function TfrmDyeCardInput.GetCard(): Boolean; var MCustNo, MC_Name: string; begin try CDS_3.DisableControls; if CDS_3.IsEmpty then raise Exception.Create('请选择流程卡!'); CDS_3.First; while not CDS_3.eof do begin if Trim(MCustNo) = '' then begin MCustNo := trim(CDS_3.FieldByName('CustNo').AsString); MC_Name := trim(CDS_3.FieldByName('C_Name').AsString); end else begin if MCustNo <> trim(CDS_3.FieldByName('CustNo').AsString) then raise Exception.Create('不能选择多个客户!'); if MC_Name <> trim(CDS_3.FieldByName('C_Name').AsString) then raise Exception.Create('不能选择多个产品!'); end; if CDS_3.FieldByName('MvPiece').AsFloat > CDS_3.FieldByName('PSC_StkPiece').AsFloat then raise Exception.Create('调用匹数超限!'); if CDS_3.FieldByName('MvQty').AsFloat > CDS_3.FieldByName('PSC_StkQty').AsFloat then raise Exception.Create('调用数量超限!'); CDS_3.Next; end; CDS_3.EnableControls; Result := True; except Result := false; CDS_3.EnableControls; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmDyeCardInput.InitRepairCard(PPCID: string); begin with ADOQueryTmp do begin close; sql.Clear; sql.Add('select A.*'); sql.Add(',GlideList=[dbo].[F_Dye_Card_GlideList](A.PCID) '); sql.Add(',MvPiece=PSC_StkPiece,MvQty=PSC_StkQty '); sql.Add('from Dye_Plan_Card A '); if TRIM(PPCID) = '' then sql.Add('where 1=2 ') else sql.Add('where PCID= ' + Quotedstr(trim(PPCID))); open; end; if TRIM(PPCID) = '' then begin SCreateCDS(ADOQueryTmp, CDS_3); end else begin SInitCDSData(ADOQueryTmp, CDS_3); end; end; procedure TfrmDyeCardInput.InitGreyClothStk(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered := False; Close; sql.Clear; sql.Add(' select A.* '); sql.Add(' from BS_Cloth_IO A where isnull(STKName,'''')=''染色坯布'' '); SQL.Add(' and A.IOFlag=''入库'' and (isnull(STKQty,0)>0 or isnull(STKpiece,0)>0) '); Open; end; SDofilter(ADOQueryMain, SGetFilters(Panel2, 1, 2)); SCreateCDS(ADOQueryMain, CDS_2); SInitCDSData(ADOQueryMain, CDS_2); finally ADOQueryMain.EnableControls; end; end; procedure TfrmDyeCardInput.MenuItem1Click(Sender: TObject); begin SelOKNo(CDS_1, True); end; procedure TfrmDyeCardInput.MenuItem2Click(Sender: TObject); begin SelOKNo(CDS_1, False); end; procedure TfrmDyeCardInput.N1Click(Sender: TObject); begin SelOKNo(CDS_2, True); end; procedure TfrmDyeCardInput.N2Click(Sender: TObject); begin SelOKNo(CDS_2, False); end; procedure TfrmDyeCardInput.PCIDKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin if Trim(PCID.Text) = '' then exit; InitRepairCard(PCID.Text); PCID.Text := ''; end; end; procedure TfrmDyeCardInput.InitCard(); begin with Ado_car do begin close; sql.Clear; sql.Add('select A.*'); sql.Add(',GlideList=[dbo].[F_Dye_Card_GlideList](A.PCID) '); sql.Add('from Dye_Plan_Card A '); sql.Add('where EXISTS(select X.RTValue from [dbo].[F_Tool_SplitString](' + Quotedstr(trim(FPCIDS)) + ', '';'' ) X where X.RTValue=A.PCID ) '); open; end; SCreateCDS(Ado_car, CDS_1); SInitCDSData(Ado_car, CDS_1); end; function TfrmDyeCardInput.GetGreyClothStk(): Boolean; begin FNote := ''; FC_Name := ''; FFromCoNo := ''; FGC_BatchNo := ''; FGC_Piece := ''; FGC_STKID := ''; FGC_Position := ''; FRollNum := 0; try CDS_2.DisableControls; CDS_2.First; while not CDS_2.eof do begin if CDS_2.FieldByName('ssel').AsBoolean then begin FGC_BatchNo := FGC_BatchNo + trim(CDS_2.FieldByName('BatchNo').AsString) + '+'; FRollNum := FRollNum + CDS_2.FieldByName('STKPIECE').AsInteger; FGC_Piece := FGC_Piece + trim(CDS_2.FieldByName('STKPIECE').AsString) + ','; FGC_STKID := FGC_STKID + trim(CDS_2.FieldByName('STKID').AsString) + ';'; FGC_Position := FGC_Position + trim(CDS_2.FieldByName('StkPosition').AsString) + ';'; if Trim(FFromCoNo) = '' then begin FFromCoNo := trim(CDS_2.FieldByName('FromCoNo').AsString); FFromCoName := trim(CDS_2.FieldByName('FromCoName').AsString); FSaleser := trim(CDS_2.FieldByName('Saleser').AsString); FC_Name := trim(CDS_2.FieldByName('C_Name').AsString); FNote := trim(CDS_2.FieldByName('Note').AsString); end else begin if FFromCoNo <> trim(CDS_2.FieldByName('FromCoNo').AsString) then raise Exception.Create('不能选择多个客户!'); if FC_Name <> trim(CDS_2.FieldByName('C_Name').AsString) then raise Exception.Create('不能选择多个产品!'); end; end; CDS_2.Next; end; CDS_2.EnableControls; if length(FGC_STKID) > 0 then begin FGC_BatchNo := copy(FGC_BatchNo, 1, Length(FGC_BatchNo) - 1); FGC_Piece := copy(FGC_Piece, 1, Length(FGC_Piece) - 1); FGC_STKID := copy(FGC_STKID, 1, Length(FGC_STKID) - 1); FGC_Position := copy(FGC_Position, 1, Length(FGC_Position) - 1); FNote := copy(FNote, 1, Length(FNote) - 1); end else raise Exception.Create('请选择坯布!'); Result := True; except Result := false; CDS_2.EnableControls; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmDyeCardInput.FormDestroy(Sender: TObject); begin inherited; frmDyeCardInput := nil; end; procedure TfrmDyeCardInput.Button1Click(Sender: TObject); var maxId: string; begin PCID.SetFocus; if not GetCard() then Exit; if GetLSNo(ADOQueryCmd, maxId, 'CZ', 'Dye_Plan_Card', 3, 1) = False then begin Application.MessageBox('取最大号失败!', '提示', 0); Exit; end; FPCIDS := FPCIDS + maxId + ';'; try ADOQueryCmd.Connection.BeginTrans; CDS_3.DisableConstraints; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('select * from Dye_Plan_Card A where 1=2'); Open; Append; FieldByName('Filler').Value := trim(DName); FieldByName('Workshop').Value := trim(FWorkshop); FieldByName('PCType').Value := trim(RePCType.Text); FieldByName('PCID').Value := trim(maxId); FieldByName('PCTime').Value := formatdateTime('yyyy-MM-dd', now()); FieldByName('GC_BatchNo').Value := ''; FieldByName('GC_Piece').Value := ''; FieldByName('GC_STKID').Value := ''; FieldByName('GC_Position').Value := ''; FieldByName('C_Name').Value := trim(CDS_3.FieldByName('C_Name').AsString); FieldByName('CustNo').Value := trim(CDS_3.FieldByName('CustNo').AsString); FieldByName('CustName').Value := trim(CDS_3.FieldByName('CustName').AsString); FieldByName('MainId').Value := trim(CDS_3.FieldByName('MainId').AsString); FieldByName('SubId').Value := trim(CDS_3.FieldByName('SubId').AsString); FieldByName('C_GramWeight').Value := trim(Re_GramWeight.Text); FieldByName('C_Width').Value := trim(Re_Width.Text); FieldByName('C_Color').Value := trim(Re_Color.Text); FieldByName('PCUnit').Value := trim(ReUnit.Text); FieldByName('C_ColorNo').Value := trim(Re_ColorNo.Text); FieldByName('PCPiece').Value := 0; FieldByName('PCQty').Value := 0; post; end; with CDS_3 do begin first; while not Eof do begin with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('select * from Dye_Plan_Card_Move A where 1=2'); Open; Append; FieldByName('Filler').Value := trim(DName); FieldByName('FromID').Value := trim(CDS_3.FieldByName('PCID').AsString); FieldByName('ToID').Value := maxId; FieldByName('MvPiece').Value := CDS_3.FieldByName('MvPiece').AsFloat; FieldByName('MvQty').Value := CDS_3.FieldByName('MvQty').AsFloat; post; end; Next; end; end; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Card_Move '); Sql.Add('@PCID=' + quotedstr(trim(maxId))); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then begin raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); end; ADOQueryCmd.Connection.CommitTrans; CDS_3.EnableConstraints; except ADOQueryCmd.Connection.RollbackTrans; CDS_3.EnableConstraints; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; InitCard(); InitRepairCard(''); end; procedure TfrmDyeCardInput.Button2Click(Sender: TObject); var i, k, fhxInt: integer; maxId, ForderNo: string; begin if not GetGreyClothStk() then Exit; if trim(OrderNo.Text) = '' then begin if GetLSNo(ADOQueryCmd, ForderNo, 'JH', 'Dye_Plan_Main', 3, 1) = False then begin application.MessageBox('取计划单号失败!', '提示信息', MB_ICONERROR); exit; end; OrderNo.Text := ForderNo; end; if trim(edt_Width.Text) = '' then begin application.MessageBox('门幅不能为空!', '提示信息', MB_ICONERROR); exit; end; if trim(edt_GramWeight.Text) = '' then begin application.MessageBox('克重不能为空!', '提示信息', MB_ICONERROR); exit; end; if (StrToFloatDef(PCPiece.Text, 0) + StrToFloatDef(PCQty.Text, 0)) = 0 then begin application.MessageBox('开卡匹数、数量不能都为零!', '提示信息', MB_ICONERROR); exit; end; if strtointdef(trim(carNum.text), 0) <= 1 then k := 1 else k := strtointdef(trim(carNum.text), 0); CDS_1.Last; for i := 1 to k do begin if GetLSNo(ADOQueryCmd, maxId, 'SM', 'Dye_Plan_Card', 3, 1) = False then begin Application.MessageBox('取最大号失败!', '提示', 0); Exit; end; FPCIDS := FPCIDS + maxId + ';'; try ADOQueryCmd.Connection.BeginTrans; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('select * from Dye_Plan_Card A where 1=2'); Open; Append; FieldByName('Filler').Value := trim(DName); FieldByName('OrderNo').Value := trim(OrderNo.Text); FieldByName('Workshop').Value := trim(FWorkshop); FieldByName('PCType').Value := trim(PCType.Text); FieldByName('PCID').Value := trim(maxId); FieldByName('PCTime').Value := formatdateTime('yyyy-MM-dd', PCTime.DateTime); FieldByName('GC_BatchNo').Value := trim(FGC_BatchNo); FieldByName('GC_Piece').Value := trim(FGC_Piece); FieldByName('GC_STKID').Value := trim(FGC_STKID); FieldByName('GC_Position').Value := trim(FGC_Position); FieldByName('CustNo').Value := trim(FFromCoNo); FieldByName('CustName').Value := trim(FFromCoName); FieldByName('Saleser').Value := trim(FSaleser); FieldByName('C_Name').Value := trim(FC_Name); FieldByName('PCNote').Value := trim(FNote); FieldByName('processRequirements').Value := trim(processRequirements.Text); FieldByName('C_GramWeight').Value := trim(edt_GramWeight.Text); FieldByName('C_Width').Value := trim(edt_Width.Text); FieldByName('C_Color').Value := trim(edt_Color.Text); FieldByName('PCUnit').Value := trim(PCUnit.Text); FieldByName('C_ColorNo').Value := trim(edt_ColorNo.Text); FieldByName('SPR1').Value := trim(SPR1.Text); FieldByName('SPR2').Value := trim(SPR2.Text); FieldByName('PCPiece').Value := StrtoIntDef(PCPiece.Text, 0); FieldByName('PCQty').Value := StrtoFloatDef(PCQty.Text, 0); post; end; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_GreyCloth_Out '); Sql.Add('@PCID=' + quotedstr(trim(maxId))); Sql.Add(',@Filler=' + quotedstr(trim(DName))); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then begin raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); end; ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; InitCard(); InitGreyClothStk(); end; procedure TfrmDyeCardInput.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := cahide; end; procedure TfrmDyeCardInput.FormCreate(Sender: TObject); begin inherited; PCTime.Date := DServerDate; end; procedure TfrmDyeCardInput.FormShow(Sender: TObject); begin inherited; ReadCxGrid(self.Caption + 'TV1', Tv1, '生产指示单管理'); ReadCxGrid(self.Caption + 'TV2', Tv2, '生产指示单管理'); InitCard(); InitGreyClothStk(); InitRepairCard(''); end; procedure TfrmDyeCardInput.FromCoNoChange(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel2, 1, 2)); SCreateCDS(ADOQueryMain, CDS_2); SInitCDSData(ADOQueryMain, CDS_2); end; end; procedure TfrmDyeCardInput.ToolButton1Click(Sender: TObject); var MPCIDS: string; begin if CDS_1.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; with CDS_1 do begin DisableControls; First; while not Eof do begin if Fieldbyname('Ssel').AsBoolean then begin MPCIDS := MPCIDS + trim(CDS_1.FieldByName('PCID').AsString) + ';'; end; Next; end; EnableControls; end; with ADOQueryTmp do begin close; sql.Clear; sql.Add('select distinct GX=[dbo].[F_Dye_Card_GlideList](A.RTValue) from [dbo].[F_Tool_SplitString](' + quotedstr(MPCIDS) + ','';'') A '); open; end; if ADOQueryTmp.RecordCount > 1 then begin Application.MessageBox('请选择相同工序的卡编辑!', '提示', 0); Exit; end; try frmDyeCardGlideEdit := TfrmDyeCardGlideEdit.Create(Application); with frmDyeCardGlideEdit do begin FPCIDS := MPCIDS; FWorkshop := self.FWorkshop; if ShowModal = 1 then begin InitCard(); end; end; finally frmDyeCardGlideEdit.Free; end; end; procedure TfrmDyeCardInput.ToolButton2Click(Sender: TObject); begin WriteCxGrid(self.Caption + 'TV1', Tv1, '生产指示单管理'); WriteCxGrid(self.Caption + 'TV2', Tv2, '生产指示单管理'); end; procedure TfrmDyeCardInput.ToolButton3Click(Sender: TObject); begin close; end; procedure TfrmDyeCardInput.ToolButton4Click(Sender: TObject); begin if CDS_1.IsEmpty then exit; 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_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))); 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; Next; EnableControls; end; InitCard(); InitGreyClothStk(); end; except CDS_1.EnableControls; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmDyeCardInput.ToolButton5Click(Sender: TObject); begin carnum.SetFocus; try CDS_1.DisableControls; CDS_1.First; while not CDS_1.Eof do begin if CDS_1.Fieldbyname('Ssel').AsBoolean then begin ADOQueryCmd.Connection.BeginTrans; try with ADOQueryCmd do begin close; sql.Clear; sql.Add('select * from Dye_Plan_Card A'); sql.Add('where PCID=''' + trim(CDS_1.fieldbyname('PCID').AsString) + ''''); open; edit; FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTmp); RTSetSaveDataCDS(ADOQueryCmd, Tv1, CDS_1, 'Dye_Plan_Card', 0); post; 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))); with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_GreyCloth_Out '); Sql.Add('@PCID=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString))); Sql.Add(',@Filler=' + quotedstr(trim(DName))); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then begin raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); end; end else begin with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Card_Move '); Sql.Add('@PCID=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString))); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then begin raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); end; end; ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; raise Exception.Create(PChar(Exception(ExceptObject).Message)); end; end; CDS_1.Next; end; CDS_1.EnableControls; InitCard(); InitGreyClothStk(); except CDS_1.EnableControls; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmDyeCardInput.ToolButton6Click(Sender: TObject); begin inherited; try frmDyeCardOrdSel := TfrmDyeCardOrdSel.Create(Application); with frmDyeCardOrdSel do begin if ShowModal = 1 then begin Self.OrderNo.Text := frmDyeCardOrdSel.CDS_1.FieldByName('OrderNo').AsString; end; end; finally frmDyeCardOrdSel.Free; end; end; procedure TfrmDyeCardInput.ToolButton7Click(Sender: TObject); begin OrderNo.Text := ''; end; procedure TfrmDyeCardInput.TV2DblClick(Sender: TObject); begin edt_Width.Text := trim(CDS_2.FieldByName('C_Width').AsString); edt_GramWeight.Text := trim(CDS_2.FieldByName('C_GramWeight').AsString); end; procedure TfrmDyeCardInput.TextEdit(Sender: TObject); var mvalue: string; begin mvalue := TcxTextEdit(Sender).EditingText; with CDS_3 do begin Edit; FieldByName('MvPiece').Value := STRTOFLOATDEF(mvalue, 0); if FieldByName('PSC_StkPiece').AsFloat > 0 then FieldByName('MvQty').Value := STRTOFLOATDEF(mvalue, 0) * (FieldByName('PSC_StkQty').AsFloat / FieldByName('PSC_StkPiece').AsFloat) else FieldByName('MvQty').Value := 0; Post; end; Tv3.Controller.EditingController.ShowEdit(); end; procedure TfrmDyeCardInput.TV3DblClick(Sender: TObject); begin CDS_3.Delete; end; end.