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

📄 gmthreport.cpp

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

#include <vcl.h>
#pragma hdrstop

#include "GmthReport.h"
#include "VW_Gmtd.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"
TfrmGmthReport *frmGmthReport;
//---------------------------------------------------------------------------
__fastcall TfrmGmthReport::TfrmGmthReport(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TGroupBaseForm(Owner,chWnd,MidCode,WhereStr)
{
  OwGrid=sgGmth;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmthReport::InitEditControl()
{
 AddGroupItem(edGmthCodeBox,edGmthCode,"GmthCode","GmthCode","\t单据编号");
 AddGroupItem(edGmthWoCodeBox,edGmthWoCode,"GmthWoCode","GmthWoCode","\t加工单号");
 AddGroupItem(cbGmthTypeBox,cbGmthType,"GmthType1","GmthType","\t领料类型");
 AddGroupItem(cbGmthDeptBox,cbGmthDept,"GmthDept1","GmthDept","\t领料部门");
 l_SumField ="";
 l_SumField+="";
 l_SumDisp="";
 l_DefField=" GmthCode,GmthFmonth,GmthDate,GmthType1,GmthPosType,GmthWoCode,GmthDept1,GmthCheck1,GmthChecker,GmthCheckDate,GmthUser1,GmthDesc from SDVW_Gmth ";
 l_DefDisp="\t单据编号\t财务月份\t制单日期\t领料类型\t收发类型\t加工单号\t领料部门\t审核\t审核日期\t审核人\t制单人\t备注";
 s_DateField="GmthDate";

  FillComboBox(Handle,cbGmthType,"SELECT DISTINCT GmthType1=case GmthType when 1 then '定额领料' when 2 then '工单领料' when 3 then '工序补料' when 4 then '共用件领料'  when 5 then '部门领料' end FROM sdGmth","GmthType1","GmthType1");
  FillComboBox(Handle,cbGmthDept,"SELECT DISTINCT GmthDept1=isnull((select DeptName from sdDept where DeptCode=GmthDept),'') FROM sdGmth","GmthDept1","GmthDept1");
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmthReport::edGmthCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="003[单据编号][财务月份][制单日期]select GmthCode,GmthFmonth,GmthDate from SDVW_Gmth  order by GmthDate DESC,GmthCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"单号查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
     edGmthCode->Text=(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmthReport::edGmthWoCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="004[加工单号][单据编号][财务月份][制单日期]select GmthWoCode,GmthCode,GmthFmonth,GmthDate from SDVW_Gmth  order by GmthDate DESC,GmthCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"加工单号查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
     edGmthWoCode->Text=(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmthReport::dtDateEnChange(TObject *Sender)
{

 dtDateBg->Text=dtDateEn->Text;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmthReport::sgGmthDblClick(TObject *Sender)
{
    int ARow=sgGmth->Row;
    if(ARow>0)
       FillGridWithDetail();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGmthReport::GetDetailQueryStr()
{
    AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
    if(sgGmth->RowCount < 2)
      return("");
    if(sgGmth->Row == 0)
      return("");
    Selectstr="select "
            +AnsiString("GmtdLine, ")
            +AnsiString("GmtdProcess, ")
            +AnsiString("GmtdGoods, ")
            +AnsiString("GmtdUnit, ")
            +AnsiString("GmtdQty, ")
            +AnsiString("GmtdDQty, ")
            +AnsiString("GmtdDLoc, ")
            +AnsiString("GmtdSLoc, ")
            +AnsiString("GmtdBatch, ")
            +AnsiString("GmtdDesc ");

    Fromstr=" from SDVW_Gmtd ";
    Wherestr=" where GmtdCode='"+sgGmth->Cells[1][sgGmth->Row]+"'";
    Orderstr=" order by GmtdLine ";
    return(Selectstr+Fromstr+Wherestr+Orderstr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmthReport::FillGridWithDetail()
{
    TComResultSet *RsQuery;
    AnsiString ItemStr,sSql;
    TfrmVW_Gmtd *VW_Gmtd;
    sSql=GetDetailQueryStr();  //取Detail查询的SQL语句
    if(sSql=="")
       return;
    try
    {
      VW_Gmtd=new TfrmVW_Gmtd(this);
      int ARow=sgGmth->Row;
      VW_Gmtd->seGmthCode->Text=sgGmth->Cells[1][ARow];
      VW_Gmtd->scGmthFmonth->Text=sgGmth->Cells[2][ARow];
      VW_Gmtd->deGmthDate->Text=sgGmth->Cells[3][ARow];
      VW_Gmtd->scGmthType->Text=sgGmth->Cells[4][ARow];
      VW_Gmtd->scGmthWoCode->Text=sgGmth->Cells[6][ARow];

      VW_Gmtd->sgGmtd->RowCount=1;
      RsQuery=new  TComResultSet(Handle,g_ClientHandle);
      RsQuery->Open(sSql,"");
      RsQuery->MoveFirst();
      while(RsQuery->Eof == 0)
      {
         ItemStr=  RsQuery->FieldByName("GmtdLine")+
              "\t"+RsQuery->FieldByName("GmtdProcess")+
              "\t"+RsQuery->FieldByName("GmtdGoods")+
              "\t"+RsQuery->FieldByName("GmtdUnit")+
              "\t"+RsQuery->FieldByName("GmtdQty")+
              "\t"+RsQuery->FieldByName("GmtdDQty")+
              "\t"+RsQuery->FieldByName("GmtdDLoc")+
              "\t"+RsQuery->FieldByName("GmtdSLoc")+
              "\t"+RsQuery->FieldByName("GmtdBatch")+
              "\t"+RsQuery->FieldByName("GmtdDesc");
       VW_Gmtd->sgGmtd->AddItem(ItemStr);
       RsQuery->MoveNext();
    }
    RsQuery->Close();
    delete RsQuery;
    if(VW_Gmtd->sgGmtd->RowCount > 1)
       VW_Gmtd->ShowModal();
    }
    __finally
    {
       delete VW_Gmtd;
    }
}



⌨️ 快捷键说明

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