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

📄 sy_ckjhdcx.pas

📁 省级集邮品管理ERP
💻 PAS
字号:
{*******************************************************}
{                                                       }
{                     出库计划单查询                    }
{                                                       }
{            中软金马公司版权所有。2002.12前            }
{                                                       }
{            编制:中软金马邮资票品项目开发组           }
{                                                       }
{                                                       }
{*******************************************************}
(*
省级集邮品,省级集邮票,省级零枚票,省级市场购入票
地市集邮票,地市集邮品,地市市场购入票 管理

*)
unit SY_CKJHDCX;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, DBTables, ComCtrls, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids, Spin,
  Mask, ToolEdit, CurrEdit, ActnList, RXCtrls, ImgList, Menus, DBGridExport;

type
  TFrmY_CKJHDCX = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    BBt_Quit: TBitBtn;
    Ldwmc: TLabel;
    Label3: TLabel;
    BBt_Find: TBitBtn;
    BBt_Print: TBitBtn;
    ND: TSpinEdit;
    Panel5: TPanel;
    Qry_JJNFPJH: TQuery;
    DataSource3: TDataSource;
    Qry_GXDWSJB: TQuery;
    Qry_Static: TQuery;
    BBt_Hide: TBitBtn;
    Panel4: TPanel;
    RG_PX: TRadioGroup;
    GroupBox1: TGroupBox;
    Label11: TLabel;
    CB_ZBR: TComboBox;
    CB_DWMC: TComboBox;
    CB_JHH: TComboBox;
    CB_PPMC: TComboBox;
    CBB_DWMC: TCheckBox;
    CBB_PPMC: TCheckBox;
    CBB_JHH: TCheckBox;
    DP_FROM: TDateTimePicker;
    DP_TO: TDateTimePicker;
    CBB_PZR: TCheckBox;
    CB_PZR: TComboBox;
    CBB_ZBR: TCheckBox;
    CBB_ZDRQ: TCheckBox;
    RG_ZT: TRadioGroup;
    Query1: TQuery;
    Panel6: TPanel;
    DBGrid2: TDBGrid;
    CBo_CKXZ: TCheckBox;
    CB_CKXZ: TComboBox;
    XttxTitle: TRxLabel;
    ImageList: TImageList;
    Qry_JJNFPJHCKJHDH: TStringField;
    Qry_JJNFPJHCKXZ: TStringField;
    Qry_JJNFPJHZBR: TStringField;
    Qry_JJNFPJHPZR: TStringField;
    Qry_JJNFPJHZDRQ: TDateTimeField;
    Qry_JJNFPJHBZ: TStringField;
    Qry_JJNFPJHZT: TStringField;
    Qry_JJNFPJHKFDM: TStringField;
    Qry_JJNFPJHDWDM: TStringField;
    Qry_JJNFPJHPPDM: TStringField;
    Qry_JJNFPJHJJ: TFloatField;
    Qry_JJNFPJHDWMC: TStringField;
    Qry_JJNFPJHKWH: TStringField;
    Qry_JJNFPJHPPMC: TStringField;
    Qry_JJNFPJHYJ: TFloatField;
    Qry_JJNFPJHXJ: TFloatField;
    Qry_JJNFPJHZK: TFloatField;
    Qry_JJNFPJHJSJ: TFloatField;
    Qry_JJNFPJHFPSL: TFloatField;
    Bevel1: TBevel;
    procedure FormCreate(Sender: TObject);
    procedure DBG_JJNFPJHTitleClick(Column: TColumn);
    procedure NDChange(Sender: TObject);
    procedure Act_PrintExecute(Sender: TObject);
    procedure BBt_FindClick(Sender: TObject);
    procedure BBt_HideClick(Sender: TObject);
    procedure Qry_JJNFPJHJSJGetText(Sender: TField; var Text: string;
      DisplayText: Boolean);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmY_CKJHDCX: TFrmY_CKJHDCX;

implementation
uses
  pub, SY_CKJHDOne_More_RPT, SY_CKJHDMore_More_RPT, SJ_RICHEDIT;

{$R *.DFM}

procedure TFrmY_CKJHDCX.FormCreate(Sender: TObject);
begin
//  CHQMsgBox('formcreate-1');
  DP_FROM.DateTime := GetSysDate;
  DP_TO.DateTime := DP_FROM.DateTime;
  ND.Value := VG_Year;
  Ldwmc.Caption := '使用单位:' + VG_UnitName;
//  CHQMsgBox('formcreate-2');
  with Qry_Static do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select CKJHDH,ZBR,PZR from TYS_JYCKJHDB');
    SQL.Add('where not CKJHDH LIKE ''GR%'' and  TO_CHAR(ZDRQ,''YYYY'') =''' + ND.Text + ''' ');
    SQL.Add('order by CKJHDH DESC ');
    Open;
//    CHQMsgBox('formcreate-3');
    while not Eof do
    begin
      if CB_JHH.Items.IndexOf(Fields[0].AsString) = -1 then
        CB_JHH.Items.Add(Fields[0].AsString);

      if trim(Fields[1].AsString) <> '' then
        if CB_ZBR.Items.IndexOf(Fields[1].AsString) = -1 then
          CB_ZBR.Items.Add(Fields[1].AsString);

      if trim(Fields[2].AsString) <> '' then
        if CB_PZR.Items.IndexOf(Fields[2].AsString) = -1 then
          CB_PZR.Items.Add(Fields[2].AsString);
      Next;
    end;
//    CHQMsgBox('formcreate-4');
    Close;
    SQL.Clear;
    SQL.Add('select Distinct PPMC from TYS_JYCKJHDPPB');
    SQL.Add('where not CKJHDH LIKE ''GR%''  ');
    Open;
//    CHQMsgBox('formcreate-5');
    while not Eof do
    begin
      if CB_PPMC.Items.IndexOf(Fields[0].AsString) = -1 then
        CB_PPMC.Items.Add(Fields[0].AsString);
      Next;
    end;
//    CHQMsgBox('formcreate-6');
    Close;
    SQL.Clear;
    SQL.Add('select DISTINCT b.DWJC, b.DWDM, b.PXM from TYS_JYCKJHDPPB a, TGS_GXDWSJB b WHERE a.DWDM=b.DWDM order by b.PXM');
    Open;
//    CHQMsgBox('formcreate-7');
    while not Eof do
    begin
      if CB_DWMC.Items.IndexOf(Fields[0].AsString) = -1 then
        CB_DWMC.Items.Add(Fields[0].AsString);
      Next;
    end;
//    CHQMsgBox('formcreate-8');
    Close;
    SQL.Clear;
    SQL.Add('select RCKXZMC from TGS_JRCKXZDM where RCKXZDM like ''1%''');
    Open;
//    CHQMsgBox('formcreate-9');
    while not Eof do
    begin
      if CB_CKXZ.Items.IndexOf(Fields[0].AsString) = -1 then
        CB_CKXZ.Items.Add(Fields[0].AsString);
      Next;
    end;
//    CHQMsgBox('formcreate-10');
  end;
  GetAllColWidth(self);
//  CHQMsgBox('formcreate-11-end');

end;

procedure TFrmY_CKJHDCX.DBG_JJNFPJHTitleClick(Column: TColumn);
begin
  if Qry_JJNFPJH.SQL.Count < 0 then Exit;
  if Qry_JJNFPJH.SQL.Count > 2 then
    with Qry_JJNFPJH do
    begin
      Close;
      if Column.FieldName = 'DWMC' then
        SQL[SQl.Count - 1] := 'order by DWDM'
      else
        SQL[SQl.Count - 1] := 'order by ' + Column.FieldName;
      if RG_PX.ItemIndex = 1 then
        SQL[SQl.Count - 1] := SQL[SQl.Count - 1] + ' DESC';
      Open;
    end;
  if RG_PX.ItemIndex = 1 then
    RG_PX.ItemIndex := 0
  else
    RG_PX.ItemIndex := 1;
end;

procedure TFrmY_CKJHDCX.NDChange(Sender: TObject);
begin
//  BBt_FindClick(nil);
end;


procedure TFrmY_CKJHDCX.Act_PrintExecute(Sender: TObject);
var
  StrSQL: string;
  Qry_SumDw: TQuery;
  Count_DW: Integer;
  Count_PP: Integer;
begin
  if CB_JHH.Text = '' then
  begin
    CHQMsgBox('请选择分配单号!');
    Exit;
  end;
  if Qry_JJNFPJH.IsEmpty then
    Exit;
  Qry_SumDw := TQuery.Create(nil);
  try
    with Qry_SumDw do
    begin
      Close;
      DatabaseName := 'yzpp';
      SQL.Clear;
      SQl.Add('select sum(fpsl),dwmc from tys_jyckjhdppb where CKJHDH =''' + CB_JHH.Text + ''' group by dwmc');
      Open;
    end;
    Count_DW := Qry_SumDw.RecordCount;
    with Qry_SumDw do
    begin
      Close;
      DatabaseName := 'yzpp';
      SQL.Clear;
      SQl.Add('select sum(fpsl),ppdm from tys_jyckjhdppb where CKJHDH =''' + CB_JHH.Text + ''' group by ppdm');
      Open;
    end;
    Count_PP := Qry_SumDw.RecordCount;
  finally
    Qry_SumDw.Free;
    Qry_SumDw := nil;
  end;
  if (Count_DW >= 1) and (Count_PP = 1) then //单品种多去向
  begin
    Frm_One_More_RPT := TFrm_One_More_RPT.Create(nil);
    with Frm_One_More_RPT do
    try
      Qry_Print.Close;
      StrSQL := 'select ROWNUM, A.CKJHDH, A.CKXZ, A.ZBR, A.PZR, A.ZDRQ, A.BZ, B.DWMC, B.PPMC, B.XJ/100 XJ,B.JJ/100 JJ, B.ZK, B.JSJ/100 JSJ,';
      StrSQL := StrSQL + ' B.FPSL, decode(JSJ,0,B.ZK*B.XJ*B.FPSL/10000, B.JSJ*B.FPSL/100) JE,C.ZH FROM TYS_JYCKJHDB A,TYS_JYCKJHDPPB B,TB_YZPPXXB C where A.CKJHDH = B.CKJHDH AND B.PPDM=C.TDM and A.CKJHDH =''' + CB_JHH.Text + '''';
      Qry_Print.SQL.Text := StrSQL;
      Qry_Print.Open;
      QRLabel4.Caption := Qry_Print.fieldByName('ckjhdh').AsString;
      QRlabel14.Caption := FormatDateTime('YYYY"年"MM"月"DD"日"', StrToDate(Qry_Print.FieldByName('zdrq').AsString));
      QRLabel6.Caption := Qry_Print.fieldbyname('zh').AsString;
      QRLabel8.Caption := Qry_Print.FieldByName('ppmc').AsString;
      QRLabel12.Caption := FormatFloat('#,##0.00', QRy_Print.FieldByName('xj').AsFloat);
      QRLabel10.Caption := FormatFloat('#,##0.00', Qry_Print.fieldbyName('jj').AsFloat);
      Prepare;
      if CHQMsgBox('是否采用套打?', 2) = IDYES then
        Tao_Print_Flag := True
      else
        Tao_Print_Flag := False;

      QRLabel24.Caption := IntToStr(QRPrinter.PageCount);
      DetailLines := 0;
      Qry_Print.First;
      Preview;
      Destroy;
    except
      Free;
    end;
  end;
  if (Count_Dw >= 1) and (Count_PP > 1) then
  begin //多品种多去向
    Application.CreateForm(TFrm_RichEdit, Frm_richedit);
    Frm_More_More_RPT := TFrm_More_More_RPT.Create(nil);
    with Frm_More_More_RPT, Frm_RichEdit do
    try
      Qry_Print.Close;
      StrSQL := 'select ROWNUM, A.CKJHDH, A.CKXZ, A.ZBR, A.PZR, A.ZDRQ, A.BZ, B.DWMC, B.PPMC, B.XJ/100 XJ,B.JJ/100 JJ, B.ZK, Decode(B.JSJ,0,B.ZK,B.JSJ/100) JSJ, ';
      StrSQL := StrSQL + ' B.FPSL, decode(JSJ,0,B.ZK*B.XJ*B.FPSL/10000, B.JSJ*B.FPSL/100) JE,C.ZH FROM TYS_JYCKJHDB A,TYS_JYCKJHDPPB B,TB_YZPPXXB C where A.CKJHDH = B.CKJHDH AND B.PPDM=C.TDM and A.CKJHDH =''' + CB_JHH.Text + ''' order by dwmc';
      Qry_Print.SQL.Text := StrSQL;
      Qry_Print.Open;
      QRLabel4.Caption := Qry_Print.fieldByName('ckjhdh').AsString;
      QRlabel5.Caption := FormatDateTime('YYYY"年"MM"月"DD"日"', StrToDate(Qry_Print.FieldByName('zdrq').AsString));
      Prepare;
      QRLabel21.Caption := IntToStr(QRPrinter.PageCount);
      if CHQMsgBox('是否采用套打?', 2) = IDYES then
        Tao_Print_Flag := True
      else
        Tao_Print_Flag := False;

      DetailLines := 0;
      Qry_Print.First;
      Preview;
      Frm_More_More_RPT.Destroy;
      Frm_RichEdit.Destroy;
    except
      Frm_More_More_RPT.Free;
      Frm_RichEdit.Free;
    end;
  end;
end; { CKJHDCX_RPT := TCKJHDCX_RPT.Create(nil);
  with CKJHDCX_RPT do
  try
    Qry_Print.Close;
    Qry_Print.SQL.Text := 'select ROWNUM, A.CKJHDH, A.CKXZ, A.ZBR, A.PZR, A.ZDRQ, A.BZ ,B.DWMC, B.PPMC, B.XJ, B.ZK, B.JSJ, B.FPSL, decode(JSJ,0,B.ZK*B.XJ*B.FPSL/100, B.JSJ*B.FPSL) JE FROM TYS_JYCKJHDB A,TYS_JYCKJHDPPB B where A.CKJHDH = B.CKJHDH and A.CKJHDH =''' + CB_JHH.Text + '''';
    Qry_Print.Open;
    Preview;
    Destroy;
  except
    Destroy;
  end;
end;}

procedure TFrmY_CKJHDCX.BBt_FindClick(Sender: TObject);
begin
//------------------------------------------------------------------------------
  VG_SQLWhere := '';
  if CBB_JHH.Checked and (CB_JHH.Text <> '') then //1计划号
    VG_SQLWhere := ' and A.CKJHDH = ''' + CB_JHH.Text + ''' ';
  if CBB_DWMC.Checked and (CB_DWMC.Text <> '') then //2单位名称
    VG_SQLWhere := VG_SQLWhere + ' and DWMC = ''' + CB_DWMC.Text + '''';
  if CBB_PPMC.Checked and (CB_PPMC.Text <> '') then //2票品名称
    VG_SQLWhere := VG_SQLWhere + ' and PPMC = ''' + CB_PPMC.Text + '''';
  if CBB_PZR.Checked and (CB_PZR.Text <> '') then //3批准人
    VG_SQLWhere := VG_SQLWhere + ' and PZR = ''' + CB_PZR.Text + ''' ';
  if CBB_ZBR.Checked and (CB_ZBR.Text <> '') then //4制表人
    VG_SQLWhere := VG_SQLWhere + ' and ZBR = ''' + CB_ZBR.Text + ''' ';
  if CBo_CKXZ.Checked and (CB_CKXZ.Text <> '') then
    VG_SQLWhere := VG_SQLWhere + ' and RCKXZMC = ''' + CB_CKXZ.Text + ''' ';
  case RG_ZT.ItemIndex of //5状态
    0: VG_SQLWhere := VG_SQLWhere + ' and ZT =''' + CG_WCL + '''  ';
    1: VG_SQLWhere := VG_SQLWhere + ' and ZT =''' + CG_DG + '''  ';
    2: VG_SQLWhere := VG_SQLWhere + ' and ZT =''' + CG_YCL + '''  ';
  end;
  if CBB_ZDRQ.Checked then //6制单日期
  begin
    VG_SQLWhere := VG_SQLWhere + ' and ZDRQ >=TO_DATE(''' + FormatDateTime('YYYY-DD-MM', DP_FROM.DateTime) + ''',''YYYY-DD-MM'') ';
    VG_SQLWhere := VG_SQLWhere + ' and ZDRQ <=TO_DATE(''' + FormatDateTime('YYYY-DD-MM', DP_TO.DateTime) + ''',''YYYY-DD-MM'') ';
  end;
//------------------------------------------------------------------------------
  with Qry_JJNFPJH do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select A.CKJHDH, C.RCKXZMC CKXZ, A.ZBR, A.PZR,A.ZDRQ, A.BZ , A.ZT, ');
    SQL.Add('B.KFDM, B.DWDM, B.PPDM, B.JJ JJ, B.DWMC, B.KWH, B.PPMC, B.YJ YJ, B.XJ XJ, B.ZK, B.JSJ JSJ, B.FPSL ');
    SQL.Add('FROM TYS_JYCKJHDB A,TYS_JYCKJHDPPB B, TGS_JRCKXZDM C ');
    SQL.Add('where A.CKJHDH = B.CKJHDH and A.CKXZ=C.RCKXZDM ');
    SQL.Add('and TO_CHAR(A.ZDRQ,''YYYY'') =''' + IntToStr(ND.Value) + ''' and not A.CKJHDH LIKE ''GR%'' ');
    SQL.Add(VG_SQLWhere);
    SQL.Add('order by A.CKJHDH ');
    Open;
  end;

end;

procedure TFrmY_CKJHDCX.BBt_HideClick(Sender: TObject);
begin
  Panel4.Visible := not Panel4.Visible;
  if panel4.Visible then
  begin
    BBt_Hide.Caption := '隐藏(&H)';
    BBt_Hide.Hint := '隐藏所有的查询条件。';
  end
  else
  begin
    BBt_Hide.Caption := '显示(&X)';
    BBt_Hide.Hint := '显示所有的查询条件。'
  end;

end;

procedure TFrmY_CKJHDCX.Qry_JJNFPJHJSJGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  CurrGetText(Sender, Text, DisplayText);
end;

procedure TFrmY_CKJHDCX.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  SaveAllColWidth(self);
end;

end.

⌨️ 快捷键说明

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