unit U_fssb;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, Dialogs, StdCtrls, DBGridEh, Buttons, ExtCtrls,
  DBLookupEh, DBCtrlsEh, RzEdit, Mask ,UntDataBaseTGDZC;
type
  Tfrm_fssb=class(TForm)
    GroupBox2: TGroupBox;
    Panel1: TPanel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label4: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    zcbm: TRzEdit;
    zcmc: TRzEdit;
    ggxh: TRzEdit;
    gzrq: TRzEdit;
    zcly: TRzEdit;
    zczz: TRzEdit;
    djrq: TDBDateTimeEditEh;
    bz: TRzMemo;
    pcid: TRzEdit;
    pjmc: TRzEdit;
    pjgg: TRzEdit;
    dj: TRzNumericEdit;
    sl: TrzNumericEdit;
    je: TrzNumericEdit;
    jldw: TDBComboBoxEh;
    gys: TDBLookupComboboxEh;
    exit: TSpeedButton;
    save: TSpeedButton;
    helpbtn: TSpeedButton;
    procedure FormShow(Sender : TObject);
    procedure djChange(Sender : TObject);
    procedure saveClick(Sender : TObject);
    procedure exitClick(Sender : TObject);
    procedure helpbtnClick(Sender : TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    FFSSB :Tfssb;
    FiZcInfoID: Integer;
    FiAddorEdit: Integer;
    procedure SetiAddorEdit(const Value: Integer);
    procedure SetiZcInfoID(const Value: Integer);
    { Private declarations }
  public
    { Public declarations }
    property iAddorEdit :Integer read FiAddorEdit write SetiAddorEdit;
    property iZcInfoID :Integer read FiZcInfoID write SetiZcInfoID;
    procedure QueryInfo(m_ZCID :Integer);    
  end ;

var
  frm_fssb: Tfrm_fssb;

implementation

uses DataModuleU;

{$R *.DFM}

procedure Tfrm_fssb.FormShow(Sender : TObject);
begin
///
end;

procedure Tfrm_fssb.djChange(Sender : TObject);
begin
  je.Value := sl.Value * dj.Value;
end;

procedure Tfrm_fssb.saveClick(Sender : TObject);
var
  m_bOK :Boolean;
begin
  FFSSB.Ppjbh := pcid.Text ;
  FFSSB.Ppjmc := pjmc.Text ;
  FFSSB.Pxhgg := pjgg.Text ;
  FFSSB.Pjldw := jldw.Text ;
  FFSSB.Pgys := gys.Text ;
  FFSSB.Pdj := dj.Value ;
  FFSSB.Psl := sl.IntValue ;
  FFSSB.Pje := je.Value ;
  FFSSB.Pdjrq := djrq.Value ;
  FFSSB.Pbz := bz.Text ;
  case FiAddorEdit of
    0: m_bOK := FFSSB.InsertIntoTable;
    1: m_bOK := FFSSB.UpdateTable;
  else ;
  end;
  if m_bOK then
  begin
    Application.MessageBox('保存成功!', '系统提示', MB_OK + 
      MB_ICONINFORMATION);
    ModalResult := mrOk;
  end;    
end;

procedure Tfrm_fssb.exitClick(Sender : TObject);
begin
  Close;
end;

procedure Tfrm_fssb.helpbtnClick(Sender : TObject);
begin
Application.MessageBox('帮助文档正在制作中……', '系统提示', MB_OK + 
  MB_ICONINFORMATION);
end;

procedure Tfrm_fssb.SetiAddorEdit(const Value: Integer);
begin
  FiAddorEdit := Value;
end;

procedure Tfrm_fssb.SetiZcInfoID(const Value: Integer);
begin
  FiZcInfoID := Value;
  QueryInfo(FiZcInfoID);
end;

procedure Tfrm_fssb.QueryInfo(m_ZCID: Integer);
begin
  FFSSB.Pid := m_ZCID;
  if FFSSB.FindRecorder(True) then
  begin
    pcid.Text := FFSSB.Ppjbh;
    pjmc.Text := FFSSB.Ppjmc;
    pjgg.Text := FFSSB.Pxhgg;
    jldw.Text := FFSSB.Pjldw;
    gys.Text := FFSSB.Pgys;
    dj.Value := FFSSB.Pdj;
    sl.Value := FFSSB.Psl;
    je.Value := FFSSB.Pje;
    djrq.Value := FFSSB.Pdjrq;
    bz.Text := FFSSB.Pbz;
  end;
end;

procedure Tfrm_fssb.FormCreate(Sender: TObject);
begin
  djrq.Value := Now;
  DmFrm.OpenAdoquery('select mc from zd_jldw');
  DmFrm.AQ.First;
  while not DmFrm.AQ.Eof do
  begin
    jldw.Items.Add(DmFrm.AQ.FieldByName('mc').AsString);
    DmFrm.AQ.Next;
  end;
  DmFrm.gys.Open;
  FFSSB := Tfssb.Create(DmFrm.gdzccon);
end;

procedure Tfrm_fssb.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  FFSSB.Free;
end;

end.