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

📄 cashpd.pas

📁 晓风财务软件源码,具有财务软基本功能,仅供学习,勿商用,后果与本人无关 1、使用的第三方VCL: FastReport2.6中文版 EHLIB3 sncCurrency SUIPac
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  tq.Open;
  if tq.RecordCount>0 then
  begin
    DefaultSubject_id:=tq.FieldByName('id').AsInteger;
    DefaultCodeLongSubjectName:=tq.FieldByName('CodeLongSubjectName').AsString;
  end
  else
  begin
    DefaultSubject_id:=-1;
    DefaultCodeLongSubjectName:='';
  end;
  tq.Close;

  t.Close;
  t.TableName:='#TempCashCredence';
  t.Open;
  t.Sort:='Number';
  tbAddRow.Click;
end;

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

procedure TFrmCashPD.tbAddRowClick(Sender: TObject);
begin
  t.Append;
  t.FieldByName('Year').AsInteger:=DM.CashAccountYear;
  t.FieldByName('Month').AsInteger:=DM.CashAccountMonth;
  t.FieldByName('Number').AsInteger:=Fun_GetMaxID(DM.adoc,'#TempCashCredence','Number');
  t.FieldByName('day').AsInteger:=MaxDay;
  t.FieldByName('MakeOperator_id').AsInteger:=DM.UserID;
  t.FieldByName('MakeOperator').AsString:=DM.UserName;
  editZD.Text:=DM.UserName;
  if DefaultSubject_id<>-1 then
  begin
    t.FieldByName('Subject_id').AsInteger:=DefaultSubject_id;
    t.FieldByName('CodeLongSubjectName').AsString:=DefaultCodeLongSubjectName;
  end;
  t.Post;
  EditChange;
  Added:=true; //作过增加,便于记录 Log
end;

procedure TFrmCashPD.tbInsertRowClick(Sender: TObject);
var
  CurrentNumber:integer;
begin
  CurrentNumber:=t.FieldByName('Number').AsInteger;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempCashCredence set Number=Number+1 where Number>='+IntToStr(CurrentNumber));
  tq.ExecSQL;
  tq.Close;
  t.Append;
  t.FieldByName('Year').AsInteger:=DM.CashAccountYear;
  t.FieldByName('Month').AsInteger:=DM.CashAccountMonth;
  t.FieldByName('Number').AsInteger:=CurrentNumber;
  t.FieldByName('day').AsInteger:=MaxDay;
  t.FieldByName('MakeOperator_id').AsInteger:=DM.UserID;
  t.FieldByName('MakeOperator').AsString:=DM.UserName;
  editZD.Text:=DM.UserName;
  if DefaultSubject_id<>-1 then
  begin
    t.FieldByName('Subject_id').AsInteger:=DefaultSubject_id;
    t.FieldByName('CodeLongSubjectName').AsString:=DefaultCodeLongSubjectName;
  end;
  t.Post;
  t.Requery;
  EditChange;
  Added:=true; //作过增加,便于记录 Log
end;

procedure TFrmCashPD.tbDeleteRowClick(Sender: TObject);
var
  CurrentNumber:integer;
begin
  CurrentNumber:=t.FieldByName('Number').AsInteger;
  t.Delete;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempCashCredence set Number=Number-1 where Number>'+IntToStr(CurrentNumber));
  tq.ExecSQL;
  tq.Close;
  t.Requery;
  if t.RecordCount<1 then tbAddRow.Click;
  EditChange;
  Deleted:=true;//作过删除操作,用于记录 Log
end;

procedure TFrmCashPD.tbSwapClick(Sender: TObject);
var
  tm:Currency;
begin
  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 TFrmCashPD.tbSaveClick(Sender: TObject);
begin
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempCashCredence set DateTime=cast(cast([year] as varchar(4))+''-''+cast([month] as varchar(2))+''-''+cast([day] as varchar(2)) as Datetime)');
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempCashCredence set J_Money=null where J_Money=0');
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('update #TempCashCredence set D_Money=null where D_Money=0');
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('delete from CashCredence where [year]='+IntToStr(DM.CashAccountYear)+' and [Month]='+IntToStr(DM.CashAccountMonth));
  tq.ExecSQL;
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('insert into CashCredence select DateTime,Year,Month,Number,EarningNumber,PayNumber,Summary,Subject_id,J_Money,D_Money,MakeOperator_ID from #TempCashCredence where J_Money<>0 or D_Money<>0');
  tq.ExecSQL;
  tq.Close;
  t.Requery;
  tbSave.Enabled:=false;
  Edited:=true;//作过修改记录操作,用于记录 Log
end;

procedure TFrmCashPD.tbCalcClick(Sender: TObject);
begin
  WinExec('calc.exe',SW_SHOW);
end;

procedure TFrmCashPD.gColumns5EditButtonClick(Sender: TObject;var Handled: Boolean);
var
  id:integer;
  d:pChar;
begin
  GetMem(d,1000);
  if Frm_CodeInput(DM.adoc,'#TempSubject','ID','Code_PinYin','Code_WuBi','CodeLongSubjectName','Used',@id,d)=mrOK then
  begin
    t.Edit;
    t.FieldByName('Subject_id').AsInteger:=id;
    t.FieldByName('CodeLongSubjectName').AsString:=d;
    t.Post;
  end;
  FreeMem(d,1000);
  g.Col:=4;
  g.Col:=5;
  EditChange;
end;
procedure TFrmCashPD.gColumns4EditButtonClick(Sender: TObject;
  var Handled: Boolean);
var
  id:integer;
  d:pChar;
begin
  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);
  g.Col:=1;
  g.Col:=0;
  EditChange;
end;

procedure TFrmCashPD.gExit(Sender: TObject);
begin
  EditChange;
end;

procedure TFrmCashPD.GetMaxDay;
var
  y,m,d:word;
  dt:TDate;
begin
  if DM.CashAccountMonth=12 then
    dt:=StrToDate(IntToStr(DM.CashAccountYear+1)+'-1-1')-1
  else
    dt:=StrToDate(IntToStr(DM.CashAccountYear)+'-'+IntToStr(DM.CashAccountMonth+1)+'-1')-1;

  DecodeDate(dt,y,m,d);
  MaxDay:=d;
end;

procedure TFrmCashPD.btnBackMonthClick(Sender: TObject);
begin
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('select count(*) as CountRow from CashCredence where [Year]='+IntToStr(DM.CashAccountYear)+' and [month]='+IntToStr(DM.CashAccountMonth));
  tq.Open;
  if tq.FieldByName('CountRow').AsInteger>0 then
  begin
    tq.Close;
    Frm_MsgBox('系统信息','本月已经有收付记录,不能回到上月。如果需要查询上月现金日记记录,请从“现金日记查询”查询。',MsgBox_OK_ERROR);
    Exit;
  end;
  tq.Close;

  if Frm_MsgBox('系统信息','确信要退回到上一月吗?',MsgBox_YESNO)=mrNo then Exit;

  //删除上月结转至本月的余额
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('delete from CashBalance where [Year]='+IntToStr(DM.CashAccountYear)+' and [month]='+IntToStr(DM.CashAccountMonth));
  tq.ExecSQL;
  tq.Close;

  //计算上月年度数和月份数
  if DM.CashAccountMonth=1 then
  begin
    DM.CashAccountYear:=DM.CashAccountYear-1;
    DM.CashAccountMonth:=12;
  end
  else
    DM.CashAccountMonth:=DM.CashAccountMonth-1;

  //保存选项
  SetOptionsKeyValue(t.Connection,'当前现金日记年度',IntToStr(DM.CashAccountYear));
  SetOptionsKeyValue(t.Connection,'当前现金日记月份',IntToStr(DM.CashAccountMonth));

  isGoon:=true;
  Close;
end;

procedure TFrmCashPD.btnNextMonthClick(Sender: TObject);
begin
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('select count(*) as CountRow from CashCredence where [Year]='+IntToStr(DM.CashAccountYear)+' and [month]='+IntToStr(DM.CashAccountMonth));
  tq.Open;
  if tq.FieldByName('CountRow').AsInteger<1 then
  begin
    tq.Close;
    if Frm_MsgBox('系统信息','本月还没有录入现金收付记录,确信要直接到下一月吗?',MsgBox_YESNO)=mrNo then Exit;
  end
  else
  begin
    tq.Close;
    if Frm_MsgBox('系统信息','转到下一月份后,将不能再修改本月记录,确信要转到到下一月吗?',MsgBox_YESNO)=mrNo then Exit;
  end;
  tq.Close;

  //计算余额,写入余额表,然后进入下月
  tq.Close;
  tq.SQL.Clear;
  tq.SQL.Add('P_CashCarryForward');
  tq.ExecSQL;
  tq.Close;

  //计算下月年度数和月份数
  if DM.CashAccountMonth=12 then
  begin
    DM.CashAccountMonth:=1;
    DM.CashAccountYear:=DM.CashAccountYear+1;
  end
  else
    DM.CashAccountMonth:=DM.CashAccountMonth+1;

  isGoon:=true;
  Close;
end;

procedure TFrmCashPD.tAfterScroll(DataSet: TDataSet);
begin
  editZD.Text:=t.FieldByName('MakeOperator').AsString;
end;

end.

⌨️ 快捷键说明

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