rpohcancel.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 249 行
CPP
249 行
//---------------------------------------------------------------------------
#include <vcl.h>
#include "RpohCancel.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "ListBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmRpohCancel *frmRpohCancel;
//---------------------------------------------------------------------------
__fastcall TfrmRpohCancel::TfrmRpohCancel(TComponent* Owner, HWND chWnd, AnsiString ClassCode,AnsiString WhereStr)
: TListBaseForm(Owner,chWnd,ClassCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::FillHeadObjToGrid()
{
AnsiString ItemStr;
int i=0;
try
{
StartWaitForm("正在获取数据...");
comServer->FilterString=WideString(WhereStr);
comServer->Query();
if(comServer->RecordCount>0)
{
sgRpohCheck->RowCount=1;
for(i=0;i<comServer->RecordCount;i++)
{
comServer->LocateByIndex(i);
ItemStr="\t"+ AnsiString(" ")+
"\t"+ GetHeadValue("RpohCode")+
"\t"+ GetHeadValue("RpohDate")+
"\t"+ GetHeadValue("RpohSupplyCode")+
"\t"+ GetHeadValue("RpohCurrencyCode")+
"\t"+ GetHeadValue("RpohTaxCode")+
"\t"+ GetHeadValue("RpohBuyerCode")+
"\t"+ GetHeadValue("RpohPsite")+
"\t"+ GetHeadValue("RpohDeliver");
sgRpohCheck->AddItem(ItemStr);
}
}
else
{
sgRpohCheck->RowCount=1;
sgRpodCheck->RowCount=1;
}
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::GetWhereStrToSQL()
{
WhereStr="RpohCheck=0 and RpohCancel=0 and ";
if(Trim(seRpohCodeF->Text).IsEmpty()==false)
WhereStr=WhereStr+ "RpohCode>='"+Trim(seRpohCodeF->Text)+"' and ";
if(Trim(seRpohCodeT->Text).IsEmpty()==false)
WhereStr=WhereStr+ "RpohCode<='"+Trim(seRpohCodeT->Text)+"' and ";
if(Trim(deRpohDateF->Text).IsEmpty()==false)
WhereStr=WhereStr+ "RpohDate>='"+FormatDateTime("yyyy-mm-dd",deRpohDateF->Date)+"' and ";
if(Trim(deRpohDateT->Text).IsEmpty()==false)
WhereStr=WhereStr+ "RpohDate<='"+FormatDateTime("yyyy-mm-dd",deRpohDateT->Date)+"' and ";
if(Trim(scRpohBuyerCode->Text).IsEmpty()==false)
WhereStr=WhereStr+ "RpohBuyerCode = '"+Trim(scRpohBuyerCode->ItemData[cbItem2])+"' and ";
if(Trim(scRpohSupplyCode->Text).IsEmpty()==false)
WhereStr=WhereStr+ "RpohSupplyCode = '"+Trim(scRpohSupplyCode->ItemData[cbItem2])+"' and ";
if (WhereStr.Length() > 5)
WhereStr=WhereStr.SubString(1,WhereStr.Length()-5);
else
WhereStr="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::InitEditControl()
{
sgRpohCheck->RowCount=1;
sgRpodCheck->RowCount=1;
btnCheck->Enabled=false;
seRpohCodeF->Text="";
seRpohCodeT->Text="";
deRpohDateF->Text="";
deRpohDateT->Text=deRpohDateT->InitDate;
scRpohBuyerCode->Text="";
scRpohSupplyCode->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::ChangeToBrowseState(bool agree)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::AddDetailObjToGrid(AnsiString s_Code)
{
AnsiString ItemStr,temp;
sgRpodCheck->RowCount=1;
comServer->LocateByKey(WideString(s_Code));
if(comServer->RecordCount>0)
{
for (int i=0;i<comServer->ItemCount;i++)
{ l_Query->LocateByKey(GetDetailValue("RpodGoodsCode"));
ItemStr="\t"+GetDetailValue("RpodCode")+
"\t"+GetDetailValue("RpodLine")+
"\t"+GetDetailValue("RpodGoodsCode")+
"\t"+l_Query->FieldByName("goodsname")+
"\t"+l_Query->FieldByName("goodsspec")+
"\t"+GetDetailValue("RpodUnitCode")+
"\t"+GetDetailValue("RpodConvRate")+
"\t"+GetDetailValue("RpodQty")+
"\t"+GetDetailValue("RpodPrice")+
"\t"+GetDetailValue("RpodAmt")+
"\t"+GetDetailValue("RpodReqDate");
sgRpodCheck->AddItem(ItemStr,i+1);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::DelDetailObjFromGrid(AnsiString s_Code)
{
AnsiString m;
for(int i=sgRpodCheck->RowCount;i>0;i--)
{
m = Trim(sgRpodCheck->Cells[1][i]);
if(m==s_Code)
sgRpodCheck->RemoveItem(i);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::btnClearClick(TObject *Sender)
{
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::btnQueryClick(TObject *Sender)
{
HavingRight();
GetWhereStrToSQL();
FillHeadObjToGrid();
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::FormShow(TObject *Sender)
{
FillComboBox(Handle,scRpohBuyerCode,"select BuyerCode,BuyerName from sdBuyer order By BuyerCode","BuyerName","BuyerCode");
FillComboBox(Handle,scRpohSupplyCode,"select SupplyCode,SupplyName from sdSupply order By SupplyCode","SupplyName","SupplyCode");
InitEditControl();
l_Query->Close();
l_Query->Open("select goodsname,goodscode,goodsspec from sdgoods","goodscode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::BitExitClick(TObject *Sender)
{
frmRpohCancel->Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::btnCheckClick(TObject *Sender)
{
AnsiString sBillCode;
for(int i=sgRpohCheck->RowCount-1; i>0;i--)
{
if(sgRpohCheck->Cells[1][i]=="√")
{
sBillCode=sgRpohCheck->Cells[2][i];
comServer->LocateByKey(WideString(sBillCode));
if(!comServer->Eof)
{
try
{
comServer->Edit();
SetHeadValue("RpohCancel",0);
SetHeadValue("RpohCancelDate",g_sdCurDate);
comServer->Revoke(1);
}
catch(Exception &e)
{
throw Exception("审核请购单<"+sBillCode+">出现错误!\n"+e.Message);
}
}
DelDetailObjFromGrid(sgRpohCheck->Cells[2][i]);
sgRpohCheck->Cells[1][i]="";
sgRpohCheck->RemoveItem(i);
}
}
sgRpodCheck->RowCount=1;
btnCheck->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::sgRpohCheckDblClick(TObject *Sender)
{
int ARow=sgRpohCheck->Row;
if(ARow>0)
{
if(sgRpohCheck->Cells[1][ARow]==" ")
{
btnCheck->Enabled=true;
sgRpohCheck->Cells[1][ARow]="√";
}
else
{
sgRpohCheck->Cells[1][ARow]=" ";
//找到有没有需要审核的
for (int i=1;i<sgRpohCheck->RowCount;i++)
{
if(sgRpohCheck->Cells[1][i]=="√")
{
btnCheck->Enabled=true;
break;
}
else
btnCheck->Enabled=false;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCancel::HavingRight()
{
}
//---------------------------------------------
void __fastcall TfrmRpohCancel::sgRpohCheckClick(TObject *Sender)
{
if(sgRpohCheck->RowCount > 1 && sgRpohCheck->Row > 0)
{
AddDetailObjToGrid(sgRpohCheck->Cells[2][sgRpohCheck->Row]);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?