📄 soghdisp.cpp
字号:
//---------------------------------------------------------------------------
#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)
:TListBaseForm(Owner,euSdSogh,"")
{
}
//---------------------------------------------------------------------------
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(fiSogdState)=="8")
ID="√";
else
ID=" ";
ItemStr="\t"+ID+"\t"+GetDetailValue(fiSogdLine)+"\t"+GetDetailValue(fiSogdSoCode)+"\t"+
GetDetailValue(fiSogdSodLine)+"\t"+
GetDetailValue(fiSogdGoods)+"\t"+GetDetailValue(fiSogdUnit)+"\t"+
GetDetailValue(fiSogdQty);
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(fiSoghType));
switch(Type)
{
case 1:
TypeStr="据订单发货";
break;
case 2:
TypeStr="非订单发货";
break;
}
// HeadStr="\t"+AnsiString(" ")+"\t"+GetHeadValue(fiSoghCode)+"\t"+GetHeadValue(fiSoghSoCode)+"\t"+
// GetHeadValue(fiSoghContract)+"\t"+
// GetHeadValue(fiSoghClient)+"\t"+GetHeadValue(fiSoghDate)+"\t"+
// TypeStr+"\t"+GetHeadValue(fiSoghSaler);
SoghGrid->AddItem(HeadStr);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSoghDisp::GetHeadValue(int Index)
{
WideString S;
S = ReadFieldValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSoghDisp::GetDetailValue(int Index)
{
WideString S;
S = ReadItemValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
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(fiSogdState,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(fiSogdState,"0");
}
else
{
SogdGrid->TextMatrix[SogdGrid->Row][1]="√";
SetDetailValue(fiSogdState,"8");
}
comServer->AddToObject();
//假设没有选定明细;
SoghGrid->TextMatrix[SoghGrid->Row][1]="";
for(int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
if(GetDetailValue(fiSogdState)=="8")
{
//明细有,则单头可选;
SoghGrid->TextMatrix[SoghGrid->Row][1]="√";
break;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghDisp::FormClose(TObject *Sender,
TCloseAction &Action)
{
//..
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -