unit U_YarnInput; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, cxPC, cxControls, ComCtrls, ToolWin, StdCtrls, Menus, cxTextEdit, cxCurrencyEdit, BtnEdit, cxContainer, cxEdit, cxImage, DB, ADODB, cxDBEdit, cxLookAndFeelPainters, cxButtons, strUtils, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxDBData, cxButtonEdit, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid, DBClient; type TfrmYarnInput = class(TForm) ToolBar1: TToolBar; ToolButton3: TToolButton; TBClose: TToolButton; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; ADOQueryCmd: TADOQuery; ADOQueryTmp: TADOQuery; ADOQuerymain: TADOQuery; Panel1: TPanel; Label1: TLabel; Label2: TLabel; Y_Code: TEdit; Y_CodeName: TEdit; Label5: TLabel; Y_Spec: TEdit; procedure FormDestroy(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure FormShow(Sender: TObject); private function savedata(): Boolean; procedure InitGrid(); { Private declarations } public FCYID: string; fFlileFlag: string; CopyInt: Integer; { Public declarations } end; var frmYarnInput: TfrmYarnInput; implementation uses U_DataLink, U_Fun10, U_ZDYHelp, U_YarnListSel; {$R *.dfm} function TfrmYarnInput.savedata(): Boolean; var maxno: string; begin result := false; try with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from BS_Yarn where ATID=''' + Trim(FCYID) + ''''); Open; if IsEmpty then begin append; FieldByName('Filler').Value := Trim(DName); end else begin Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTmp); end; SSetsaveSqlNew(ADOQueryCmd, 'BS_Yarn', Panel1, 2); FieldByName('ATID').Value := Trim(FCYID); post; end; result := true; except end; end; procedure TfrmYarnInput.InitGrid(); begin with ADOQueryMain do begin close; sql.Clear; sql.Add('select * from BS_Yarn A'); sql.Add('where ATID=' + quotedstr(trim(FCYID))); open; end; if not ADOQueryMain.IsEmpty then begin SCSHDataNew(ADOQueryMain, Panel1, 2); end; end; procedure TfrmYarnInput.FormDestroy(Sender: TObject); begin frmYarnInput := nil; end; procedure TfrmYarnInput.TBCloseClick(Sender: TObject); begin close; end; procedure TfrmYarnInput.FormCreate(Sender: TObject); begin Panel1.Align := alclient; clearControl(Panel1, 2); end; procedure TfrmYarnInput.ToolButton3Click(Sender: TObject); begin if trim(Y_Code.Text) = '' then begin application.MessageBox('纱线编号不能为空!', '提示信息', MB_ICONERROR); exit; end; if trim(Y_CodeName.Text) = '' then begin application.MessageBox('纱线名称不能为空!', '提示信息', MB_ICONERROR); exit; end; AdoqueryCmd.Connection.BeginTrans; try if not savedata() then begin AdoqueryCmd.Connection.RollbackTrans; end; AdoqueryCmd.Connection.CommitTrans; application.MessageBox('保存成功!', '提示信息'); self.ModalResult := 1; except AdoqueryCmd.Connection.RollbackTrans; application.MessageBox('保存失败!', '提示信息', MB_ICONERROR); end; end; procedure TfrmYarnInput.FormShow(Sender: TObject); begin initGrid(); if CopyInt = 99 then begin FCYID := ''; end; if FCYID = '' then begin if GetLSNo(ADOQueryCmd, FCYID, 'SX', 'BS_SX_YDang', 4, 1) = False then begin Application.MessageBox('取最大号失败!', '提示', 0); Exit; end; Y_Code.Text := trim(FCYID); end; end; end.