⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 infonew.pas

📁 飞恒进销存(超市批发)管理系统V5.1(含源程序) 语言:Delphi 6/7 相关控件:FastReport 2.4以上, Ehlib 3.4以上 1.数据库为fhe2db_V51.da
💻 PAS
字号:
unit infoNew;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGridEh, ImgList, Menus, ComCtrls, ToolWin, ExtCtrls,adoDb,
  db,EhlibAdo, StdCtrls, Mask, DBCtrlsEh, Buttons, FR_Class, FR_DSet, comobj,
  FR_DBSet;

type
  TInfoNewForm = class(TForm)
    dbGrid1: TDBGridEh;
    Tbinfo: TToolBar;
    Tbadd: TToolButton;
    Tbedit: TToolButton;
    Tbdel: TToolButton;
    ToolButton4: TToolButton;
    tbCopy: TToolButton;
    TBsec: TToolButton;
    Tbprint: TToolButton;
    Tbsave: TToolButton;
    ToolButton7: TToolButton;
    Tbexit: TToolButton;
    PanelCondition1: TPanel;
    Label3: TLabel;
    Label1: TLabel;
    edtTypeCode: TDBEditEh;
    edtCode: TDBEditEh;
    PMprint: TPopupMenu;
    Mpreview: TMenuItem;
    ILinfo: TImageList;
    SaveDialog1: TSaveDialog;
    procedure FormShow(Sender: TObject);
    procedure TbaddClick(Sender: TObject);
    procedure TbexitClick(Sender: TObject);
    procedure TbeditClick(Sender: TObject);
    procedure dbGrid1DblClick(Sender: TObject);
    procedure TbdelClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    FSql:string;
    FTableId:integer;
    sTablename:string;
    sQueryCode,sFrName:string;
    sCdnSql:string;
    FMemuItem:TMenuItem;
    //Function GetConditionValue(sCondition,sParam:string):string;
    //Function GetStoreIdValue(sCondition,sParam:string):integer;
    //procedure secCondition;
  public
    { Public declarations }
    property  xSql:string read FSql write FSql;
    property  xTableId:integer read FTableId write FTableId;
  end;

var
  InfoNewForm: TInfoNewForm;

implementation

uses datamodule1, CusFile;

{$R *.dfm}

procedure TInfoNewForm.FormShow(Sender: TObject);
var
  tmpStream:TADOBlobStream;
  dLastMonth:TDateTime;
begin
  Application.ProcessMessages;
  dLastMonth:=dataE2.GetLastMonth(date);
  dbGrid1.DataSource :=nil;
  
  //panelCondition1.caption:='  查询条件:[ '+'开单日期: '+dateTostr(dLastMonth)+'至'+dateTostr(date)+' ]';
  // read blob field
  if dataE2.OpenTable('select * from queryModule where id= :id',FTableId) then
  begin
    tmpStream := TADOBlobStream.Create(DataE2.adoQuery1.FieldByName('GridColumns') as TBlobField, bmRead);
    xSql:=dataE2.ADOQuery1.fieldbyname('Sql1').asstring+' '+dataE2.ADOQuery1.fieldbyname('Sql2').asstring;
    sQueryCode:=dataE2.ADOQuery1.fieldbyname('queryCode').asstring;
    //相对应的报表文件名
    sFrName:=dataE2.ADOQuery1.fieldbyname('RptName').asstring;
    dataE2.ADOQuery1.close;  end
  else exit;

  try
    tmpStream.Position :=0;
    try
      dbGrid1.Columns.LoadFromStream(tmpStream);  //load columns from gridcolumns
    except
      dbGrid1.Columns.clear;
    end;
  finally
    tmpStream.Free ;
  end;

  if  fTableId < 90 then
    sCdnSql:=' where Billdate between '''+dateTostr(dLastMonth)+''' and '''+dateTostr(date)+'''' //dateTimeTostr(now)+''''
  else
    sCdnSql:='';

  with dataE2 do
  begin
    if QueryRpt.active then QueryRpt.Close;
    QueryRpt.sql.clear;
    QueryRpt.sql.add(xSql);
    QueryRpt.open;
  end;

  dbGrid1.DataSource :=dataE2.dsRpt;
end;

procedure TInfoNewForm.TbaddClick(Sender: TObject);
begin
  CusFileForm.sStatus:='sInsert';
  CusFileForm.ShowModal;
end;

procedure TInfoNewForm.TbexitClick(Sender: TObject);
begin
  close;
end;

procedure TInfoNewForm.TbeditClick(Sender: TObject);
begin
  CusFileForm.sStatus:='sEdit';
  with dataE2 do
  begin
    if Not QueryRpt.Eof then
    begin
      CusFileForm.nCLIENTID:=QueryRpt.fieldByName('CLIENTID').AsInteger;
      CusFileForm.edtClient.Text:=trim(QueryRpt.fieldByName('ShortName').AsString);
      CusFileForm.edtBuyDate.Text:=trim(QueryRpt.fieldByName('BuyDate').AsVariant);
      CusFileForm.edtMachineID.Text:=trim(QueryRpt.fieldByName('MachineID').AsString);
      CusFileForm.edtCheckNo.Text:=trim(QueryRpt.fieldByName('CheckNo').AsString);
      CusFileForm.edtMotorLabel.Text:=trim(QueryRpt.fieldByName('MotorLabel').AsString);
      CusFileForm.edtSalePrice.Text:=FloatToStr(QueryRpt.fieldByName('SalePrice').AsFloat);
      CusFileForm.ShowModal;
    end;
  end;
end;

procedure TInfoNewForm.dbGrid1DblClick(Sender: TObject);
begin
  Tbedit.Click;
end;

procedure TInfoNewForm.TbdelClick(Sender: TObject);
begin
  if MessageDlg('真的要删除当前记录吗?', mtconfirmation, [mbyes, mbno], 0)=idyes then
  with DataE2.QueryTmp do
  begin
    close;
    SQL.Clear;
    SQL.Add('delete from CusFile where cusFileid=:cusFileid');
    Parameters[0].Value:=DataE2.QueryRpt.fieldByName('cusFileid').AsInteger;
    ExecSQL;
  end;
  DataE2.QueryRpt.Close;
  DataE2.QueryRpt.Open;
end;

procedure TInfoNewForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  dbGrid1.DataSource :=nil;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -