unit U_DyePlanCardInput; 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, dxScrollbarAnnotations; type TfrmDyePlanCardInput = 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; 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; 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; ADO_Order: TADOQuery; CDS_Color: TClientDataSet; pnlkpkk: TPanel; Label1: TLabel; Label7: TLabel; Label15: TLabel; Label16: TLabel; Label17: TLabel; PCTime: TDateTimePicker; carnum: TcxCurrencyEdit; PCPiece: TcxCurrencyEdit; PCType: TComboBox; PCQty: TEdit; Button2: TButton; pnlOrder: TPanel; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; cxGridDBColumn5: TcxGridDBColumn; v2Column6: TcxGridDBColumn; cxGridDBColumn6: TcxGridDBColumn; Tv1OrderNo: TcxGridDBColumn; v2Column1: TcxGridDBColumn; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn1: TcxGridDBColumn; v1Column8: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; cxGrid2Level1: TcxGridLevel; Label23: TLabel; OrderNo: TBtnEditA; Label4: TLabel; Label9: TLabel; Label11: TLabel; Label10: TLabel; C_Width: TEdit; C_GramWeight: TEdit; C_COLORNO: TEdit; Label24: TLabel; OrdQty: TEdit; OrdUnit: TEdit; TV3Column9: TcxGridDBColumn; TV1Column20: TcxGridDBColumn; TV1Column21: TcxGridDBColumn; Label2: TLabel; OrdPiece: TEdit; Label3: TLabel; DTMPSlist: TBtnEditA; Label5: TLabel; C_Name: TEdit; ADO_PB: TADOQuery; TV2Column1: TcxGridDBColumn; Label6: TLabel; DTMID: TEdit; avgCard: TButton; Label8: TLabel; CINote: TEdit; TV1KaZu: TcxGridDBColumn; TV2C_description: TcxGridDBColumn; C_description: TEdit; Label12: TLabel; TV1C_description: TcxGridDBColumn; TV1CINote: TcxGridDBColumn; C_COLOR: TEdit; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); procedure ToolButton4Click(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 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 OrderNoBtnClick(Sender: TObject); procedure C_COLORChange(Sender: TObject); procedure TV3Column1PropertiesEditValueChanged(Sender: TObject); procedure DTMPSlistBtnClick(Sender: TObject); procedure TV2DblClick(Sender: TObject); procedure OrderNoKeyPress(Sender: TObject; var Key: Char); procedure avgCardClick(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private FC_Code: string; FRollNum: integer; FGC_BatchNo, FGC_Piece, FGC_STKID, FGC_Position: string; FFromCoNo, FFromCoName, FSaleser, FC_Name, fbzunit: string; procedure InitCard(); procedure InitOrder(); procedure InitGreyClothStk(); function GetCard(): Boolean; procedure InitRepairCard(PPCID: string); { Private declarations } procedure ShowDistributionResult(cardCount: Integer; pieceArray, qtyArray: array of Double); procedure CalculateDistribution(totalValue: Double; cardCount: Integer; var resultArray: array of Double); public FWorkshop, FPCIDS, FMainID: string; { Public declarations } end; var frmDyePlanCardInput: TfrmDyePlanCardInput; implementation uses U_DataLink, U_ZDYHelp, U_RTFun, U_DyePlanForCardSel, U_DyeProcessSel, U_DyeTechnicsSel, U_DyePlanCardSel, U_DyeGreyClothStkSel, U_DyeCardGlideEdit, U_CraftSel; {$R *.dfm} function TfrmDyePlanCardInput.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 TfrmDyePlanCardInput.InitOrder(); var fsj: string; begin with Ado_Order do begin close; sql.Clear; sql.Add('select A.*'); sql.Add('from Dye_Plan_Main A '); // sql.Add('inner join Dye_Plan_Sub B on A.MainID=B.mainID '); sql.Add('where A.MainID=''' + trim(FMainID) + ''' '); // ShowMessage(sql.Text); open; end; SCreateCDS(Ado_Order, CDS_Color); SInitCDSData(Ado_Order, CDS_Color); if not Ado_Order.IsEmpty then begin // fsj := 'select distinct(C_Color) name from Dye_Plan_sub where mainid= ' + QuotedStr(Trim(FMainID)); // SInitComBoxBySql(ADOQueryTmp, C_COLOR, False, fsj); // SCSHData(Ado_Order, pnlOrder, 2); OrderNo.Text := Trim(Ado_Order.FieldByName('OrderNo').AsString); FC_Name := Trim(Ado_Order.FieldByName('C_Name').AsString); FFromCoNo := Trim(Ado_Order.FieldByName('CustNo').AsString); FFromCoName := Trim(Ado_Order.FieldByName('CustName').AsString); FGC_BatchNo := Trim(Ado_Order.FieldByName('GC_BatchNo').AsString); FGC_Piece := Trim(Ado_Order.FieldByName('GC_Piece').AsString); FGC_STKID := Trim(Ado_Order.FieldByName('GC_STKID').AsString); FGC_Position := Trim(Ado_Order.FieldByName('GC_Position').AsString); // fbzunit := Trim(Ado_Order.FieldByName('bzunit').AsString); // FRollNum :=Trim(Ado_Order.FieldByName('').AsString); end; end; procedure TfrmDyePlanCardInput.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 TfrmDyePlanCardInput.InitGreyClothStk(); begin try ADO_PB.DisableControls; with ADO_PB do begin Filtered := False; Close; sql.Clear; sql.Add(' select A.OrderNo, A.C_Name, A.F_Name, A.QtyUnit, A.Material,SUM(A.StkQty) as StkQty, SUM(A.StkPiece) as StkPiece '); sql.Add(' ,IOTime = min(A.IOTime) ,IOType = min(A.ioType) ,C_Width = min(A.C_Width) ,F_Width = min(A.F_Width),C_description = min(B.C_description)'); sql.Add(' from BS_Cloth_IO A left join Dye_Plan_Main B on A.OrderNo= B.OrderNo '); SQL.Add(' where isnull(A.STKName,'''')=''染色坯布'' and A.IOFlag=''入库'' '); // SQL.Add(' and EXISTS(select * from [dbo].[F_Tool_SplitString](' + quotedstr(FGC_STKID) + ','','' ) X where X.RTValue=A.StkId AND ISNULL(RTValue,'''')<>'''') '); SQL.Add(' and A.OrderNo= ' + QuotedStr(trim(OrderNo.Text))); SQL.Add(' group by A.OrderNo, A.C_Name, A.F_Name, A.QtyUnit, A.Material '); // ShowMessage(sql.Text); Open; end; SCreateCDS(ADO_PB, CDS_2); SInitCDSData(ADO_PB, CDS_2); with ADO_PB 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=''入库'' '); // SQL.Add(' and EXISTS(select * from [dbo].[F_Tool_SplitString](' + quotedstr(FGC_STKID) + ','','' ) X where X.RTValue=A.StkId AND ISNULL(RTValue,'''')<>'''') '); SQL.Add(' and A.OrderNo= ' + QuotedStr(trim(OrderNo.Text))); // ShowMessage(sql.Text); Open; end; ADO_PB.First; while not ADO_PB.Eof do begin if (FGC_STKID <> '') and (FGC_STKID <> null) then begin FGC_STKID := ADO_PB.FieldByName('StkID').AsString + ',' + FGC_STKID; end else begin FGC_STKID := ADO_PB.FieldByName('StkID').AsString; end; ADO_PB.Next; end; finally ADO_PB.EnableControls; end; end; procedure TfrmDyePlanCardInput.MenuItem1Click(Sender: TObject); begin SelOKNo(CDS_1, True); end; procedure TfrmDyePlanCardInput.MenuItem2Click(Sender: TObject); begin SelOKNo(CDS_1, False); end; procedure TfrmDyePlanCardInput.N1Click(Sender: TObject); begin SelOKNo(CDS_2, True); end; procedure TfrmDyePlanCardInput.N2Click(Sender: TObject); begin SelOKNo(CDS_2, False); end; procedure TfrmDyePlanCardInput.OrderNoBtnClick(Sender: TObject); begin frmProductOrderListSel := TfrmProductOrderListSel.create(self); with frmProductOrderListSel do begin FWorkshop := self.FWorkshop; if ShowModal = 1 then begin fmainID := Order_Main.fieldbyname('mainID').asstring; // fC_Code := Order_Main.fieldbyname('C_Code').asstring; // fC_name := Order_Main.fieldbyname('C_name').asstring; InitOrder(); InitGreyClothStk(); if CDS_2.IsEmpty then begin Application.MessageBox('无产品库存!', '提示信息', MB_OK); end; InitCard(); // initGlide(); end; free; end; end; procedure TfrmDyePlanCardInput.OrderNoKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin with ADOQueryTmp do begin close; sql.Clear; sql.Add('exec P_OrderCR'); // ShowMessage(sql.Text); execsql; end; fmainID := OrderNo.Text; // fC_Code := Order_Main.fieldbyname('C_Code').asstring; // fC_name := Order_Main.fieldbyname('C_name').asstring; InitOrder(); InitGreyClothStk(); if CDS_2.IsEmpty then begin Application.MessageBox('无产品库存!', '提示信息', MB_OK); end; InitCard(); // initGlide(); end; end; procedure TfrmDyePlanCardInput.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 TfrmDyePlanCardInput.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 ) '); // ShowMessage(sql.Text); open; end; SCreateCDS(Ado_car, CDS_1); SInitCDSData(Ado_car, CDS_1); end; procedure TfrmDyePlanCardInput.FormDestroy(Sender: TObject); begin inherited; frmDyePlanCardInput := nil; end; procedure TfrmDyePlanCardInput.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 TfrmDyePlanCardInput.DTMPSlistBtnClick(Sender: TObject); begin try if OrderNo.Text = '' then begin Application.MessageBox('请先选择计划单', '提示信息', MB_OK); exit; end; frmCraftSel := TfrmCraftSel.Create(Application); with frmCraftSel do begin fcode := Self.FC_Code; fC_name := Self.fC_name; if ShowModal = 1 then begin with frmCraftSel.CDS_1 do begin Self.DTMPSlist.Text := frmCraftSel.CDS_1.FieldByName('DTMPSlist').Value; Self.DTMID.Text := frmCraftSel.CDS_1.FieldByName('DTMID').Value; end; end; end; finally frmCraftSel.Free; end; end; procedure TfrmDyePlanCardInput.avgCardClick(Sender: TObject); var i, k: integer; maxId, KZmaxID: string; totalPieces, totalQty: Double; pieceArray: array of Double; qtyArray: array of Double; mQRCode : string; begin // 验证输入 if trim(C_Name.Text) = '' then begin application.MessageBox('产品名称不能为空!', '提示信息', MB_ICONERROR); exit; end; if (StrToFloatDef(PCPiece.Text, 0) + StrToFloatDef(PCQty.Text, 0)) = 0 then begin application.MessageBox('开卡匹数、数量不能都为零!', '提示信息', MB_OK); exit; end; if DTMPSlist.Text = '' then begin application.MessageBox('产品工序不能为空!', '提示信息', MB_OK); exit; end; if GetLSNo(ADOQueryCmd, KZmaxID, 'KZ', 'Dye_Plan_Card_KZ', 3, 1) = False then begin Application.MessageBox('取最大号失败!', '提示', 0); Exit; end; // 获取车数 if strtointdef(trim(carNum.text), 0) <= 1 then k := 1 else k := strtointdef(trim(carNum.text), 0); // 获取总匹数和总数量 totalPieces := StrToFloatDef(PCPiece.Text, 0); totalQty := StrToFloatDef(PCQty.Text, 0); // 预分配数组 SetLength(pieceArray, k); SetLength(qtyArray, k); // 计算每张卡的分配值 CalculateDistribution(totalPieces, k, pieceArray); CalculateDistribution(totalQty, k, qtyArray); CDS_Color.Locate('C_Color', C_Color.Text, []); CDS_1.Last; for i := 0 to k - 1 do begin if GetLSNo(ADOQueryCmd, maxId, 'CZ', 'Dye_Plan_Card', 3, 1) = False then begin Application.MessageBox('取最大号失败!', '提示', 0); Exit; end; FPCIDS := FPCIDS + maxId + ';'; mQRCode := FC_Name + '|' + OrderNo.Text + '|0|'; mQRCode := mQRCode + FormatDateTime('yyyymmddhhnnss', SGetServerDateTime(ADOQueryBaseTemp)); mQRCode := mQRCode + '|0|'; mQRCode := mQRCode + OrderNo.Text + '*0|0'; 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('OrderNo').Value := OrderNo.Text; FieldByName('Mainid').Value := FMainid; FieldByName('Filler').Value := trim(DName); FieldByName('Workshop').Value := trim(FWorkshop); FieldByName('PCType').Value := trim(PCType.Text); FieldByName('PCID').Value := trim(maxId); FieldByName('KaZu').Value := trim(KZmaxID); 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('DTMPSlist').Value := trim(DTMPSlist.Text); FieldByName('C_description').Value := trim(C_description.Text); FieldByName('bzunit').Value := trim(Fbzunit); FieldByName('CustNo').Value := trim(FFromCoNo); FieldByName('CustName').Value := trim(FFromCoName); FieldByName('Saleser').Value := trim(FSaleser); FieldByName('C_Name').Value := trim(FC_Name); FieldByName('C_Code').Value := trim(FC_Code); FieldByName('C_GramWeight').Value := trim(C_GramWeight.Text); FieldByName('C_Width').Value := trim(C_Width.Text); FieldByName('C_Color').Value := trim(C_Color.Text); FieldByName('PCUnit').Value := trim(OrdUnit.Text); FieldByName('C_ColorNo').Value := trim(C_ColorNo.Text); FieldByName('CINote').Value := trim(CINote.Text); // 使用预分配的匹数和数量 FieldByName('PCPiece').Value := pieceArray[i]; FieldByName('PCQty').Value := qtyArray[i]; FieldByName('batchno').Value := INTTOSTR(k) + '-' + INTTOSTR(i + 1); FieldByName('QRCode').Value := trim(mQRCode); FieldByName('PrtCount').Value := 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 FGC_STKID := ''; 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; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Plan_UpdateOrderNo '); Sql.Add('@OrderNo=' + quotedstr(Trim(OrderNo.Text))); Open; end; end; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Cloth_GX @carno=' + QuotedStr(trim(KZmaxID))); sql.add(',@dname=' + QuotedStr(trim(dname))); SQL.Add(',@C_Name=' + QuotedStr(Trim(C_Name.Text))); SQL.Add(',@OrderNo=' + QuotedStr(Trim(OrderNo.Text))); SQL.Add(',@DTMID=' + QuotedStr(Trim(DTMID.Text))); execsql; end; with ADOQueryCmd do begin SQL.Clear; SQL.Add('EXEC P_InsertGxToKaika @PCID = ' + quotedstr(trim(KZmaxID))); ExecSQL; end; InitCard(); InitGreyClothStk(); // 显示分配结果信息 ShowDistributionResult(k, pieceArray, qtyArray); end; // 分配计算函数 procedure TfrmDyePlanCardInput.CalculateDistribution(totalValue: Double; cardCount: Integer; var resultArray: array of Double); var i: Integer; baseValue, remainder: Double; intBaseValue, intRemainder: Integer; begin if cardCount <= 0 then Exit; // 如果是整数,按整数分配 if Frac(totalValue) = 0 then begin intBaseValue := Trunc(totalValue) div cardCount; intRemainder := Trunc(totalValue) mod cardCount; for i := 0 to cardCount - 1 do begin if i < intRemainder then resultArray[i] := intBaseValue + 1 else resultArray[i] := intBaseValue; end; end; end; // 显示分配结果 procedure TfrmDyePlanCardInput.ShowDistributionResult(cardCount: Integer; pieceArray, qtyArray: array of Double); var i: Integer; distributionInfo: string; begin distributionInfo := '成功开立' + IntToStr(cardCount) + '张卡,分配情况:' + #13#10; for i := 0 to cardCount - 1 do begin distributionInfo := distributionInfo + Format('卡%d: %.0f匹, %.2f米' + #13#10, [i + 1, pieceArray[i], qtyArray[i]]); end; ShowMessage(distributionInfo); end; procedure TfrmDyePlanCardInput.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 TfrmDyePlanCardInput.Button2Click(Sender: TObject); var i, k, fhxInt: integer; maxId, maxno, KZmaxID: string; mQRCode : string; begin if trim(C_Name.Text) = '' then begin application.MessageBox('产品名称不能为空!', '提示信息', MB_ICONERROR); exit; end; if (StrToFloatDef(PCPiece.Text, 0) + StrToFloatDef(PCQty.Text, 0)) = 0 then begin application.MessageBox('开卡匹数、数量不能都为零!', '提示信息', MB_OK); exit; end; if DTMPSlist.Text = '' then begin application.MessageBox('产品工序不能为空!', '提示信息', MB_OK); exit; end; if GetLSNo(ADOQueryCmd, KZmaxID, 'KZ', 'Dye_Plan_Card_KZ', 3, 1) = False then begin Application.MessageBox('取最大号失败!', '提示', 0); Exit; end; if strtointdef(trim(carNum.text), 0) <= 1 then k := 1 else k := strtointdef(trim(carNum.text), 0); CDS_Color.Locate('C_Color', C_Color.Text, []); CDS_1.Last; for i := 1 to k do begin if GetLSNo(ADOQueryCmd, maxId, 'CZ', 'Dye_Plan_Card', 3, 1) = False then begin Application.MessageBox('取最大号失败!', '提示', 0); Exit; end; FPCIDS := FPCIDS + maxId + ';'; // if not GetLSNo(ADOQueryCmd, maxno, 'PC', 'BS_Cloth_IO', 3, 1) then // raise Exception.Create('取染色坯布出库编号失败!'); mQRCode := FC_Name + '|' + OrderNo.Text + '|0|'; mQRCode := mQRCode + FormatDateTime('yyyymmddhhnnss', SGetServerDateTime(ADOQueryBaseTemp)); mQRCode := mQRCode + '|0|'; mQRCode := mQRCode + OrderNo.Text + '*0|0'; 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('OrderNo').Value := OrderNo.Text; // FieldByName('SubId').Value := CDS_Color.FieldByName('SubId').Value; FieldByName('Mainid').Value := FMainid; // FieldByName('BCIOID').Value := maxno; FieldByName('Filler').Value := trim(DName); FieldByName('Workshop').Value := trim(FWorkshop); FieldByName('PCType').Value := trim(PCType.Text); FieldByName('PCID').Value := trim(maxId); FieldByName('KaZu').Value := trim(KZmaxID); 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('DTMPSlist').Value := trim(DTMPSlist.Text); FieldByName('C_description').Value := trim(C_description.Text); FieldByName('bzunit').Value := trim(Fbzunit); FieldByName('CINote').Value := trim(CINote.Text); // FieldByName('STATUS').Value := '9'; FieldByName('CustNo').Value := trim(FFromCoNo); FieldByName('CustName').Value := trim(FFromCoName); FieldByName('Saleser').Value := trim(FSaleser); FieldByName('C_Name').Value := trim(FC_Name); FieldByName('C_Code').Value := trim(FC_Code); FieldByName('C_GramWeight').Value := trim(C_GramWeight.Text); FieldByName('C_Width').Value := trim(C_Width.Text); FieldByName('C_Color').Value := trim(C_Color.Text); FieldByName('PCUnit').Value := trim(OrdUnit.Text); FieldByName('C_ColorNo').Value := trim(C_ColorNo.Text); FieldByName('PCPiece').Value := StrtoIntDef(PCPiece.Text, 0); FieldByName('PCQty').Value := StrtoFloatDef(PCQty.Text, 0); // ShowMessage(FieldByName('PCQty').Value); FieldByName('batchno').Value := INTTOSTR(k) + '-' + INTTOSTR(i); FieldByName('QRCode').Value := trim(mQRCode); FieldByName('PrtCount').Value := 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 FGC_STKID := ''; 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; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Plan_UpdateOrderNo '); Sql.Add('@OrderNo=' + quotedstr(Trim(OrderNo.Text))); Open; end; end; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Cloth_GX @carno=' + QuotedStr(trim(KZmaxID))); sql.add(',@dname=' + QuotedStr(trim(dname))); SQL.Add(',@C_Name=' + QuotedStr(Trim(C_Name.Text))); SQL.Add(',@OrderNo=' + QuotedStr(Trim(OrderNo.Text))); SQL.Add(',@DTMID=' + QuotedStr(Trim(DTMID.Text))); execsql; end; with ADOQueryCmd do begin SQL.Clear; SQL.Add('EXEC P_InsertGxToKaika @PCID = ' + quotedstr(trim(KZmaxID))); ExecSQL; end; InitCard(); InitGreyClothStk(); end; procedure TfrmDyePlanCardInput.C_COLORChange(Sender: TObject); begin CDS_Color.Locate('C_Color', C_Color.Text, []); C_COLOR.Text := CDS_Color.FieldByName('C_COLOR').AsString; OrdQty.Text := CDS_Color.FieldByName('C_PlanQty').AsString; OrdUnit.Text := CDS_Color.FieldByName('C_Unit').AsString; C_COLORNO.Text := CDS_Color.FieldByName('C_COLORNO').AsString; end; procedure TfrmDyePlanCardInput.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := cahide; end; procedure TfrmDyePlanCardInput.FormCreate(Sender: TObject); begin inherited; PCTime.Date := DServerDate; end; procedure TfrmDyePlanCardInput.FormShow(Sender: TObject); begin inherited; ReadCxGrid(self.Caption + 'TV1', Tv1, '生产指示单管理'); ReadCxGrid(self.Caption + 'TV2', Tv2, '生产指示单管理'); ReadCxGrid(self.Caption + 'TV3', Tv3, '生产指示单管理'); InitOrder(); InitCard(); InitGreyClothStk(); InitRepairCard(''); KeyPreview := True; end; procedure TfrmDyePlanCardInput.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; fname := SELF.CDS_1.FieldByName('c_name').AsString; FWorkshop := self.FWorkshop; if ShowModal = 1 then begin InitCard(); end; end; finally frmDyeCardGlideEdit.Free; end; end; procedure TfrmDyePlanCardInput.ToolButton2Click(Sender: TObject); begin WriteCxGrid(self.Caption + 'TV1', Tv1, '生产指示单管理'); WriteCxGrid(self.Caption + 'TV2', Tv2, '生产指示单管理'); WriteCxGrid(self.Caption + 'TV3', Tv3, '生产指示单管理'); end; procedure TfrmDyePlanCardInput.ToolButton3Click(Sender: TObject); begin close; end; procedure TfrmDyePlanCardInput.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_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(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 ADOQueryTmp do begin Close; SQL.Clear; SQL.Add('select * from Dye_Plan_card where KaZu = ' + QuotedStr(Trim(CDS_1.FieldByName('KaZu').AsString))); Open; end; if ADOQueryTmp.IsEmpty then begin with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('delete from Dye_Plan_glide where PCID = ' + quotedstr(Trim(CDS_1.fieldbyname('KaZu').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('KaZu').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('KaZu').AsString))); ExecSQL; end; 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; Next; EnableControls; end; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Dye_Plan_UpdateOrderNo '); Sql.Add('@OrderNo=' + quotedstr(Trim(OrderNo.Text))); Open; end; InitCard(); InitGreyClothStk(); end; except CDS_1.EnableControls; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmDyePlanCardInput.ToolButton5Click(Sender: TObject); var HasSaved: Boolean; // 记录是否成功保存 begin HasSaved := False; // 初始化标志 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; HasSaved := True; // 标记有保存操作 except ADOQueryCmd.Connection.RollbackTrans; raise Exception.Create(PChar(Exception(ExceptObject).Message)); end; // end; CDS_1.Next; end; CDS_1.EnableControls; // 显示保存成功提示 if HasSaved then begin Application.MessageBox('保存成功!', '提示信息', MB_OK + MB_ICONINFORMATION); end; InitCard(); InitGreyClothStk(); except CDS_1.EnableControls; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', MB_OK + MB_ICONERROR); end; end; //procedure TfrmDyePlanCardInput.ToolButton5Click(Sender: TObject); //begin // // 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 TfrmDyePlanCardInput.TV2DblClick(Sender: TObject); begin inherited; with ADOQueryTmp do begin Close; sql.Clear; SQL.Add(' select * from BS_Cloth_info where C_Name = ' + QuotedStr(Trim(CDS_2.FieldByName('C_Name').Value))); Open; end; C_Width.Text := ADOQueryTmp.FieldByName('C_Width').AsString; C_GramWeight.Text := ADOQueryTmp.FieldByName('C_GramWeight').AsString; C_Color.Text := ADOQueryTmp.FieldByName('C_Color').AsString; C_COLORNO.Text := ADOQueryTmp.FieldByName('C_COLORNO').AsString; C_Name.Text := ADOQueryTmp.FieldByName('C_Name').AsString; CINote.Text := ADOQueryTmp.FieldByName('CINote').AsString; PCType.Text := '正常卡'; carnum.Text := '1'; PCPiece.Text := CDS_2.FieldByName('StkPiece').AsString; PCQty.Text := CDS_2.FieldByName('STKQty').AsString; C_description.Text := CDS_2.FieldByName('C_description').AsString; if (ADOQueryTmp.FieldByName('DTMID').AsString = '') or (ADOQueryTmp.FieldByName('DTMID').AsString = null) then begin Application.MessageBox('未设置默认工序!', '提示信息', MB_OK); end; DTMID.Text := ADOQueryTmp.FieldByName('DTMID').AsString; with ADOQueryCmd do begin Close; sql.Clear; SQL.Add(' select * from Dye_Technics_Main where DTMID = ' + QuotedStr(Trim(DTMID.Text))); Open; end; DTMPSlist.Text := ADOQueryCmd.FieldByName('DTMPSlist').AsString; FC_Code := ADOQueryTmp.FieldByName('C_Code').AsString; FC_Name := ADOQueryTmp.FieldByName('C_Name').AsString; // C_Width.Text := ADOQueryTmp.FieldByName('C_Width').Value; // C_Width.Text := ADOQueryTmp.FieldByName('C_Width').Value; end; procedure TfrmDyePlanCardInput.TV3Column1PropertiesEditValueChanged(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 TfrmDyePlanCardInput.TV3DblClick(Sender: TObject); begin // CDS_3.Delete; end; end.