📄 srethcheck.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "SrethCheck.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSrethCheck *frmSrethCheck;
//---------------------------------------------------------------------------
__fastcall TfrmSrethCheck::TfrmSrethCheck(TComponent* Owner)
:TListBaseForm(Owner,euSdSreth,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::InitEditControl()
{
FillComboBox(scSrethSaler,"Select userCode,UserName from sdUser where UserCode in (select SalerCode from SdSaler)","UserName","UserCode");
FillComboBox(scSrethClient,"Select ClientCode,ClientName from sdClient where ClientCancel=0","ClientName","ClientCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::ClearControl()
{
seSrethCodeF->Text ="";
seSrethCodeT->Text ="";
deSrethDateF->Text ="";
deSrethDateT->Text ="";
scSrethClient->ItemIndex =-1;
scSrethSaler->ItemIndex =-1;
SrethGrid->RowCount=1;
SretdGrid->RowCount=1;
btnCheck->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::GetDataFromComObject(int Section)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::SendDataToComObject(int Section)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::WaitUserInput(int Section)
{
}
void __fastcall TfrmSrethCheck::ChangeToBrowseState(bool Browse)
{
ClearControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::DisplayBill()
{
FillHeadGridWithData();
comServer->MoveFirst();
FillDetailGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::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 TfrmSrethCheck::FillDetailGridWithData()
{
int i;
AnsiString ItemStr;
SretdGrid->RowCount=1;
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
ItemStr="\t"+GetDetailValue(fiSretdLine)+"\t"+GetDetailValue(fiSretdSogCode)+"\t"+
GetDetailValue(fiSretdSogdLine)+"\t"+
GetDetailValue(fiSretdGoods)+"\t"+GetDetailValue(fiSretdUnit)+"\t"+
GetDetailValue(fiSretdQty);
SretdGrid->AddItem(ItemStr);
}
}
void __fastcall TfrmSrethCheck::FillHeadGridWithData()
{
int i;
AnsiString HeadStr;
SrethGrid->RowCount=1;
for (i=0;i<comServer->RecordCount;i++)
{
comServer->LocateByIndex(i);
HeadStr="\t"+AnsiString(" ")+"\t"+GetHeadValue(fiSrethCode)+"\t"+
GetHeadValue(fiSrethClient)+"\t"+GetHeadValue(fiSrethDate)+"\t"+
GetHeadValue(fiSrethCurrency)+"\t"+GetHeadValue(fiSrethRr);
SrethGrid->AddItem(HeadStr);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSrethCheck::GetHeadValue(int Index)
{
WideString S;
S = ReadFieldValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSrethCheck::GetDetailValue(int Index)
{
WideString S;
S = ReadItemValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::FormShow(TObject *Sender)
{
// InitEditControl();
ClearControl();
ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSrethCheck::GetWhereSQLString()
{
AnsiString WhereStr;
WhereStr="SrethCheck=0 and SrethCancel=0";
WhereStr=WhereStr+" and SrethClient in(select ClientCode from sdClient where ClientCancel=0)";
if(!seSrethCodeF->Text.IsEmpty())
WhereStr=WhereStr+" and SrethCode>='"+Trim(seSrethCodeF->Text)+"'";
if(!seSrethCodeT->Text.IsEmpty())
WhereStr=WhereStr+" and SrethCode<='"+Trim(seSrethCodeT->Text)+"'";
// if(!scSrethSaler->Text.IsEmpty())
// WhereStr=WhereStr+" and SrethSaler='"+Trim(scSrethSaler->ItemData[1])+"'";
if(!deSrethDateF->Text.IsEmpty())
WhereStr=WhereStr+" and SrethDate>='"+FormatDateTime("YYYY-MM-DD",deSrethDateF->Date)+"'";
if(!deSrethDateT->Text.IsEmpty())
WhereStr=WhereStr+" and SrethDate<='"+FormatDateTime("YYYY-MM-DD",deSrethDateT->Date)+"'";
if(!scSrethClient->Text.IsEmpty())
WhereStr=WhereStr+" and SrethClient='"+Trim(scSrethClient->ItemData[1])+"'";
return(WhereStr);
}
void __fastcall TfrmSrethCheck::btnClearClick(TObject *Sender)
{
ClearControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::btnQueryClick(TObject *Sender)
{
SrethGrid->RowCount=1;
SretdGrid->RowCount=1;
btnCheck->Enabled=false;
AnsiString WhereStr=GetWhereSQLString();
GetBill(WhereStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::SrethGridClick(TObject *Sender)
{
if(SrethGrid->Row>0)
{
comServer->LocateByKey(WideString(SrethGrid->TextMatrix[SrethGrid->Row][2]));
if(SrethGrid->Col == 1)
{
if(SrethGrid->TextMatrix[SrethGrid->Row][1]=="√")
{
SrethGrid->TextMatrix[SrethGrid->Row][1]="";
}
else
{
SrethGrid->TextMatrix[SrethGrid->Row][1]="√";
}
}
FillDetailGridWithData();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::btnCheckClick(TObject *Sender)
{
for(int i=1; i<SrethGrid->RowCount;i++)
{
if(SrethGrid->TextMatrix[i][1]=="√")
{
comServer->LocateByKey(WideString(SrethGrid->TextMatrix[i][2]));
SetHeadValue(fiSrethChecker,g_sdUserCode);
try{
comServer->Check(1);
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
}
ClearControl();
btnQueryClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::btnQuiteClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCheck::SrethGridMouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
int Column,Row;
SrethGrid->MouseToCell(X,Y,Column,Row);
if(Column==1&&Row>0)
SrethGrid->Cursor=crHandPoint;
else
SrethGrid->Cursor=crDefault;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -