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

📄 dmahreport.cpp

📁 科思ERP部分源码及控件
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "DmahReport.h"
#include "VW_Dmad.h"
#include "WnQuery.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "GroupBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "KSAdvReport"
#pragma resource "*.dfm"
TfrmDmahReport *frmDmahReport;
//---------------------------------------------------------------------------
__fastcall TfrmDmahReport::TfrmDmahReport(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TGroupBaseForm(Owner,chWnd,MidCode,WhereStr)
{
  OwGrid=sgDmah;
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmahReport::InitEditControl()
{
 AddGroupItem(edDmahCodeBox,edDmahCode,"DmahCode","DmahCode","\t单据编号");
 AddGroupItem(cbDmahFMonthBox,cbDmahFMonth,"DmahFmonth","DmahFmonth","\t财务月份");
 AddGroupItem(cbDmahPosTypeBox,cbDmahPosType,"DmahPosType1","DmahPosType","\t收发类型");
 AddGroupItem(cbDmahLocBox,cbDmahLoc,"DmahLoc1","DmahLoc1","\t分摊货位");
 l_SumField ="";
 l_SumField+="";
 l_SumDisp="";
 l_DefField=" DmahCode,DmahFmonth,DmahDate,DmahPosType,DmahLoc1,DmahCheck1,DmahChecker,DmahCheckDate,DmahUser1,DmahDesc from SDVW_Dmah ";
 l_DefDisp="\t单据编号\t财务月份\t制单日期\t收发类型\t分摊货位\t审核\t审核日期\t审核人\t制单人\t备注";
 s_DateField="DmahDate";

  FillComboBox(Handle,cbDmahFMonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
  FillComboBox(Handle,cbDmahPosType,"SELECT DISTINCT DmahPosType=(select PosTypeName from sdPosType where PosTypeCode=DmahPosType) FROM sdDmah","DmahType","DmahType");
  FillComboBox(Handle,cbDmahLoc,"select LocName from sdLoc","LocName","LocName");
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmahReport::edDmahCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="003[单据编号][财务月份][制单日期]select DmahCode,DmahFmonth,DmahDate from SDVW_Dmah  order by DmahDate DESC,DmahCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"单号查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
     edDmahCode->Text=(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmahReport::dtDateEnChange(TObject *Sender)
{

 dtDateBg->Text=dtDateEn->Text;
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmahReport::sgDmahDblClick(TObject *Sender)
{
    int ARow=sgDmah->Row;
    if(ARow>0)
       FillGridWithDetail();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmDmahReport::GetDetailQueryStr()
{
    AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
    if(sgDmah->RowCount < 2)
       return("");
    if(sgDmah->Row == 0)
       return("");
    Selectstr="select "
            +AnsiString("DmadLine, ")
            +AnsiString("DmadWoCode, ")
            +AnsiString("DmadGoods, ")
            +AnsiString("DmadGoodsName, ")
            +AnsiString("DmadUnit, ")
            +AnsiString("DmadQty, ")     //分摊数量
            +AnsiString("DmadDesc ");

    Fromstr=" from SDVW_Dmad ";
    Wherestr=" where DmadCode='"+sgDmah->Cells[1][sgDmah->Row]+"'";
    Orderstr=" order by DmadLine ";
    return(Selectstr+Fromstr+Wherestr+Orderstr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmahReport::FillGridWithDetail()
{
    TComResultSet *RsQuery;
    AnsiString ItemStr,sSql;
    TfrmVW_Dmad *VW_Dmad;
    sSql=GetDetailQueryStr();  //取Detail查询的SQL语句
    if(sSql=="")
       return;
    try
    {
      VW_Dmad=new TfrmVW_Dmad(this);
      int ARow=sgDmah->Row;
      VW_Dmad->seDmahCode->Text=sgDmah->Cells[1][ARow];
      VW_Dmad->scDmahFmonth->Text=sgDmah->Cells[2][ARow];
      VW_Dmad->deDmahDate->Text=sgDmah->Cells[3][ARow];
      VW_Dmad->scDmahLoc->Text=sgDmah->Cells[5][ARow];

      VW_Dmad->sgDmad->RowCount=1;
      RsQuery=new  TComResultSet(Handle,g_ClientHandle);
      RsQuery->Open(WideString(sSql),WideString(""));
      RsQuery->MoveFirst();
      while(RsQuery->Eof == 0)
      {
         ItemStr=  RsQuery->FieldByName("DmadLine")+
              "\t"+RsQuery->FieldByName("DmadWoCode")+
              "\t"+RsQuery->FieldByName("DmadGoods")+
              "\t"+RsQuery->FieldByName("DmadGoodsName")+
              "\t"+RsQuery->FieldByName("DmadUnit")+
              "\t"+RsQuery->FieldByName("DmadQty")+
              "\t"+RsQuery->FieldByName("DmadDesc");
       VW_Dmad->sgDmad->AddItem(ItemStr);
       RsQuery->MoveNext();
    }
    RsQuery->Close();
    delete RsQuery;
    if(VW_Dmad->sgDmad->RowCount > 1)
       VW_Dmad->ShowModal();
    }
    __finally
    {
       delete VW_Dmad;
    }
}



⌨️ 快捷键说明

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