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

📄 mainform.~pas

📁 电力行业前台收费程序,需要有后台SQL数据库,和电费管理系统配合应用.
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
    end;
  except
    on e:Exception do ShowMessage(e.Message);
  end;
  FormPrintInfo.Free;
  if ToolBarLB.Enabled then begin
    EditHuHao.SetFocus;
    EditHuHao.SelectAll;
  end;
end;

procedure TFormMain.MenuP_ZuoFeiClick(Sender: TObject);
begin
  if HaveThesePower(OpID,'sf_xt_zhanghu','发票作废')<>1 then begin
    ShowMessage('当前帐号没有作废发票的权利!');
    Exit;
  end;
  if QueryYiShou.Eof then
    Exit;
  with DataMD do begin
    if Application.MessageBox('您确认要作废当前收费记录?','',MB_OKCANCEL+MB_ICONQUESTION)=ID_OK then begin
       ADOSPzuofeiFP.Parameters.ParamByName('@lsh').Value:=QueryYiShou.FieldByName('流水号').AsString;

       ADOSPzuofeiFP.Parameters.ParamByName('@ShouFeiXH').Value:=QueryYiShou.FieldByName('收费序号').AsInteger;

       ADOSPzuofeiFP.Parameters.ParamByName('@OpName').Value:=OpName;

       ADOSPzuofeiFP.ExecProc;
    end;
    QueryYiShou.Close;
    QueryYiShou.Open;
    DBGridFldRef(QueryYiShou);
  end;
end;

function TFormMain.GetPrintRepName(FName:String):String;
var
  PrnRepName:Pchar;
begin
  Result:=FName+' ';//如果不这样做,Result将于FName共用同一地址
  PrnRepName:=PChar(FName);
  CopyMemory(StrIPos(PrnRepName,'.ept'),Pchar('.prn'),4);
  if FileExists(PrnRepName) then
    Result:=PrnRepName;
end;

procedure TFormMain.QueryYiShouAfterOpen(DataSet: TDataSet);
begin
  EnableButtons;
end;

Procedure TFormMain.EnableButtons;
begin
  ShowORHideZHAOLING(False);
  if RadioButtonWSH.Down then begin
    //Label6.Visible:=True;
    //LabelYJ.Visible:=True;

    Label2.Visible:=True;
    LabelHJ.Visible:=True;
    //Label11.Visible:=True;
    //LabelYSZNJ.Visible:=True;

    Panel4.Visible:=True;
    CEditShiShou.ReadOnly:=False;
    CurrencyEditZHNJ.ReadOnly:=False;
    ToolButtonSel.Enabled:=True;
    SpeedButtonZuoFei.Enabled:=False;
    MenuP_ZuoFei.Enabled:=False;
    if QueryMain.Eof then begin
      StringGridDETAIL.Visible:=False;
      SpeedButtonPrn.Enabled:=False;
      MenuP_Print.Enabled:=False;
      SpeedButtonPre.Enabled:=False;
      MenuP_View.Enabled:=False;
      ToolButtonSelPrn.Enabled:=False;
      MenuS_Selete.Enabled:=False;
    end
    else begin
      StringGridDETAIL.Visible:=True;
      SpeedButtonPrn.Enabled:=True;
      MenuP_Print.Enabled:=True;
      SpeedButtonPre.Enabled:=True;
      MenuP_View.Enabled:=True;
      ToolButtonSelPrn.Enabled:=True;
      MenuS_Selete.Enabled:=True;
    end;
  end;
  if RadioButtonWDFP.Down then begin
    Label6.Visible:=False;
    LabelYJ.Visible:=False;

    Label2.Visible:=False;
    LabelHJ.Visible:=False;
    Label11.Visible:=False;
    LabelYSZNJ.Visible:=False;

    Panel4.Visible:=False;
    CEditShiShou.ReadOnly:=True;
    CurrencyEditZHNJ.ReadOnly:=True;
    ToolButtonSel.Enabled:=True;
    SpeedButtonZuoFei.Enabled:=False;
    MenuP_ZuoFei.Enabled:=False;
    if QueryWDFP.Eof then begin
      StringGridDETAIL.Visible:=False;
      SpeedButtonPrn.Enabled:=False;
      MenuP_Print.Enabled:=False;
      SpeedButtonPre.Enabled:=False;
      MenuP_View.Enabled:=False;
      ToolButtonSelPrn.Enabled:=False;
      MenuS_Selete.Enabled:=False;
    end
    else begin
      StringGridDETAIL.Visible:=True;
      SpeedButtonPrn.Enabled:=True;
      ToolButtonSelPrn.Enabled:=True;
      MenuP_Print.Enabled:=True;
      SpeedButtonPre.Enabled:=True;
      MenuP_View.Enabled:=True;
      MenuS_Selete.Enabled:=True;
    end;
  end;

  if RadioButtonYSH.Down then begin
      Label6.Visible:=False;
      LabelYJ.Visible:=False;

      Label2.Visible:=False;
      LabelHJ.Visible:=False;
      Label11.Visible:=False;
      LabelYSZNJ.Visible:=False;

      Panel4.Visible:=False;
      CEditShiShou.ReadOnly:=True;
      CurrencyEditZHNJ.ReadOnly:=True;
      SpeedButtonPrn.Enabled:=False;
      MenuP_Print.Enabled:=False;
      ToolButtonSelPrn.Enabled:=False;
      MenuS_Selete.Enabled:=False;
      ToolButtonSel.Enabled:=False;
      SpeedButtonPre.Enabled:=False;
      MenuP_View.Enabled:=False;
    if QueryYiShou.Eof then begin
      StringGridDETAIL.Visible:=False;
      SpeedButtonZuoFei.Enabled:=False;
      MenuP_ZuoFei.Enabled:=False;
    end
    else begin
      StringGridDETAIL.Visible:=True;    
      SpeedButtonZuoFei.Enabled:=True;
      MenuP_ZuoFei.Enabled:=True;
    end;
  end;
end;

procedure TFormMain.ToolButtonSelPrnClick(Sender: TObject);
begin
  MenuS_SeleteClick(nil);
end;

procedure TFormMain.ToolButtonSumClick(Sender: TObject);
begin
  MenuH_SumClick(nil);
end;

procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  IniFile.writeInteger('最新设置','发票票号',SpinEditPiaoHao.Value);
  if ComboBoxCurFP.ItemIndex>-1 then
     IniFile.WriteString('最新设置','默认发票',ComboBoxCurFP.Items[ComboBoxCurFP.ItemIndex]);
  if FormInfoList<>nil then begin
    IniFile.WriteInteger('设置','InfoTop',FormInfoList.Top);
    IniFile.WriteInteger('设置','InfoLeft',FormInfoList.Left);
  end;
end;

procedure TFormMain.SpeedButtonPrnClick(Sender: TObject);
begin
  MenuP_PrintClick(nil);
  if MenuP_View.Checked then
     MenuP_ViewClick(nil);
end;

procedure TFormMain.SpeedButtonPreClick(Sender: TObject);
begin
  MenuP_ViewClick(nil);
end;

procedure TFormMain.SpeedButtonZuoFeiClick(Sender: TObject);
begin
  MenuP_ZuoFeiClick(nil);
end;

procedure TFormMain.RadioButtonYSHClick(Sender: TObject);
begin
  if dgRowSelect in DBGridMain.Options then
    DBGridMain.Options:=DBGridMain.Options-[dgRowSelect];
  FormOpDate:=TFormOpDate.Create(Self);
  if FormOpDate.ShowModal=mrOK then begin
    ChkIdx:=1;
    try
      if RecallSqlLst.Strings[2]='' then begin
        if Abs(FormOpDate.DateT-FormOpDate.DateF)>1 then
          OpenQueryProc(RecallSqlLst[0]+RecallSqlLst[1]+' where 发票已打=''T'' and 收费日期 between '''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateF)+''' and '''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateT)+''' '+RecallSqlLst[3]+RecallSqlLst[4],QueryYiShou)
        else
          OpenQueryProc(RecallSqlLst[0]+RecallSqlLst[1]+' where 发票已打=''T'' and datediff(dd,收费日期,'''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateF)+''')=0 '+RecallSqlLst[3]+RecallSqlLst[4],QueryYiShou);
      end
      else begin
        if Abs(FormOpDate.DateT-FormOpDate.DateF)>1 then
          OpenQueryProc(RecallSqlLst[0]+RecallSqlLst[1]+RecallSqlLst[2]+' and 发票已打=''T'' and 收费日期 between '''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateF)+''' and '''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateT)+''' '+RecallSqlLst[3]+RecallSqlLst[4],QueryYiShou)
        else
          OpenQueryProc(RecallSqlLst[0]+RecallSqlLst[1]+RecallSqlLst[2]+' and 发票已打=''T'' and datediff(dd,收费日期,'''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateF)+''')=0 '+RecallSqlLst[3]+RecallSqlLst[4],QueryYiShou);
      end;
      DBGridFldRef(QueryYiShou);
      DataSourceGrid.DataSet:=QueryYiShou;
      EnableButtons;
      QueryYiShouAfterScroll(nil);
    except
      FormOpDate.Free;
      RadioButtonWSH.Down:=True;
    end;
    FormOpDate.Free;
  end
  else begin
    FormOpDate.Free;
    if ChkIdx=0 then begin
      RadioButtonWSH.Down:=True;
    end
    else if ChkIdx=2 then begin
      RadioButtonWDFP.Down:=True;
    end;
  end;
end;

procedure TFormMain.RadioButtonWDFPClick(Sender: TObject);
begin
  ChkIdx:=2;
  DataSourceGrid.DataSet:=QueryWDFP;
  EnableButtons;
  if QueryWDFP.Active then
     QueryWDFP.First;
  QueryWDFPAfterScroll(nil);
  if(ToolButtonSelPrn.Down)and(not (dgRowSelect in DBGridMain.Options)) then
    DBGridMain.Options:=DBGridMain.Options+[dgRowSelect];
end;

procedure TFormMain.QueryWDFPAfterOpen(DataSet: TDataSet);
begin
  EnableButtons;
  QueryWDFPAfterScroll(nil);  
end;

function GetFieldorValue(FVString:String;ForV:char):String;
var
  I:Integer;
begin
  I:=Pos('=',FVString);
  Result:=FVString;
  if I<=0 then
     Exit;
  if ForV='F' then
    Result:=Copy(FVString,1,I-1)
  else
    Result:=Copy(FVString,I+1,Length(FVString)-I);
end;

procedure TFormMain.ReadDetail(AdoQuery:TAdoQuery);
var
  TempList : TStringList;
  i        : Integer;
begin
   with AdoQuery do begin
       if ChkIdx=0 then//如果是新缴费,则从sf_shoufei_ye中取值
          with DataMD.OpenQuery('select 余额 from sf_shoufei_ye where ID='+FieldByName('ID').AsString) do begin
               if RecordCount>0 then
                  LabelSYYE.Caption:=FieldByName('余额').AsString
               else
                  LabelSYYE.Caption:='0';
               Close;
          end
       else
          LabelSYYE.Caption:=FieldByName('上月余额').AsString;
       LabelYSJE.Caption:=FieldByName('应收金额').AsString;
       with DataMD.OpenQuery('select 明细内容 from sf_shoufeimx where 流水号='''+FieldByName('流水号').AsString+'''') do begin
          if RecordCount>0 then begin
             TempList := TStringList.Create;
             CutStr(FieldByName('明细内容').AsString,TempList,';');
             StringGridDETAIL.RowCount:=TempList.Count+1;
             if TempList.Count>0 then
                StringGridDETAIL.FixedRows:=1
             else
                StringGridDETAIL.FixedRows:=0;
             for i:=1 to TempList.Count do begin
                 StringGridDETAIL.Rows[i].Strings[0]:=GetFieldorValue(TempList.Strings[i-1],'F');
                 StringGridDETAIL.Rows[i].Strings[1]:=GetFieldorValue(TempList.Strings[i-1],'V');
             end;
             TempList.Free;
          end
          else
             StringGridDETAIL.RowCount:=1;
          Close;
       end;
   end;
end;

procedure TFormMain.ResetValue;
begin
  LabelYSJE.Caption:='0.00';
  LabelSYYE.Caption:='0.00';
  LabelYJ.Caption:='0.00';
  LabelYC.Caption:='0.00';
  LabelHJ.Caption:='0.00';
  LabelYSZNJ.Caption:='0.00';
  CEditShiShou.Value:=0;
  CurrencyEditZHNJ.Value:=0;
end;

procedure TFormMain.QueryMainAfterScroll(DataSet: TDataSet);
begin
  if ChkIdx=0 then begin
     if not RefreshUIFee then Exit;
     if not QueryMain.Active then Exit;
     if QueryMain.RecordCount=0 then Exit;
     //注意计算
     //sf_CalcFee计算:用户已缴,用户应缴,应收滞纳金
     DataMD.ADOSPCalcfee.Parameters.ParamByName('@lsh').Value:=QueryMain.FieldByName('流水号').AsString;
     if JINEQUZHENG then
        DataMD.ADOSPCalcfee.Parameters.ParamByName('@quzheng').Value:='T'
     else
        DataMD.ADOSPCalcfee.Parameters.ParamByName('@quzheng').Value:='F';
     DataMD.ADOSPCalcfee.Parameters.ParamByName('@quzhengws').Value:=QUZHENGWS;
     DataMD.ADOSPCalcfee.ExecProc;

     LabelYJ.Caption:=DataMD.ADOSPCalcfee.Parameters.ParamByName('@yonghuyjfee').Value;
     LabelYC.Caption:=DataMD.ADOSPCalcfee.Parameters.ParamByName('@yucunfee').Value;//预存金额
     LabelHJ.Caption:=DataMD.ADOSPCalcfee.Parameters.ParamByName('@yingjiaofee').Value;
     LabelYSZNJ.Caption:=DataMD.ADOSPCalcfee.Parameters.ParamByName('@znj').Value; //计算滞纳金
     ShowORHideZHAOLING(False);
     CEditShiShou.Text:=LabelHJ.Caption;
     CurrencyEditZHNJ.Value:=DataMD.ADOSPCalcfee.Parameters.ParamByName('@znj').Value;
     ReadDetail(QueryMain);
  end;
end;

procedure TFormMain.QueryYiShouAfterScroll(DataSet: TDataSet);
begin
  if ChkIdx=1 then begin
     if not QueryYiShou.Active then Exit;
     if QueryYiShou.RecordCount=0 then Exit;

⌨️ 快捷键说明

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