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

📄 cpccdwh.pas

📁 仓库管理信息系统
💻 PAS
字号:
unit cpccdwh;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FR_DSet, FR_DBSet, FR_Class, Grids, DBGridEh, StdCtrls, Buttons,
  DBCtrls, DBCtrlsEh, Mask, ExtCtrls, ComCtrls, SrchDlg,db;

type
  Tfrm_cpxsdwh = class(TForm)
    GroupBox1: TGroupBox;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    dtp1: TDateTimePicker;
    dtp2: TDateTimePicker;
    Edit1: TEdit;
    GroupBox2: TGroupBox;
    Panel1: TPanel;
    Label1: TLabel;
    Label3: TLabel;
    Label7: TLabel;
    DBEdit1: TDBEdit;
    DBDateTimeEditEh1: TDBDateTimeEditEh;
    Panel3: TPanel;
    DBNavigator1: TDBNavigator;
    DBEdit3: TDBEdit;
    GroupBox3: TGroupBox;
    DBGridEh1: TDBGridEh;
    frReport1: TfrReport;
    frDBDataSet1: TfrDBDataSet;
    frDBDataSet2: TfrDBDataSet;
    Label2: TLabel;
    DBLookupComboBox1: TDBLookupComboBox;
    Label4: TLabel;
    DBLookupComboBox2: TDBLookupComboBox;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    Label5: TLabel;
    DBLookupComboBox3: TDBLookupComboBox;
    Panel2: TPanel;
    DBNavigator2: TDBNavigator;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    BitBtn1: TBitBtn;
    Label11: TLabel;
    sbt: TSpeedButton;
    Label6: TLabel;
    ysd_ckb: TCheckBox;
    rb1: TRadioButton;
    rb2: TRadioButton;
    Label12: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure dtp1Change(Sender: TObject);
    procedure dtp2Change(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure DBGridEh1EditButtonClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure dtp1Enter(Sender: TObject);
    procedure dtp2Enter(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure sbtClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frm_cpxsdwh: Tfrm_cpxsdwh;

implementation
uses data, khzlcz, xsyzl, cpcclx;

{$R *.dfm}

procedure Tfrm_cpxsdwh.FormCreate(Sender: TObject);
var year,month,day:Word;
begin
decodedate(now,year,month,day);
if day>26 then
begin
  dtp1.Date:=EncodeDate(Year,Month,26);
  dtp2.Date:=incmonth(EncodeDate(Year,Month,25),1);
end
else
begin
  if month=1 then
  begin
    dtp1.Date:=EncodeDate(Year-1,12,26);
    dtp2.Date:=EncodeDate(Year,1,25);
  end
  else
  begin
    dtp1.Date:=EncodeDate(Year,Month-1,26);
    dtp2.Date:=EncodeDate(Year,Month,25);
  end;
end;
dm.jzxxbads.Close;
dm.jzxxbads.Open;
dm.jzxxbads.Filter:='结转项目='+''''+'产品'+'''';
dm.jzxxbads.Filtered:=true;
dm.lastjznf:=dm.jzxxbads.fieldbyname('最后年份').Value;
dm.djwhads_cpxsd.Close;
dm.djwhads_cpxsd.Parameters.ParamByName('date1').Value:=dtp1.Date;
dm.djwhads_cpxsd.Parameters.ParamByName('date2').Value:=dtp2.Date;
dm.djwhads_cpxsd.Open;
Label12.Caption:='共有单据:'+
inttostr(dm.djwhads_cpxsd.RecordCount)+'笔';
label11.Caption:='当前可处理年份:'+inttostr(dm.lastjznf);
dm.djwhads_cpxsdmx.Close;
dm.djwhads_cpxsdmx.Open;
dm.zlads_cpcclx.Close;
dm.zlads_cpcclx.Open;
dm.zlads_cpzl.Close;
dm.zlads_cpzl.Open;
dm.zlads_xsyzl.Close;
dm.zlads_xsyzl.Open;
dm.zlads_khzl.Close;
dm.zlads_khzl.Open;
dm.zlads_cpjclx.Close;
dm.zlads_cpjclx.Open;
end;

procedure Tfrm_cpxsdwh.dtp1Change(Sender: TObject);
begin
if dtp1.date>dtp2.Date then
begin
  showmessage('对不起!日期范围有误。');
  dtp1.Date:=dtp2.Date;
end;
dm.djwhads_cpxsd.Close;
dm.djwhads_cpxsd.Parameters.ParamByName('date1').Value:=dtp1.Date;
dm.djwhads_cpxsd.Open;
end;

procedure Tfrm_cpxsdwh.dtp2Change(Sender: TObject);
begin
if dtp1.date>dtp2.Date then
begin
  showmessage('对不起!日期范围有误。');
  dtp2.Date:=dtp1.Date;
end;
dm.djwhads_cpxsd.Close;
dm.djwhads_cpxsd.Parameters.ParamByName('date2').Value:=dtp2.Date;
dm.djwhads_cpxsd.Open;
end;

procedure Tfrm_cpxsdwh.BitBtn1Click(Sender: TObject);
begin
if dm.djwhads_cpxsd.Modified then
  dm.djwhads_cpxsd.Post;
if dm.djwhads_cpxsd.Modified then
  dm.djwhads_cpxsd.Post;
if dm.djwhads_cpxsd.RecordCount=0 then
abort;
if rb1.Checked then
begin
  dm.djwhads_cpxsd.Filter:='单据号='+''''+
    dm.djwhads_cpxsd.fieldbyname('单据号').Value+'''';
  dm.djwhads_cpxsd.Filtered:=true;
end;
if rb2.Checked then
  dm.djwhads_cpxsd.Filtered:=false;
frreport1.LoadFromFile(ExtractFileDir(application.ExeName)+'\djprint\prcpxsd.frf');
  if ysd_ckb.Checked then
    frreport1.ShowReport
  else
  begin
    frreport1.PrepareReport;
    frReport1.PrintPreparedReport('', 1, True, frAll);
  end;
end;

procedure Tfrm_cpxsdwh.DBGridEh1EditButtonClick(Sender: TObject);
begin
  if dbgrideh1.SelectedField.FieldName = '产品id' then
  begin
    if not assigned(SearchDlg) then
      SearchDlg := tSearchDlg.create(self);
    if (SearchDlg.ShowModal = mrOk) and (
      dm.zlads_cpzl.RecordCount>0) then
      if dm.djwhads_cpxsdmx.FieldByName('产品ID').Value <>
        dm.zlads_cpzl.FieldByName('产品ID').Value then
      begin
        dm.djwhads_cpxsdmx.Edit;
        dm.djwhads_cpxsdmx.FieldByName('产品ID').Value :=
          dm.zlads_cpzl.FieldByName('产品ID').Value;
      end;
  end;
end;

procedure Tfrm_cpxsdwh.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
if dm.djwhads_cpxsd.State in [dsinsert,dsedit] then
  if MessageDlg('单据未保存,要保存吗?', mtConfirmation,
    [mbYes, mbNo], 0) = mrYes then
    begin
    dm.djwhads_cpxsd.Post;
    end
  else
    dm.djwhads_cpxsd.Cancel;
action := cafree;
frm_cpxsdwh:=nil;
end;

procedure Tfrm_cpxsdwh.dtp1Enter(Sender: TObject);
begin
  if dm.djwhads_cpxsd.State in [dsedit,dsinsert] then
  begin
    showmessage('对不起!当前单据编辑中...请先处理。');
    abort;
  end;
end;

procedure Tfrm_cpxsdwh.dtp2Enter(Sender: TObject);
begin
  if dm.djwhads_cpxsd.State in [dsedit,dsinsert] then
  begin
    showmessage('对不起!当前单据编辑中...请先处理。');
    abort;
  end;
end;

procedure Tfrm_cpxsdwh.SpeedButton1Click(Sender: TObject);
begin
    if not assigned(frm_khzlcz) then
      frm_khzlcz := tfrm_khzlcz.create(self);
    if (frm_khzlcz.ShowModal = mrOk) and (
      dm.zlads_khzl.RecordCount>0) then
      if dm.djwhads_cpxsd.FieldByName('客户ID').Value <>
        dm.zlads_khzl.FieldByName('客户ID').Value then
      begin
        dm.djwhads_cpxsd.Edit;
        dm.djwhads_cpxsd.FieldByName('客户ID').Value :=
          dm.zlads_khzl.FieldByName('客户ID').Value;
      end;
end;

procedure Tfrm_cpxsdwh.SpeedButton2Click(Sender: TObject);
begin
  if dm.djwhads_cpxsd.State in [dsedit,dsinsert] then
  begin
    showmessage('对不起!当前单据编辑中...请先处理。');
    abort;
  end;
  if not dm.djwhads_cpxsd.Locate('单据号',edit1.Text,[]) then
  begin
    showmessage('没有你要查找的单据号');
    edit1.SetFocus;
    abort;
  end;
end;

procedure Tfrm_cpxsdwh.SpeedButton3Click(Sender: TObject);
begin
if not Assigned(frm_xsyzl) then
  frm_xsyzl := tfrm_xsyzl.Create(Self);
  frm_xsyzl.ShowModal;
if (dm.zlads_xsyzl.RecordCount>0) then
  if dm.djwhads_cpxsd.FieldByName('销售员ID').Value <>
    dm.zlads_xsyzl.FieldByName('销售员ID').Value then
    begin
      dm.djwhads_cpxsd.Edit;
      dm.djwhads_cpxsd.FieldByName('销售员ID').Value:=
        dm.zlads_xsyzl.FieldByName('销售员ID').Value;
    end;
end;

procedure Tfrm_cpxsdwh.SpeedButton4Click(Sender: TObject);
begin
if not assigned(frm_cclxwh) then
  frm_cclxwh := tfrm_cclxwh.create(self);
  frm_cclxwh.showmodal;
if (dm.zlads_cpcclx.RecordCount>0) then
  if dm.djwhads_cpxsd.FieldByName('出仓类型ID').Value <>
    dm.zlads_cpcclx.FieldByName('出仓类型ID').Value then
    begin
      dm.djwhads_cpxsd.Edit;
      dm.djwhads_cpxsd.FieldByName('出仓类型ID').Value:=
        dm.zlads_cpcclx.FieldByName('出仓类型ID').Value;
    end;
end;

procedure Tfrm_cpxsdwh.sbtClick(Sender: TObject);
begin
groupbox1.Visible:=not groupbox1.Visible;
if groupbox1.Visible then
begin
  sbt.Caption:='▼';
  sbt.hint:='隐藏条件框';
end
else
begin
  sbt.Caption:='▲';
  sbt.hint:='展开条件框';
end;
end;

end.

⌨️ 快捷键说明

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