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

📄 ufinance.pas

📁 成本系统三层结构源码 开发工具:Delphi 7.0+SQLServer 2005 主要技术:Midas、COM+ 所用第三方控件: FastReport V2.47 D7 Inforp
💻 PAS
字号:
unit uFinance;

interface

uses
  Windows, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dxExEdtr, ExtCtrls, dxCntner, dxTL, dxDBCtrl, dxDBGrid,
  dxDBTLCl, dxGrClms, StdCtrls, Buttons, Mask, DBCtrls, DB, dxEditor,
  dxEdLib, DateUtils, ImgList, ComCtrls;

type
  Tfmfinance = class(TForm)
    dxDBGrid1: TdxDBGrid;
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    DataSource1: TDataSource;
    Panel2: TPanel;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    DBEdit1: TDBEdit;
    Label2: TLabel;
    DBEdit2: TDBEdit;
    Label3: TLabel;
    DBMemo1: TDBMemo;
    dxDBGrid1CostMonth: TdxDBGridMaskColumn;
    dxSpinEdit1: TdxSpinEdit;
    Label4: TLabel;
    Label5: TLabel;
    Panel3: TPanel;
    Panel4: TPanel;
    BitBtn3: TBitBtn;
    ImageList1: TImageList;
    dxDBGrid1Status: TdxDBGridImageColumn;
    ImageList2: TImageList;
    dxDBGrid1Finished: TdxDBGridImageColumn;
    Label6: TLabel;
    DateTimePicker1: TDateTimePicker;
    BitBtn4: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn1Click(Sender: TObject);
    procedure dxSpinEdit1Change(Sender: TObject);
    procedure DataSource1DataChange(Sender: TObject; Field: TField);
    procedure BitBtn3Click(Sender: TObject);
    procedure dxDBGrid1DblClick(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmfinance: Tfmfinance;

implementation

uses udmcost, udata, SherryLib, udminv;

{$R *.dfm}

procedure Tfmfinance.FormCreate(Sender: TObject);
begin
  DMCost.CFinance.Open;
  dxSpinEdit1.Value:=Yearof(Date);
  dxSpinEdit1.MinValue:=YearOf(SystemStartDate);
  dxSpinEdit1.MaxValue:=YearOf(IncYear(Sys_Time,1));
  DateTimePicker1.DateTime:=Sys_time;
  DMCost.CFinance.Locate('YearNo;MonthNo',VarArrayOf([YearOf(DateTimePicker1.Date),MonthOf(DateTimePicker1.Date)]),[]);
  Log(Self.Caption,'进入'+Self.Caption);  
end;

procedure Tfmfinance.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  DMCost.CFinance.Close;
  Log(Self.Caption,'关闭'+Self.Caption);  
  action:=cafree;
end;

procedure Tfmfinance.BitBtn1Click(Sender: TObject);
begin
  DMCost.CFinance.RefreshRecord;
  if DMCost.CFinance.IsEmpty then
  Warn('会计期间的列表还未生成。');
  if DMCost.CFinance['Finished'] then Abort;
  {if not exists(Format('Select 1 from Invmonth where YearNo=%s and MonthNo=%s',[DMCost.CFinance['YearNo'],DMCost.CFinance['MonthNo']])) then
  Warn(Format('当前期间【%s】的进销存帐还未计算。',[DMCost.CFinance['CostMonth']]));
  if not exists(Format('Select 1 from Costmonth where YearNo=%s and MonthNo=%s',[DMCost.CFinance['YearNo'],DMCost.CFinance['MonthNo']])) then
  Warn(Format('当前期间【%s】的订单总成本还未计算。',[DMCost.CFinance['CostMonth']]));}
  if not Ask(Format('结帐後将不允许再反结帐,当前会计期间【%s】是否结帐?',[DMCost.CFinance['CostMonth']])) then abort;
  Try
    ShowWait;
    Try
      {
      DMINV.CInvMonth.Active:=False;
      DMINV.CInvMonth.Params.ParamValues['@Flag']:=2;
      DMINV.CInvMonth.Params.ParamValues['@Date']:=EnCodeDate(Integer(DMCost.CFinance['YearNo']),Integer(DMCost.CFinance['MonthNo']),1);
      DMINV.CInvMonth.Active:=True;
      }
      DMCost.CStatCost.Active := False;
      DMCost.CStatCost.Params.ParamValues['@Date'] :=EnCodeDate(Integer(DMCost.CFinance['YearNo']),Integer(DMCost.CFinance['MonthNo']),1);
      DMCost.CStatCost.Params.ParamValues['@OrderNo'] := '';
      DMCost.CStatCost.Active := True;
      DMCost.CFinance.Edit;
      DMCost.CFinance['Status']:=True;
      DMCost.CFinance['Finished']:=True;
      DMCost.CFinance['Confirmer']:=GUserName;
      DMCost.CFinance['ConfirmDate']:=Sys_time;
      DMCost.CFinance.ApplyUpdates(0);
      Log(Self.Caption,'结帐会计期间'+String(DMCost.CFinance['CostMonth']));
      HideWait;
      Info('结帐成功!');
    except
      on E:Exception do
      SherryLib.AppException(E);
    End;
  Finally
    HideWait;
  end;
end;

procedure Tfmfinance.dxSpinEdit1Change(Sender: TObject);
var i:integer;
begin
  if not DMCost.CFinance.Locate('YearNo',dxSpinEdit1.Value,[]) then
  For i:=1 to 12 do
  DMCost.CFinance.AppendRecord([nil,dxSpinEdit1.Value,i,False,False,null,null,null]);
end;

procedure Tfmfinance.DataSource1DataChange(Sender: TObject; Field: TField);
begin
  dxDBGrid1.ColumnByFieldName('Finished').ReadOnly:=False; //DMCost.CFinance['Finished'];
  dxDBGrid1.ColumnByFieldName('Status').ReadOnly:=DMCost.CFinance['Finished'];
  DBMemo1.ReadOnly:=DMCost.CFinance['Finished'];
  if DMCost.CFinance['Status'] then BitBtn4.Caption:='解锁' else BitBtn4.Caption:='锁定';
  if DMCost.CFinance['Finished'] then Begin BitBtn1.Enabled:=False; BitBtn4.Enabled:=False end
  else begin BitBtn1.Enabled:=True; BitBtn4.Enabled:=True; End;
end;

procedure Tfmfinance.BitBtn3Click(Sender: TObject);
begin
  Help1('G5');
end;

procedure Tfmfinance.dxDBGrid1DblClick(Sender: TObject);
Var Pwd:String;
begin
  if DMCost.CFinance.IsEmpty then
  Warn('会计期间的列表还未生成。');
  if not DMCost.CFinance['Finished'] then abort;
  Pwd:='';
  if InputPassword('受控功能(反结帐)', '请输入你的密码:   ', Pwd) then
  if MyEncrypt(pwd,Key)=String(Get_Value('Select UpgradePath from SysConfig where ID=1')) then
  Begin
    DMCost.CFinance.Edit;
    DMCost.CFinance['Finished']:=False;
    DMCost.CFinance.ApplyUpdates(0);
  end;
end;

procedure Tfmfinance.BitBtn4Click(Sender: TObject);
begin
  DMCost.CFinance.RefreshRecord;
  if DMCost.CFinance.IsEmpty then
  Warn('会计期间的列表还未生成。');
  if DMCost.CFinance['Finished'] then abort;
  DMCost.CFinance.Edit;
  DMCost.CFinance['Status']:=Not DMCost.CFinance['Status'];
  DMCost.CFinance.ApplyUpdates(0);
  if DMCost.CFinance['Status'] then
    Log(Self.Caption,'锁定会计期间'+String(DMCost.CFinance['CostMonth']))
  else
    Log(Self.Caption,'解锁会计期间'+String(DMCost.CFinance['CostMonth']));    
end;

end.

⌨️ 快捷键说明

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