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

📄 saleitemcha_unit.~pas

📁 餐营的数据核算,模拟入库,出库,库存.对餐营的流程详细叙述
💻 ~PAS
字号:
unit SALEITEMCHA_Unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, DbChart, Series,teeprevi,
  DB, ADODB;

type
  TSALEITEMCHA_Form = class(TForm)
    DBChart1: TDBChart;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    ComboBox3: TComboBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label5: TLabel;
    ComboBox4: TComboBox;
    Label6: TLabel;
    ComboBox5: TComboBox;
    Series1: TFastLineSeries;
    PDADOQ: TADOQuery;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure ComboBox3Exit(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SALEITEMCHA_Form: TSALEITEMCHA_Form;

implementation

uses DMUnit;

{$R *.dfm}

procedure TSALEITEMCHA_Form.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
Action:=cafree;
end;

procedure TSALEITEMCHA_Form.FormCreate(Sender: TObject);
begin
  with DM.LIRUN_ADOQ do
  begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT * FROM LCBASE');
    Open;
  end;
  while not DM.LIRUN_ADOQ.Eof do
  begin
    Combobox1.Items.Add(DM.LIRUN_ADOQ.FieldByName('LC_CARNO').AsString);
    DM.LIRUN_ADOQ.Next;
  end;
  with DM.LIRUN_ADOQ do
  begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT * FROM CLASS_ITEM');
    Open;
  end;
  while not DM.LIRUN_ADOQ.Eof do
  begin
    Combobox2.Items.Add(DM.LIRUN_ADOQ.FieldByName('CLASS_NAME').AsString);
    DM.LIRUN_ADOQ.Next;
  end;
  with DM.LIRUN_ADOQ do
  begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT DISTINCT ITEM_MARKS FROM LCITEM_ITEM');
    Open;
  end;
  while not DM.LIRUN_ADOQ.Eof do
  begin
    Combobox3.Items.Add(DM.LIRUN_ADOQ.FieldByName('ITEM_MARKS').AsString);
    DM.LIRUN_ADOQ.Next;
  end;
end;

procedure TSALEITEMCHA_Form.ComboBox3Exit(Sender: TObject);
begin
  if Combobox3.ItemIndex>=0 then
  begin
    with DM.LIRUN_ADOQ do
    begin
      Close;
      SQL.Clear;
      SQL.Add('SELECT ITEM_NAME FROM LCITEM_ITEM WHERE ITEM_MARKS='''+Combobox3.Text+'''');
      OPen;
    end;
    while not DM.LIRUN_ADOQ.Eof do
    begin
      Combobox4.Items.Add(DM.LIRUN_ADOQ.FieldByName('ITEM_NAME').AsString);
      DM.LIRUN_ADOQ.Next;
    end;
  end;
end;

procedure TSALEITEMCHA_Form.Button2Click(Sender: TObject);
begin
chartpreview(self,dbchart1);
end;

procedure TSALEITEMCHA_Form.Button3Click(Sender: TObject);
begin
  Combobox1.Items.Clear;
  Combobox2.Items.Clear;
  Combobox3.Items.Clear;
  Combobox4.Items.Clear;
  Combobox4.ItemIndex:=-1;
  with DM.LIRUN_ADOQ do
  begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT * FROM LCBASE');
    Open;
  end;
  while not DM.LIRUN_ADOQ.Eof do
  begin
    Combobox1.Items.Add(DM.LIRUN_ADOQ.FieldByName('LC_CARNO').AsString);
    DM.LIRUN_ADOQ.Next;
  end;
  with DM.LIRUN_ADOQ do
  begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT * FROM CLASS_ITEM');
    Open;
  end;
  while not DM.LIRUN_ADOQ.Eof do
  begin
    Combobox2.Items.Add(DM.LIRUN_ADOQ.FieldByName('CLASS_NAME').AsString);
    DM.LIRUN_ADOQ.Next;
  end;
  with DM.LIRUN_ADOQ do
  begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT DISTINCT ITEM_MARKS FROM LCITEM_ITEM');
    Open;
  end;
  while not DM.LIRUN_ADOQ.Eof do
  begin
    Combobox3.Items.Add(DM.LIRUN_ADOQ.FieldByName('ITEM_MARKS').AsString);
    DM.LIRUN_ADOQ.Next;
  end;
end;

procedure TSALEITEMCHA_Form.Button1Click(Sender: TObject);
var
  S,P:string;
begin
  if Combobox1.ItemIndex<0 then
  begin
    ShowMessage('请选择车次!');
    Exit;
  end;
  if Combobox2.ItemIndex<0 then
  begin
    ShowMessage('请选择班组!');
    Exit;
  end;
  if Combobox3.ItemIndex<0 then
  begin
    ShowMessage('请选择菜谱!');
  end;
  if Combobox4.ItemIndex<0 then
  begin
    ShowMessage('请选择产品名称!');
    Exit;
  end;
  if Combobox5.ItemIndex<0 then
  begin
    ShowMessage('请选择年度!');
    Exit;
  end;
  S:='SELECT S.ITEM_CARNO,S.ITEM_BZ,LCI.ITEM_NAME,SUM(S.ITEM_MON) AS ITEM_MON,YEAR(S.ITEM_DATE) AS YEARD,MONTH(S.ITEM_DATE) AS MONTHD '+
     'FROM SALE S LEFT JOIN LCITEM_ITEM LCI ON LCI.ITEM_NO=S.ITEM_NO WHERE 2>1 ';
  P:='GROUP BY ITEM_CARNO,ITEM_BZ,LCI.ITEM_NAME,YEAR(ITEM_DATE),MONTH(ITEM_DATE)';
  if Combobox1.ItemIndex>=0 then
    S:=S+' AND S.ITEM_CARNO='''+Combobox1.Text+'''';
  if Combobox2.ItemIndex>=0 then
    S:=S+' AND S.ITEM_BZ='''+Combobox2.Text+'''';
  if Combobox3.ItemIndex>=0 then
    S:=S+' AND LCI.ITEM_MARKS='''+Combobox3.Text+'''';
  if Combobox4.ItemIndex>=0 then
    S:=S+' AND LCI.ITEM_NAME='''+Combobox4.Text+'''';
  if Combobox5.ItemIndex>=0 then
    S:=S+' AND YEAR(S.ITEM_DATE)='''+Combobox5.Text+'''';
  with PDADOQ do
  begin
    Close;
    SQL.Clear;
    SQl.Add(S+p);
    open;
  end;
  if PDADOQ.RecordCount<=0 then
  begin
    ShowMessage('没有相应的统计数据!');
    Exit;
  end;
  with DM.SALEITEM_ADOQ do
  begin
    Close;
    SQL.Clear;
    SQL.Add(S+P);
    Open;
  end;
end;

end.

⌨️ 快捷键说明

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