unit U_YarnInfoInPut; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit, ComCtrls, ToolWin, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxButtonEdit, cxTextEdit, StdCtrls, ExtCtrls, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseInput, U_BaseList, System.ImageList, Vcl.ImgList, cxContainer, dxSkinWXI, cxMaskEdit, cxMemo, 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, cxImageList; type TfrmYarnInfoInPut = class(TfrmBaseInput) ToolBar1: TToolBar; TBSave: TToolButton; TBClose: TToolButton; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; ToolButton1: TToolButton; ScrollBox1: TScrollBox; Label2: TLabel; Label6: TLabel; Label7: TLabel; Label1: TLabel; Brand: TcxTextEdit; Y_Name: TcxTextEdit; Label3: TLabel; Y_Code: TcxTextEdit; Label4: TLabel; Label8: TLabel; Denier: TcxTextEdit; Y_Spec: TcxTextEdit; Label9: TLabel; Y_Color: TcxTextEdit; Note: TcxMemo; Y_Type: TcxComboBox; Y_Composition: TcxTextEdit; Label5: TLabel; ADOConnection1: TADOConnection; cxImageList_bar: TcxImageList; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } function SaveData(): Boolean; public { Public declarations } FBYIID, FSTKName: string; end; var frmYarnInfoInPut: TfrmYarnInfoInPut; implementation uses U_DataLink, U_RTFun, U_ZDYHelp; //, U_ProductInfoSel {$R *.dfm} procedure TfrmYarnInfoInPut.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := caFree; end; function TfrmYarnInfoInPut.SaveData(): Boolean; var MaxNo, MaxPRID: string; begin try ADOQueryCmd.Connection.BeginTrans; if Trim(FBYIID) = '' then begin if GetLSNo(ADOQueryCmd, MaxNo, 'P', 'BS_Yarn_Info', 4, 0) = False then raise Exception.Create('取最大号失败!'); Y_Code.Text := MaxNo; end else begin MaxNo := Trim(FBYIID); end; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from BS_Yarn_Info where BYIID=''' + Trim(MaxNo) + ''''); Open; end; with ADOQueryCmd do begin if Trim(FBYIID) = '' then begin Append; FieldByName('FillId').Value := Trim(DCode); FieldByName('Filler').Value := Trim(DName); end else begin Edit; FieldByName('EditId').Value := Trim(DCode); FieldByName('Editer').Value := Trim(DName); FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp); end; FieldByName('BYIID').Value := Trim(MaxNo); RTSetsavedata(ADOQueryCmd, 'BS_Yarn_Info', ScrollBox1, 2); Post; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('select * from BS_Yarn_Info where Y_Code=' + quotedstr(trim(Y_Code.Text))); Open; end; if ADOQueryCmd.RecordCount > 1 then raise Exception.Create('编号重复!'); with ADOQueryCmd do begin Close; sql.Clear; sql.Add('select * from BS_Yarn_Info where Y_Name=' + quotedstr(trim(Y_Name.Text))); Open; end; if ADOQueryCmd.RecordCount > 1 then raise Exception.Create('品名重复!'); ADOQueryCmd.Connection.CommitTrans; Result := True; except Result := False; ADOQueryCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmYarnInfoInPut.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmYarnInfoInPut.FormCreate(Sender: TObject); begin inherited; try with ADOConnection1 do begin Connected := false; ConnectionString := DConString; Connected := true; end; ADOQueryBaseCmd.Connection := ADOConnection1; ADOQueryBaseTemp.Connection := ADOConnection1; except application.MessageBox('网络连接失败!', '提示信息'); end; end; procedure TfrmYarnInfoInPut.FormShow(Sender: TObject); var fsj: string; begin inherited; fsj := ' select Code=ZDYNo,Name=ZDYName from KH_ZDY where Type=''YType'' and MainType=''纱线档案'' '; SInitTcxComBoxBySql(ADOQueryTemp, Y_Type, TRUE, fsj); with ADOQueryTemp do begin Close; SQL.Clear; sql.Add(' select * from BS_Yarn_Info '); sql.Add(' where BYIID=''' + Trim(FBYIID) + ''''); Open; end; SCSHData(ADOQueryTemp, ScrollBox1, 2); end; procedure TfrmYarnInfoInPut.TBSaveClick(Sender: TObject); begin // if Trim(Y_Code.Text) = '' then // begin // Application.MessageBox('编号不能为空!', '提示', 0); // Exit; // end; if Trim(Y_Name.Text) = '' then begin Application.MessageBox('名称不能为空!', '提示', 0); Exit; end; if Trim(Denier.Text) <> '' then begin if StrToFloatdef(Denier.Text, 0) = 0 then begin Application.MessageBox('理论D数请输入数字!', '提示', 0); Exit; end; end; if SaveData() then begin Application.MessageBox('保存成功!', '提示', 0); ModalResult := 1; Exit; end; end; end.