U_fzlr_clbm.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:3k
- unit U_fzlr_clbm;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ComCtrls, ExtCtrls, Db, DBClient, MConnect, Grids, DBGrids, StdCtrls,
- Buttons;
- type
- TfrmCLBM_FZLR = class(TForm)
- Panel2: TPanel;
- StatusBar1: TStatusBar;
- DataSource1: TDataSource;
- Panel4: TPanel;
- btnOK: TSpeedButton;
- btnCancel: TSpeedButton;
- Panel1: TPanel;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- btnQuery: TSpeedButton;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- DBGrid: TDBGrid;
- procedure btnQueryClick(Sender: TObject);
- procedure btnOKClick(Sender: TObject);
- procedure btnCancelClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- type
- TClbmRec = record
- clbm: string[11];
- clmc: string[40];
- ggxh: string[40];
- jldw: string[20];
- djdw: string[20];
- jhdj: real;
- end;
- var
- frmCLBM_FZLR: TfrmCLBM_FZLR;
- ClbmRec: array of TClbmRec;
- implementation
- uses U_mainform, WzglDB;
- {$R *.DFM}
- procedure TfrmCLBM_FZLR.btnQueryClick(Sender: TObject);
- begin
- DM.CDS_CLBM_TEMP_INDEX.filter := '材料编码 like' + '''' + trim(edit1.text) + '%''' + ' and 材料名称 like ' + '''%' + trim(edit2.text) + '%''' + ' and 规格型号 like' + '''%' + trim(edit3.text) + '%''';
- DM.CDS_CLBM_TEMP_INDEX.filtered := true;
- end;
- procedure TfrmCLBM_FZLR.btnOKClick(Sender: TObject);
- var
- I: integer;
- begin
- //设置动态数组长度
- setLength(ClbmRec, dbgrid.SelectedRows.Count);
- //将DbGrid里的数据传进到全局数组clbmRec中
- for i := 0 to dbgrid.SelectedRows.Count - 1 do
- begin
- DBGrid.DataSource.DataSet.GotoBookmark(pointer(DBGrid.SelectedRows.Items[i]));
- clbmRec[i].clbm := DM.CDS_CLBM_TEMP_INDEX.fieldbyname('材料编码').asstring;
- clbmRec[i].clmc := DM.CDS_CLBM_TEMP_INDEX.fieldbyname('材料名称').asstring;
- clbmRec[i].ggxh := DM.CDS_CLBM_TEMP_INDEX.fieldbyname('规格型号').asstring;
- clbmRec[i].jldw := DM.CDS_CLBM_TEMP_INDEX.fieldbyname('计量单位').asstring;
- clbmRec[i].jhdj := DM.CDS_CLBM_TEMP_INDEX.fieldbyname('计划单价').value;
- clbmRec[i].djdw := DM.CDS_CLBM_TEMP_INDEX.fieldbyname('单价单位').asstring;
- end;
- close;
- end;
- procedure TfrmCLBM_FZLR.btnCancelClick(Sender: TObject);
- begin
- close;
- end;
- procedure TfrmCLBM_FZLR.FormCreate(Sender: TObject);
- begin
- //初始化变量
- setLength(clbmRec,0);
- DM.CDS_CLBM_TEMP_INDEX.Active := True;
- end;
- end.