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

📄 pd.pas

📁 晓风财务软件源码,具有财务软基本功能,仅供学习,勿商用,后果与本人无关 1、使用的第三方VCL: FastReport2.6中文版 EHLIB3 sncCurrency SUIPac
💻 PAS
📖 第 1 页 / 共 2 页
字号:

  if (Key=#13) and (g.SelectedField.FieldName='Name') then
  begin
    ChangeGridCol(2);
    Exit;
  end;

  if (Key=#32) and (g.SelectedField.FieldName='Name') then
  begin
    if not CanEdit then Exit;
    GetMem(d,1000);
    if Frm_CodeInput(DM.adoc,'V_SubSubject','ID','Code_PinYin','Code_WuBi','CodeLongSubjectName','Used',@id,d)=mrOK then
    begin
      t.Edit;
      t.FieldByName('Subject_id').AsInteger:=id;
      t.FieldByName('Name').AsString:=d;
      t.FieldByName('CodeLongSubjectName').AsString:=d;
      t.Post;
    end;
    FreeMem(d,1000);
    ChangeGridCol(2);
    EditChange;
    Exit;
  end;

  if (key<>chr(9)) and CheckCurrencyField(g.SelectedField.FieldName) then
  begin
    sncDBCurrencyInplaceEdit.SetFocus;
    SendMessage(sncDBCurrencyInplaceEdit.Handle, WM_Char, WORD(Key), 0);
  end;
end;

procedure TFrmPD.editFJExit(Sender: TObject);
begin
  TsuiEdit(Sender).Text:='0'+TsuiEdit(Sender).Text;
  TsuiEdit(Sender).Text:=IntToStr(StrToInt(TsuiEdit(Sender).Text));
end;

procedure TFrmPD.FormShow(Sender: TObject);
begin
  tbCalc.Enabled:=false;

  t.Connection:=DM.adoc;
  tq.Connection:=DM.adoc;
  qPDAll.Connection:=DM.adoc;

  Deleted:=false;
  Edited:=false;
  Added:=false;
  EditSubjected:=false;

  qPDAll.Close;
  qPDAll.SQL.Clear;
  qPDAll.SQL.Add('select [Year],[Month],Number,RecNo from Credence where RecNo=1 order by [Year],[Month],Number');
  qPDAll.Open;

  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('select * into #TempSubject from V_Subject where IsHasSubSubject=0');
  tq.ExecSQL;

  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('select * into #TempPD from V_Credence where 1=2');
  tq.ExecSQL;

  t.Close;
  t.TableName:='#TempPD';
  t.Open;
  t.Sort:='RecNo';

  if DefaultNum<>-1 then
  begin
    qPDAll.Locate('Year;Month;Number',VarArrayOf([DefaultYear,DefaultMonth,DefaultNum]),[loPartialKey]);
    GoPD(qPDAll.RecNo);
  end
  else
    NewPD;
end;

procedure TFrmPD.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  qPDAll.Close;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('drop table #TempPD');
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('drop table #TempSubject');
  tq.ExecSQL;
  t.Close;
end;

procedure TFrmPD.gColumns1EditButtonClick(Sender: TObject; var Handled: Boolean);
var
  fes:TFrmEditSubject;
begin
  if not CanEdit then Exit;

  fes:=TFrmEditSubject.Create(self);
  fes.CanEdit:=CanEditSubject;
  fes.CanSelect:=true;
  fes.ShowModal;
  if not EditSubjected then EditSubjected:=fes.isEdited;
  if fes.SelectID<>-1 then
  begin
    t.Edit;
    t.FieldByName('Subject_id').AsInteger:=fes.SelectID;
    t.FieldByName('Name').AsString:=fes.SelectCodeLongSubjectName;
    t.FieldByName('CodeLongSubjectName').AsString:=fes.SelectCodeLongSubjectName;
    t.Post;
  end;
  fes.Destroy;
  ChangeGridCol(2);
  EditChange;
end;

procedure TFrmPD.gColumns0EditButtonClick(Sender: TObject;
  var Handled: Boolean);
var
  id:integer;
  d:pChar;
begin
  if not CanEdit then Exit;
  GetMem(d,1000);
  if Frm_CodeInput(DM.adoc,'Summary','ID','Code_PinYin','Code_WuBi','Name','Used',@id,d)=mrOK then
  begin
    t.Edit;
    t.FieldByName('Summary').AsString:=d;
    t.Post;
  end;
  FreeMem(d,1000);
  ChangeGridCol(1);
  EditChange;
end;

procedure TFrmPD.Label1MouseEnter(Sender: TObject);
begin
  TLabel(Sender).Font.Color:=clRed;
end;

procedure TFrmPD.Label1MouseLeave(Sender: TObject);
begin
  TLabel(Sender).Font.Color:=clBlue;
end;

procedure TFrmPD.Label1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TLabel(Sender).Top:=TLabel(Sender).Top+1;
  TLabel(Sender).Left:=TLabel(Sender).Left+1;
end;

procedure TFrmPD.Label1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TLabel(Sender).Top:=TLabel(Sender).Top-1;
  TLabel(Sender).Left:=TLabel(Sender).Left-1;
end;

procedure TFrmPD.Label1Click(Sender: TObject);
begin
  if not CanEdit then Exit;
  Frm_EditDictTable(DM.adoc,'Summary','Name','Code_PinYin','Code_WuBi','Used');
end;

procedure TFrmPD.gCellClick(Column: TColumnEh);
begin
  if CanEdit then EditChange;
end;

procedure TFrmPD.tbAddRowClick(Sender: TObject);
var
  Summary:string;
begin
  if not CanEdit then Exit;
  Summary:=t.FieldByName('Summary').AsString;
  t.Append;
  t.FieldByName('RecNo').AsInteger:=t.RecordCount+1;
  t.FieldByName('Summary').AsString:=Summary;
  t.Post;
  ChangeGridCol(0);
  EditChange;
end;

procedure TFrmPD.tbInsertRowClick(Sender: TObject);
var
  Summary:string;
  CurrentRecNo:integer;
begin
  if not CanEdit then Exit;
  Summary:=t.FieldByName('Summary').AsString;
  CurrentRecNo:=t.FieldByName('RecNo').AsInteger;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempPD set RecNo=RecNo+1 where RecNo>='+IntToStr(CurrentRecNo));
  tq.ExecSQL;
  tq.Close;
  t.Append;
  t.FieldByName('RecNo').AsInteger:=CurrentRecNo;
  t.FieldByName('Summary').AsString:=Summary;
  t.Post;
  t.Requery;
  g.SumList.RecalcAll;
  ChangeGridCol(0);
  EditChange;
end;

procedure TFrmPD.tbDeleteRowClick(Sender: TObject);
var
  CurrentRecNo:integer;
begin
  if not CanEdit then Exit;
  CurrentRecNo:=t.FieldByName('RecNo').AsInteger;
  t.Delete;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempPD set RecNo=RecNo-1 where RecNo>'+IntToStr(CurrentRecNo));
  tq.ExecSQL;
  tq.Close;
  t.Requery;
  g.SumList.RecalcAll;
  EditChange;
end;

procedure TFrmPD.tbSwapClick(Sender: TObject);
var
  tm:Currency;
begin
  if not CanEdit then Exit;
  tm:=t.FieldByName('J_Money').AsCurrency;
  t.Edit;
  t.FieldByName('J_Money').AsCurrency:=t.FieldByName('D_Money').AsCurrency;
  t.FieldByName('D_Money').AsCurrency:=tm;
  t.Post;
  EditChange;
end;

procedure TFrmPD.tbBalanceClick(Sender: TObject);
var
  m:Currency;
begin
  if not CanEdit then Exit;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('select Sum(J_Money) as J,Sum(D_Money) as D from #TempPD where RecNo<>'+IntToStr(t.RecNo));
  tq.Open;
  m:=tq.FieldByName('J').AsCurrency-tq.FieldByName('D').AsCurrency;
  tq.Close;
  t.Edit;
  t.FieldByName('J_Money').AsCurrency:=0;
  t.FieldByName('D_Money').AsCurrency:=0;
  t.Post;
  if m=0 then Exit;
  t.Edit;
  if m>0 then t.FieldByName('D_Money').AsCurrency:=m;
  if m<0 then t.FieldByName('J_Money').AsCurrency:=-m;
  t.Post;
  EditChange;
end;

procedure TFrmPD.tbSaveClick(Sender: TObject);
begin
  if not CanEdit then Exit;
  Edited:=true;//作过修改凭证操作,用于记录 Log
  if not tbNext.Enabled then Added:=true;//作过增加凭证操作,用于记录 Log

  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempPD set [DateTime]='''+DateToStr(DatePD.Date)+''',[Year]='+IntToStr(CurrentYear)+',[Month]='+IntToStr(CurrentMonth)+',Number='+editPZBH.Text+',AccessoryNum='+editFJ.text+',MakeOperator_id='+IntToStr(DM.UserID));
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempPD set J_Money=null where J_Money=0');
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempPD set D_Money=null where D_Money=0');
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('insert into CredenceSpoor select * from Credence where [year]='+IntToStr(CurrentYear)+' and [Month]='+IntToStr(CurrentMonth)+' and Number='+editPZBH.Text);
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('delete from Credence where [year]='+IntToStr(CurrentYear)+' and [Month]='+IntToStr(CurrentMonth)+' and Number='+editPZBH.Text);
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('insert into Credence select DateTime,Year,Month,Number,RecNo,Summary,Subject_id,J_Money,D_Money,AccessoryNum,MakeOperator_ID,auditingOperator_ID from #TempPD');
  tq.ExecSQL;
  tq.Close;
  tbNext.Enabled:=true;
  qPDAll.Requery;
  qPDAll.Locate('Year;Month;Number',VarArrayOf([CurrentYear,CurrentMonth,editPZBH.Text]),[loPartialKey]);
  tbDel.Enabled:=(qPDAll.RecNo=qPDAll.RecordCount);
end;

procedure TFrmPD.editFJKeyPress(Sender: TObject; var Key: Char);
begin
  if not (key in ['0','1','2','3','4','5','6','7','8','9']) then Key:=#0;
end;

procedure TFrmPD.tbDelClick(Sender: TObject);
begin
  if not CanEdit then Exit;
  if Frm_MsgBox('系统信息','确信要删除此凭证吗?',MsgBox_YESNO)=mrNo then Exit;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('delete from #TempPD');
  tq.ExecSQL;
  tq.Close;
  t.Requery;
  g.SumList.RecalcAll;
  tq.SQL.Clear;
  tq.SQL.Add('insert into CredenceSpoor select * from Credence where [year]='+IntToStr(CurrentYear)+' and [Month]='+IntToStr(CurrentMonth)+' and Number='+editPZBH.Text);
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('delete from Credence where [year]='+IntToStr(CurrentYear)+' and [Month]='+IntToStr(CurrentMonth)+' and Number='+editPZBH.Text);
  tq.ExecSQL;
  tq.Close;
  qPDAll.Requery;
  if qPDAll.RecordCount>0 then
    GoPD(qPDAll.RecordCount)
  else
    NewPD;

  Deleted:=true;//作过删除凭证操作,用于记录 Log  
end;

procedure TFrmPD.tbPreviousClick(Sender: TObject);
begin
  if qPDAll.Locate('Year;Month;Number',VarArrayOf([CurrentYear,CurrentMonth,editPZBH.Text]),[loPartialKey]) then
    GoPD(qPDAll.RecNo-1)
  else GoPD(qPDAll.RecordCount);
end;

procedure TFrmPD.tbNextClick(Sender: TObject);
begin
  qPDAll.Locate('Year;Month;Number',VarArrayOf([CurrentYear,CurrentMonth,editPZBH.Text]),[loPartialKey]);
  if qPDAll.RecNo=qPDAll.RecordCount then NewPD
  else GoPD(qPDAll.RecNo+1);
end;

procedure TFrmPD.tbCalcClick(Sender: TObject);
begin
  if ((g.SelectedField.FieldName='J_Money') and (t.FieldByName('D_Money').AsCurrency<>0)) or
     ((g.SelectedField.FieldName='D_Money') and (t.FieldByName('J_Money').AsCurrency<>0)) then
    Exit;

  t.Edit;
  sncDBCurrencyInplaceEdit.Field.Value:=Frm_Calc;
end;

procedure TFrmPD.FormCreate(Sender: TObject);
begin
  DefaultNum:=-1;
  DefaultYear:=-1;
  DefaultMonth:=-1;
end;

procedure TFrmPD.SetPDDateRange;
var
  MaxD,MinD:TDatetime;
  y,m,d:WORD;
begin
  DecodeDate(datePD.Date,y,m,d);
  MinD:=StrToDate(IntToStr(y)+'-'+IntToStr(m)+'-1');
  if m=12 then
    MaxD:=StrToDate(IntToStr(y+1)+'-1-1')
  else
    MaxD:=StrToDate(IntToStr(y)+'-'+IntToStr(m+1)+'-1')-1;

  datePD.MinDate:=MinD;
  datePD.MaxDate:=MaxD;
end;

procedure TFrmPD.SetPDDateRangeCancel;
begin
  datePD.MinDate:=StrToDate('1900-1-1');
  datePD.MaxDate:=StrToDate('9999-12-31');
end;

procedure TFrmPD.PrintPD(PrintType:integer);
begin
  fr.LoadFromFile(FUN_GetCurrentPath^+'Report\Credence.frf');
  fr.Pages[0].ChangePaper(256,DM.PDPageWidth,DM.PDPageHeight,-1,poLandscape);
  frVariables['DeptName']:=DM.DeptName;
  frVariables['ReportDate']:=DateToStr(DatePD.Date);
  frVariables['FinanceManager']:=DM.FinanceManager;
  frVariables['MakeOperator']:=editZD.Text;
  frVariables['AuditingOperator']:=editSH.Text;
  frVariables['Number']:=editPZBH.Text;
  frVariables['AccessoryNum']:=editFJ.Text;
  fr.PrepareReport;
  if PrintType=1 then fr.PrintPreparedReport('',1,true,frAll)
  else fr.ShowReport;
  //直接打印说明:
//  说明:PageNumbers:string //为空打印全部页,指定如"1,3,5-12" 即打印第1,3,5-12页
//  Copies:integer//打印份数
//  Collate:Boolean//是否自动分页
//  PrintPages:TfrPrintPages // {frAll, frOdd, frEven} 全部 奇页 偶页
end;

procedure TFrmPD.tbPrePrintClick(Sender: TObject);
begin
  PrintPD(0);
end;

procedure TFrmPD.tbPrintClick(Sender: TObject);
begin
  if not DM.CheckSoftReg then Exit;
  PrintPD(1);
end;

procedure TFrmPD.sncDBCurrencyInplaceEditKeyPress(Sender: TObject;var Key: Char);
var
  i:integer;
begin
  if Key=#13 then
  begin
    i:=g.Col;
    i:=i+1;
    if i>3 then i:=0;
    ChangeGridCol(i);
    if (t.RecNo=t.RecordCount) and (CheckRowFull) and (tbAddRow.Enabled) then
    begin
      t.Edit;
      t.Post;
      tbAddRow.Click;
    end;
  end;
end;

procedure TFrmPD.ChangeGridCol(Col:integer);
begin
  g.SetFocus;
  if g.Col>=2 then
    sncDBCurrencyInplaceEdit.OnExit(sncDBCurrencyInplaceEdit);
  g.OnColExit(g);
  g.Col:=Col;
  g.OnColEnter(g);
  if g.Col>=2 then
  begin
    sncDBCurrencyInplaceEdit.Visible:=true;
    sncDBCurrencyInplaceEdit.OnEnter(sncDBCurrencyInplaceEdit);
  end;
  g.Refresh;
end;

end.

⌨️ 快捷键说明

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