📄 pohclose.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "PohClose.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"
TfrmPohClose *frmPohClose;
//---------------------------------------------------------------------------
__fastcall TfrmPohClose::TfrmPohClose(TComponent* Owner)
: TListBaseForm(Owner,euSdPoh,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::FillHeadObjToGrid()
{
int i;
AnsiString HeadStr;
try
{
StartWaitForm("正在获取数据...");
comServer->FilterString=WideString(WhereStr);
comServer->Query();
if(comServer->RecordCount>0)
{
sgPohClose->RowCount=1;
sgPodClose->RowCount=1;
for (i=0;i<comServer->RecordCount;i++)
{
comServer->LocateByIndex(i);
HeadStr="\t"+AnsiString(" ")+
"\t"+GetHeadValue(fiPohCode)+
"\t"+GetHeadValue(fiPohDate)+
"\t"+GetHeadValue(fiPohSupply)+
"\t"+ GetHeadValue(fiPohCurrency)+
"\t"+GetHeadValue(fiPohTaxCode)+
"\t"+GetHeadValue(fiPohBuyer)+
"\t"+GetHeadValue(fiPohContract)+
"\t"+GetHeadValue(fiPohSugDate);
sgPohClose->AddItem(HeadStr);
}
}
else
{
sgPohClose->RowCount=1;
sgPodClose->RowCount=1;
}
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::GetWhereStrToSQL()
{
WhereStr="PohCheck=1 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 TfrmPohClose::InitEditControl()
{
sgPohClose->RowCount=1;
sgPodClose->RowCount=1;
btnClose->Enabled=true;
sePohCodeF->Text="";
sePohCodeT->Text="";
dePohDateF->Text="";
dePohDateT->Text=dePohDateT->InitDate;
scPohBuyerCode->Text="";
scPohSupplyCode->Text="";
sbBar->Panels->Items[1]->Text="操作员:"+g_sdUserCode;
sbBar->Panels->Items[2]->Text=g_sdCompanyName;
sbBar->Panels->Items[3]->Text=g_sdCurDate;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPohClose::GetHeadValue(int Index)
{
return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPohClose::GetDetailValue(int Index)
{
return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::ChangeToBrowseState(bool agree)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::AddDetailObjToGrid(AnsiString s_Code)
{
int i;
AnsiString ItemStr,ID;
sgPodClose->RowCount=1;
comServer->LocateByKey(WideString(s_Code));
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
if(GetDetailValue(fiPodClose)=="1")
ID="√";
else
ID=" ";
ItemStr="\t"+ID+
"\t"+GetDetailValue(fiPodCode)+
"\t"+GetDetailValue(fiPodLine)+
"\t"+GetDetailValue(fiPodGoods)+
"\t"+GetDetailValue(fiPodUnit)+
"\t"+GetDetailValue(fiPodRecDate)+
"\t"+GetDetailValue(fiPodQty)+
// "\t"+GetDetailValue(fiPodThQty)+
// "\t"+GetDetailValue(fiPodInvQty)+
"\t"+GetDetailValue(fiPodLoc);
sgPodClose->AddItem(ItemStr);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::btnClearClick(TObject *Sender)
{
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::btnQueryClick(TObject *Sender)
{
HavingRight();
GetWhereStrToSQL();
FillHeadObjToGrid();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::FormShow(TObject *Sender)
{
FillComboBox(scPohBuyerCode,"select BuyerCode,BuyerName from sdBuyer order By BuyerCode","BuyerName","BuyerCode");
FillComboBox(scPohSupplyCode,"select SupplyCode,SupplyName from sdSupply order By SupplyCode","SupplyName","SupplyCode");
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::BitExitClick(TObject *Sender)
{
frmPohClose->Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::btnCloseClick(TObject *Sender)
{
btnQueryClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::sgPohCloseSelectCell(TObject *Sender,
int ACol, int ARow, bool &CanSelect)
{
if(sgPohClose->RowCount > 1 && ARow > 0)
{
AddDetailObjToGrid(sgPohClose->Cells[2][ARow]);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::sgPohCloseDblClick(TObject *Sender)
{
if(sgPohClose->RowCount<=1)
return;
comServer->LocateByKey(WideString(sgPohClose->TextMatrix[sgPohClose->Row][2]));
if(sgPohClose->TextMatrix[sgPohClose->Row][1]=="√")
{
BillClose(0);//清空主从表的结清标志
sgPohClose->TextMatrix[sgPohClose->Row][1]="";
for(int i=1;i<sgPodClose->RowCount;i++)
sgPodClose->TextMatrix[i][1]="";
sgPodClose->Enabled=true; //解锁
}
else
{
BillClose(1);//设置主从表的结清标志
sgPohClose->TextMatrix[sgPohClose->Row][1]="√";
for(int i=1;i<sgPodClose->RowCount;i++)
sgPodClose->TextMatrix[i][1]="√";
sgPodClose->Enabled=false; //锁定从表不允许修改
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::sgPodCloseDblClick(TObject *Sender)
{
comServer->LocateByKey(WideString(sgPodClose->TextMatrix[sgPodClose->Row][2]));
comServer->LocateItemByKey(WideString(sgPodClose->TextMatrix[sgPodClose->Row][3]));
if(sgPodClose->TextMatrix[sgPodClose->Row][1]=="√")
{
BillClose(2);//清空从表的结清标志
sgPodClose->TextMatrix[sgPodClose->Row][1]="";
}
else
{
BillClose(3);//设置从表的结清标志
sgPodClose->TextMatrix[sgPodClose->Row][1]="√";
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::BillClose(int iFlag)
{
switch(iFlag)
{
case 0:
comServer->Close(0);
for(int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
WriteItemValue(comServer,fiPodClose,"0");
comServer->AddToObject();
}
break;
case 1:
comServer->Close(1);
for(int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
WriteItemValue(comServer,fiPodClose,"1");
comServer->AddToObject();
}
break;
case 2:
comServer->Close(2);
WriteItemValue(comServer,fiPodClose,"0");
comServer->AddToObject();
break;
case 3:
comServer->Close(3);
WriteItemValue(comServer,fiPodClose,"1");
comServer->AddToObject();
break;
default:
break;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohClose::HavingRight()
{
TComResultSet *RsTemp;
AnsiString sSQL;
sSQL=" select buyercode from sdbuyer where buyerclose=1 and buyercode='"
+g_sdUserCode+"'";
RsTemp=NewResultSet();
RsTemp->Open(WideString(sSQL),WideString(""));
if(RsTemp->RecordCount <= 0)
{
RsTemp->Close();
throw Exception("当前用户没有结清/反结清权限");
}
else
RsTemp->Close();
delete RsTemp;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -