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

📄 lscgcx.pas

📁 本系统前端界面采用WINDOWS 窗口风格
💻 PAS
字号:
unit lscgcx;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, Db, DBTables, ExtCtrls, StdCtrls, Grids, DBGrids, Buttons;

type
  Tfrmlscgcx = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label5: TLabel;
    SpeedButton3: TSpeedButton;
    DBGrid1: TDBGrid;
    ListBox1: TListBox;
    Panel1: TPanel;
    Label3: TLabel;
    Label4: TLabel;
    Label6: TLabel;
    SpeedButton1: TSpeedButton;
    wpbm_edit: TEdit;
    pm_edit: TEdit;
    BitBtn4: TBitBtn;
    BitBtn6: TBitBtn;
    Edit_ghs: TEdit;
    Query_cg1: TQuery;
    DataSource_cg: TDataSource;
    Query_ckxx: TQuery;
    Query_zero: TQuery;
    Database: TDatabase;
    Label7: TLabel;
    dtpFrom: TDateTimePicker;
    Label8: TLabel;
    dtpTo: TDateTimePicker;
    Shape1: TShape;
    Label9: TLabel;
    lblHj: TLabel;
    BitBtn1: TBitBtn;
    Query_cg1bh: TStringField;
    Query_cg1pm: TStringField;
    Query_cg1gg: TStringField;
    Query_cg1dw: TStringField;
    Query_cg1jj: TFloatField;
    Query_cg1jhrq: TDateTimeField;
    Query_cg1ph: TStringField;
    Query_cg1cd: TStringField;
    Query_cg1ck_bh: TStringField;
    Query_cg1wp_bm: TStringField;
    Query_cg1ghs_mc: TStringField;
    Query_cg1je: TFloatField;
    Query_cg1hsj: TFloatField;
    Query_cg1bz: TIntegerField;
    Query_cg2: TQuery;
    Query_cg2bh: TStringField;
    Query_cg2pm: TStringField;
    Query_cg2gg: TStringField;
    Query_cg2dw: TStringField;
    Query_cg2jj: TFloatField;
    Query_cg2jhrq: TDateTimeField;
    Query_cg2ph: TStringField;
    Query_cg2ck_bh: TStringField;
    Query_cg2cd: TStringField;
    Query_cg2wp_bm: TStringField;
    Query_cg2ghs_mc: TStringField;
    Query_cg2je: TFloatField;
    Query_cg2hsj: TFloatField;
    Query_cg1sl: TFloatField;
    Query_cg2sl: TFloatField;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
    procedure BitBtn6Click(Sender: TObject);
    procedure Query_cg1CalcFields(DataSet: TDataSet);
    procedure BitBtn1Click(Sender: TObject);
    procedure Query_cg2CalcFields(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmlscgcx: Tfrmlscgcx;
  cArrNumOfStore:array[0..25] of string;

implementation 

uses ghs, main, lscgrep;

{$R *.DFM}

procedure Tfrmlscgcx.SpeedButton1Click(Sender: TObject);
begin
  Frmghs:=TFrmghs.create(Self);
  Frmmain.pubedit:=Edit_ghs;
  Frmghs.ShowModal;
end;

procedure Tfrmlscgcx.FormCreate(Sender: TObject);
var i:integer;
begin
  dtpFrom.date:=now;
  dtpTo.date:=now;
  i:=0;
  Query_ckxx.close;
  Query_ckxx.sql.Clear;
  Query_ckxx.sql.Add('select * from ckxxb');
  Query_ckxx.open;
  Query_ckxx.First;
  while not Query_ckxx.Eof do
    begin
      listbox1.Items.Add(Query_ckxx.fieldbyname('ck_mc').asstring);
      cArrNumOfStore[i]:=Query_ckxx.fieldbyName('ck_bh').asString;
      inc(i);
      Query_ckxx.Next;
    end;
  listbox1.ItemIndex:=0;
  listbox1click(self);
end;

procedure Tfrmlscgcx.ListBox1Click(Sender: TObject);
var total:real;
begin
  if listbox1.Items[listbox1.ItemIndex]<>'中药库' then begin
    datasource_cg.DataSet:=query_cg1;
    total:=0;
    wpbm_edit.Clear;
    pm_edit.Clear;
    edit_ghs.Clear;
    with Query_cg1 do begin
      DisableControls;
      close;
      UnPrepare;
      sql.Clear;
      SQL.Add('select * from cgxxb');
      sql.Add('where jhrq between :d1');
      sql.add('and :d2');
      sql.add('and ck_bh='''+cArrNumOfStore[listbox1.itemindex]+'''');
      sql.Add(' order by jhrq');
      parambyname('d1').asstring:=datetostr(dtpFrom.date);
      parambyname('d2').asstring:=datetostr(dtpTo.date);
      Prepare;
      open;
      if not (bof and eof) then begin
         first;
         while not Eof do begin
           total:=total+fieldbyname('je').asfloat;
           next;
         end;
         lblHj.Caption:=floattostr(total);
      end else begin
         lblHj.Caption:='0.00';
      end;
      EnableControls;
    end;
  end else begin
    datasource_cg.DataSet:=query_cg2;
    total:=0;
    wpbm_edit.Clear;
    pm_edit.Clear;
    edit_ghs.Clear;
    with Query_cg2 do begin
      DisableControls;
      close;
      UnPrepare;
      sql.Clear;
      sql.Add('select * from cgxxb');
      sql.Add('where jhrq between :d1');
      sql.add('and :d2');
      sql.add('and ck_bh='''+cArrNumOfStore[listbox1.itemindex]+'''');
      sql.Add(' order by jhrq');
      parambyname('d1').asstring:=datetostr(dtpFrom.date);
      parambyname('d2').asstring:=datetostr(dtpTo.date);
      Prepare;
      open;
      if not (bof and eof) then begin
         first;
         while not Eof do begin
           total:=total+fieldbyname('je').asfloat;
           next;
         end;
         lblHj.Caption:=floattostr(total);
      end else begin
         lblHj.Caption:='0.00';
      end;
      EnableControls;
    end;
  end;
end;

procedure Tfrmlscgcx.BitBtn6Click(Sender: TObject);
var total:real;
begin
  if listbox1.Items[listbox1.ItemIndex]<>'中药库' then begin
    datasource_cg.DataSet:=query_cg1;
    total:=0;
    with Query_cg1 do begin
      DisableControls;
      close;
      UnPrepare;
      sql.Clear;
      SQL.Add('select * from cgxxb');
      if wpbm_edit.Text<>'' then
        sql.Add(' where wp_bm like'+''''+wpbm_edit.Text+'%'+'''');
      if (wpbm_edit.text<>'') and (pm_edit.Text<>'') then
        sql.Add(' and pm like'+''''+'%'+pm_edit.Text+'%'+'''')
      else if pm_edit.Text<>'' then
        sql.Add(' where pm like'+''''+'%'+pm_edit.Text+'%'+'''');
      if ((wpbm_edit.text<>'') or (pm_edit.Text<>'')) and (edit_ghs.Text<>'') then
        sql.Add(' and ghs_mc like'+''''+'%'+edit_ghs.Text+'%'+'''')
      else if Edit_ghs.Text<>'' then
        sql.Add(' where ghs_mc like'+''''+'%'+edit_ghs.Text+'%'+'''');
      if (wpbm_edit.Text='') and (pm_edit.Text='') and (edit_ghs.Text='') then
        sql.Add('where jhrq between :d1')
      else
        sql.Add('and jhrq between :d1');
      sql.Add('and :d2');
      sql.add('and ck_bh='''+cArrNumOfStore[listbox1.itemindex]+'''');
      sql.Add(' order by jhrq');
      parambyname('d1').asstring:=datetostr(dtpFrom.date);
      parambyname('d2').asstring:=datetostr(dtpTo.date);
      Prepare;
      open;
      if not (bof and eof) then begin
         first;
         while not Eof do begin
           total:=total+fieldbyname('je').asfloat;
           next;
         end;
         lblHj.Caption:=floattostr(total);
      end else begin
         lblHj.Caption:='0.00';
      end;
      EnableControls;
    end;
  end else begin
    datasource_cg.DataSet:=query_cg2;
    total:=0;
    with Query_cg2 do begin
      DisableControls;
      close;
      UnPrepare;
      sql.Clear;
      SQL.Add('select * from cgxxb');
      if wpbm_edit.Text<>'' then
        sql.Add(' where wp_bm like'+''''+wpbm_edit.Text+'%'+'''');
      if (wpbm_edit.text<>'') and (pm_edit.Text<>'') then
        sql.Add(' and pm like'+''''+'%'+pm_edit.Text+'%'+'''')
      else if pm_edit.Text<>'' then
        sql.Add(' where pm like'+''''+'%'+pm_edit.Text+'%'+'''');
      if ((wpbm_edit.text<>'') or (pm_edit.Text<>'')) and (edit_ghs.Text<>'') then
        sql.Add(' and ghs_mc like'+''''+'%'+edit_ghs.Text+'%'+'''')
      else if Edit_ghs.Text<>'' then
        sql.Add(' where ghs_mc like'+''''+'%'+edit_ghs.Text+'%'+'''');
      if (wpbm_edit.text='') and (pm_edit.text='') and (edit_ghs.text='') then
        sql.Add('where jhrq between :d1')
      else
        sql.Add('and jhrq between :d1');
      sql.Add('and :d2');
      sql.add('and ck_bh='''+cArrNumOfStore[listbox1.itemindex]+'''');
      sql.Add(' order by jhrq');
      parambyname('d1').asstring:=datetostr(dtpFrom.date);
      parambyname('d2').asstring:=datetostr(dtpTo.date);
      Prepare;
      open;
      if not (bof and eof) then begin
         first;
         while not Eof do begin
           total:=total+fieldbyname('je').asfloat;
           next;
         end;
         lblHj.Caption:=floattostr(total);
      end else begin
         lblHj.Caption:='0.00';
      end;
      EnableControls;
    end;
  end;
end;

procedure Tfrmlscgcx.Query_cg1CalcFields(DataSet: TDataSet);
begin
  with query_cg1 do begin
    fieldbyname('je').asfloat:=fieldbyname('jj').asfloat*fieldbyname('sl').asfloat;
    if listbox1.Items[listbox1.ItemIndex]='中药库' then
      fieldbyname('hsj').asfloat:=round((fieldbyname('jj').asfloat*1.13)*10000)/10000
    else
      fieldbyname('hsj').asfloat:=round((fieldbyname('jj').asfloat*1.17)*10000)/10000;
  end;
end;

procedure Tfrmlscgcx.BitBtn1Click(Sender: TObject);
begin
  if listbox1.Items[listbox1.ItemIndex]<>'中药库' then begin
    frmlscgrep.QuickRep1.DataSet:=query_cg1;
    frmlscgrep.QRDBText_pm.DataSet:=query_cg1;
    frmlscgrep.QRDBText_gg.DataSet:=query_cg1;
    frmlscgrep.QRDBText_dw.DataSet:=query_cg1;
    frmlscgrep.QRDBText_sl.DataSet:=query_cg1;
    frmlscgrep.QRDBText_jj.DataSet:=query_cg1;
    frmlscgrep.QRDBText_je.DataSet:=query_cg1;
    frmlscgrep.QRDBText_bz.DataSet:=query_cg1;
    frmlscgrep.QRDBText_ph.DataSet:=query_cg1;
    frmlscgrep.QRDBText_cd.DataSet:=query_cg1;
    frmlscgrep.QRDBText_hsj.DataSet:=query_cg1;
    frmlscgrep.Qrlabel_fhdw.Caption:=edit_ghs.Text;
    frmlscgrep.Qrlabel_czy.Caption:=frmmain.name;
    frmlscgrep.Qrlabel_shdw.Caption:=listbox1.Items[listbox1.itemindex];
    frmlscgrep.Qrlabel_hj.Caption:=format('¥%.2f',[strtofloat(lblHj.Caption)]);
    frmlscgrep.Qrlabel_rq.Caption:=formatdatetime('yyyy"年"mm"月"dd"日"',dtpFrom.date)+' 至 '+formatdatetime('yyyy"年"mm"月"dd"日"',dtpTo.date);
    frmlscgrep.Quickrep1.Page.Length:=168+28*query_cg1.RecordCount;
    frmlscgrep.Quickrep1.Prepare;
    frmlscgrep.Quickrep1.print;
  end else begin
    frmlscgrep.QuickRep1.DataSet:=query_cg2;
    frmlscgrep.QRDBText_pm.DataSet:=query_cg2;
    frmlscgrep.QRDBText_gg.DataSet:=query_cg2;
    frmlscgrep.QRDBText_dw.DataSet:=query_cg2;
    frmlscgrep.QRDBText_sl.DataSet:=query_cg2;
    frmlscgrep.QRDBText_jj.DataSet:=query_cg2;
    frmlscgrep.QRDBText_bz.DataSet:=nil;
    frmlscgrep.QRDBText_je.DataSet:=query_cg2;
    frmlscgrep.QRDBText_ph.DataSet:=query_cg2;
    frmlscgrep.QRDBText_cd.DataSet:=query_cg2;
    frmlscgrep.QRDBText_hsj.DataSet:=query_cg2;
    frmlscgrep.Qrlabel_fhdw.Caption:=edit_ghs.Text;
    frmlscgrep.Qrlabel_czy.Caption:=frmmain.name;
    frmlscgrep.Qrlabel_shdw.Caption:=listbox1.Items[listbox1.itemindex];
    frmlscgrep.Qrlabel_hj.Caption:=format('¥%.2f',[strtofloat(lblHj.Caption)]);
    frmlscgrep.Qrlabel_rq.Caption:=formatdatetime('yyyy"年"mm"月"dd"日"',dtpFrom.date)+' 至 '+formatdatetime('yyyy"年"mm"月"dd"日"',dtpTo.date);
    frmlscgrep.Quickrep1.Page.Length:=168+28*query_cg2.RecordCount;
    frmlscgrep.Quickrep1.Prepare;
    frmlscgrep.Quickrep1.print;
  end;
end;

procedure Tfrmlscgcx.Query_cg2CalcFields(DataSet: TDataSet);
begin
  with query_cg2 do begin
    fieldbyname('je').asfloat:=fieldbyname('jj').asfloat*fieldbyname('sl').asfloat;
    if listbox1.Items[listbox1.ItemIndex]='中药库' then
      fieldbyname('hsj').asfloat:=round((fieldbyname('jj').asfloat*1.13)*10000)/10000
    else
      fieldbyname('hsj').asfloat:=round((fieldbyname('jj').asfloat*1.17)*10000)/10000;
  end;
end;

end.

⌨️ 快捷键说明

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