pohcancel.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 253 行
CPP
253 行
//---------------------------------------------------------------------------
#include <vcl.h>
//---------------------------------------------------------------------------
#pragma hdrstop
#include "PohCancel.h"
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "ListBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmPohCancel *frmPohCancel;
//---------------------------------------------------------------------------
__fastcall TfrmPohCancel::TfrmPohCancel(TComponent* Owner, HWND chWnd, AnsiString ClassCode,AnsiString WhereStr)
: TListBaseForm(Owner,chWnd,ClassCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::FillHeadObjToGrid()
{
AnsiString ItemStr;
try
{
StartWaitForm("正在获取数据...");
comServer->FilterString=WideString(WhereStr);
comServer->Query();
if(comServer->RecordCount>0)
{
sgPohCancel->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");
sgPohCancel->AddItem(ItemStr);
}
}
else
{
sgPohCancel->RowCount=1;
sgPodCancel->RowCount=1;
}
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::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 TfrmPohCancel::InitEditControl()
{
sgPohCancel->RowCount=1;
sgPodCancel->RowCount=1;
btnCancel->Enabled=false;
sePohCodeF->Text="";
sePohCodeT->Text="";
dePohDateF->Text="";
dePohDateT->Text=dePohDateT->InitDate;
scPohBuyerCode->Text="";
scPohSupplyCode->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::ChangeToBrowseState(bool agree)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::AddDetailObjToGrid(AnsiString s_Code)
{
AnsiString ItemStr,temp;
sgPodCancel->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");
sgPodCancel->AddItem(ItemStr,i+1);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::DelDetailObjFromGrid(AnsiString s_Code)
{
AnsiString m;
for(int i=sgPodCancel->RowCount;i>0;i--)
{
m = Trim(sgPodCancel->Cells[1][i]);
if(m==s_Code)
sgPodCancel->RemoveItem(i);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::btnClearClick(TObject *Sender)
{
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::btnQueryClick(TObject *Sender)
{
HavingRight();
GetWhereStrToSQL();
FillHeadObjToGrid();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::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 TfrmPohCancel::BitExitClick(TObject *Sender)
{
frmPohCancel->Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::btnCancelClick(TObject *Sender)
{
AnsiString sBillCode;
for(int i=sgPohCancel->RowCount; i>0;i--)
{
if(sgPohCancel->Cells[1][i]=="√")
{
sBillCode=sgPohCancel->Cells[2][i];
comServer->LocateByKey(WideString(sBillCode));
if(!comServer->Eof)
{
try
{
comServer->Edit();
SetHeadValue("PohCancel",1);
SetHeadValue("PohCanceler",g_sdUserCode);
SetHeadValue("PohCancelDate",g_sdCurDate);
comServer->Revoke(1);
}
catch(Exception &e)
{
throw Exception("取消采购单<"+sBillCode+">出现错误!\n"+e.Message);
}
}
DelDetailObjFromGrid(sgPohCancel->Cells[2][i]);
sgPohCancel->Cells[1][i]="";
sgPohCancel->RemoveItem(i);
}
}
sgPodCancel->RowCount=1;
btnCancel->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::sgPohCancelDblClick(TObject *Sender)
{
if(sgPohCancel->Row>0)
{
if(sgPohCancel->Cells[1][sgPohCancel->Row]==" ")
{
btnCancel->Enabled=true;
sgPohCancel->Cells[1][sgPohCancel->Row]="√";
// AddDetailObjToGrid(sgPohCancel->Cells[2][ARow]);
}
else
{
sgPohCancel->Cells[1][sgPohCancel->Row]=" ";
// DelDetailObjFromGrid(sgPohCancel->Cells[2][ARow]);
//找到有没有需要审核的
for (int i=1;i<sgPohCancel->RowCount;i++)
{
if(sgPohCancel->Cells[1][i]=="√")
{
btnCancel->Enabled=true;
break;
}
else
btnCancel->Enabled=false;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::HavingRight()
{
}
//---------------------------------------------
void __fastcall TfrmPohCancel::sgPohCancelClick(TObject *Sender)
{
if(sgPohCancel->RowCount > 1 && sgPohCancel->Row > 0)
{
AddDetailObjToGrid(sgPohCancel->Cells[2][sgPohCancel->Row]);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?