scraphcheck.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 260 行
CPP
260 行
//---------------------------------------------------------------------------
#include <vcl.h>
#include "ScraphCheck.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"
TfrmScraphCheck *frmScraphCheck;
//---------------------------------------------------------------------------
__fastcall TfrmScraphCheck::TfrmScraphCheck(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TListBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::FillHeadObjToGrid()
{
AnsiString ItemStr;
try
{
StartWaitForm("正在获取数据...");
comServer->FilterString=WideString(WhereStr);
comServer->Query();
if(comServer->RecordCount>0)
{
sgScraphCheck->RowCount=1;
for(int i=0;i<comServer->RecordCount;i++)
{
comServer->LocateByIndex(i);
ItemStr="\t"+ AnsiString(" ")+
"\t"+ GetHeadValue("ScraphCode")+
"\t"+ GetHeadValue("ScraphDate")+
"\t"+ GetHeadValue("ScraphPosType")+
"\t"+ GetHeadValue("ScraphDept")+
"\t"+ GetHeadValue("ScraphUser")+
"\t"+ GetHeadValue("ScraphKeeper");
sgScraphCheck->AddItem(ItemStr);
}
}
else
{
sgScraphCheck->RowCount=1;
sgScrapdCheck->RowCount=1;
}
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::GetWhereStrToSQL()
{
WhereStr="ScraphCheck=0 and ScraphCancel=0 and ";
if(Trim(seScraphCodeF->Text).IsEmpty()==false)
WhereStr=WhereStr+ "ScraphCode>='"+Trim(seScraphCodeF->Text)+"' and ";
if(Trim(seScraphCodeT->Text).IsEmpty()==false)
WhereStr=WhereStr+ "ScraphCode<='"+Trim(seScraphCodeT->Text)+"' and ";
if(Trim(deScraphDateF->Text).IsEmpty()==false)
WhereStr=WhereStr+ "ScraphDate>='"+FormatDateTime("yyyy-mm-dd",deScraphDateF->Date)+"' and ";
if(Trim(deScraphDateT->Text).IsEmpty()==false)
WhereStr=WhereStr+ "ScraphDate<='"+FormatDateTime("yyyy-mm-dd",deScraphDateT->Date)+"' and ";
if(Trim(scScraphUser->Text).IsEmpty()==false)
WhereStr=WhereStr+ "ScraphUser like '"+Trim(scScraphUser->ItemData[cbItem2])+"' and ";
if(Trim(scScraphKeeper->Text).IsEmpty()==false)
WhereStr=WhereStr+ "ScraphKeeper like '"+Trim(scScraphKeeper->ItemData[cbItem2])+"' and ";
if (WhereStr.Length() > 5)
WhereStr=WhereStr.SubString(1,WhereStr.Length()-5);
else
WhereStr="";
// ShowMessage(WhereStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::InitEditControl()
{
sgScraphCheck->RowCount=1;
sgScrapdCheck->RowCount=1;
btnCheck->Enabled=false;
seScraphCodeF->Text="";
seScraphCodeT->Text="";
deScraphDateF->Text="";
deScraphDateT->Text=g_sdCurDate;
scScraphUser->Text="";
scScraphKeeper->Text="";
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::ChangeToBrowseState(bool agree)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::AddDetailObjToGrid(AnsiString s_Code)
{
AnsiString ItemStr;
sgScrapdCheck->RowCount=1;
comServer->LocateByKey(WideString(s_Code));
if(comServer->RecordCount>0)
{
for (int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
ItemStr="\t"+GetDetailValue("ScrapdCode")+
"\t"+GetDetailValue("ScrapdLine")+
"\t"+GetDetailValue("ScrapdGoods")+
"\t"+GetDetailValue("ScrapdUnit")+
"\t"+GetDetailValue("ScrapdQty")+
"\t"+GetDetailValue("ScrapdSr");
sgScrapdCheck->AddItem(ItemStr,i+1);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::DelDetailObjFromGrid(AnsiString s_Code)
{
AnsiString m;
for(int i=sgScrapdCheck->RowCount-1;i>0;i--)
{
m = Trim(sgScrapdCheck->Cells[1][i]);
if(m==s_Code)
sgScrapdCheck->RemoveItem(i);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::btnClearClick(TObject *Sender)
{
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::btnQueryClick(TObject *Sender)
{
sgScraphCheck->RowCount=1;
sgScrapdCheck->RowCount=1;
HavingRight();
GetWhereStrToSQL();
FillHeadObjToGrid();
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::FormShow(TObject *Sender)
{
AnsiString sSQL;
sSQL="select '('+usercode+')'+username name,usercode from sduser order by usercode";
FillComboBox(Handle,scScraphUser,sSQL,"name","usercode");
sSQL="select '('+usercode+')'+username name,usercode from sdkeeper,sduser ";
sSQL=sSQL+" where sdkeeper.keepercode=sduser.usercode ";
sSQL=sSQL+" order by usercode ";
FillComboBox(Handle,scScraphKeeper,sSQL,"name","usercode");
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::BitExitClick(TObject *Sender)
{
frmScraphCheck->Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::btnCheckClick(TObject *Sender)
{
AnsiString sBillCode;
for(int i=sgScraphCheck->RowCount-1; i>0;i--)
{
if(sgScraphCheck->Cells[1][i]=="√")
{
sBillCode=sgScraphCheck->Cells[2][i];
comServer->LocateByKey(WideString(sBillCode));
if(!comServer->Eof)
{
try
{
comServer->Check(1);
}
catch(Exception &e)
{
throw Exception("审核报废单<"+sBillCode+">出现错误!\n"+e.Message);
}
}
DelDetailObjFromGrid(sgScraphCheck->Cells[2][i]);
sgScraphCheck->Cells[1][i]="";
sgScraphCheck->RemoveItem(i);
}
}
sgScrapdCheck->RowCount=1;
btnCheck->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::HavingRight()
{
TComResultSet *RsTemp;
AnsiString sSQL;
sSQL=" select keepercode from sdkeeper where keepercheck=1 and keepercode='"
+g_sdUserCode+"'";
RsTemp=new TComResultSet(Handle,g_ClientHandle);
RsTemp->Open(sSQL,"");
if(RsTemp->RecordCount <= 0)
{
RsTemp->Close();
throw Exception("当前用户没有审核/反审核权限");
}
else
RsTemp->Close();
delete RsTemp;
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::sgScraphCheckDblClick(TObject *Sender)
{
int ARow=sgScraphCheck->Row;
if(ARow>0)
{
if(sgScraphCheck->Cells[1][ARow]==" ")
{
btnCheck->Enabled=true;
sgScraphCheck->Cells[1][ARow]="√";
// AddDetailObjToGrid(sgScraphCheck->Cells[2][ARow]);
}
else
{
sgScraphCheck->Cells[1][ARow]=" ";
// DelDetailObjFromGrid(sgScraphCheck->Cells[2][ARow]);
//找到有没有需要审核的
for (int i=1;i<sgScraphCheck->RowCount;i++)
{
if(sgScraphCheck->Cells[1][i]=="√")
{
btnCheck->Enabled=true;
break;
}
else
btnCheck->Enabled=false;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraphCheck::sgScraphCheckSelectCell(TObject *Sender,
int ACol, int ARow, bool &CanSelect)
{
if(sgScraphCheck->RowCount>1 && ARow>0)
AddDetailObjToGrid(sgScraphCheck->Cells[2][ARow]);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?