goodsinfocenter.cpp

来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 577 行 · 第 1/2 页

CPP
577
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "GoodsInfoCenter.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "fpanel"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
#define l_PageCount 6
TfrmGoodsInfoCenter *frmGoodsInfoCenter;
//---------------------------------------------------------------------------
__fastcall TfrmGoodsInfoCenter::TfrmGoodsInfoCenter(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
    : TListBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmGoodsInfoCenter::FormShow(TObject *Sender)
{
    AnsiString sSQL;
        ///////////////////
  try
 {
  StartWaitForm("正在获取数据...");
  ///////////////////
  InitEditControl();
        PageControlGoods->ActivePage=TabGoodSee;
        FillGridWithData();
        //FillGridWithMaccDate();
        FillEditText();
        l_CurrentRow=1;
        for(int i=0;i<l_PageCount;i++)
        {
           l_RecordRow[i]=0;
        }
  }
 __finally
 {
  EndWaitForm();
 }

}
//---------------------------------------------------------------------------
void __fastcall TfrmGoodsInfoCenter::InitEditControl()
{
        seGoodsCode->Text="";
        seGoodsName->Text="";
        seGoodsUnit->Text="";
        seGoodsType->Text="";
        seGoodsPmpc->Text="";
        seGoodsSthQty->Text="";
        seMadeQty->Text="";
        seDopQty->Text="";
        //seGuest->Text="";
        //seMaccFopQty->Text="";

        FillComboBox(Handle,scFcBegin,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
        FillComboBox(Handle,scFcEnd,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
        scFcBegin->Text="";
        scFcEnd->Text="";
}
//---------------------------------------------------------------------------
AnsiString  __fastcall TfrmGoodsInfoCenter::GetGoodsbaseSQL()
{
   AnsiString sql;
   sql="select * from  ksVW_GoodsSee where GoodsCode like '%'    order by goodspmpccode,goodscode ";
   return (sql);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGoodsInfoCenter::FillGridWithData()
{
 TComResultSet *RsQuery;
 AnsiString ItemStr,sSql;
 //获取查询语句
 sSql=GetGoodsbaseSQL();
 if(sSql=="")
  return;
 try
 {
  sgGoodsGrid->RowCount=1;
  RsQuery=new  TComResultSet(Handle,g_ClientHandle);
  RsQuery->Open(sSql,"");
  RsQuery->MoveFirst();
  //StartWaitForm("正在获取数据...");
//  AnsiString l_GoodsType,l_GoodsFrom;
  while( RsQuery->Eof == 0)
  {
       ItemStr=RsQuery->FieldByName("GoodsCode")+     //物料编码
          "\t"+RsQuery->FieldByName("GoodsName")+      //物料名称
          "\t"+RsQuery->FieldByName("PmpcName")+    //物料分类
          "\t"+RsQuery->FieldByName("GoodsUnitCode")+     //计量单位
          "\t"+RsQuery->FieldByName("GoodsType")+    //物料类型
          "\t"+RsQuery->FieldByName("GoodsSpec")+      //规格
          "\t"+RsQuery->FieldByName("LocName")+ //货位
          "\t"+RsQuery->FieldByName("GoodsFrom")+  //货物来源
          "\t"+RsQuery->FieldByName("GoodsSafeQty")+      //安全库存量
          "\t"+RsQuery->FieldByName("GoodsRopQty")+  //再订货点
          "\t"+RsQuery->FieldByName("GoodsEoq")+     //订货批量
          "\t"+RsQuery->FieldByName("GoodsMaxQty")+      //最大库存
          "\t"+RsQuery->FieldByName("GoodsWasteRate")+ //损耗率
          "\t"+RsQuery->FieldByName("GoodsPaot")+ //采购提前期
          "\t"+RsQuery->FieldByName("GoodsPlanType")+    //计划方法
          "\t"+RsQuery->FieldByName("sypplyname")+  //供应商
          "\t"+RsQuery->FieldByName("GoodsCurrencyCode")+      //币种
          "\t"+RsQuery->FieldByName("GoodsGtqVal")+        //保质期
          "\t"+RsQuery->FieldByName("GoodsMinQty")+        //最小库存
          "\t"+RsQuery->FieldByName("GoodsLlc");     //底层码
   sgGoodsGrid->AddItem(ItemStr);
   RsQuery->MoveNext();
  }
  RsQuery->Close();

 }
 __finally
 {
  delete RsQuery;
  //EndWaitForm();
 }
}

//---------------------------------------------------------------------------
void __fastcall TfrmGoodsInfoCenter::FillEditText()
{
   int irow;
        irow=sgGoodsGrid->Row;
        //FillEditText(iRow);
        seGoodsCode->Text=sgGoodsGrid->Cells[0][irow];
        seGoodsName->Text=sgGoodsGrid->Cells[1][irow];
        seGoodsPmpc->Text=sgGoodsGrid->Cells[2][irow];
        seGoodsUnit->Text=sgGoodsGrid->Cells[3][irow];
        seGoodsType->Text=sgGoodsGrid->Cells[4][irow];

}
//---------------------------------------------------------------------------
void __fastcall TfrmGoodsInfoCenter::FillEditTextPage(int row)
{
  AnsiString l_GoodsCode;
  l_GoodsCode=sgGoodsGrid->Cells[0][row];

  if (PageControlGoods->ActivePage==TabTshbase&&l_RecordRow[0]!=row)
  {
        FillGridWithSthDate(Trim(l_GoodsCode));
        l_RecordRow[0]=row;
  }
  else if(PageControlGoods->ActivePage==TabDeptbase&&l_RecordRow[1]!=row)
  {
        FillGridWithDeptDate(Trim(l_GoodsCode));
        l_RecordRow[1]=row;
  }
  else if(PageControlGoods->ActivePage==TabBatchbase&&l_RecordRow[2]!=row)
  {
        FillGridWithBatchDate(Trim(l_GoodsCode));
        l_RecordRow[2]=row;
  }
  else if(PageControlGoods->ActivePage==TabDohbase&&l_RecordRow[3]!=row)
  {
        FillGridWithSodtDate(Trim(l_GoodsCode));
        l_RecordRow[3]=row;
  }
  else if(PageControlGoods->ActivePage==TabSee&&l_RecordRow[4]!=row)
  {
        FillGridWithMaccDate(Trim(l_GoodsCode));
        l_RecordRow[4]=row;
  }
  else if(PageControlGoods->ActivePage==TabBase&&l_RecordRow[5]!=row)
  {
        InitCtrolFree();
        InitCtrolSet(Trim(l_GoodsCode));
        l_RecordRow[5]=row;
  }

}
void __fastcall TfrmGoodsInfoCenter::FillGridWithSthDate(AnsiString GoodsCode)
{
    TComResultSet *RsQuery;
    AnsiString SthSQL,ItemStr;
    AnsiString MonthSQL;
    MonthSQL=GetFmonthSQL("MaccFmonth");
    if (MonthSQL!="")
    SthSQL="select LocSthCode,SthName=isNull((select SthName from sdSth where SthCode=LocSthCode),''),maccloc,Locname=isnull((select LocName from sdLoc where LocCode=MaccLoc),''),MaccFmonth,MaccBopQty,MaccIopQty,MaccSopQty,MaccRopQty,MaccFopQty,lgState=(case lgState when 1 then '正在使用' when 2 then  '正在停用' else '已停用' end)  from sdmacc,sdLoc,sdlg where MaccLoc=LocCode and lgLoccode=Maccloc and LgGoodsCode='"+GoodsCode+"'"+" and MaccGoods= '"+GoodsCode+"' and "+MonthSQL;
    else
    SthSQL="select LocSthCode,SthName=isNull((select SthName from sdSth where SthCode=LocSthCode),''),maccloc,Locname=isnull((select LocName from sdLoc where LocCode=MaccLoc),''),MaccFmonth,MaccBopQty,MaccIopQty,MaccSopQty,MaccRopQty,MaccFopQty,lgState=(case lgState when 1 then '正在使用' when 2 then  '正在停用' else '已停用' end)  from sdmacc,sdLoc,sdlg where MaccLoc=LocCode and lgLoccode=Maccloc and LgGoodsCode='"+GoodsCode+"'"+" and MaccGoods= '"+GoodsCode+"'";
    if(SthSQL=="")
        return;
 try
 {
  sgSthState->RowCount=1;
  RsQuery=new  TComResultSet(Handle,g_ClientHandle);
  RsQuery->Open(SthSQL,"");
  RsQuery->MoveFirst();
  //StartWaitForm("正在获取数据...");
  while( RsQuery->Eof == 0)
  {
       ItemStr=RsQuery->FieldByName("LocSthCode")+     //仓库编码
          "\t"+RsQuery->FieldByName("SthName")+      //仓库名称
          "\t"+RsQuery->FieldByName("maccloc")+    //货位编码
          "\t"+RsQuery->FieldByName("Locname")+     //货位名称
          "\t"+RsQuery->FieldByName("MaccBopQty")+    //期初数
          "\t"+RsQuery->FieldByName("MaccIopQty")+      //入库数量
          "\t"+RsQuery->FieldByName("MaccSopQty")+ //出库数量
          "\t"+RsQuery->FieldByName("MaccRopQty")+  //调整数
          "\t"+RsQuery->FieldByName("MaccFopQty")+      //结存数量
          "\t"+RsQuery->FieldByName("MaccFmonth")+  //财务月份
          "\t"+RsQuery->FieldByName("lgState");     //库位状态
          sgSthState->AddItem(ItemStr);
   RsQuery->MoveNext();
  }
  RsQuery->Close();

 }
 __finally
 {
  delete RsQuery;
  //EndWaitForm();
 }
}
//------------------------------------------------------------------------
void __fastcall TfrmGoodsInfoCenter::FillGridWithDeptDate(AnsiString GoodsCode)
{
    TComResultSet *RsQuery;
    AnsiString DeptSQL,ItemStr;
   /* DeptSQL="select DthtDept,DeptName=isnull((select DeptName from sddept where DeptCode=DthtDept),''),DthtLoc,Locname=isnull((select LocName from sdloc where loccode=DthtLoc),'')," ;
    DeptSQL=DeptSQL+"DthtBopQty,DthtIopQty,DthtOopQty,DthtFopQty=(DthtBopQty+DthtIopQty-DthtOopQty),lgState=(case lgState when 1 then '正在使用' when 2 then  '正在停用' else '已停用' end),DthtFmonth ";
    DeptSQL=DeptSQL+"  from sdDtht,sdlg where DthtGoods=lgGoodscode and DthtLoc=lgLocCode and DthtGoods='"+GoodsCode+"' order by DthtFmonth,DthtDept";
    */
    AnsiString MonthSQL;
    MonthSQL=GetFmonthSQL("DthtFmonth");
    if (MonthSQL!="")
    DeptSQL="select * from ksVW_DthtCenter where DthtGoods='"+GoodsCode+"' and " +MonthSQL+" order by DthtFmonth,DthtDept";
    else
    DeptSQL="select * from ksVW_DthtCenter where DthtGoods='"+GoodsCode+"' order by DthtFmonth,DthtDept";
    if(DeptSQL=="")
  return;
 try
 {
  sgDeptGrid->RowCount=1;
  RsQuery=new  TComResultSet(Handle,g_ClientHandle);
  RsQuery->Open(DeptSQL,"");
  RsQuery->MoveFirst();
  while( RsQuery->Eof == 0)
  {
       ItemStr=RsQuery->FieldByName("DthtFmonth")+      //财务月份
          "\t"+RsQuery->FieldByName("DthtDept")+     //部门编码
          "\t"+RsQuery->FieldByName("DeptName")+      //部门名称
          "\t"+RsQuery->FieldByName("DthtLoc")+    //货位编码
          "\t"+RsQuery->FieldByName("Locname")+     //货位名称
          "\t"+RsQuery->FieldByName("DthtBopQty")+    //期初数
          "\t"+RsQuery->FieldByName("DthtIopQty")+      //入库数量
          "\t"+RsQuery->FieldByName("DthtOopQty")+ //出库数量
          "\t"+RsQuery->FieldByName("DthtFopQty")+  //结存数量
          "\t"+RsQuery->FieldByName("DthtFmonth")+  //财务月份
          "\t"+RsQuery->FieldByName("lgState");     //库位状态
          sgDeptGrid->AddItem(ItemStr);
   RsQuery->MoveNext();
  }
  RsQuery->Close();

 }
 __finally
 {
  delete RsQuery;
 }
}
//----------------------------------------------------------------------
void __fastcall TfrmGoodsInfoCenter::FillGridWithBatchDate(AnsiString GoodsCode)
{
  TComResultSet *RsQuery;
    AnsiString BatchSQL,ItemStr;
   /* BatchSQL="select BthtBatch,BthtFmonth,BthtLoc,Locname=isnull((select LocName from sdloc where loccode=BthtLoc),'')," ;
    BatchSQL=BatchSQL+"BthtBopQty,BthtIopQty,BthtOopQty,BthtFopQty=(BthtBopQty+BthtIopQty-BthtOopQty),BthtBoyQty,BthtIoyQty,BthtOoyQty,BthtAoyQty,lgState=(case lgState when 1 then '正在使用' when 2 then  '正在停用' else '已停用' end) ";
    BatchSQL=BatchSQL+"  from sdBtht,sdlg where BthtGoods=lgGoodscode and BthtLoc=lgLocCode and BthtGoods='"+GoodsCode+"' order by BthtFmonth,BthtBatch ";
   */
    AnsiString MonthSQL;
    MonthSQL=GetFmonthSQL("BthtFmonth");
    if (MonthSQL!="")
    BatchSQL="select * from ksVW_BthtCenter where BthtGoods='"+GoodsCode+"' and "+MonthSQL+" order by BthtFmonth,BthtBatch ";
    else
    BatchSQL="select * from ksVW_BthtCenter where BthtGoods='"+GoodsCode+"' order by BthtFmonth,BthtBatch ";
  if(BatchSQL=="")
  return;
 try
 {
  sgBatchGrid->RowCount=1;

⌨️ 快捷键说明

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