unit U_TradePlanInPut; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Winapi.ShellAPI, ComObj, 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, cxGridCustomPopupMenu, cxGridPopupMenu, cxDropDownEdit, RM_Common, RM_Preview, RM_System, RM_Class, RM_GridReport, RM_Dataset, Menus, cxSplitter, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, cxCheckBox, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, cxPC, System.ImageList, Vcl.ImgList, U_BaseInput, dxSkinWXI, dxCore, cxDateUtils, dxScrollbarAnnotations, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdFTP, cxImage, cxDBEdit, cxGroupBox, dxSkinBasic, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkroom, dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinOffice2016Colorful, dxSkinOffice2016Dark, dxSkinOffice2019Black, dxSkinOffice2019Colorful, dxSkinOffice2019DarkGray, dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringtime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinTheBezier, dxSkinValentine, dxSkinVisualStudio2013Blue, dxSkinVisualStudio2013Dark, dxSkinVisualStudio2013Light, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue; type TfrmTradePlanInPut = class(TfrmBaseInput) ToolBar1: TToolBar; TBSave: TToolButton; TBClose: TToolButton; ScrollBox1: TScrollBox; OrderNo: TcxTextEdit; ADOTemp: TADOQuery; ADOCmd: TADOQuery; DS_1: TDataSource; CDS_1: TClientDataSet; Label3: TLabel; Label25: TLabel; GPM_1: TcxGridPopupMenu; ADOQueryLabel: TADOQuery; Label51: TLabel; Label7: TLabel; ADO_I1: TADOQuery; DS_I1: TDataSource; ToolButton3: TToolButton; Label1: TLabel; Label2: TLabel; Label4: TLabel; BuyConNo: TcxTextEdit; C_Name: TcxTextEdit; Label6: TLabel; Label8: TLabel; C_Spec: TcxTextEdit; C_Composition: TcxTextEdit; Label9: TLabel; C_GramWeight: TcxTextEdit; Label10: TLabel; C_Width: TcxTextEdit; Label11: TLabel; Label27: TLabel; IdFTP1: TIdFTP; Label14: TLabel; Label20: TLabel; ConNo: TcxTextEdit; ADO_I2: TADOQuery; DS_I2: TDataSource; CDS_LM: TClientDataSet; OpenDialog1: TOpenDialog; PM_1: TPopupMenu; N5: TMenuItem; N6: TMenuItem; GPM_2: TcxGridPopupMenu; cxPageControl3: TcxPageControl; cxTabSheet2: TcxTabSheet; cxTabSheet3: TcxTabSheet; tlb2: TToolBar; btnConSel: TToolButton; ToolButton5: TToolButton; ToolButton7: TToolButton; ToolButton4: TToolButton; ToolButton1: TToolButton; ToolButton6: TToolButton; ToolButton2: TToolButton; cxGrid1: TcxGrid; TV1: TcxGridDBTableView; TV1Column8: TcxGridDBColumn; v1Column11: TcxGridDBColumn; v1Column4: TcxGridDBColumn; v1PRTColor: TcxGridDBColumn; TV1Column5: TcxGridDBColumn; TV1Column6: TcxGridDBColumn; v1Column5: TcxGridDBColumn; TV1Column3: TcxGridDBColumn; VC_PRTPs: TcxGridDBColumn; v1PRTOrderQty: TcxGridDBColumn; TV1Column2: TcxGridDBColumn; TV1Column4: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; cxTabSheet1: TcxTabSheet; Panel3: TPanel; cxGroupBox1: TcxGroupBox; cxGroupBox2: TcxGroupBox; cxGroupBox3: TcxGroupBox; cxDBImage4: TcxDBImage; OrdDate: TcxDateEdit; DlyDate: TcxDateEdit; CustName: TcxButtonEdit; OurCoName: TcxButtonEdit; OrdUnit: TcxComboBox; Panel1: TPanel; lbl1: TLabel; lbl2: TLabel; lbl3: TLabel; lbl4: TLabel; lbl5: TLabel; lbl10: TLabel; lbl11: TLabel; lbl13: TLabel; lbl14: TLabel; lbl16: TLabel; lbl18: TLabel; RuleBeforeTare: TcxTextEdit; Coefficient: TcxTextEdit; RuleLaterTare: TcxTextEdit; RuleLenUnit: TcxComboBox; RuleConversion: TcxComboBox; RulePieceNo: TcxComboBox; PackType: TcxButtonEdit; PackSeal: TcxButtonEdit; PackNote: TcxMemo; LabVolume: TcxButtonEdit; LabPackage: TcxButtonEdit; RMPreview1: TRMPreview; RMPreview2: TRMPreview; RM2: TRMGridReport; RM1: TRMGridReport; RMDB_1: TRMDBDataSet; RMDB_2: TRMDBDataSet; ADO_1: TADOQuery; lbl17: TLabel; C_Degree: TcxComboBox; TV1Column7: TcxGridDBColumn; TV1Column1: TcxGridDBColumn; lbl32: TLabel; OtherProcess12: TcxButtonEdit; Label16: TLabel; GC_Name: TcxTextEdit; Label17: TLabel; CraftCode: TcxTextEdit; Label18: TLabel; CraftName: TcxTextEdit; Label15: TLabel; OrdType: TcxComboBox; TV1Column9: TcxGridDBColumn; lbl9: TLabel; lbl15: TLabel; Label12: TLabel; lbl19: TLabel; lbl20: TLabel; lbl26: TLabel; lbl28: TLabel; Label35: TLabel; Label36: TLabel; LightNote: TcxButtonEdit; FtyName: TcxButtonEdit; Technics: TcxButtonEdit; Feel: TcxButtonEdit; OtherProcess6: TcxButtonEdit; OtherProcess8: TcxButtonEdit; ReferenceNumber: TcxButtonEdit; LightType: TcxButtonEdit; OtherProcess1: TcxComboBox; Label23: TLabel; OrdNote: TcxMemo; Label38: TLabel; Follower: TcxButtonEdit; Label37: TLabel; lbl24: TLabel; Saleser: TcxTextEdit; Tallyer: TcxTextEdit; TV1Column10: TcxGridDBColumn; cxTabSheet4: TcxTabSheet; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; TV2Column1: TcxGridDBColumn; TV2Column2: TcxGridDBColumn; TV2Column3: TcxGridDBColumn; TV2Column4: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; TV2Column5: TcxGridDBColumn; ToolBar2: TToolBar; ToolButton12: TToolButton; ToolButton14: TToolButton; TV2Column6: TcxGridDBColumn; Label5: TLabel; GC_BatchNo: TcxButtonEdit; Label39: TLabel; Export: TcxComboBox; Label40: TLabel; SampleCloth1: TcxTextEdit; Label41: TLabel; SampleCloth3: TcxTextEdit; Label42: TLabel; SampleCloth4: TcxTextEdit; SampleCloth2: TcxTextEdit; Label43: TLabel; Label44: TLabel; FixedLength: TcxTextEdit; Label13: TLabel; DyeingMach: TcxButtonEdit; Label19: TLabel; EnvironmentalProtection: TcxButtonEdit; Label21: TLabel; ShrinkageRate: TcxTextEdit; ADO_2: TADOQuery; DS_2: TDataSource; CDS_2: TClientDataSet; TV2Column7: TcxGridDBColumn; Label22: TLabel; CraftEName: TcxTextEdit; Label24: TLabel; ShippingMark: TcxMemo; Label26: TLabel; ClothUse: TcxButtonEdit; procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure CustomerNoNameBtnDnClick(Sender: TObject); procedure v1OrderUnitPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v1PriceUnitPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure YCLFactoryBtnUpClick(Sender: TObject); procedure v1Column5PropertiesEditValueChanged(Sender: TObject); procedure HYTTBtnUpClick(Sender: TObject); procedure KYTTBtnUpClick(Sender: TObject); procedure btnConSelClick(Sender: TObject); procedure TV1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure v1OrderUnitPropertiesEditValueChanged(Sender: TObject); procedure Tv1Column4PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure cxDBImage1DblClick(Sender: TObject); procedure SYRNameBtnUpClick(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure TechnicsBtnDnClick(Sender: TObject); procedure Tv1Column1PropertiesEditValueChanged(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); procedure ToolButton7Click(Sender: TObject); procedure CustNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure CustNameDblClick(Sender: TObject); procedure C_CodePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure OrdNoteDblClick(Sender: TObject); procedure QtyNotePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure PackSealPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure OurCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure LabVolumePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure LabPackagePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure LabVolumeDblClick(Sender: TObject); procedure LabPackageDblClick(Sender: TObject); procedure FollowerPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure FtyNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure ToolButton12Click(Sender: TObject); procedure ToolButton14Click(Sender: TObject); procedure TV2Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); private FSCXDH: string; procedure InitData(); procedure ZDYHelp(FButn: TcxButtonEdit; LType: string); function SaveData(): Boolean; function getOrderNo(fconNo: string): string; procedure InitImage1(); procedure InitImage2(); procedure LookImage(FileName: string); procedure SetXH(CDS_PX: TClientDataSet); procedure InitLabVolume(); procedure InitLabPackage(); { Private declarations } public PState, CopyInt, PriceFlag: Integer; FMainId, FFMainId, FOrderNo: string; FXS: Integer; canshu1: string; fFlileFlag: string; { Public declarations } end; var frmTradePlanInPut: TfrmTradePlanInPut; newh: hwnd; implementation uses U_DataLink, U_ZDYHelp, U_ZDYHelpSel, U_RTFun, U_TradeSalesContractSel, U_CompanySel, U_PictureUpload, U_ClothInfoSel, U_PatternColorHelp, U_TradeLabelSel, U_TradeGreyClothStkSel; {$R *.dfm} procedure TfrmTradePlanInPut.InitLabVolume(); begin with ADOQueryLabel do begin close; sql.Clear; sql.Add('select top 1 * from RT_FileUpdate'); sql.Add('where FileName=' + quotedstr(trim(LabVolume.Text) + '.rmf')); Open; end; if ADOQueryLabel.IsEmpty then exit; with RM1 do begin LoadFromBlobField(tblobfield(ADOQueryLabel.fieldbyname('Files'))); Preview := RMPreview1; ShowReport; end; end; procedure TfrmTradePlanInPut.InitLabPackage(); begin with ADOQueryLabel do begin close; sql.Clear; sql.Add('select top 1 * from RT_FileUpdate'); sql.Add('where FileName=' + quotedstr(trim(LabPackage.Text) + '.rmf')); Open; end; if ADOQueryLabel.IsEmpty then exit; with RM2 do begin LoadFromBlobField(tblobfield(ADOQueryLabel.fieldbyname('Files'))); Preview := RMPreview2; ShowReport; end; end; procedure TfrmTradePlanInPut.SetXH(CDS_PX: TClientDataSet); var i: Integer; begin with CDS_PX do begin First; i := 1; while not Eof do begin with CDS_PX do begin Edit; FieldByName('XHNoTemp').Value := i; Post; end; i := i + 1; Next; end; end; with CDS_PX do begin CDS_PX.IndexFieldNames := ''; First; i := 1; while not Eof do begin with CDS_PX do begin Edit; FieldByName('SerialNo').Value := FieldByName('XHNoTemp').AsInteger; Post; end; i := i + 1; Next; end; CDS_PX.IndexFieldNames := 'SerialNo'; end; end; procedure TfrmTradePlanInPut.InitImage1(); begin with ADO_I1 do begin close; sql.Clear; sql.Add('select * from TP_File A'); sql.Add('where isnull(WBID,'''')<>'''' and FileName=' + quotedstr(Trim(PackSeal.Text))); open; end; end; procedure TfrmTradePlanInPut.InitImage2(); begin with ADO_I2 do begin close; sql.Clear; sql.Add('select * from TP_File A'); sql.Add('where isnull(WBID,'''')<>'''' and FileName=' + quotedstr(Trim(CDS_1.fieldbyname('AttName').AsString))); open; end; end; function TfrmTradePlanInPut.getOrderNo(fconNo: string): string; var str1: string; i: integer; begin str1 := trim(fconNo) + '01'; with ADOTemp do begin close; sql.Clear; sql.Add('select MainID from Trade_Plan_Main where orderNo=' + quotedstr(trim(str1))); open; end; if not ADOTemp.IsEmpty then begin for i := 1 to 99 do begin str1 := trim(fconNo) + rightstr(inttostr(100 + i), 2); with ADOCmd do begin close; sql.Clear; sql.Add('select MainID from Trade_Plan_Main where orderNo=' + quotedstr(trim(str1))); open; end; if ADOCmd.IsEmpty then break; end; end; result := str1; end; procedure TfrmTradePlanInPut.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmTradePlanInPut.InitData(); var FDate: TDateTime; begin FDate := SGetServerDateTime(ADOTemp); OrdDate.Date := FDate; DlyDate.Date := FDate; with ADOTemp do begin Close; sql.Clear; sql.Add('select * from Trade_Plan_Main where MainId=''' + Trim(FMainId) + ''''); Open; end; SCSHData(ADOTemp, ScrollBox1, 1); SCSHData(ADOTemp, Panel1, 1); SCSHData(ADOTemp, Panel3, 1); OurCoName.Properties.LookupItems.Text := Trim(ADOTemp.FieldByName('OurCoNo').AsString); CustName.Properties.LookupItems.Text := Trim(ADOTemp.FieldByName('CustNo').AsString); with ADOTemp do begin Close; SQL.Clear; sql.Add(' select * from Trade_Plan_Sub '); sql.Add(' where MainId=''' + Trim(FMainId) + ''''); Open; end; SCSHData(ADOTemp, ScrollBox1, 2); SCreateCDS(ADOTemp, CDS_1); SInitCDSData(ADOTemp, CDS_1); with ADOTemp do begin Close; sql.Clear; sql.Add('select * from Trade_Cloth_Inspect_Rule where RuleID=''' + Trim(FMainId) + ''''); Open; end; SCSHData(ADOTemp, Panel1, 3); with ADOTemp do begin Close; SQL.Clear; sql.Add(' select * from Trade_Plan_Fty '); sql.Add(' where MainId=''' + Trim(FMainId) + ''''); Open; end; SCSHData(ADOTemp, Panel3, 4); SCSHData(ADOTemp, ScrollBox1, 4); with ADOTemp do begin Close; SQL.Clear; sql.Add(' select * from Trade_Plan_Technical '); sql.Add(' where MainId=''' + Trim(FMainId) + ''''); Open; end; SCreateCDS(ADOTemp, CDS_2); SInitCDSData(ADOTemp, CDS_2); if PState = 0 then begin OrdDate.Date := SGetServerDate(ADOTemp); DlyDate.Date := OrdDate.Date; OrderNo.Text := ''; OrderNo.Enabled := True; end else begin end; if CopyInt = 99 then begin PState := 0; FMainId := ''; OrderNo.Text := ''; OrderNo.Enabled := True; OrdDate.Date := FDate; with CDS_1 do begin First; while not Eof do begin Edit; FieldByName('MainId').Value := ''; FieldByName('SubId').Value := ''; Post; Next; end; end; with CDS_2 do begin First; while not Eof do begin Edit; FieldByName('MainId').Value := ''; FieldByName('TPTID').Value := ''; Post; Next; end; end; end; end; procedure TfrmTradePlanInPut.ZDYHelp(FButn: TcxButtonEdit; LType: string); var FType, ZDYName, FText: string; begin end; procedure TfrmTradePlanInPut.FollowerPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); var fRollNum: integer; MGC_BatchNo: string; begin MGC_BatchNo := ''; if trim(CustName.Text) = '' then begin Application.MessageBox('客户不能为空!', '提示', 0); Exit; end; frmTradeGreyClothStkSel := TfrmTradeGreyClothStkSel.create(self); with frmTradeGreyClothStkSel do begin if showmodal = 1 then begin CDS_Main.DisableControls; CDS_Main.First; while not CDS_Main.eof do begin if CDS_Main.FieldByName('ssel').AsBoolean then begin MGC_BatchNo := MGC_BatchNo + trim(CDS_Main.FieldByName('BatchNo').AsString) + '+'; end; CDS_Main.Next; end; CDS_Main.EnableControls; end; free; end; if length(MGC_BatchNo) > 0 then begin MGC_BatchNo := copy(MGC_BatchNo, 1, Length(MGC_BatchNo) - 1); GC_BatchNo.Text := MGC_BatchNo; end; end; procedure TfrmTradePlanInPut.FormShow(Sender: TObject); var i: Integer; begin inherited; with CDS_LM do begin FieldDefs.Clear; FieldDefs.Add('LXH', ftInteger, 0); FieldDefs.Add('lCode', ftString, 40); FieldDefs.Add('LName', ftString, 40); close; CreateDataSet; end; with ADO_1 do begin Close; SQL.Clear; sql.Add('exec P_BS_Label_Get_Test'); Open; end; readCxGrid(TRIM(SELF.Caption) + 'Tv1', Tv1, '生产指示单管理'); readCxGrid(TRIM(SELF.Caption) + 'Tv2', Tv2, '生产指示单管理'); OrderNo.Text := ''; fFlileFlag := UserDataFlag + 'HX'; InitData(); InitImage1(); InitImage2(); InitLabVolume(); InitLabPackage(); end; procedure TfrmTradePlanInPut.FtyNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '供应商'; if ShowModal = 1 then begin self.FtyName.Properties.LookupItems.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString); self.FtyName.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; function TfrmTradePlanInPut.SaveData(): Boolean; var maxno, Smaxno, maxorderno, MaxFNo, MaxTFTNo: string; begin try ADOCmd.Connection.BeginTrans; ///保存主表 if Trim(FMainId) = '' then begin if GetLSNo(ADOCmd, maxno, 'JM', 'Trade_Plan_Main', 3, 1) = False then raise Exception.Create('取最大号失败!'); end else begin maxno := Trim(FMainId); end; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from Trade_Plan_Main where MainId=''' + Trim(FMainId) + ''''); Open; end; with ADOCmd do begin if Trim(FMainId) = '' then begin Append; FieldByName('FillId').Value := Trim(DCode); FieldByName('Filler').Value := Trim(DName); FieldByName('MasterOrderNo').Value := Trim(OrderNo.Text); end else begin Edit; FieldByName('EditId').Value := Trim(DCode); FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOTemp); end; RTSetsavedata(ADOCmd, 'Trade_Plan_Main', ScrollBox1, 1); RTSetsavedata(ADOCmd, 'Trade_Plan_Main', Panel1, 1); RTSetsavedata(ADOCmd, 'Trade_Plan_Main', Panel3, 1); FieldByName('MainId').Value := Trim(maxno); FieldByName('OrdType').Value := '大货单'; FieldByName('OurCoNo').Value := Trim(OurCoName.Properties.LookupItems.Text); FieldByName('CustNo').Value := Trim(CustName.Properties.LookupItems.Text); Post; end; ///////////////////// 保存子表 /////////////////////////// with CDS_1 do begin First; while not Eof do begin if Trim(CDS_1.fieldbyname('SubId').AsString) = '' then begin if GetLSNo(ADOCmd, Smaxno, 'JS', 'Trade_Plan_Sub', 4, 1) = False then raise Exception.Create('取子流水号失败!'); end else begin Smaxno := Trim(CDS_1.fieldbyname('SubId').AsString); end; with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from Trade_Plan_Sub where MainId=''' + Trim(maxno) + ''''); sql.Add(' and SubId=''' + Trim(Smaxno) + ''''); Open; end; with ADOCmd do begin if Trim(CDS_1.fieldbyname('SubId').AsString) = '' then Append else Edit; RTSetSaveDataCDS(ADOCmd, Tv1, CDS_1, 'Trade_Plan_Sub', 0); RTSetsavedata(ADOCmd, 'Trade_Plan_Sub', ScrollBox1, 2); FieldByName('MainId').Value := Trim(maxno); FieldByName('SubId').Value := Trim(Smaxno); FieldByName('ConSId').Value := Trim(CDS_1.fieldbyname('ConSId').AsString); FieldByName('ConMId').Value := Trim(CDS_1.fieldbyname('ConMId').AsString); Post; with CDS_1 do begin Edit; fieldbyname('SubId').Value := Trim(Smaxno); Post; end; end; Next; end; end; ///////////////////// 保存子表 /////////////////////////// ///////////////////// 保存加工厂 /////////////////////////// with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from Trade_Plan_Fty where TPFId=''' + Trim(maxno) + ''''); Open; end; with ADOCmd do begin if ADOCmd.IsEmpty then begin Append; end else Edit; RTSetsavedata(ADOCmd, 'Trade_Plan_Fty', ScrollBox1, 4); RTSetsavedata(ADOCmd, 'Trade_Plan_Fty', Panel3, 4); FieldByName('FtyNo').Value := Trim(FtyName.Properties.LookupItems.Text); FieldByName('MainId').Value := Trim(maxno); FieldByName('TPFId').Value := Trim(maxno); Post; end; ///////////////////// 保存加工厂 /////////////////////////// ///////////////////// 保存加工条款 /////////////////////////// with CDS_2 do begin First; while not Eof do begin if Trim(CDS_2.fieldbyname('TPTID').AsString) = '' then begin if GetLSNo(ADOCmd, MaxTFTNo, 'TF', 'Trade_Plan_Technical', 4, 1) = False then raise Exception.Create('取子流水号失败!'); end else begin MaxTFTNo := Trim(CDS_2.fieldbyname('TPTID').AsString); end; with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from Trade_Plan_Technical where MainId=''' + Trim(maxno) + ''''); sql.Add(' and TPTID=''' + Trim(MaxTFTNo) + ''''); Open; end; with ADOCmd do begin if Trim(CDS_2.fieldbyname('TPTID').AsString) = '' then Append else Edit; if Trim(CDS_2.fieldbyname('TPTID').AsString) <> '' then begin with ADOTemp do begin Close; SQL.Clear; sql.Add('select * from Trade_Plan_Technical where MainId=''' + Trim(maxno) + ''''); Open; end; end; FieldByName('MainId').Value := Trim(maxno); FieldByName('TPTID').Value := Trim(MaxTFTNo); RTSetSaveDataCDS(ADOCmd, Tv2, CDS_2, 'Trade_Plan_Technical', 0); Post; with CDS_2 do begin Edit; fieldbyname('TPTID').Value := Trim(MaxTFTNo); Post; end; end; Next; end; end; ///////////////////// 保存加工条款 /////////////////////////// /////////////// 保存打卷设置 /////////////// with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from Trade_Cloth_Inspect_Rule where RuleID=''' + Trim(maxno) + ''''); Open; end; with ADOCmd do begin if ADOCmd.IsEmpty then begin Append; end else Edit; RTSetsavedata(ADOCmd, 'Trade_Cloth_Inspect_Rule', Panel1, 3); FieldByName('RuleID').Value := Trim(maxno); Post; end; /////////////// 保存打卷设置 /////////////// with ADOCmd do begin Close; sql.Clear; sql.Add('select * from Trade_Plan_Main where orderno=''' + Trim(OrderNo.Text) + ''''); Open; end; if ADOCmd.RecordCount > 1 then raise Exception.Create('订单号重复!'); with ADOCmd do begin Close; sql.Clear; sql.Add('update Trade_Plan_Main set SalesId=X.SalesId,Saleser=X.Saleser,TallyId=X.TallyId,Tallyer=X.Tallyer from Bs_Company X where X.CoCode=CustNo'); sql.Add('and orderno=''' + Trim(OrderNo.Text) + ''''); execsql; end; FMainId := Trim(maxno); ADOCmd.Connection.CommitTrans; Result := True; except Result := False; ADOCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); if pos('KEY 约束', Exception(ExceptObject).Message) > 0 then begin if GetLSNo(ADOCmd, Smaxno, 'JS', 'Trade_Plan_Sub', 4, 1) = False then begin Application.MessageBox('重新取子流水号失败!', '提示', 0); Exit; end; end; end; end; procedure TfrmTradePlanInPut.TBSaveClick(Sender: TObject); begin if PState <> 1 then begin ToolBar1.SetFocus; end; if CDS_1.IsEmpty then begin Application.MessageBox('明细不能为空!', '提示', 0); Exit; end; if OrdUnit.Text = '' then begin Application.MessageBox('单位不能为空!', '提示', 0); Exit; end; // if OrdTYpe.Text = '' then // begin // Application.MessageBox('类型不能为空!', '提示', 0); // Exit; // end; if CDS_1.Locate('OrdQty', null, []) then begin Application.MessageBox('数量不能为空!', '提示', 0); Exit; end; if Trim(OrderNo.Text) = '' then begin with ADOTemp do begin Close; sql.Clear; SQL.Add('exec P_Trade_Plan_Get_OrdNo @ConNo=''' + Trim(ConNo.Text) + ''''); Open; end; OrderNo.Text := ADOTemp.FieldByName('OrderNo').AsString; end; if SaveData() then begin Application.MessageBox('保存成功!', '提示', 0); // ModalResult := 1; end; end; procedure TfrmTradePlanInPut.ToolButton12Click(Sender: TObject); var i: Integer; begin i := CDS_2.RecordCount; try frmZDYHelpSel := TfrmZDYHelpSel.Create(Application); with frmZDYHelpSel do begin fnote := True; V1Note.Caption := '单位'; flag := 'TPTName'; flagname := '测试项目'; if ShowModal = 1 then begin while ClientDataSet1.Locate('SSel', True, []) do begin with Self.CDS_2 do begin append; FieldByName('SSel').Value := false; FieldByName('SerialNo').Value := i + 1; FieldByName('TPTName').Value := frmZDYHelpSel.ClientDataSet1.FieldByName('ZDYName').AsString; FieldByName('TPTUnit').Value := frmZDYHelpSel.ClientDataSet1.FieldByName('Note').AsString; Post; end; ClientDataSet1.Delete; i := i + 1 end; end; end; finally frmZDYHelpSel.Free; end; end; procedure TfrmTradePlanInPut.ToolButton14Click(Sender: TObject); begin if CDS_2.IsEmpty then Exit; if CDS_2.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要删除选择的数据吗?', '提示', 32 + 4) <> IDYES then exit; CDS_2.DisableControls; with CDS_2 do begin First; while Locate('SSel', True, []) do begin if Trim(CDS_2.fieldbyname('TPTID').AsString) <> '' then begin with ADOCmd do begin Close; sql.Clear; sql.Add('delete Trade_Plan_Technical where TPTID=''' + Trim(CDS_2.fieldbyname('TPTID').AsString) + ''''); ExecSQL; end; end; Delete; end; end; CDS_2.EnableControls; SetXH(CDS_2); end; procedure TfrmTradePlanInPut.ToolButton1Click(Sender: TObject); var i: Integer; begin i := CDS_1.RecordCount; CopyAddRow(Tv1, CDS_1); with CDS_1 do begin Edit; FieldByName('SSel').Value := false; FieldByName('SerialNo').Value := i + 1; FieldByName('AttName').Value := ''; Post; end; end; procedure TfrmTradePlanInPut.ToolButton2Click(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; CDS_1.DisableControls; with CDS_1 do begin First; while Locate('SSel', True, []) do begin with ADOTemp do begin Close; sql.Clear; sql.Add('select * from Trade_Cloth_Inspect where isnull(SubId,'''')<>'''' and SubId=''' + Trim(CDS_1.fieldbyname('SubId').AsString) + ''''); Open; end; if ADOTemp.IsEmpty = False then begin Application.MessageBox('已检验不能删除数据!', '提示', 0); Exit; end; if Trim(CDS_1.fieldbyname('SubId').AsString) <> '' then begin with ADOCmd do begin Close; sql.Clear; // sql.Add('insert into Trade_Plan_Sub_Del select * from Trade_Plan_Sub where SubId=''' + Trim(CDS_1.fieldbyname('SubId').AsString) + ''''); sql.Add('delete Trade_Plan_Sub where SubId=''' + Trim(CDS_1.fieldbyname('SubId').AsString) + ''''); ExecSQL; end; end; Delete; end; end; CDS_1.EnableControls; SetXH(CDS_1); end; procedure TfrmTradePlanInPut.ToolButton3Click(Sender: TObject); begin WriteCxGrid(TRIM(SELF.Caption) + 'Tv1', Tv1, '生产指示单管理'); WriteCxGrid(TRIM(SELF.Caption) + 'Tv2', Tv2, '生产指示单管理'); end; procedure TfrmTradePlanInPut.ToolButton4Click(Sender: TObject); var excelApp, WorkBook: Variant; i, j, k, LX, ExcelRowCount: integer; maxId, FCPID, FCPName, t1, t2, t3, FFID: string; begin try excelApp := CreateOleObject('Excel.Application'); openDialog1.Filter := '*.CSV;*.xls'; if opendialog1.Execute then begin WorkBook := excelApp.WorkBooks.Open(OpenDialog1.FileName); end else exit; excelApp.Visible := false; ExcelRowCount := WorkBook.WorkSheets[1].UsedRange.Rows.Count; except application.MessageBox('加载EXCEL错误!', '错误信息', MB_ICONERROR); exit; end; CDS_LM.EmptyDataSet; for j := 0 to Tv1.ColumnCount - 1 do begin with CDS_LM do begin Append; FieldByName('LCode').Value := trim(Tv1.Columns[j].DataBinding.FieldName); FieldByName('LName').Value := trim(Tv1.Columns[j].Caption); Post; end; end; try for i := 1 to 50 do begin if trim(WorkBook.WorkSheets[1].Cells[1, i].value) = '' then continue; if CDS_LM.Locate('LName', trim(WorkBook.WorkSheets[1].Cells[1, i].value), []) then begin with CDS_LM do begin Edit; FieldByName('LXH').Value := i; Post; end; end; end; except application.MessageBox('加载数组错误!', '错误信息', MB_ICONERROR); exit; end; try for i := 2 to ExcelRowCount do begin with CDS_1 do begin Append; CDS_LM.First; while not CDS_LM.Eof do begin if CDS_LM.FieldByName('LXH').AsInteger > 0 then CDS_1.fieldbyname(CDS_LM.FieldByName('LCode').AsString).Value := WorkBook.WorkSheets[1].Cells[i, CDS_LM.FieldByName('LXH').AsInteger].Value; CDS_LM.Next; end; CDS_1.FieldByName('SSel').Value := false; Post; end; end; WorkBook.Close; excelApp.Quit; excelApp := Unassigned; WorkBook := Unassigned; except WorkBook.Close; excelApp.Quit; excelApp := Unassigned; WorkBook := Unassigned; exit; end; SetXH(CDS_1); end; procedure TfrmTradePlanInPut.ToolButton5Click(Sender: TObject); begin try frmClothInfoSel := TfrmClothInfoSel.Create(Application); with frmClothInfoSel do begin if ShowModal = 1 then begin while CDS_1.locate('SSel', true, []) do begin if self.CDS_1.locate('ConSubId', trim(CDS_1.Fieldbyname('SubId').AsString), []) then begin CDS_1.Edit; CDS_1.fieldbyname('SSel').value := false; continue; end; with self.CDS_1 do begin append; FieldByName('SSel').Value := false; C_Code.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Code').AsString); C_Name.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Name').AsString); C_Spec.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Spec').AsString); C_Composition.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Composition').AsString); C_Width.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Width').AsString); C_GramWeight.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_GramWeight').AsString); self.GC_Name.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('GC_Name').AsString); self.CraftCode.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('CraftCode').AsString); self.CraftName.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('CraftName').AsString); self.CraftEName.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('CraftEName').AsString); // OrdUnit.ItemIndex := OrdUnit.Properties.Items.IndexOf(trim(frmClothInfoSel.CDS_1.fieldbyname('ConUnit').AsString)); Fieldbyname('C_ColorNo').value := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_ColorNo').AsString); Fieldbyname('C_Color').value := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Color').AsString); Fieldbyname('C_Pattern').value := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Pattern').AsString); Fieldbyname('OrdQty').value := frmClothInfoSel.CDS_1.Fieldbyname('ConQty').AsFloat; Fieldbyname('DDQtyUnit').value := frmClothInfoSel.CDS_1.Fieldbyname('SCSUnit').AsString; Fieldbyname('OrderUnit').value := trim(frmClothInfoSel.CDS_1.Fieldbyname('SCSUnit').AsString); Fieldbyname('SerialNo').value := 999; end; CDS_1.Edit; CDS_1.fieldbyname('SSel').value := false; end; end; end; finally frmClothInfoSel.Free; end; SetXH(CDS_1); end; procedure TfrmTradePlanInPut.ToolButton6Click(Sender: TObject); var i: Integer; begin i := CDS_1.RecordCount; with CDS_1 do begin Append; FieldByName('SSel').Value := false; FieldByName('SerialNo').Value := i + 1; FieldByName('AttName').Value := ''; Post; end; end; procedure TfrmTradePlanInPut.ToolButton7Click(Sender: TObject); var I, J, K: Integer; begin K := CDS_1.RecordCount + 1; try frmPatternColorHelp := TfrmPatternColorHelp.Create(Application); with frmPatternColorHelp do begin if ShowModal = 1 then begin for I := STRTOINTDEF(QSHX.Text, 1) to STRTOINTDEF(JSHX.Text, 1) do begin for J := 1 to STRTOINTDEF(YSSL.Text, 1) do begin with CDS_1 do begin Append; FieldByName('SSel').Value := false; FieldByName('SerialNo').Value := K; if STRTOINTDEF(QSHX.Text, 0) <> 0 then FieldByName('C_Pattern').Value := 'D#' + inttostr(I); if STRTOINTDEF(YSSL.Text, 0) <> 0 then FieldByName('C_ColorNo').Value := 'C#' + inttostr(J); FieldByName('OrdPiece').Value := STRTOINTDEF(ps.Text, 0); FieldByName('OrdQty').Value := STRTOINTDEF(sl.Text, 0); FieldByName('C_GS').Value := STRTOINTDEF(GS.Text, 0); FieldByName('C_GL').Value := STRTOINTDEF(GL.Text, 0); FieldByName('OrdPiece').Value := STRTOINTDEF(GS.Text, 0) * STRTOINTDEF(GL.Text, 0); Post; end; K := K + 1; end; end; SetXH(CDS_1); end; end; finally frmPatternColorHelp.Free; end; end; procedure TfrmTradePlanInPut.TechnicsBtnDnClick(Sender: TObject); begin TcxButtonEdit(Sender).Text := ''; TcxButtonEdit(Sender).Properties.LookupItems.Text := ''; end; procedure TfrmTradePlanInPut.CustNameDblClick(Sender: TObject); begin TcxButtonEdit(Sender).Text := ''; TcxButtonEdit(Sender).Properties.LookupItems.Text := ''; end; procedure TfrmTradePlanInPut.CustNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '客户'; if ShowModal = 1 then begin self.CustName.Properties.LookupItems.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString); self.CustName.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; procedure TfrmTradePlanInPut.CustomerNoNameBtnDnClick(Sender: TObject); begin TcxButtonEdit(Sender).Text := ''; TcxButtonEdit(Sender).Properties.LookupItems.Text := ''; end; procedure TfrmTradePlanInPut.C_CodePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmClothInfoSel := TfrmClothInfoSel.Create(Application); with frmClothInfoSel do begin if ShowModal = 1 then begin // Self.C_Code.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Code').AsString); Self.C_Name.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Name').AsString); Self.C_Spec.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Spec').AsString); Self.C_Composition.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Composition').AsString); Self.C_Width.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_Width').AsString); Self.C_GramWeight.Text := trim(frmClothInfoSel.CDS_1.Fieldbyname('C_GramWeight').AsString); end; end; finally frmClothInfoSel.Free; end; end; procedure TfrmTradePlanInPut.cxDBImage1DblClick(Sender: TObject); begin if TcxDBImage(Sender).Picture.Height = 0 then exit; LookImage(ADO_I1.fieldbyname(TcxDBImage(Sender).Hint).asstring); end; procedure TfrmTradePlanInPut.OrdNoteDblClick(Sender: TObject); var fsj: string; FWZ: Integer; i: integer; begin fsj := Trim(TMemo(Sender).Hint); FWZ := Pos('/', fsj); i := 0; try frmZDYHelpSel := TfrmZDYHelpSel.Create(Application); with frmZDYHelpSel do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TMemo(Sender).Lines.Clear; with ClientDataSet1 do begin First; while not Eof do begin if FieldByName('SSel').AsBoolean = True then begin i := i + 1; TMemo(Sender).Lines.Add(inttostr(i) + '.' + FieldByName('ZDYName').AsString) //inttostr(i)+'.'+ end; Next; end; end; end; end; finally frmZDYHelpSel.Free; end; end; procedure TfrmTradePlanInPut.OurCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '我司'; if ShowModal = 1 then begin self.OurCoName.Properties.LookupItems.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString); self.OurCoName.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; procedure TfrmTradePlanInPut.PackSealPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmPictureUpload := TfrmPictureUpload.create(self); with frmPictureUpload do begin fFlileFlag := self.fFlileFlag; FDataId := TRIM(PackSeal.Text); FPictureName := TRIM(PackSeal.Text); FWidth := 450; FHeight := 600; FTFType := 'HX'; if showmodal = 1 then begin Self.PackSeal.Text := frmPictureUpload.FPictureName; end; end; finally frmPictureUpload.free; end; InitImage1(); end; procedure TfrmTradePlanInPut.LabPackageDblClick(Sender: TObject); begin TcxButtonEdit(Sender).Text := ''; TcxButtonEdit(Sender).Properties.LookupItems.Text := ''; Self.InitLabPackage(); end; procedure TfrmTradePlanInPut.LabPackagePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmTradeLabelSel := TfrmTradeLabelSel.Create(Application); with frmTradeLabelSel do begin if ShowModal = 1 then begin TcxButtonEdit(Sender).Text := Trim(frmTradeLabelSel.CDS_Label.fieldbyname('labelCaption').AsString); Self.InitLabPackage(); end; end; finally frmTradeLabelSel.Free; end; end; procedure TfrmTradePlanInPut.LabVolumeDblClick(Sender: TObject); begin TcxButtonEdit(Sender).Text := ''; TcxButtonEdit(Sender).Properties.LookupItems.Text := ''; Self.InitLabVolume(); end; procedure TfrmTradePlanInPut.LabVolumePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmTradeLabelSel := TfrmTradeLabelSel.Create(Application); with frmTradeLabelSel do begin if ShowModal = 1 then begin TcxButtonEdit(Sender).Text := Trim(frmTradeLabelSel.CDS_Label.fieldbyname('labelCaption').AsString); Self.InitLabVolume(); end; end; finally frmTradeLabelSel.Free; end; end; procedure TfrmTradePlanInPut.LookImage(FileName: string); var sFieldName: string; begin sFieldName := leftbstr(ExtractFilePath(Application.ExeName), 1) + ':\图片查看'; if not DirectoryExists(pchar(sFieldName)) then CreateDirectory(pchar(sFieldName), nil); sFieldName := sFieldName + '\' + trim(FileName); try IdFTP1.Host := ReadINIFileStr('SYSTEMSET.INI', 'SERVER', '服务器地址', '127.0.0.1'); IdFTP1.Username := 'three'; IdFTP1.Password := '641010'; IdFTP1.Connect(); except ; end; if IdFTP1.Connected then begin try IdFTP1.Get(fFlileFlag + '\' + Trim(FileName), sFieldName, true, false); except Application.MessageBox('客户图样文件不存在', '提示', MB_ICONWARNING); IdFTP1.Quit; Exit; end; end else begin Application.MessageBox('无法连接文件服务器', '提示', MB_ICONWARNING); IdFTP1.Quit; Exit; end; if IdFTP1.Connected then IdFTP1.Quit; ShellExecute(Handle, 'open', PChar(sFieldName), '', '', SW_SHOWNORMAL); end; procedure TfrmTradePlanInPut.N5Click(Sender: TObject); begin SelOKNo(CDS_1, True); end; procedure TfrmTradePlanInPut.N6Click(Sender: TObject); begin SelOKNo(CDS_1, False); end; procedure TfrmTradePlanInPut.v1OrderUnitPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); var mvalues: string; begin mvalues := tv1.Columns[tv1.Controller.FocusedColumn.index].DataBinding.FieldName; try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'OrderUnit'; flagname := '数量单位'; if ShowModal = 1 then begin Self.CDS_1.Edit; Self.CDS_1.FieldByName(mvalues).Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmTradePlanInPut.v1OrderUnitPropertiesEditValueChanged(Sender: TObject); var mvalue, FFieldName, YValue: string; FDDQty, FCPCDXS, FQty, FDKCQty: Double; begin mvalue := TcxComboBox(Sender).EditingText; //变化后单位 FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName); with CDS_1 do begin Edit; FieldByName(FFieldName).Value := mvalue; Post; YValue := FieldByName('DDQtyUnit').AsString; //原单位=订单单位 FDDQty := FieldByName('DDQty').AsFloat; //订单数量 FCPCDXS := FieldByName('CPCDXS').AsFloat; FDKCQty := FieldByName('DKCQty').AsFloat; FQty := FieldByName('PRTOrderQty').AsFloat; end; if mvalue = 'Kg' then begin if YValue = 'Y' then begin FQty := FDDQty * 0.9144 / FCPCDXS; end; if YValue = 'M' then begin FQty := FDDQty / FCPCDXS; end; if YValue = 'Kg' then begin FQty := FDDQty; end; end; if mvalue = 'M' then begin if YValue = 'Y' then begin FQty := FDDQty * 0.9144; end; if YValue = 'Kg' then begin FQty := FDDQty * FCPCDXS; end; if YValue = 'M' then begin FQty := FDDQty; end; end; if mvalue = 'Y' then begin if YValue = 'M' then begin FQty := FDDQty / 0.9144; end; if YValue = 'Kg' then begin FQty := FDDQty * FCPCDXS / 0.9144; end; if YValue = 'Y' then begin FQty := FDDQty; end; end; with CDS_1 do begin Edit; FieldByName('PRTOrderQty').Value := FQty - FDKCQty; Post; end; Tv1.Controller.EditingController.ShowEdit(); end; procedure TfrmTradePlanInPut.v1PriceUnitPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'PriceUnit'; flagname := '价格单位'; if Trim(DParameters1) <> '高权限' then begin TBAdd.Visible := False; TBEdit.Visible := False; TBDel.Visible := False; end; if ShowModal = 1 then begin Self.CDS_1.Edit; Self.CDS_1.FieldByName('PriceUnit').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmTradePlanInPut.YCLFactoryBtnUpClick(Sender: TObject); var fsj: string; FWZ: Integer; begin fsj := Trim(TcxTextEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TcxTextEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmTradePlanInPut.btnConSelClick(Sender: TObject); var FConMainId, FMPRTCode: string; begin try frmTradeSalesContractSel := TfrmTradeSalesContractSel.Create(Application); with frmTradeSalesContractSel do begin fconNo := self.ConNo.Text; // fC_Code := self.C_Code.Text; if ShowModal = 1 then begin while CDS_1.locate('SSel', true, []) do begin if self.CDS_1.locate('ConSId', trim(CDS_1.Fieldbyname('ConSId').AsString), []) then begin CDS_1.Edit; CDS_1.fieldbyname('SSel').value := false; continue; end; self.BuyConNo.Text := Trim(frmTradeSalesContractSel.CDS_1.fieldbyname('BuyConNo').AsString); self.CustName.Properties.LookupItems.Text := Trim(frmTradeSalesContractSel.CDS_1.fieldbyname('BuyNo').AsString); self.CustName.Text := Trim(frmTradeSalesContractSel.CDS_1.fieldbyname('BuyName').AsString); self.PackNote.Text := Trim(frmTradeSalesContractSel.CDS_1.fieldbyname('PackNote').AsString); self.OurCoName.Properties.LookupItems.Text := Trim(frmTradeSalesContractSel.CDS_1.fieldbyname('Sellno').AsString); self.OurCoName.Text := Trim(frmTradeSalesContractSel.CDS_1.fieldbyname('Sellname').AsString); // self.OrderNo.Text := Trim(frmTradeSalesContractSel.CDS_1.fieldbyname('ConNo').AsString); self.ConNo.Text := Trim(frmTradeSalesContractSel.CDS_1.fieldbyname('ConNo').AsString); self.C_Name.Text := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_Name').AsString); self.C_Spec.Text := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_Spec').AsString); self.C_Composition.Text := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_Composition').AsString); self.C_Width.Text := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_Width').AsString); self.C_GramWeight.Text := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_GramWeight').AsString); self.GC_Name.Text := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('GC_Name').AsString); self.CraftCode.Text := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('CraftCode').AsString); self.CraftName.Text := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('CraftName').AsString); self.CraftEName.Text := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('CraftEName').AsString); self.OrdUnit.ItemIndex := OrdUnit.Properties.Items.IndexOf(trim(frmTradeSalesContractSel.CDS_1.fieldbyname('ConUnit').AsString)); with self.CDS_1 do begin Append; FieldByName('SSel').Value := false; Fieldbyname('C_Code').value := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_Code').AsString); Fieldbyname('SerialNo').value := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('SerialNo').AsString); Fieldbyname('ConNo').value := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('ConNo').AsString); Fieldbyname('ConMId').value := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('ConMId').AsString); Fieldbyname('ConSId').value := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('ConSId').AsString); Fieldbyname('C_ColorNo').value := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_ColorNo').AsString); Fieldbyname('C_Color').value := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_Color').AsString); Fieldbyname('C_Pattern').value := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_Pattern').AsString); Fieldbyname('C_ColorConfirm').value := trim(frmTradeSalesContractSel.CDS_1.Fieldbyname('C_ColorConfirm').AsString); Fieldbyname('OrdQty').value := frmTradeSalesContractSel.CDS_1.Fieldbyname('ConQty').AsFloat; Post; end; CDS_1.Edit; CDS_1.fieldbyname('SSel').value := false; end; end; end; finally frmTradeSalesContractSel.Free; end; SetXH(CDS_1); end; procedure TfrmTradePlanInPut.QtyNotePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); var fsj: string; FWZ: Integer; begin fsj := Trim(TcxButtonEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TcxButtonEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmTradePlanInPut.SYRNameBtnUpClick(Sender: TObject); var fsj: string; FWZ: Integer; begin fsj := Trim(TcxTextEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin fnote := True; flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TcxTextEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmTradePlanInPut.Tv1Column1PropertiesEditValueChanged(Sender: TObject); var mvalue, FFieldName: string; FGS, FGL, FOrdPiece: Double; i: Integer; begin mvalue := TcxTextEdit(Sender).EditingText; FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName); FOrdPiece := 0; if Trim(mvalue) = '' then begin mvalue := '0'; end; with CDS_1 do begin Edit; FieldByName(FFieldName).Value := mvalue; Post; FGL := CDS_1.fieldbyname('C_Gl').AsFloat; FGS := CDS_1.fieldbyname('C_GS').AsFloat; FOrdPiece := CDS_1.fieldbyname('OrdPiece').AsFloat; end; if Trim(FFieldName) <> 'OrdPiece' then begin FOrdPiece := (FGS * FGL); end; with CDS_1 do begin Edit; FieldByName('OrdPiece').Value := FOrdPiece; Post; end; tv1.Controller.EditingController.ShowEdit(); end; procedure TfrmTradePlanInPut.Tv1Column4PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmPictureUpload := TfrmPictureUpload.create(self); with frmPictureUpload do begin fFlileFlag := self.fFlileFlag; FDataId := Trim(self.CDS_1.fieldbyname('AttName').AsString); FPictureName := Trim(self.CDS_1.fieldbyname('AttName').AsString); FWidth := 450; FHeight := 600; FTFType := 'HX'; if showmodal = 1 then begin with self.CDS_1 do begin Edit; Fieldbyname('AttName').Value := frmPictureUpload.FPictureName; Post; end; end; end; finally frmPictureUpload.free; end; end; procedure TfrmTradePlanInPut.TV1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin InitImage2(); end; procedure TfrmTradePlanInPut.TV2Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'TPTName' + Trim(Self.CDS_2.fieldbyname('TPTName').AsString); flagname := '检测方法'; if ShowModal = 1 then begin Self.CDS_2.Edit; Self.CDS_2.FieldByName('TPTType').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmTradePlanInPut.v1Column5PropertiesEditValueChanged(Sender: TObject); var mvalue, FFieldName: string; begin mvalue := TcxTextEdit(Sender).EditingText; FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName); with CDS_1 do begin Edit; FieldByName(FFieldName).Value := mvalue; FieldByName('MGMainId').Value := ''; Post; end; Tv1.Controller.EditingController.ShowEdit(); end; procedure TfrmTradePlanInPut.HYTTBtnUpClick(Sender: TObject); var fsj: string; FWZ: Integer; begin fsj := Trim(TcxTextEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TcxTextEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmTradePlanInPut.KYTTBtnUpClick(Sender: TObject); var fsj: string; FWZ: Integer; begin fsj := Trim(TcxTextEdit(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if Trim(flag) = 'OrdDefStr2' then begin V1Name.Caption := '中文名称'; V1Note.Caption := '英文名称'; fnote := True; end; if ShowModal = 1 then begin TcxTextEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; end.