qcsh.cpp
来自「速达开源ERP系统」· C++ 代码 · 共 477 行 · 第 1/2 页
CPP
477 行
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Qcsh.h"
#include "Qcsd.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "GenBaseForm"
#pragma link "DateEdit"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmQcsh *frmQcsh;
//---------------------------------------------------------------------------
__fastcall TfrmQcsh::TfrmQcsh(TComponent* Owner)
: TGenBaseForm(Owner,euSdQcsh,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcsh::InitEditControl()
{
ClientGroup->AddComponent(1,false,false,true,fpQcshHead,fpQcshHead->Name);
ClientGroup->AddComponent(1,false,true,false,seQcshCode,seQcshCode->Name);
ClientGroup->AddComponent(1,true,true,true,scQcshUser,scQcshUser->Name);
ClientGroup->AddComponent(1,false,true,true,scQcshType,scQcshType->Name);
ClientGroup->AddComponent(1,false,true,true,seQcshDocCode,seQcshDocCode->Name);
ClientGroup->AddComponent(2,false,false,true,fpQcsdDetail,fpQcsdDetail->Name);
ClientGroup->AddComponent(2,true,true,true,seQcsdFLine,seQcsdFLine->Name);
ClientGroup->AddComponent(2,true,true,true,seQcsdGoods,seQcsdGoods->Name);
ClientGroup->AddComponent(2,true,true,true,scQcsdState,scQcsdState->Name);
ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
//Qcsh
FillComboBox(scQcshUser,"SELECT UserName memo,QcmCode FROM sdQcm,sdUser where QcmCode=UserCode order by QcmCode","memo","QcmCode");
scQcshType->ClearAll();
scQcshType->AddItems("1-采购收货质检","1");
scQcshType->AddItems("2-完成品质检","2");
scQcshType->AddItems("3-工序质检","3");
//Qcsd
FillComboBox(scQcsdTrd,"select TrdName memo,TrdCode from sdTrd order by TrdCode","memo","TrdCode");
scQcsdState->ClearAll();
scQcsdState->AddItems("1-未确认","1");
scQcsdState->AddItems("2-确认","2");
scQcsdMode->ClearAll();
scQcsdMode->AddItems("1-退货","1");
scQcsdMode->AddItems("2-全检","2");
scQcsdMode->AddItems("3-回用","3");
scQcsdMode->AddItems("4-换货","4");
scQcsdMode->AddItems("5-返工/修","5");
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcsh::ClearControl(int Section,bool BringToNext)
{
if (Section == 1)
{
if (! BringToNext)
{
seQcshCode->Text=""; //质检单号
deQcshDate->Text=g_sdCurDate; //质检日期
scQcshType->ItemIndex=0; //质检类型
seQcshDocCode->Text=""; //送检单号
scQcshUser->LocateKey(g_sdUserCode);//质检员
cbxQcshCheck->Checked=false; //审核标志
labQcshChecker->Caption=""; //审核人
labSysDate->Caption=""; //系统日期
//新增单据,工具栏使能
SetCheckToolbarStatus(false);
}
sgQcsh->RowCount=1;
}
else if (Section==2)
{
if (!BringToNext)
{
seQcsdLine->Text=""; //行号
seQcsdFLine->Text=""; //来源行号
seQcsdGoods->Text=""; //物料编码
lblQcsdGoodsName->Caption=""; //物料编码
scQcsdTrd->Text=""; //技术要求
scQcsdTrd->ItemIndex=-1; //技术要求
seQcsdDQty->Text=""; //送检数量
seQcsdCQty->Text=""; //实检数量
seQcsdYQty->Text=""; //合格数
seQcsdNQty->Text=""; //不合格数
scQcsdMode->ItemIndex=0; //不合格处理方式
scQcsdState->ItemIndex=0; //行状态
memQcsdDesc->Text=""; //备注
}
}
}
//-------------------------------------------------------------
void __fastcall TfrmQcsh::GetDataFromComObject(int Section)
{
AnsiString s;
if (Section==1)
{
seQcshCode->Text=this->comServer->FieldValue[fiQcshCode]; //质检单号
deQcshDate->Text=this->comServer->FieldValue[fiQcshDate];; //质检日期
scQcshType->LocateKey(this->comServer->FieldValue[fiQcshType]); //质检类型
seQcshDocCode->Text=this->comServer->FieldValue[fiQcshDocCode]; //送检单号
scQcshUser->LocateKey(this->comServer->FieldValue[fiQcshUser]); //质检员
cbxQcshCheck->Checked=(this->comServer->FieldValue[fiQcshCheck]=="1"); //审核标志
labQcshChecker->Caption=this->comServer->FieldValue[fiQcshChecker]; //审核人
labSysDate->Caption=this->comServer->FieldValue[fiQcshSysDate]; //系统日期
//根据审核、取消状态,设置工具栏
if(GetHeadValue(fiQcshCheck)=="1")
SetCheckToolbarStatus(true);
else
SetCheckToolbarStatus(false);
}
else
{
seQcsdLine->Text=this->comServer->ItemValue[fiQcsdLine]; //行号
seQcsdFLine->Text=this->comServer->ItemValue[fiQcsdFLine];; //来源行号
seQcsdGoods->Text=this->comServer->ItemValue[fiQcsdGoods];; //来源行号
int GoodsFound=g_sdRsGoods->LocateByKey(WideString(this->comServer->ItemValue[fiQcsdGoods]));
if(GoodsFound == 0)
lblQcsdGoodsName->Caption=GetGoodsValue("GoodsName");
else
lblQcsdGoodsName->Caption="";
scQcsdTrd->LocateKey(this->comServer->ItemValue[fiQcsdTrd]); //技术要求
seQcsdDQty->Text=this->comServer->ItemValue[fiQcsdDQty]; //送检数量
seQcsdCQty->Text=this->comServer->ItemValue[fiQcsdCQty]; //实检数量
seQcsdYQty->Text=this->comServer->ItemValue[fiQcsdYQty]; //合格数
seQcsdNQty->Text=this->comServer->ItemValue[fiQcsdNQty]; //不合格数
scQcsdMode->LocateKey(this->comServer->ItemValue[fiQcsdMode]); //不合格处理方式
scQcsdState->LocateKey(this->comServer->ItemValue[fiQcsdState]); //行状态
memQcsdDesc->Text=this->comServer->ItemValue[fiQcsdDesc]; //备注
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcsh::SendDataToComObject(int Section)
{
if (Section==1) // Head
{
this->comServer->FieldValue[fiQcshCode] = seQcshCode->Text;
this->comServer->FieldValue[fiQcshDate] = deQcshDate->Text;
this->comServer->FieldValue[fiQcshType] = scQcshType->ItemData[1];
this->comServer->FieldValue[fiQcshDocCode] = seQcshDocCode->Text;
this->comServer->FieldValue[fiQcshUser] = scQcshUser->ItemData[1];
}
else
{
this->comServer->ItemValue[fiQcsdLine] = seQcsdLine->Text;
this->comServer->ItemValue[fiQcsdFLine] = seQcsdFLine->Text;
this->comServer->ItemValue[fiQcsdGoods] = seQcsdGoods->Text;
this->comServer->ItemValue[fiQcsdTrd] = scQcsdTrd->ItemData[1];
if(seQcsdDQty->Text == "")
throw Exception("请输入送检数量");
this->comServer->ItemValue[fiQcsdDQty] = seQcsdDQty->Text;
if(seQcsdCQty->Text == "")
throw Exception("请输入实检数量");
this->comServer->ItemValue[fiQcsdCQty] = seQcsdCQty->Text;
if(seQcsdYQty->Text == "")
throw Exception("请输入合格数量");
this->comServer->ItemValue[fiQcsdYQty] = seQcsdYQty->Text;
if(seQcsdNQty->Text == "")
throw Exception("请输入不合格数量");
this->comServer->ItemValue[fiQcsdNQty] = seQcsdNQty->Text;
this->comServer->ItemValue[fiQcsdMode] = scQcsdMode->ItemData[1];
this->comServer->ItemValue[fiQcsdState] = scQcsdState->ItemData[1];
this->comServer->ItemValue[fiQcsdDesc] = memQcsdDesc->Text;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcsh::WaitUserInput(int Section)
{
if (Section ==1)
{
if(seQcshCode->Enabled)
seQcshCode->SetFocus();
else
deQcshDate->SetFocus();
}
else
{
sgQcsh->Visible=false;
fpQcsdDetail->Visible=true;
scQcsdTrd->SetFocus();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmQcsh::GetDataToGrid()
{
AnsiString ItemStr;
ItemStr="\t"+this->comServer->ItemValue[fiQcsdLine]+
"\t"+this->comServer->ItemValue[fiQcsdFLine]+
"\t"+this->comServer->ItemValue[fiQcsdGoods]+
"\t"+this->comServer->ItemValue[fiQcsdDQty]+
"\t"+this->comServer->ItemValue[fiQcsdCQty]+
"\t"+this->comServer->ItemValue[fiQcsdYQty]+
"\t"+this->comServer->ItemValue[fiQcsdNQty];
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcsh::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr;
switch(mAction)
{
case 0: // Append
ItemStr=GetDataToGrid();
sgQcsh->AddItem(ItemStr);
break;
case 1: // Modify
i=sgQcsh->Row;
ItemStr=GetDataToGrid();
sgQcsh->ChangeItem(ItemStr,i);
break;
case 2: // Delete
sgQcsh->RemoveItem(sgQcsh->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcsh::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgQcsh->RowCount=1;
if(comServer->RecordCount > 0)
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0); // Append
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?