pohcheck.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 255 行
CPP
255 行
//---------------------------------------------------------------------------
#include <vcl.h>
#include "PohCheck.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"
TfrmPohCheck *frmPohCheck;
//---------------------------------------------------------------------------
__fastcall TfrmPohCheck::TfrmPohCheck(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TListBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::FillHeadObjToGrid()
{
AnsiString ItemStr;
try
{
StartWaitForm("正在获取数据...");
comServer->FilterString=WideString(WhereStr);
comServer->Query();
if(comServer->RecordCount>0)
{
sgPohCheck->RowCount=1;
for(int i=0;i<comServer->RecordCount;i++)
{
comServer->LocateByIndex(i);
ItemStr="\t"+ AnsiString(" ")+
"\t"+ GetHeadValue("PohCode")+
"\t"+ GetHeadValue("PohDate")+
"\t"+ GetHeadValue("PohSupply")+
"\t"+ GetHeadValue("PohCurrency")+
"\t"+ GetHeadValue("PohTaxCode")+
"\t"+ GetHeadValue("PohBuyer")+
"\t"+ GetHeadValue("PohContract")+
"\t"+ GetHeadValue("PohSugDate");
sgPohCheck->AddItem(ItemStr);
}
}
else
{
sgPohCheck->RowCount=1;
sgPodCheck->RowCount=1;
}
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::GetWhereStrToSQL()
{
WhereStr="PohCheck=0 and PohCancel=0 and PohStop=0 and PohClose=0 and ";
if(Trim(sePohCodeF->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohCode>='"+Trim(sePohCodeF->Text)+"' and ";
if(Trim(sePohCodeT->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohCode<='"+Trim(sePohCodeT->Text)+"' and ";
if(Trim(dePohDateF->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohDate>='"+FormatDateTime("yyyy-mm-dd",dePohDateF->Date)+"' and ";
if(Trim(dePohDateT->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohDate<='"+FormatDateTime("yyyy-mm-dd",dePohDateT->Date)+"' and ";
if(Trim(scPohBuyerCode->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohBuyer like '"+Trim(scPohBuyerCode->ItemData[cbItem2])+"' and ";
if(Trim(scPohSupplyCode->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohSupply like '"+Trim(scPohSupplyCode->ItemData[cbItem2])+"' and ";
if (WhereStr.Length() > 5)
WhereStr=WhereStr.SubString(1,WhereStr.Length()-5);
else
WhereStr="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::InitEditControl()
{
sgPohCheck->RowCount=1;
sgPodCheck->RowCount=1;
btnCheck->Enabled=false;
sePohCodeF->Text="";
sePohCodeT->Text="";
dePohDateF->Text="";
dePohDateT->Text=dePohDateT->InitDate;
scPohBuyerCode->Text="";
scPohSupplyCode->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::ChangeToBrowseState(bool agree)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::AddDetailObjToGrid(AnsiString s_Code)
{
AnsiString ItemStr,temp;
sgPodCheck->RowCount =1;
comServer->LocateByKey(WideString(s_Code));
if(comServer->RecordCount>0)
{
for (int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
l_Query->LocateByKey(GetDetailValue("PodGoods"));
ItemStr="\t"+GetDetailValue("PodCode")+
"\t"+GetDetailValue("PodLine")+
"\t"+GetDetailValue("PodGoods")+
"\t"+l_Query->FieldByName("goodsname")+
"\t"+l_Query->FieldByName("goodsspec")+
"\t"+GetDetailValue("PodUnit")+
"\t"+GetDetailValue("PodReqDate")+
"\t"+GetDetailValue("PodQty")+
"\t"+GetDetailValue("PodDept")+
"\t"+GetDetailValue("PodLoc")+
"\t"+GetDetailValue("PodSo");
sgPodCheck->AddItem(ItemStr,i+1);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::DelDetailObjFromGrid(AnsiString s_Code)
{
AnsiString m;
for(int i=sgPodCheck->RowCount;i>0;i--)
{
m = Trim(sgPodCheck->Cells[1][i]);
if(m==s_Code)
sgPodCheck->RemoveItem(i);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::btnClearClick(TObject *Sender)
{
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::btnQueryClick(TObject *Sender)
{
HavingRight();
GetWhereStrToSQL();
FillHeadObjToGrid();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::FormShow(TObject *Sender)
{
l_Query->Close();
l_Query->Open("select goodsname,goodscode,goodsspec from sdgoods","goodscode");
FillComboBox(Handle,scPohBuyerCode,"select BuyerCode,BuyerName from sdBuyer order By BuyerCode","BuyerName","BuyerCode");
FillComboBox(Handle,scPohSupplyCode,"select SupplyCode,SupplyName from sdSupply order By SupplyCode","SupplyName","SupplyCode");
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::BitExitClick(TObject *Sender)
{
frmPohCheck->Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::btnCheckClick(TObject *Sender)
{
AnsiString sBillCode;
for(int i=sgPohCheck->RowCount-1; i>0;i--)
{
if(sgPohCheck->Cells[1][i]=="√")
{
sBillCode=sgPohCheck->Cells[2][i];
comServer->LocateByKey(WideString(sBillCode));
if(!comServer->Eof)
{
try
{
comServer->Edit();
SetHeadValue("PohCheck",1);
SetHeadValue("PohChecker",g_sdUserCode);
SetHeadValue("PohCheckDate",g_sdCurDate);
comServer->Check(1);
}
catch(Exception &e)
{
throw Exception("审核采购单<"+sBillCode+">出现错误!\n"+e.Message);
}
}
DelDetailObjFromGrid(sgPohCheck->Cells[2][i]);
sgPohCheck->Cells[1][i]="";
sgPohCheck->RemoveItem(i);
}
}
sgPodCheck->RowCount=1;
btnCheck->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::sgPohCheckDblClick(TObject *Sender)
{
if(sgPohCheck->Row>0)
{
if(sgPohCheck->Cells[1][sgPohCheck->Row]==" ")
{
btnCheck->Enabled=true;
sgPohCheck->Cells[1][sgPohCheck->Row]="√";
// AddDetailObjToGrid(sgPohCheck->Cells[2][ARow]);
}
else
{
sgPohCheck->Cells[1][sgPohCheck->Row]=" ";
// DelDetailObjFromGrid(sgPohCheck->Cells[2][ARow]);
//找到有没有需要审核的
for (int i=1;i<sgPohCheck->RowCount;i++)
{
if(sgPohCheck->Cells[1][i]=="√")
{
btnCheck->Enabled=true;
break;
}
else
btnCheck->Enabled=false;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCheck::HavingRight()
{
}
//---------------------------------------------
void __fastcall TfrmPohCheck::sgPohCheckClick(TObject *Sender)
{
if(sgPohCheck->RowCount > 1 && sgPohCheck->Row > 0)
{
AddDetailObjToGrid(sgPohCheck->Cells[2][sgPohCheck->Row]);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?