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

📄 w_more.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{
财务模块
write by Lqiao at 2004-02-29
}
unit w_more;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, Grids,Mask, ExtCtrls, ComCtrls, DB, DBClient,variants;

const
     w_form1:array[0..2]of string=('费用项目编号','费用项目名称','金额');
     w_form2:array[0..2]of string=('费用项目编号','费用项目名称','金额');
     w_form3:array[0..2]of string=('收入项目编号','收入项目名称','收入金额');
     w_form7:array[0..2]of string=('支款帐户编号','支款帐户名称','支款金额');
     w_form8:array[0..2]of string=('费用项目编号','摊销转移的费用项目名称','金额');

type
  Tw_morefm = class(TForm)
    Panel2: TPanel;
    BitBtn2: TBitBtn;
    Panel3: TPanel;
    Label13: TLabel;
    TotalMoneyTb: TLabel;
    Panel4: TPanel;
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label7: TLabel;
    BtnSelPayComponey: TSpeedButton;
    Label9: TLabel;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit6: TEdit;
    Panel5: TPanel;
    SuperDataGrid1: TStringGrid;
    StringGrid1: TStringGrid;
    Label24: TLabel;
    CheckEdit: TEdit;
    BtnSelCheck: TSpeedButton;
    Label4: TLabel;
    EditDoman: TEdit;
    BtnSelDoman: TSpeedButton;
    Label25: TLabel;
    BillEEdit: TEdit;
    Label6: TLabel;
    Edit5: TEdit;
    BtnSelPayAccount: TSpeedButton;
    MaskEdit1: TDateTimePicker;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    cdsdata: TClientDataSet;
    bitcheck: TBitBtn;
    procedure BitBtn2Click(Sender: TObject);
    procedure SuperDataGrid1EditButtonClick(Sender: TObject);
    procedure BtnSelPayComponeyClick(Sender: TObject);
    procedure SuperDataGrid1AfterEdit(Sender: TObject; col, row: Integer);
    procedure FormShow(Sender: TObject);
    procedure BtnSelCheckClick(Sender: TObject);
    procedure Edit3Enter(Sender: TObject);
    procedure SuperDataGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure SuperDataGrid1BeforeEdit(Sender: TObject; col, row: Integer);
    procedure Edit3KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure EditDomanKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure SuperDataGrid1DblClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BtnSelPayAccountClick(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure SuperDataGrid1KeyPress(Sender: TObject; var Key: Char);
    procedure SuperDataGrid1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure BtnSelDomanClick(Sender: TObject);
    procedure bitcheckClick(Sender: TObject);
  private
    bRed:boolean;
    lNumberID,czShowMode,szEnterText,szUnitId:string;
    lnewNumberId,lbilltype:integer;
    szBillEId,szPassEId,szCheckEId,szAccountId2,szAccountName2,szAccountId,szAccountName,
    szUserCode,szUserCode2:string;
    procedure RefreshTotal;
    function CheckGrid(bCheckAll:boolean=true):integer ;
    function ShowAccountWin(row:integer):integer;
    procedure FormClear;
    procedure FormShowMode;
    procedure ReadData;
    function writeMainBill: integer;
    function writeDetailBill: integer;
    function DeleteBill(billId:string):integer;
    function SaveDraft: boolean;
    procedure RefreshGrid;
    procedure RefreshTitle;
 private
     { Private declarations }
     editmode:integer;
     BIllid:integer;
  public
      w_formid:integer;
    { Public declarations }
  end;

var
   w_morefm: Tw_morefm;
procedure w_skBill(czShowMode,lNumberID:String;formid:integer;bRedWord:Boolean);

implementation

uses ExitInfo, AccountSelect, Supply_Monad, Login_Man,
  func, untdatadm, Data, UntSQpspart;

{$R *.DFM}

procedure w_skBill(czShowMode,lNumberID:String;formid:integer;bRedWord:Boolean);
begin
  w_morefm:=Tw_morefm.Create(nil);
  w_morefm.czShowMode:=czShowMode;
  if czShowMode='Edit' then
  begin

    w_morefm.editmode:=1;
  end else
  begin
    w_morefm.editmode:=0;
  end;
  w_morefm.lNumberID:=lNumberID;
  w_morefm.bRed:=bRedWord;
  w_morefm.w_formid:=formid;
  w_morefm.BillEEdit.Text:=trim(Handle_Man);
  w_morefm.CheckEdit.Text:=trim(Handle_Man);
  try
    w_morefm.ShowModal;
  finally
    w_morefm.Free;
  end;
end;

procedure Tw_morefm.FormShowMode;
begin
  if czShowMode ='Edit' then
  begin
    edit2.Enabled:=False;
    edit3.Enabled:=False;
    EditDoman.Enabled:=False;
    edit5.Enabled:=False;
    edit6.Enabled:=False;
    CheckEdit.Enabled:=False;
    maskedit1.Enabled:=False;
    BtnSelDoman.Enabled:=False;
    BtnSelPayComponey.Enabled:=False;
    BtnSelPayAccount.Enabled:=False;
    BtnSelCheck.Enabled:=False;
    ReadData;
    RefreshTotal;
   end;



end;

procedure tw_morefm.ReadData;
var
  sql:widestring;
  datas:olevariant;
begin
  cdsdata.close;
  cdsdata.data:=null;
  datas:=null;
  sql:='select * from MainTable where BillCode='+''''+trim(lNumberID)+'''';
  try
    datas:=adisp.execsql(sql);
    if not varisnull(datas) then
    begin
      cdsdata.data:=datas;
      cdsdata.open;
      billid:=cdsdata.fieldbyname('billid').AsInteger;
    end;
    RefreshTitle;
  except
  end;
   cdsdata.close;
  cdsdata.data:=null;
  datas:=null;
  sql:='select *,(select UserCode from AccountTable where AccountId=a.AccountId) as UserCode from financebill a where BillId='+inttostr(billid)+' order by ord';
  try
    datas:=adisp.execsql(sql);
    if not varisnull(datas) then
    begin
      cdsdata.data:=datas;
      cdsdata.open;
    end;
  except
  end;
  RefreshGrid;
end;

procedure tw_morefm.RefreshTitle;
begin     //根据基本信息表把Title值取出来,并更新单元内的相应变量。由于基本信息单元不全,暂不写这部分。
  edit3.Text:=cdsdata.fieldbyname('unitname').AsString;
  edit2.Text:=cdsdata.fieldbyname('billcode').AsString;
  maskedit1.Date :=cdsdata.fieldbyname('billdate').AsDateTime;
  //edit5.Text:=cdsdata.fieldbyname('billdate').AsString;
  edit6.Text:=cdsdata.fieldbyname('Explain').AsString;
  checkedit.Text:=cdsdata.fieldbyname('checkeid').AsString;
  editdoman.Text:=cdsdata.fieldbyname('passeid').AsString;
  BILLeedit.Text:=cdsdata.fieldbyname('billeid').AsString;
  szUnitId:=trim(cdsdata.fieldbyname('Unitid').AsString);
end;

procedure tw_morefm.RefreshGrid;
var i:integer;
begin
  if SuperDataGrid1.RowCount+2<= cdsdata.RecordCount then
     SuperDataGrid1.RowCount:=cdsdata.RecordCount+5;
  i:=1;
  while not cdsdata.Eof do
     begin
        SuperDataGrid1.Cells[1,i]:=trim(cdsdata.fieldbyname('UserCode').AsString);
        SuperDataGrid1.Cells[2,i]:=trim(cdsdata.fieldbyname('AccountName').AsString);
        SuperDataGrid1.Cells[3,i]:=trim(cdsdata.fieldbyname('Total').AsString);
        SuperDataGrid1.Cells[4,i]:=trim(cdsdata.fieldbyname('Comment').AsString);
        cdsdata.Next;
        inc(i);
     end;
  cdsdata.First;
  szAccountId2:=trim(cdsdata.fieldbyname('AccountId2').AsString);
  szAccountName2:=trim(cdsdata.fieldbyname('AccountName2').AsString);
  for i:=1 to SuperDataGrid1.RowCount -1 do
  begin
    if czShowMode='Edit' then
    begin
      szAccountId:=trim(SuperDataGrid1.Cells[2,i]);
      ShowAccountWin(i);
    end;
  end;
  edit5.Text:=szAccountName2;
end;


procedure Tw_morefm.FormClear;
begin
  edit2.text := '';
  edit3.text := '';
  EditDoman.text := '';
  edit6.text := '';
  edit5.text:='现  金';
  //Checkedit.Text:='';
  clearGrid(SuperDataGrid1);
  if czShowMode='' then//录新单
    begin
      Edit2.Text:='';
    end;
  maskedit1.Date:=date;
  totalmoneytb.Caption := '0.00';

  if maskedit1.CanFocus then maskedit1.SetFocus
  else if Edit2.CanFocus then edit2.SetFocus;
end;

procedure Tw_morefm.RefreshTotal;
var
 i: integer;
 n:double;
begin
  totalMoneytb.Caption:='0.00';
    for i := 1 to superDataGrid1.RowCount do
    begin
      if SuperDataGrid1.Cells[1,i] <> '' then
         begin
           if not TryStrToFloat(SuperDataGrid1.Cells[3,i],n) then SuperDataGrid1.Cells[3,i]:='0';
           TotalMoneyTb.Caption := FloatToStr(StrtoFloat(TotalMoneytb.caption)+StrtoFloat(SuperDataGrid1.Cells[3,i]));
         end;
    end;
end;

function Tw_morefm.ShowAccountWin(row:integer):integer;
var i:string;
begin
{     00000                   会计科目
     0000100004              银行账户
     0000100002              固定资产
     0000300003              其他收入
     0000400003              费用合计       }
  if czShowMode<>'Edit' then
  begin
  i:='';
  if w_formid=1 then  szAccountId:='0000400003';
  if w_formid in [2,6,9] then  szAccountId:='0000400003';
  if w_formid in [3,7,8] then  szAccountId:='0000300003';
  if w_formid=4 then  begin szAccountId:='00001';i:='1';end;
  if w_formid=5 then  begin szAccountId:='0000400003';end;
  if AccountSelectShow(szUserCode,szAccountId,szAccountName,i)=1 then
     begin
       SuperDataGrid1.Cells[1,row]:=  szUserCode;
       SuperDataGrid1.Cells[2,row]:=  szAccountName;
       StringGrid1.Cells[1,row]   :=  szAccountId;
       result:=0;
     end;
  end else
  begin
    StringGrid1.Cells[1,row]   :=  szAccountId;
  end;
end;

function Tw_morefm.CheckGrid(bCheckAll:boolean=true):integer ;
var i:integer;
begin
 if strtofloat(TotalMoneyTb.Caption)=0 then
    begin
      application.messagebox('还没有录入数据!',pchar(application.title),mb_iconinformation);
      Result:=-1;
      exit;
    end;
 for i:=1 to SuperDataGrid1.RowCount-1 do
    begin
      if ((SuperDataGrid1.Cells[1,i]<>'') or (SuperDataGrid1.Cells[2,i]<>'')
           or (SuperDataGrid1.Cells[3,i]<>'') or (SuperDataGrid1.Cells[4,i]<>''))
      and (StringGrid1.Cells[1,i]='') then
          begin
             application.messagebox(pchar('第'+inttostr(i)+'行数据错误,请重新选择!'),pchar(application.title),mb_iconinformation);
             Result:=-1;
             exit;
          end;
    end;
 if (EditDoman.text='') then
    begin
       showmessage('数据不完整,请录入经手人!');
       //EditDoman.SetFocus;
       Result:=-1;
       exit;
    end;
  if (CheckEdit.text='')  then
    begin
       showmessage('数据不完整,请录入审核人!');
       //CheckEdit.SetFocus;
       Result:=-1;
       exit;
    end;
    if ((Edit5.text='') or (szAccountId2='')) and (Edit5.Visible=true) then
    begin
       showmessage('数据不完整,请录入'+label6.Caption+'!');
      // Edit5.SetFocus;
       Result:=-1;
       exit;
    end;
   if (Edit3.text='') or (szUnitId='') then
    begin
       showmessage('数据不完整,请录入'+label6.Caption+'!');
       //Edit5.SetFocus;
       Result:=-1;
       exit;
    end;

 result:=0;
end;


procedure Tw_morefm.BitBtn2Click(Sender: TObject);
  var
  tempModalResult :TModalResult;
  szSql:string;
  nret:integer;
begin
  if czShowmode <> 'ReadOnly' then  //只读直接退出
  begin
    tempModalResult := Exitinfowin;
    case tempModalResult of
        mrCancel : begin            //返回
                     abort;
                   end;
        mrAbort  : begin            //废弃退出
                     close;
                   end;
        mrOk     : begin            //过帐
                     if SaveDraft then
                        begin
                           nret:=ipubtemp.EditMoney(lnewNumberId,'');
                           if nRet=-1 then
                              begin
                                 DeleteBill(inttostr(lnewNumberId));
                                 Showmessage('过帐失败');
                              end;
                        end
                        else
                        begin

                        end;
                     end;
       mrRetry  : begin            //存草稿
                      if not SaveDraft then exit;
                   end;
    end;
  end;
end;

procedure Tw_morefm.SuperDataGrid1EditButtonClick(Sender: TObject);
begin
  if czShowMode = 'ReadOnly' then exit;
  if (superdatagrid1.Col <> 1) and (superdatagrid1.Col <> 2) then  exit
  else  ShowAccountWin(superdatagrid1.row);
end;

procedure Tw_morefm.BtnSelPayComponeyClick(Sender: TObject);
var
  czText: string;
begin
  if czShowMode = 'ReadOnly' then exit;
  if not (w_formid in [4,5]) then
  begin
    edit3.SetFocus;
    Check_Mond:='DW-0001';
    frm_Supply_Monad:=Tfrm_Supply_Monad.Create(self);
    frm_Supply_Monad.Caption:='【付款单位】';
    frm_Supply_Monad.ShowModal;
    frm_Supply_Monad.Free;
    edit3.Text:=Trim(check_Mond_Result);
    szUnitId:=trim(wldwno);
  end else
  begin
    dlgSQpspart:=tdlgSQpspart.Create(self);
    dlgSQpspart.Caption:='选择部门';
    dlgSQpspart.ShowModal;
    dlgSQpspart.Free;
    if dmmain.CDSdata.IsEmpty  then exit;
    edit3.Text:=trim(dmmain.CDSdata.fieldbyname('part_name').AsString);
    szUnitId:=trim(dmmain.CDSdata.fieldbyname('part_no').AsString);
  end;
end;

procedure Tw_morefm.SuperDataGrid1AfterEdit(Sender: TObject; col,
  row: Integer);
begin
  if Row =0 then Exit;
  RefreshTotal;
  if (col=1)  or (col=2) then
  begin
    if  (SuperDataGrid1.cells[1,row]='') and (SuperDataGrid1.Cells[2,row]='') then exit;
      if SuperDataGrid1.Cells[col,row]='' then
      begin
       RefreshTotal;
      end;
      RefreshTotal;
      exit;

    if ShowAccountWin(SuperDataGrid1.row)=0 then
    begin
       RefreshTotal;
       Exit;
    end
    else
      szEnterText:=SuperDataGrid1.Cells[SuperDataGrid1.col,SuperDataGrid1.row];
  end;

  RefreshTotal;
end;


procedure Tw_morefm.FormShow(Sender: TObject);
var
  recno:integer;
  sqls,make:string;
begin
   szUnitId :='0000100001';//住来单位编号
  szBillEId:='0000100001';//制单人编号
  szPassEId:='0000100001';//经手人编号
  szCheckEId:='0000100001';//审核人编号
  RefreshOrd(SuperDataGrid1);
  superdatagrid1.Cells[0,0]:='序号';
  superdatagrid1.Cells[4,0]:='备注';
  FormClear;
  case w_formid of
   1:  begin
        superdatagrid1.Cells[1,0]:=w_form1[0] ;
        superdatagrid1.Cells[2,0]:=w_form1[1] ;

⌨️ 快捷键说明

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