unit U_BatchEditUnit; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit, Vcl.Menus, Vcl.StdCtrls, cxButtons, cxLabel, cxTextEdit, cxMaskEdit, cxDropDownEdit, dxSkinsCore, dxSkinWXI, Data.DB, Data.Win.ADODB, U_BaseInput; type TfrmBatchEditUnit = class(TfrmBaseInput) btnOK: TcxButton; btnCancel: TcxButton; cxLabel2: TcxLabel; ADOConnection1: TADOConnection; ADOQuery1: TADOQuery; QtyUnit: TcxComboBox; procedure btnCancelClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure btnOKClick(Sender: TObject); private { Private declarations } public FDRSIDList: string; Fflag: Integer; { Public declarations } end; var frmBatchEditUnit: TfrmBatchEditUnit; implementation uses U_DataLink; {$R *.dfm} procedure TfrmBatchEditUnit.btnCancelClick(Sender: TObject); begin close; end; procedure TfrmBatchEditUnit.btnOKClick(Sender: TObject); begin inherited; if Trim(QtyUnit.Text) = '' then begin Application.MessageBox('请输入单位', '提示信息', 0); Exit; end; if FDRSIDList = '' then Exit; // 只允许 Tab=2 的情况(更新 Trade_Cloth_DR_Sub 的 QtyUnit) if Fflag = 2 then begin try with ADOQuery1 do begin Close; SQL.Clear; SQL.Add('update Trade_Cloth_DR_Sub set QtyUnit = ' + QuotedStr(QtyUnit.Text) + ' where DRSID in (' + FDRSIDList + ')'); ExecSQL; end; finally ModalResult := mrOk; end; end; end; procedure TfrmBatchEditUnit.FormShow(Sender: TObject); begin try with ADOConnection1 do begin if not Connected then begin Connected := false; ConnectionString := DConString; LoginPrompt := false; Connected := true; end; end; except application.MessageBox('数据库连接失败!', '错误', mb_Ok + MB_ICONERROR); end; end; end.