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

📄 piecehreport.cpp

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

#include <vcl.h>
#pragma hdrstop

#include "PiecehReport.h"
#include "VW_Pieced.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"
TfrmPiecehReport *frmPiecehReport;
//---------------------------------------------------------------------------
__fastcall TfrmPiecehReport::TfrmPiecehReport(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TGroupBaseForm(Owner,chWnd,MidCode,WhereStr)
{
  OwGrid=sgPieceh;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPiecehReport::InitEditControl()
{
 AddGroupItem(edPiecehCodeBox,edPiecehCode,"PiecehCode","PiecehCode","\t单据编号");
 AddGroupItem(cbPiecehFMonthBox,cbPiecehFMonth,"PiecehFmonth","PiecehFmonth","\t财务月份");
 AddGroupItem(cbPiecehShopBox,cbPiecehShop,"PiecehShop1","PiecehShop1","\t车间");
 AddGroupItem(cbPiecehTeamBox,cbPiecehTeam,"PiecehTeam1","PiecehTeam1","\t班组");
 l_SumField ="";
 l_SumField+="";
 l_SumDisp="";
 l_DefField="PiecehCode,PiecehFmonth,PiecehDate,PiecehState1,PiecehShop1,PiecehTeam1,PiecehCheck1,PiecehChecker,PiecehCheckDate,PiecehUser1 from SDVW_Pieceh ";
 l_DefDisp="\t单据编号\t财务月份\t制单日期\t状态\t车间\t班组\t审核\t审核日期\t审核人\t制单人";
 s_DateField="PiecehDate";

  FillComboBox(Handle,cbPiecehFMonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
  FillComboBox(Handle,cbPiecehShop,"SELECT DISTINCT PiecehShop1=IsNull((select ShopName from sdShop where ShopCode=PiecehShop),'') from sdPieceh","PiecehShop1","PiecehShop1");
  FillComboBox(Handle,cbPiecehTeam,"SELECT DISTINCT PiecehTeam1=isnull((select TeamName from sdTeam where TeamCode=PiecehTeam),'') FROM sdPieceh","PiecehTeam1","PiecehTeam1");
}
//---------------------------------------------------------------------------
void __fastcall TfrmPiecehReport::edPiecehCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="004[单据编号][财务月份][制单日期][状态]select PiecehCode,PiecehFmonth,PiecehDate,PiecehState1 from SDVW_Pieceh  order by PiecehDate DESC,PiecehCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"单据编号查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
     edPiecehCode->Text=(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPiecehReport::dtDateEnChange(TObject *Sender)
{

 dtDateBg->Text=dtDateEn->Text;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPiecehReport::sgPiecehDblClick(TObject *Sender)
{
    int ARow=sgPieceh->Row;
    if(ARow>0)
       FillGridWithDetail();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPiecehReport::GetDetailQueryStr()
{
    AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
    if(sgPieceh->RowCount < 2)
       return("");
    if(sgPieceh->Row == 1)
       return("");
    Selectstr="select "
            +AnsiString("PiecedLine, ")
            +AnsiString("PiecedWo, ")
            +AnsiString("PiecedProcess, ")
            +AnsiString("PiecedEmployee, ")
            +AnsiString("PiecedEmployeeName, ")
            +AnsiString("PiecedDType, ")
            +AnsiString("PiecedQty, ")
            +AnsiString("PiecedPrice, ")
            +AnsiString("PiecedDesc ");

    Fromstr=" from SDVW_Pieced ";
    Wherestr=" where PiecedCode='"+sgPieceh->Cells[1][sgPieceh->Row]+"'";
    Orderstr=" order by PiecedLine ";
    return(Selectstr+Fromstr+Wherestr+Orderstr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPiecehReport::FillGridWithDetail()
{
    TComResultSet *RsQuery;
    AnsiString ItemStr,sSql;
    TfrmVW_Pieced *VW_Pieced;
    sSql=GetDetailQueryStr();  //取Detail查询的SQL语句
    if(sSql=="")
       return;
    try
    {
      VW_Pieced=new TfrmVW_Pieced(this);
      int ARow=sgPieceh->Row;
      VW_Pieced->sePiecehCode->Text=sgPieceh->Cells[1][ARow];
      VW_Pieced->scPiecehFmonth->Text=sgPieceh->Cells[2][ARow];
      VW_Pieced->dePiecehDate->Text=sgPieceh->Cells[3][ARow];
      VW_Pieced->scPiecehShop->Text=sgPieceh->Cells[5][ARow];

      VW_Pieced->sgPieced->RowCount=1;
      RsQuery=new  TComResultSet(Handle,g_ClientHandle);
      RsQuery->Open(sSql,"");
      RsQuery->MoveFirst();
      while(RsQuery->Eof == 0)
      {
         ItemStr=  RsQuery->FieldByName("PiecedLine")+
              "\t"+RsQuery->FieldByName("PiecedWo")+
              "\t"+RsQuery->FieldByName("PiecedProcess")+
              "\t"+RsQuery->FieldByName("PiecedEmployee")+
              "\t"+RsQuery->FieldByName("PiecedEmployeeName")+
              "\t"+RsQuery->FieldByName("PiecedDType")+
              "\t"+RsQuery->FieldByName("PiecedQty")+
              "\t"+RsQuery->FieldByName("PiecedPrice")+
              "\t"+RsQuery->FieldByName("PiecedDesc");
       VW_Pieced->sgPieced->AddItem(ItemStr);
       RsQuery->MoveNext();
    }
    RsQuery->Close();
    delete RsQuery;
    if(VW_Pieced->sgPieced->RowCount > 1)
       VW_Pieced->ShowModal();
    }
    __finally
    {
       delete VW_Pieced;
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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