soghcheck.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 252 行
CPP
252 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "SoghCheck.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSoghCheck *frmSoghCheck;
//---------------------------------------------------------------------------
__fastcall TfrmSoghCheck::TfrmSoghCheck(TComponent* Owner,HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
:TListBaseForm(Owner, chWnd, MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::InitEditControl()
{
FillComboBox(Handle,scSoghSaler,"Select userCode,UserName from sdUser where UserCode in (select SalerCode from SdSaler)","UserName","UserCode");
FillComboBox(Handle,scSoghClient,"Select ClientCode,ClientName from sdClient where ClientCancel=0","ClientName","ClientCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::ClearControl()
{
seSoghCodeF->Text ="";
seSoghCodeT->Text ="";
deSoghDateF->Text ="";
deSoghDateT->Text ="";
scSoghClient->ItemIndex =-1;
scSoghSaler->ItemIndex =-1;
SoghGrid->RowCount=1;
SogdGrid->RowCount=1;
btnCheck->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::GetDataFromComObject(int Section)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::SendDataToComObject(int Section)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::WaitUserInput(int Section)
{
}
void __fastcall TfrmSoghCheck::ChangeToBrowseState(bool Browse)
{
ClearControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::DisplayBill()
{
FillHeadGridWithData();
comServer->MoveFirst();
FillDetailGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::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 TfrmSoghCheck::FillDetailGridWithData()
{
int i;
AnsiString ItemStr;
SogdGrid->RowCount=1;
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
ItemStr="\t"+GetDetailValue("SogdLine")+"\t"+GetDetailValue("SogdSoCode")+"\t"+
GetDetailValue("SogdSodLine")+"\t"+GetDetailValue("SogdGoods")+"\t"+
GetDetailValue("SogdGoodsName")+"\t"+GetDetailValue("SogdGoodsSpec")+"\t"+
GetDetailValue("SogdUnit")+"\t"+
GetDetailValue("SogdQty")+"\t"+GetDetailValue("SogdRecDate");
SogdGrid->AddItem(ItemStr);
}
}
void __fastcall TfrmSoghCheck::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\t"+GetHeadValue("SoghCode")+"\t"+
GetHeadValue("SoghClient")+"\t"+GetHeadValue("SoghDate")+"\t"+
TypeStr+"\t"+GetHeadValue("SoghSaler");
SoghGrid->AddItem(HeadStr);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::FormShow(TObject *Sender)
{
// InitEditControl();
ClearControl();
ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSoghCheck::GetWhereSQLString()
{
AnsiString WhereStr;
WhereStr="SoghCheck=0 and SoghCancel=0";
WhereStr=WhereStr+" and SoghClient in(select ClientCode from sdClient where ClientCancel=0)";
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->ItemData[1])+"'";
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->ItemData[1])+"'";
return(WhereStr);
}
void __fastcall TfrmSoghCheck::btnClearClick(TObject *Sender)
{
ClearControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::btnQueryClick(TObject *Sender)
{
SoghGrid->RowCount=1;
SogdGrid->RowCount=1;
btnCheck->Enabled=false;
AnsiString WhereStr=GetWhereSQLString();
GetBill(WhereStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::SoghGridClick(TObject *Sender)
{
//DONE:BUG NO.569 FIXED 2001-8-26
if(SoghGrid->Row>0 && MR<=SoghGrid->Row && MR>0)
{
comServer->LocateByKey(WideString(SoghGrid->TextMatrix[MR][2]));
if(MC == 1)
{
if(SoghGrid->TextMatrix[MR][1]=="√")
{
SoghGrid->TextMatrix[MR][1]="";
}
else
{
SoghGrid->TextMatrix[MR][1]="√";
}
}
FillDetailGridWithData();
}
//======== END OF FIX =============
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::btnCheckClick(TObject *Sender)
{
for(int i=1; i<SoghGrid->RowCount;i++)
{
if(SoghGrid->TextMatrix[i][1]=="√")
{
comServer->LocateByKey(WideString(SoghGrid->TextMatrix[i][2]));
try
{
comServer->LocateByKey(WideString(SoghGrid->TextMatrix[i][2]));
comServer->Edit();
SetHeadValue("SoghCheck",1);
SetHeadValue("SoghChecker",g_sdUserCode);
comServer->Check(1);
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
}
ClearControl();
btnQueryClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::btnQuiteClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCheck::SoghGridMouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
int Column,Row;
SoghGrid->MouseToCell(X,Y,Column,Row);
//DONE:BUG NO.569 FIXED 2001-8-26
MC = Column;
MR = Row;
//======= END OF FIX ============
if(Column==1&&Row>0)
SoghGrid->Cursor=crHandPoint;
else
SoghGrid->Cursor=crDefault;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?