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

📄 uclientinfo.pas

📁 天涯進銷存系統
💻 PAS
字号:
unit uClientinfo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Grids, LBDBGrid, StdCtrls, LBCtrls, LBDBCtrls,
  ActnList, DBCtrls, FR_DSet, FR_DBSet, FR_Class, LBDBScrollBar;

type
  TfrmClientinfo = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    Panel5: TPanel;
    ActionList1: TActionList;
    Action1: TAction;
    Action2: TAction;
    Action3: TAction;
    Action5: TAction;
    Action6: TAction;
    Action4: TAction;
    Action7: TAction;
    Action8: TAction;
    Report: TfrReport;
    ReportDataSet: TfrDBDataSet;
    Panel7: TPanel;
    Image1: TImage;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    Panel9: TPanel;
    Panel11: TPanel;
    DataDBGrid: TLBDBGrid;
    Panel6: TPanel;
    Shape1: TShape;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    DBText1: TDBText;
    DBText2: TDBText;
    DBText3: TDBText;
    Label21: TLabel;
    DBText4: TDBText;
    plData: TPanel;
    Shape21: TShape;
    Shape20: TShape;
    Shape19: TShape;
    Shape18: TShape;
    Shape17: TShape;
    Shape16: TShape;
    Shape15: TShape;
    Shape2: TShape;
    Label1: TLabel;
    Shape3: TShape;
    Shape4: TShape;
    Shape5: TShape;
    Shape6: TShape;
    Shape7: TShape;
    Shape8: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Label6: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label5: TLabel;
    Label15: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label16: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label7: TLabel;
    Label17: TLabel;
    LBDBEdit1: TLBDBEdit;
    LBDBEdit2: TLBDBEdit;
    LBDBEdit3: TLBDBEdit;
    LBDBEdit4: TLBDBEdit;
    LBDBEdit5: TLBDBEdit;
    LBDBEdit6: TLBDBEdit;
    LBDBEdit7: TLBDBEdit;
    LBDBEdit8: TLBDBEdit;
    LBDBEdit9: TLBDBEdit;
    LBDBEdit10: TLBDBEdit;
    LBDBEdit11: TLBDBEdit;
    LBDBEdit12: TLBDBEdit;
    LBDBEdit13: TLBDBEdit;
    LBDBEdit14: TLBDBEdit;
    LBDBEdit15: TLBDBEdit;
    LBDBEdit16: TLBDBEdit;
    LBDBNumberEdit1: TLBDBNumberEdit;
    LBDBEdit18: TLBDBEdit;
    LBDBComboBox1: TLBDBComboBox;
    CancelButton: TLBButton;
    EnterButton: TLBButton;
    LBDBScrollBar1: TLBDBScrollBar;
    LBSpeecButton2: TLBSpeecButton;
    LBSpeecButton1: TLBSpeecButton;
    LBSpeecButton3: TLBSpeecButton;
    LBSpeecButton4: TLBSpeecButton;
    LBSpeecButton5: TLBSpeecButton;
    LBSpeecButton6: TLBSpeecButton;
    PrepayPanel: TPanel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Shape26: TShape;
    PrepaySumEdit: TLBDBNumberEdit;
    ArrearageSumEdit: TLBDBNumberEdit;
    REIMBURSESUMEdit: TLBDBNumberEdit;
    procedure FormShow(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Action2Execute(Sender: TObject);
    procedure Action1Execute(Sender: TObject);
    procedure Action3Execute(Sender: TObject);
    procedure Action5Execute(Sender: TObject);
    procedure Action6Execute(Sender: TObject);
    procedure Action4Execute(Sender: TObject);
    procedure Action7Execute(Sender: TObject);
    procedure Action8Execute(Sender: TObject);
    procedure LBDBEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DataDBGridKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormDestroy(Sender: TObject);
    procedure LBDBComboBox1Enter(Sender: TObject);
    procedure LBDBEdit18KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure REIMBURSESUMEditKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
    procedure SetView;
  public
    { Public declarations }
  end;

var
  frmClientinfo: TfrmClientinfo;
  isStateEdit, isEdit: Boolean;
  OldCode: string;


implementation

uses uDataMo, uPublicvar, uMain, uConst;

{$R *.dfm}

procedure TFrmClientInfo.SetView;
begin
  DataDBGrid.Enabled:=not DataDBGrid.Enabled;
  plData.Enabled:=not plData.Enabled;

  Action1.Enabled:=not Action1.Enabled;
  Action2.Enabled:=not Action2.Enabled;
  Action3.Enabled:=not Action3.Enabled;
  Action4.Enabled:=not Action4.Enabled;
  Action5.Enabled:=not Action5.Enabled;
  Action6.Enabled:=not Action6.Enabled;
  Action7.Enabled:=not Action7.Enabled;
  Action8.Enabled:=not Action8.Enabled;

  EnterButton.Visible:=not EnterButton.Visible;
  CancelButton.Visible:=not CancelButton.Visible;
end;

procedure TfrmClientinfo.FormShow(Sender: TObject);
begin
  SetView;
  OpenData('select * from Clientinfo', dmData.sdsClientinfo);
  isStateEdit:=False;
end;

procedure TfrmClientinfo.FormActivate(Sender: TObject);
begin
  GetWindowsItem(Caption, Self);
end;

procedure TfrmClientinfo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
  frmClientinfo:=Nil;
end;


procedure TfrmClientinfo.Action1Execute(Sender: TObject);
begin
  SetView;
  PrepayPanel.Visible:=True;
  LBDBEdit1.SetFocus;
  with dmData.sdsClientinfo do
  begin
    Append;
    FieldByName('Del').asstring:='0';
    FieldByName('PrepaySum').asfloat:=0;
    FieldByName('ArrearageSum').asfloat:=0;
    FieldByName('PaymentSum').asfloat:=0;
    FieldByName('REIMBURSESUM').asfloat:=0;
  end;  
  OldCode:='';
  isEdit:=False;
  isStateEdit:=True;
end;

procedure TfrmClientinfo.Action2Execute(Sender: TObject);
begin
  if dmData.sdsClientinfo.IsEmpty then
  begin
    Application.MessageBox(NotEditData, Hintinfo,$30);
    Exit;
  end;
  SetView;
  LBDBEdit1.SetFocus;
  dmData.sdsClientinfo.Edit;
  OldCode:=dmData.sdsClientinfo.Fieldbyname('Code').asstring ;
  isEdit:=True;
  isStateEdit:=True;
end;

procedure TfrmClientinfo.Action3Execute(Sender: TObject);
begin
  DeleteData(dmData.sdsClientinfo, True);
end;

procedure TfrmClientinfo.Action5Execute(Sender: TObject);
begin
  FindData(dmData.sdsClientinfo, '客户资料查询', 'Clientinfo');
end;

procedure TfrmClientinfo.Action6Execute(Sender: TObject);
begin
  OpenData('select * from Clientinfo', dmData.sdsClientinfo);
end;

procedure TfrmClientinfo.Action4Execute(Sender: TObject);
begin
  PrintView('RepClientinfo.frf', Report);
end;

procedure TfrmClientinfo.Action7Execute(Sender: TObject);
var
  BillCode: string;
begin
  if Trim(LBDBEdit1.Text)='' then
  begin
    Application.MessageBox('请输入客户编号。', HintInfo,$30);
    LBDBEdit1.SetFocus;
    Exit;
  end;
  if Trim(LBDBEdit2.Text)='' then
  begin
    Application.MessageBox('请输入客户名称。',HintInfo,$30);
    LBDBEdit2.SetFocus;
    Exit;
  end;
  if isExist('ClientInfo', 'Code', Trim(LBDBEdit1.Text), OldCode, '') then
  begin
    Application.MessageBox('此客户编号已存在,请重新输入。',HintInfo,$30);
    LBDBEdit1.SetFocus;
    Exit; 
  end;
  //如果有期初金额
  dmData.sdsClientinfo.Post;
  with  dmData.sdsClientinfo do
  begin
  if (isEdit=False) and
  ((FieldByName('PrepaySum').AsFloat>0) or
   (FieldByName('ArrearageSum').AsFloat>0) or
   (FieldByName('REIMBURSESUM').AsFloat>0) ) then
  begin
    if Application.MessageBox('你输入有期初金额,确定这些金额正确吗?',Hintinfo, $24)=idYes then
    begin
      Edit;
      FieldByName('PaymentSum').AsFloat:=
      FieldByName('ArrearageSum').AsFloat-FieldByName('PrepaySum').AsFloat-FieldByName('REIMBURSESUM').AsFloat;
      FieldByName('Del').asString:='1';
      if FieldByName('ArrearageSum').AsFloat>0 then
      begin
        BillCode:=ComDepotCode+'-'+'QS'+'-'+
        GetBillID('50', DateToStr(Date));
        with dmData.SQLQuery do
        begin
          Close;
          Sql.Clear;
          Sql.Text:='insert into PartsOutputHand '+
                    '(BILLCODE, BILLDATE, CLIENTCODE, CLIENTNAME, TOTALSUM, AcceptSum, Agiosum, '+
                    'ISACCEPT, ISAUDITING, OUTPUTTYPE) values('+
                    #39+BillCode+#39+','+#39+DateToStr(Date)+#39+','+
                    #39+Trim(LBDBEdit1.Text)+#39+','+
                    #39+Trim(LBDBEdit2.Text)+#39+','+
                    FloatToStr(dmData.sdsClientinfo.FieldByName('ArrearageSum').AsFloat)+',0,0,'+
                    #39+'0'+#39+','+#39+'1'+#39+','+#39+'3'+#39+')';
          ExecSql;
        end;  
      end;
      if FieldByName('REIMBURSESUM').AsFloat>0 then
      begin
        BillCode:=ComDepotCode+'-'+'QT'+'-'+
        GetBillID('51', DateToStr(Date));
        with dmData.SQLQuery do
        begin
          Close;
          Sql.Clear;
          Sql.Text:='insert into REIMBURSEBILLHAND '+
                    '(BILLCODE, BILLDATE, PROVIDERCODE, PROVIDERNAME, TOTALSUM, '+
                    'ISACCEPT, ISAUDITING, REIMBURSETYPE) values('+
                    #39+BillCode+#39+','+#39+DateToStr(Date)+#39+','+
                    #39+Trim(LBDBEdit1.Text)+#39+','+
                    #39+Trim(LBDBEdit2.Text)+#39+','+
                    FloatToStr(dmData.sdsClientinfo.FieldByName('REIMBURSESUM').AsFloat)+','+
                    #39+'0'+#39+','+#39+'1'+#39+','+#39+'4'+#39+')';
          ExecSql;
        end;
      end;
    end
    else
      Exit;
  end;
  ApplyUpdates(-1);
  end;
  if not isEdit then
  begin
    LBDBEdit1.SetFocus;
    with dmData.sdsClientinfo do
    begin
      Append;
      FieldByName('Del').asstring:='0';
      FieldByName('PrepaySum').asfloat:=0;
      FieldByName('ArrearageSum').asfloat:=0;
      FieldByName('PaymentSum').asfloat:=0;
      FieldByName('REIMBURSESUM').asfloat:=0;
    end;  
  end
  else
  begin
    SetView;
    isStateEdit:=False;
    PrepayPanel.Visible:=False;
  end;
end;

procedure TfrmClientinfo.Action8Execute(Sender: TObject);
begin
  if dmData.sdsClientinfo.Modified then
  begin
    if Application.MessageBox(OnCancelEdit,HintInfo,$24)=idYes then
    begin
      dmData.sdsClientinfo.CancelUpdates;
      PrepayPanel.Visible:=False;
      SetView;
    end;
  end
  else
  begin
    dmData.sdsClientinfo.CancelUpdates;
    PrepayPanel.Visible:=False;
    SetView;
  end;
  isStateEdit:=False;
end;

procedure TfrmClientinfo.LBDBEdit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key=13 then  Perform(WM_NEXTDLGCTL,0,0);
end;

procedure TfrmClientinfo.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key=27 then Close;
end;

procedure TfrmClientinfo.DataDBGridKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (key=VK_NEXT) or (key=VK_Down) then
    if dmData.sdsClientinfo.Eof then
       dmData.sdsClientinfo.GetNextPacket;
end;

procedure TfrmClientinfo.FormDestroy(Sender: TObject);
begin
  WindowItem.Delete(WindowItem.IndexOfObject(Self)); 
end;

procedure TfrmClientinfo.LBDBComboBox1Enter(Sender: TObject);
begin
  SetListData('select Name from Elseinfo where Code='''+'1''', LBDBComboBox1);
end;

procedure TfrmClientinfo.LBDBEdit18KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key=13 then Action7Execute(Sender);
end;

procedure TfrmClientinfo.REIMBURSESUMEditKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if key=13 then Action7Execute(Sender);
end;

end.

⌨️ 快捷键说明

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