//设置关闭窗体的模式 procedure TSecSettingFormClose(Sender: TObject; var Action: TCloseAction); begin action:=cafree; end; //设置表格宽度 procedure TSecSettingDataSourceDataChange(Sender: TObject; Field: TField); begin //显示数据数量 labelCaption:=inttostr(adoqueryRecordCount); //设置数据表宽度 dbgridColumns[]Width:=; dbgridColumns[]Width:=; end; //专门写一个函数来实现工具栏按钮的设置让代码更加简练 procedure TSecSettingSetToolBar(isEnable: bool); begin if isEnable=true then begin //将首记录等记录移动按钮设置为不可用 toolbuttonEnabled:=false; toolbuttonEnabled:=false; toolbuttonEnabled:=false; toolbuttonEnabled:=false; //将新增修改等按钮设置为不可用 toolbuttonEnabled:=false; toolbuttonEnabled:=false; toolbuttonEnabled:=false; //将保存和取消按钮设置为可用 toolbuttonEnabled:=true; toolbuttonEnabled:=true; //将窗体内的数据显示控件设为可读 dbeditReadOnly:=false; dbeditReadOnly:=false; dbeditReadOnly:=false; dbradiogroupReadOnly:=false; dbradiogroupReadOnly:=false; end; if isEnable=false then begin //将首记录等记录移动按钮设置为可用 toolbuttonEnabled:=true; toolbuttonEnabled:=true; toolbuttonEnabled:=true; toolbuttonEnabled:=true; //将新增修改等按钮设置为可用 toolbuttonEnabled:=true; toolbuttonEnabled:=true; toolbuttonEnabled:=true; //将保存和取消按钮设置为不可用 toolbuttonEnabled:=false; toolbuttonEnabled:=false; //将窗体内的数据显示控件设为只读 dbeditReadOnly:=true; dbeditReadOnly:=true; dbeditReadOnly:=true; dbradiogroupReadOnly:=true; dbradiogroupReadOnly:=true; end; end; //新增记录 procedure TSecSettingToolButtonClick(Sender: TObject); begin SetToolBar(true); datasourceDataSetInsert; end; //修改记录 procedure TSecSettingToolButtonClick(Sender: TObject); begin SetToolBar(true); datasourceDataSetEdit; end; //删除记录 procedure TSecSettingToolButtonClick(Sender: TObject); begin if applicationMessageBox(删除该条记录?财务管理系统MB_OKCANCEL)=IDOK then datasourceDataSetDelete; end; [] [] [] |