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

📄 sy_ckjhdzd1.pas

📁 省级集邮品管理ERP
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  CB_PPMC.ClearAll;
  CB_PPMC.OnChange := nil;
  with Qry_Static do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select  distinct D.DWJC DWMC, D.DWDM, D.PXM from TYS_TXPCKJHDB A,TYS_TXCKJHDPPB B, TGS_KFRYDZB C, TGS_GXDWSJB D');
    SQL.Add('where A.CKJHDH=B.CKJHDH and B.KFDM=C.KFDM and B.DWDM=D.DWDM ');
    SQL.Add('and C.YGDM = ''' + VG_UserID + ''' ');
    SQL.Add('and (A.ZT = ''' + CG_WCL + ''' or A.ZT = ''' + CG_DG + ''') ');
    SQL.Add('and A.CKXZ = ''' + V_CKXZ + '''');

    if E_CKXZ.ItemIndex = 0 then //领星请领
    begin
      SQL.Add('and subStr(A.CKJHDH,1,7) = ''' + GetFPDH1('L', ND.Text, YF.Text) + '''');
    end
    else //其他请领
    begin
      SQL.Add('and to_char(zdrq,''YYYYMM'')=''' + ND.Text + formatfloat('00', YF.Value) + ''' and A.CKJHDH like ''TX%'' ');
    end;
    SQL.Add('order by D.PXM ');
    Open;
    while not Eof do
    begin
      CB_PPMC.Items.Add(Fields[0].AsString);
      CB_PPMC.FieldItems.Add(Fields[1].AsString);
      Next;
    end;
    Close;
  end;
  CB_PPMC.OnChange := CB_PPMCChange;
  if CB_PPMC.Items.Count > 0 then
    CB_PPMC.ItemIndex := 0;
  CB_PPMCChange(nil);
end;

procedure TFrmY_CKJHDZD1.L_CKJHDHDblClick(Sender: TObject);
begin
  if Qry_Third.IsEmpty then Exit;
  if Qry_Third.FieldByName('ZT').Asstring <> CG_DG then Exit;
  if CHQMsgBox('对此签批的分配计划,取消签批?', 2) = IDNo then Exit;

  //取消签批
  with Qry_Static do
  begin
    Close;
    SQL.Text := 'update TYS_TXPCKJHDB set ZT = ''0'' ,PZR= '''' '
      + ' where CKJHDH=''' + V_CKJHDH + '''';
    ExecSQL;
  end;

  //刷新出库计划单
  CB_CKJHDHChange(nil);
end;

procedure TFrmY_CKJHDZD1.BBt_DeleteDWClick(Sender: TObject);
begin
   //删除当前票品
  if Qry_Main.IsEmpty then Exit;
  Qry_Main.Delete;
end;

procedure TFrmY_CKJHDZD1.BBt_PrintClick(Sender: TObject);
var
  StrSQL: string;
begin
  if CB_CKJHDH.Text = '' then
  begin
    CHQMsgBox('请选择分配单号!');
    Exit;
  end;
  if Qry_Main.IsEmpty then Exit;

  Application.CreateForm(TFrm_RichEdit, Frm_RichEdit);
  Application.CreateForm(TCKJHDCX_RPT, CKJHDCX_RPT);
  with CKJHDCX_RPT, Frm_RichEdit do
  try
    StrSQL := 'select ROWNUM, A.CKJHDH, A.CKXZ, A.ZBR, A.PZR, A.ZDRQ, A.BZ, C.DWJC DWMC, B.PPMC, D.TPMZ/100 MZ, B.XJ/100 XJ, B.JJ/100 JJ, DECODE(B.ZK,0,B.JSJ/100,B.ZK) ZK,B.JSJ/100 JSJ, B.FPSL,DECODE(B.JSJ,0,B.XJ*B.FPSL*B.ZK/10000,B.JSJ*B.FPSL/100) JE,d.zh ';
    StrSQL := StrSQL + ' FROM TYS_TXPCKJHDB A,TYS_TXCKJHDPPB B,TGS_GXDWSJB C,TB_YZPPXXB D where B.DWDM=C.DWDM AND A.CKJHDH = B.CKJHDH AND B.PPDM=D.TDM and A.CKJHDH =''' + CB_CKJHDH.Text + ''' order by C.PXM';
    Qry_Print.SQL.Text := StrSQL;
    Qry_Print.Open;
    QRLabel12.Caption := '零枚票';
    QRLabel20.Caption := FormatDateTime('yyyy"年"mm"月"dd"日"', StrToDate(Qry_Print.fieldByName('zdrq').AsString));

    if CHQMsgBox('是否采用套打?', 2) = IDYES then
      Tao_Print_Flag := True
    else
      Tao_Print_Flag := False;

    DetailLines := 0;
    Prepare;
    try
      QRLabel19.Caption := IntToStr(QRPrinter.PageCount);
    finally
      QRPrinter.Free;
    end;
    QRPrinter := nil;

    Preview;
  finally
    CKJHDCX_RPT.Destroy;
    Frm_RichEdit.Destroy;
  end;
end;

procedure TFrmY_CKJHDZD1.DBG_MainEnter(Sender: TObject);
begin
  with TDBGrid(Sender) do
    selectedindex := fieldcount - 1;
end;

//取得单前分配单中同一单位的说邮票品的合计金额
function TFrmY_CKJHDZD1.PS_GetHJY(DWDM: string): Double;
begin
  Result := 0;

  //求出不包括本分配单本月分配总金额
  with Data.Qry_Static do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select SUM(FPSL*MZ) from TYS_TXCKJHDPPB ');
    SQL.Add('where subStr(CKJHDH,2,6) = ''' + GetFPDH1('', ND.Text, YF.Text) + '''');
    SQL.Add('and CKJHDH <> ''' + V_CKJHDH + ''' ');
    SQL.Add('and DWDM = ''' + DWDM + ''' ');
    Open;
    Result := Result + Fields[0].AsInteger;
    Close;
  end;

  //本期库存
  with Data.Qry_Static do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select NVL(SUM(BQJC*MZ),0) from TYS_TXPKCJQLMXB ');
    SQL.Add('WHERE DWDM =''' + DWDM + ''' and ND =''' + ND.Text + ''' and YF =''' + YF.Text + '''');
    Open;
    Result := Result + Fields[0].AsInteger;
    Close;
  end;

  //计算分配单的总的分配金额
  with Qry_Main do
  begin
    DisableControls;
    Filter := 'DWDM=''' + DWDM + '''';
    Filtered := True;
    First;
    while not Eof do
    begin
      Result := Result + FieldByName('FPSL').AsInteger * FieldByName('MZ').AsInteger;
      Next;
    end;
    Filtered := False;
    Filter := '';
    First;
    EnableControls;
  end;
end;

procedure TFrmY_CKJHDZD1.BBt_DGClick(Sender: TObject);
var
  v_zt, v_pzr: string;
begin
  if Qry_Third.IsEmpty then Exit;
  if Qry_Third.FieldByName('ZT').Asstring = CG_YCL then
  begin
    CHQMsgBox('此出库计划单已处理!');
    Exit;
  end;

{  if Qry_Third.FieldByName('ZT').Asstring = CG_DG then
  begin
    CHQMsgBox('此出库计划单已签批!');
    Exit;
  end;}

  if CHQMsgBox('确实要' + copy(BBt_DG.Caption, 1, length(BBt_DG.Caption) - 4) + '吗?', 2) = IDNO then Exit;

  //签批出库计划单
  with Qry_Static do
  begin
    Close;
    if pos('取消', BBt_DG.Caption) > 0 then
    begin
      v_zt := CG_WCL;
      v_pzr := '';
    end
    else
    begin
      v_zt := CG_DG;
      v_pzr := VG_UserName;
    end;
    SQL.Text := 'update TYS_TXPCKJHDB set ZT = ''' + v_zt + ''' ,PZR= ''' + v_pzr + ''''
      + ' where CKJHDH=''' + V_CKJHDH + '''';
    ExecSQL;
  end;

  //刷新出库计划单
  CB_CKJHDHChange(nil);
end;

procedure TFrmY_CKJHDZD1.Qry_MainJJSetText(Sender: TField;
  const Text: string);
begin
  CurrSetText(Sender, Text);
end;

procedure TFrmY_CKJHDZD1.DoINSYPXX;
begin
  with Qry_Main do
  begin
    First;
    while not EOF do
    begin
      DoCheckExistYPXX;
      Next;
    end;
  end;
end;

procedure TFrmY_CKJHDZD1.DoCheckExistYPXX;
var
  s: string;
begin
  s := 'select TDM from TB_JYPTXXB where TDM=''' +
    Qry_Main.FieldByName('PPDM').AsString + '''';
  if not PY_IsExist(s) then
  begin
    s := 'insert into TB_JYPTXXB(TDM, YPLB, TZ, ZH, MC, DW, SJ, FXRQ, FXL, BZ) ' +
      'select TDM, PPLB, TZ, ZH, TMC, ''套'', TPSJ, FXRQ, TFXL, BZ from ' +
      'TB_YZPPTXXB where TDM=''' + Qry_Main.FieldByName('PPDM').AsString + '''';
    AssignSQLstr(data.Qry_Static, s);
    data.Qry_Static.ExecSQL;
  end;
end;

procedure TFrmY_CKJHDZD1.Qry_MainFPSLSetText(Sender: TField;
  const Text: string);
begin
  try
    V_FPSL := Round(StrToFloat(Text))
  except
    Exit;
  end;

  //凑版
  if RG_CB.ItemIndex <> 2 then
    V_FPSL := PS_GetCB(Qry_Main.FieldByName('PPDM').AsString, V_FPSL, RG_CB.ItemIndex = 0, RG_FX.ItemIndex = 0);

  Sender.AsInteger := V_FPSL;
  Qry_MainAfterScroll(nil);
end;

procedure TFrmY_CKJHDZD1.Qry_MainAfterScroll(DataSet: TDataSet);
begin
   //计算选定票品的库存
  CE_KC.Value := PS_GetSYTS(Qry_Main.FieldByName('KFDM').AsString, Qry_Main.FieldByName('PPDM').AsString, Qry_Main.FieldByName('JJ').AsFloat, Qry_Main.FieldByName('CKJHDH').AsString, Qry_Main.FieldByName('DWDM').AsString) - Qry_Main.FieldByName('FPSL').AsInteger;
  if CE_KC.Value < 0 then
    CE_KC.Font.Color := ClRed
  else
    CE_KC.Font.Color := ClBlue;

  BBt_DG.Enabled := (not BBt_Save.Enabled) and (Qry_Third.FieldByName('ZT').Asstring <> CG_YCL);
  if Qry_Third.FieldByName('ZT').Asstring = CG_WCL then
    BBt_DG.Caption := '签批(&H)'
  else
    BBt_DG.Caption := '取消签批(&H)';
end;

function TFrmY_CKJHDZD1.GetFPDH1(FLM, ND, YF: string; LSH: Boolean): string;
begin
  Result := FLM + FormatFloat('0000', StrToInt(ND)) + FormatFloat('00', StrToInt(YF));
  if not LSH then
    with Qry_Static do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select nvl(Max(To_number(Substr(CKJHDH,8,2))),0)+1 from TYS_TXPCKJHDB ');
      SQL.Add('where CKJHDH like ''' + Result + '%''');
      Open;
      Result := Result + FormatFloat('00', StrToInt(Fields[0].AsString));
      Close;
    end;

end;

procedure TFrmY_CKJHDZD1.Qry_MainFPSLGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  Text := FormatFloat('#,##', Sender.AsFloat);
end;

procedure TFrmY_CKJHDZD1.RG_FXClick(Sender: TObject);
begin
  if RG_FX.ItemIndex = 1 then
    RG_CB.Caption := '凑版'
  else
    RG_CB.Caption := '凑包';

end;

procedure TFrmY_CKJHDZD1.CE_KCDblClick(Sender: TObject);
begin
  if Qry_Main.IsEmpty then Exit;
  //显示当前选定票品的库存情况
  FrmY_KC := TFrmY_KC.Create(nil);
  FrmY_KC.E_PPMC.Text := Qry_MainPPMC.AsString;
  FrmY_KC.E_JJ.Text := Qry_MainJJ.AsString;
  //取得当前票品库存量
  FrmY_KC.E_KCTS.Value := PS_GetKC(Qry_Main.FieldByName('KFDM').AsString, Qry_Main.FieldByName('PPDM').AsString);
  //取得当前票品剩余库存量
  FrmY_KC.E_SYTS.Value := PS_GetSYTS(Qry_Main.FieldByName('KFDM').AsString, Qry_Main.FieldByName('PPDM').AsString, Qry_Main.FieldByName('JJ').AsFloat, Qry_Main.FieldByName('CKJHDH').AsString, Qry_Main.FieldByName('DWDM').AsString) - Qry_Main.FieldByName('FPSL').AsInteger;
  //取得当前票品已分配而未出库的分配总量
  FrmY_KC.E_FPTS.Value := FrmY_KC.E_KCTS.Value - FrmY_KC.E_SYTS.Value;
  FrmY_KC.ShowModal;
  FrmY_KC.Free;
end;

procedure TFrmY_CKJHDZD1.Qry_MainBeforeInsert(DataSet: TDataSet);
begin
  Abort;
end;

procedure TFrmY_CKJHDZD1.N_SDLClick(Sender: TObject);
var
  FFiexedCols: Integer;
begin
  Sender := PM_Main.PopupComponent;
  if Sender is TDBGrid then
  begin
    FFiexedCols := TRxDBGrid(Sender).FixedCols + 1;
    if FFiexedCols > TRxDBGrid(Sender).Col then Exit;
    TRxDBGrid(Sender).FixedCols := FFiexedCols;
  end;
end;

procedure TFrmY_CKJHDZD1.N_JSLClick(Sender: TObject);
var
  FFiexedCols: Integer;
begin
  Sender := PM_Main.PopupComponent;
  if Sender is TDBGrid then
  begin
    FFiexedCols := TRxDBGrid(Sender).FixedCols - 1;
    if FFiexedCols < 0 then Exit;
    TRxDBGrid(Sender).FixedCols := FFiexedCols;
  end;
end;

procedure TFrmY_CKJHDZD1.CE_KCEnter(Sender: TObject);
begin
  //是库存不获得焦点
  DBG_Main.SetFocus;
end;

procedure TFrmY_CKJHDZD1.Qry_MainJSJSetText(Sender: TField;
  const Text: string);
var
  TextValue: Double;
begin
  try
    TextValue := Round(StrToFloat(Text) * 100);
  except
    CHQMsgBox('输入有误,可能输入数值过大,请重新输入!');
    Exit;
  end;
  if TextValue < 0 then
  begin
    CHQMsgBox('输入有误,输入数值为负值,请重新输入!');
    Exit;
  end;
  if TextValue > 9999999 then
  begin
    CHQMsgBox('输入有误,输入数值过大,请重新输入!');
    Exit;
  end;
  Sender.AsFloat := TextValue;
end;

procedure TFrmY_CKJHDZD1.Qry_MainZKChange(Sender: TField);
begin
  //折扣和结算价互斥
  if Sender.FieldName = 'JSJ' then
  begin
    if Sender.AsFloat <> 0 then
      Sender.DataSet.FieldByName('ZK').AsFloat := 0;
  end;
  if Sender.FieldName = 'ZK' then
  begin
    if Sender.AsFloat <> 0 then
      Sender.DataSet.FieldByName('JSJ').AsFloat := 0;
  end;

end;

procedure TFrmY_CKJHDZD1.Qry_MainZKSetText(Sender: TField;
  const Text: string);
var
  TextValue: Double;
begin
  try
    TextValue := StrToFloat(Text);
  except
    CHQMsgBox('输入有误,可能输入数值过大,请重新输入!');
    Exit;
  end;
  if TextValue < 0 then
  begin
    CHQMsgBox('输入有误,输入数值为负值,请重新输入!');
    Exit;
  end;
  if TextValue > 100 then
  begin
    CHQMsgBox('输入有误,输入数值过大,请重新输入!');
    Exit;
  end;
  Sender.AsFloat := TextValue;
end;

procedure TFrmY_CKJHDZD1.CB_PPMCChange(Sender: TObject);
begin
  //刷新出库计划单下拉框
  begin
    CB_CKJHDH.Text := '';
    CB_CKJHDH.Items.Clear;
    CB_CKJHDH.OnChange := nil;
    with Qry_Static do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select distinct A.CKJHDH,A.ZT from TYS_TXPCKJHDB A,TYS_TXCKJHDPPB B, TGS_KFRYDZB C');
      SQL.Add('where A.CKJHDH=B.CKJHDH and B.KFDM=C.KFDM and A.ZT in (''0'',''2'')');
      SQL.Add('and B.DWDM = ''' + CB_PPMC.FieldString + '''');

      if E_CKXZ.ItemIndex = 0 then //领星请领
      begin
        SQL.Add('and subStr(A.CKJHDH,1,7) = ''' + GetFPDH1('L', ND.Text, YF.Text) + '''');
      end
      else //其他请领
      begin
        SQL.Add('and A.CKJHDH  like ''TX%'' ');
      end;
      SQL.Add('order by A.CKJHDH DESC ');
      Open;
      while not Eof do
      begin
        CB_CKJHDH.Items.Add(Fields[0].AsString);
        Next;
      end;
      Close;
    end;
    CB_CKJHDH.OnChange := CB_CKJHDHChange;
    if CB_CKJHDH.Items.Count > 0 then
    begin
      CB_CKJHDH.ItemIndex := 0;
    end;
  end;
  CB_CKJHDHChange(nil);
end;

function TFrmY_CKJHDZD1.SumField(Dataset: TDataSet; Field: TField): Double;
var
  vBookmark: TBookmark;
begin
  Result := 0;
  with Dataset do
    if (not IsEmpty) and Active then
    begin
      vBookmark := GetBookmark;
      try
        DisableControls;
        First;
        while not eof do
        begin
          Result := Result + Field.AsFloat;
          Next;
        end;
        GotoBookmark(vBookmark);
      finally
        FreeBookmark(vBookmark);
        EnableControls;
      end;
    end;
end;

function TFrmY_CKJHDZD1.GetExistField(FQuery: TQuery; FieldName,
  SnapStr: string): string;
var
  FBookMark: TBookMark;
begin
  Result := 'ZRJM';
  if not FQuery.Active then Exit;
  if FQuery.FindField(FieldName) = nil then Exit;
  if FQuery.IsEmpty then Exit;
  try
    with FQuery do
    begin
      FBookMark := GetBookmark;
      DisableControls;
      First;
      while not Eof do
      begin
        Result := Result + SnapStr + FindField(FieldName).AsString;
        Next;
      end;
      EnableControls;
      GotoBookMark(FBookMark);
    end;
  except
    FQuery.EnableControls;
  end;
end;

procedure TFrmY_CKJHDZD1.Qry_MainJJGetText(Sender: TField;
  var Text: String; DisplayText: Boolean);
begin
{修改,进价销价结算价显示小数点后3位 原来调用的CurrGetText替换为CurrGetText3 jhshao 2003.05.08}
  CurrGetText3(Sender, Text, DisplayText);
end;

procedure TFrmY_CKJHDZD1.Qry_MainMZGetText(Sender: TField;
  var Text: String; DisplayText: Boolean);
begin
{增加,面值显示单独调用 jhshao 2003.05.09}
  CurrGetText(Sender, Text, DisplayText);
end;

end.

⌨️ 快捷键说明

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