soghdisp.cpp
来自「科思ERP部分源码及控件」· C++ 代码 · 共 253 行
CPP
253 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "SoghDisp.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSoghDisp *frmSoghDisp;
//---------------------------------------------------------------------------
__fastcall TfrmSoghDisp::TfrmSoghDisp(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
:TListBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
__fastcall TfrmSoghDisp::TfrmSoghDisp(TComponent* Owner)
:TListBaseForm(Owner)
{
}
void __fastcall TfrmSoghDisp::InitEditControl()
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::ClearControl()
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::GetDataFromComObject(int Section)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::SendDataToComObject(int Section)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::WaitUserInput(int Section)
{
}
void __fastcall TfrmSoghDisp::ChangeToBrowseState(bool Browse)
{
ClearControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::DisplayBill()
{
FillHeadGridWithData();
comServer->MoveFirst();
FillDetailGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::GetBill(AnsiString WhereStr)
{
comServer->FilterString=WideString(WhereStr);
comServer->Query();
if (comServer->RecordCount!=0) //Found it
{
btnCheck->Enabled=true;
DisplayBill();
}
else
ShowMessageWindow("在数据库中没有查到记录,请重新输入条件",mwsInformation);
RecodCount->Caption="查询单据数为:"+IntToStr(comServer->RecordCount);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::FillDetailGridWithData()
{
int i;
AnsiString ItemStr,ID;
SogdGrid->RowCount=1;
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
if(GetDetailValue("SogdState")=="8")
ID="√";
else
ID=" ";
ItemStr="\t"+ID+"\t"+GetDetailValue("SogdLine")+"\t"+GetDetailValue("SogdSoCode")+"\t"+
GetDetailValue("SogdSodLine")+"\t"+GetDetailValue("SogdGoods")+"\t"+
GetDetailValue("sogdGoodsName")+"\t"+GetDetailValue("SogdGoodsSpec")+"\t"+
GetDetailValue("SogdUnit")+"\t"+
GetDetailValue("SogdQty");
SogdGrid->AddItem(ItemStr);
}
}
void __fastcall TfrmSoghDisp::FillHeadGridWithData()
{
int i,Type;
AnsiString HeadStr,TypeStr;
SoghGrid->RowCount=1;
for (i=0;i<comServer->RecordCount;i++)
{
comServer->LocateByIndex(i);
Type=StrToInt(GetHeadValue("SoghType"));
switch(Type)
{
case 1:
TypeStr="据订单发货";
break;
case 2:
TypeStr="非订单发货";
break;
}
// HeadStr="\t"+AnsiString(" ")+"\t"+GetHeadValue("SoghCode")+"\t"+GetHeadValue("SoghSoCode)+"\t"+
// GetHeadValue("SoghContract")+"\t"+
// GetHeadValue("SoghClient")+"\t"+GetHeadValue("SoghDate)+"\t"+
// TypeStr+"\t"+GetHeadValue("SoghSaler");
SoghGrid->AddItem(HeadStr);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::FormShow(TObject *Sender)
{
AnsiString WhereStr;
WhereStr=GetWhereSQLString()+" and SoghSoCode='"+BillNumID+"'";
GetBill(WhereStr);
ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSoghDisp::GetWhereSQLString()
{
AnsiString WhereStr;
WhereStr="SoghCheck=1 and SoghCancel=0 and SoghType<4";
/* if(!seSoghCodeF->Text.IsEmpty())
WhereStr=WhereStr+" and SoghCode>='"+Trim(seSoghCodeF->Text)+"'";
if(!seSoghCodeT->Text.IsEmpty())
WhereStr=WhereStr+" and SoghCode<='"+Trim(seSoghCodeT->Text)+"'";
if(!scSoghSaler->Text.IsEmpty())
WhereStr=WhereStr+" and SoghSaler='"+Trim(scSoghSaler->Text)+"'";
if(!deSoghDateF->Text.IsEmpty())
WhereStr=WhereStr+" and SoghDate>='"+FormatDateTime("YYYY-MM-DD",deSoghDateF->Date)+"'";
if(!deSoghDateT->Text.IsEmpty())
WhereStr=WhereStr+" and SoghDate<='"+FormatDateTime("YYYY-MM-DD",deSoghDateT->Date)+"'";
if(!scSoghClient->Text.IsEmpty())
WhereStr=WhereStr+" and SoghClient='"+Trim(scSoghClient->Text)+"'";
*/ return(WhereStr);
}
void __fastcall TfrmSoghDisp::SoghGridClick(TObject *Sender)
{
AnsiString State;
comServer->LocateByKey(WideString(SoghGrid->TextMatrix[SoghGrid->Row][2]));
if(SoghGrid->Col == 1&&SoghGrid->Row>0)
{
if(SoghGrid->TextMatrix[SoghGrid->Row][1]=="√")
{
SoghGrid->TextMatrix[SoghGrid->Row][1]="";
State="9";
}
else
{
SoghGrid->TextMatrix[SoghGrid->Row][1]="√";
State="8";
}
for(int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
SetDetailValue("SogdState",State);
comServer->AddToObject();
}
}
FillDetailGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::SoghGridMouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
int Column,Row;
SoghGrid->MouseToCell(X,Y,Column,Row);
if(Column==1&&Row>0)
SoghGrid->Cursor=crHandPoint;
else
SoghGrid->Cursor=crDefault;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::SogdGridMouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
int Column,Row;
SogdGrid->MouseToCell(X,Y,Column,Row);
if(Column==1&&Row>0)
SogdGrid->Cursor=crHandPoint;
else
SogdGrid->Cursor=crDefault;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::SogdGridClick(TObject *Sender)
{
if(SogdGrid->Col == 1&&SogdGrid->Row>0)
{
comServer->LocateItemByKey(WideString(SogdGrid->TextMatrix[SogdGrid->Row][2]));
if(SogdGrid->TextMatrix[SogdGrid->Row][1]=="√")
{
SogdGrid->TextMatrix[SogdGrid->Row][1]="";
// SoghGrid->TextMatrix[SoghGrid->Row][1]="";
SetDetailValue("SogdState","0");
}
else
{
SogdGrid->TextMatrix[SogdGrid->Row][1]="√";
SetDetailValue("SogdState","8");
}
comServer->AddToObject();
//假设没有选定明细;
SoghGrid->TextMatrix[SoghGrid->Row][1]="";
for(int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
if(GetDetailValue("SogdState")=="8")
{
//明细有,则单头可选;
SoghGrid->TextMatrix[SoghGrid->Row][1]="√";
break;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::FormClose(TObject *Sender,TCloseAction &Action)
{
TListBaseForm::FormClose(Sender,Action);
//..
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?