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

📄 dailyproductstatfrm.~pas

📁 相关的销售服务管理行业的一个软件
💻 ~PAS
字号:
unit DailyProductStatFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StatFrameFrm, Db, ADODB, ActnList, Grids, DBGridEh, StdCtrls, ExtCtrls,
  Buttons, ComCtrls, jpeg, EHGrids;

type
  TDailyProductStatForm = class(TStatFrameForm)
    Label1: TLabel;
    ADOQuery1DSDesigner: TWideStringField;
    ADOQuery1DSDesigner4: TWideStringField;
    ADOQuery1DSDesigner5: TFloatField;
    ADOQuery1DSDesigner6: TFloatField;
    Label4: TLabel;
    cbStoreName: TComboBox;
    ADOQuery2: TADOQuery;
    procedure AExecExecute(Sender: TObject);
    procedure cbStoreNameChange(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure AReviewExecute(Sender: TObject);
    procedure APrintExecute(Sender: TObject);
  private
    FStoreName: string;
    procedure SetStoreName(const Value: string);
    { Private declarations }
  protected
    procedure InitInterface; override;
    procedure InitCondition; override;
    procedure CreateConditionString; override;
  public
    { Public declarations }
    property StoreName: string read FStoreName write SetStoreName;
  end;

var
  DailyProductStatForm: TDailyProductStatForm;

implementation

uses U_DM, import1;

{$R *.DFM}

{ TDailyProductStatForm }
const AllStoreInfo = '<<全部>>';

procedure TDailyProductStatForm.InitInterface;
  procedure SetStoreNameList(StoreNameList: TStrings);
  begin
    StoreNameList.Clear;
    StoreNameList.Add(AllStoreInfo);
    with ADOQuery2 do
    begin
      Close;
      SQL.Clear;
      SQL.Add(' SELECT * FROM s_customer ');
      SQL.Add(' ORDER BY ncname ');
      Open;
    end;
    if ADOQuery2.RecordCount>0 then
    begin
      while not ADOQuery2.Eof do                                             
      begin
        StoreNameList.Add(ADOQuery2.FieldByName('ncName').asstring);
        ADOQuery2.Next;
      end;//while
    end;//if
  end;//function
begin
  inherited;
  SetStoreNameList(cbStoreName.Items);
//  cbStoreName.ItemIndex := 0;
end;

procedure TDailyProductStatForm.InitCondition;
begin
  inherited;
  StoreName := AllStoreInfo;
  ColumnIndex := 4;
  IsASCOrder := false;
end;

procedure TDailyProductStatForm.CreateConditionString;
var
  sBeginDate,sEndDate,sStoreStype,sStoreName: string;
begin
  inherited;
  sBeginDate := DateToStr(BeginDate);
  sEndDate   := DateToStr(EndDate);


  if not StypeIsEnabled then
    sStoreStype := '%'
  else
    if StoreStype=AllStypeInfo then
      sStoreStype := '%'
    else
      sStoreStype := StoreStype;

  if StoreName=AllStoreInfo then
    sStoreName := '%'
  else
    sStoreName := StoreName;

  if DTPEnd.Checked then
    ConditionString := ' WHERE  xs_rbm.rbdate<= '''+sEndDate+''''+
                       '  AND  s_customer.ncname LIKE '''+sStoreName+'''';
//                       '  AND  xs_store.type LIKE '''+sStoreStype+'''';
  if DTPBegin.Checked then
    ConditionString := ' WHERE xs_rbm.rbdate>= '''+sBeginDate+''''+
                       '  AND  s_customer.ncnamee LIKE '''+sStoreName+'''';
//                       '  AND  xs_store.type LIKE '''+sStoreStype+'''';
  if DTPBegin.Checked and DTPEnd.Checked then
    ConditionString := ' WHERE xs_rbm.drbDate>= '''+sBeginDate+''''+
                       '  AND  xs_rbm.drbDate<= '''+sEndDate+''''+
                       '  AND  s_customer.ncname LIKE '''+sStoreName+'''';
//                     '  AND  xs_store.type LIKE '''+sStoreStype+'''';
  if not DTPBegin.Checked and not DTPEnd.Checked then
    ConditionString := ' WHERE  s_customer.ncname LIKE '''+sStoreName+'''';
//                    '  AND
//                       xs_store.type LIKE '''+sStoreStype+''''+
//  ShowMessage(ConditionString);
end;

procedure TDailyProductStatForm.AExecExecute(Sender: TObject);
begin
  inherited;
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add(' SELECT dbo.xs_rbd.sgoodno AS 产品编码,               ');
    //SQL.Add('        dbo.Js_product1.Style_num AS 款式,                        ');
    //SQL.Add('        dbo.Js_product1.XuanZi_num AS 楦型,                       ');
    SQL.Add('        dbo.xs_rbd.scolor AS 颜色,                             ');
    SQL.Add('        SUM(dbo.xs_rbd.amount) AS 数量,                    ');
    SQL.Add('        SUM(dbo.xs_rbd.ntotal) AS 金额                    ');
    SQL.Add(' FROM dbo.xs_rbd INNER JOIN                               ');
    SQL.Add('      dbo.xs_rbm ON                                       ');
    SQL.Add('      dbo.xs_rbd.id = dbo.xs_rbm.sxsrbno INNER JOIN ');
    SQL.Add('      dbo.s_customer ON                                                        ');
    SQL.Add('      dbo.xs_rbm.sclientno = dbo.s_customer.nccode     ');
    SQL.Add(ConditionString);
    SQL.Add(' GROUP BY dbo.xs_rbd.sgoodno, dbo.xs_rbd.scolor       ');
    Open;
    Sort := SortString;
  end;

end;

////////////////////////////////////////////////////////////////////////////////
procedure TDailyProductStatForm.SetStoreName(const Value: string);
begin
  FStoreName := Value;
  if Value=AllStoreInfo then
    StypeIsEnabled := true
  else
    StypeIsEnabled := false;
  if cbStoreName.Text<>Value then
    cbStoreName.ItemIndex := cbStoreName.Items.IndexOf(Value);
end;

procedure TDailyProductStatForm.cbStoreNameChange(Sender: TObject);
begin
  inherited;
  StoreName := cbStoreName.Text;
  AExec.OnExecute(nil);
end;

procedure TDailyProductStatForm.FormDestroy(Sender: TObject);
begin
  inherited;
  DailyProductStatForm := nil;
end;

procedure TDailyProductStatForm.AReviewExecute(Sender: TObject);
begin
  inherited;
  CreateReport(Application.Handle,DM.ADOConnection.ConnectionString,'304',
   nil,TAdoQuery(DataSource1.DataSet),false)      ;
end;

procedure TDailyProductStatForm.APrintExecute(Sender: TObject);
begin
  inherited;
  CreateReport(Application.Handle,DM.ADOConnection.ConnectionString,'304',
    nil,TAdoQuery(DataSource1.DataSet),true)      ;
end;

end.

⌨️ 快捷键说明

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