📄 soghcancel.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "SoghCancel.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSoghCancel *frmSoghCancel;
//---------------------------------------------------------------------------
__fastcall TfrmSoghCancel::TfrmSoghCancel(TComponent* Owner)
:TListBaseForm(Owner,euSdSogh,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::InitEditControl()
{
FillComboBox(scSoghSaler,"Select userCode,UserName from sdUser where UserCode in (select SalerCode from SdSaler)","UserName","UserCode");
FillComboBox(scSoghClient,"Select ClientCode,ClientName from sdClient where ClientCancel=0","ClientName","ClientCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::ClearControl()
{
seSoghCodeF->Text ="";
seSoghCodeT->Text ="";
deSoghDateF->Text ="";
deSoghDateT->Text ="";
scSoghClient->ItemIndex =-1;
scSoghSaler->ItemIndex =-1;
SoghGrid->RowCount=1;
SogdGrid->RowCount=1;
btnCancel->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::GetDataFromComObject(int Section)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::SendDataToComObject(int Section)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::WaitUserInput(int Section)
{
}
void __fastcall TfrmSoghCancel::ChangeToBrowseState(bool Browse)
{
ClearControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::DisplayBill()
{
FillHeadGridWithData();
comServer->MoveFirst();
FillDetailGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::GetBill(AnsiString WhereStr)
{
comServer->FilterString=WideString(WhereStr);
comServer->Query();
if (comServer->RecordCount!=0) //Found it
{
btnCancel->Enabled=true;
DisplayBill();
}
else
ShowMessageWindow("在数据库中没有查到记录,请重新输入条件",mwsInformation);
RecodCount->Caption="查询单据数为:"+IntToStr(comServer->RecordCount);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::FillDetailGridWithData()
{
int i;
AnsiString ItemStr;
SogdGrid->RowCount=1;
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
ItemStr="\t"+GetDetailValue(fiSogdLine)+"\t"+GetDetailValue(fiSogdSoCode)+"\t"+
GetDetailValue(fiSogdSodLine)+"\t"+
GetDetailValue(fiSogdGoods)+"\t"+GetDetailValue(fiSogdUnit)+"\t"+
GetDetailValue(fiSogdQty)+"\t"+GetDetailValue(fiSogdRecDate);
SogdGrid->AddItem(ItemStr);
}
}
void __fastcall TfrmSoghCancel::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(fiSoghClient)+"\t"+GetHeadValue(fiSoghDate)+"\t"+
TypeStr+"\t"+GetHeadValue(fiSoghSaler);
SoghGrid->AddItem(HeadStr);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSoghCancel::GetHeadValue(int Index)
{
WideString S;
S = ReadFieldValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSoghCancel::GetDetailValue(int Index)
{
WideString S;
S = ReadItemValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::FormShow(TObject *Sender)
{
// InitEditControl();
ClearControl();
ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSoghCancel::GetWhereSQLString()
{
AnsiString WhereStr;
WhereStr="SoghCancel=0 and SoghCheck=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 TfrmSoghCancel::btnClearClick(TObject *Sender)
{
ClearControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::btnQueryClick(TObject *Sender)
{
SoghGrid->RowCount=1;
SogdGrid->RowCount=1;
btnCancel->Enabled=false;
AnsiString WhereStr=GetWhereSQLString();
GetBill(WhereStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::SoghGridClick(TObject *Sender)
{
if(SoghGrid->Row>0)
{
comServer->LocateByKey(WideString(SoghGrid->TextMatrix[SoghGrid->Row][2]));
if(SoghGrid->Col == 1)
{
if(SoghGrid->TextMatrix[SoghGrid->Row][1]=="ㄨ")
{
SoghGrid->TextMatrix[SoghGrid->Row][1]="";
}
else
{
SoghGrid->TextMatrix[SoghGrid->Row][1]="ㄨ";
}
}
FillDetailGridWithData();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::btnCancelClick(TObject *Sender)
{
for(int i=1; i<SoghGrid->RowCount;i++)
{
if(SoghGrid->TextMatrix[i][1]=="ㄨ")
{
comServer->LocateByKey(WideString(SoghGrid->TextMatrix[i][2]));
try{
comServer->Revoke(1);
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
}
ClearControl();
btnQueryClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::btnQuiteClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoghCancel::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;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -