📄 weph.cpp
字号:
"\t"+GetDetailValue(fiWepdLoc)+
"\t"+GetDetailValue(fiWepdCQty)+
"\t"+GetDetailValue(fiWepdSod)+
"\t"+GetDetailValue(fiWepdSodLine);
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr=GetDataToGrid();
switch(mAction)
{
case 0: // Append
sgWeph->AddItem(ItemStr);
sgWeph->Row=sgWeph->RowCount-1;
break;
case 1: // Modify
sgWeph->ChangeItem(ItemStr,sgWeph->Row);
break;
case 2: // Delete
sgWeph->RemoveItem(sgWeph->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgWeph->RowCount=1;
if(comServer->RecordCount > 0)
{
for(i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0); // Append
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::DisplayBill()
{
if(comServer->RecordCount>0)
{
GetDataFromComObject(1); // Head
FillGridWithData();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::GetBill(AnsiString BillID)
{
bool iRow;
iRow=comServer->Find("WephCode='"+BillID+"'");
if(iRow) //FIND THIS BILL
DisplayBill();
else
{
if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmWeph::GetHeadValue(int Index)
{
return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmWeph::GetDetailValue(int Index)
{
return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::FormShow(TObject *Sender)
{
ClearControl(1,false); //Head
ClearControl(2,false); //Detail
ChangeToBrowseState();
MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::sgWephSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if(ARow > 0)
comServer->LocateItemByKey(WideString(sgWeph->TextMatrix[ARow][0]));
if(!comServer->Eof)
GetDataFromComObject(2); //Detail
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::sgWephDblClick(TObject *Sender)
{
int iRow;
iRow=sgWeph->Row;
if(iRow == 0)
return;
ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::ChangeToBrowseState(bool t_browse)
{
if(t_browse)
{
sgWeph->Visible=true;
fpWepDetail->Visible=false;
sgWeph->Align=alClient;
fpWepDetail->Align=alNone;
}
else
{
sgWeph->Visible=false;
fpWepDetail->Visible=true;
sgWeph->Align=alNone;
fpWepDetail->Align=alClient;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::btnOKClick(TObject *Sender)
{
try{
if(CurrentState==caAddDetail || CurrentState==caAddBill)
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
seWepdLine->SetFocus();
}
else
ChangeToBrowseState();
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::seWephCodeKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
AnsiString tempS=seWephCode->Text;
if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
{
comServer->LocateByKey(WideString(tempS));
DisplayBill();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::seWepdWoButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="008[加工单号][加工件码][加工件名称][计量单位][加工数量][订单单号][订单行号][批号]SELECT WoCode,";
SqlStr=SqlStr+"WoGoods,GoodsName,WoUnit,WoQty,WoSoCode,WoSodLine,WoBatch FROM sdWo,sdGoods WHERE WoCheck=1 and ";
SqlStr=SqlStr+"WoClose=0 and WoGoods=GoodsCode ORDER BY WoCode,WoGoods";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"加工单资料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seWepdWo->Text=p->ColData[1];
seWepdGoods->Text=p->ColData[2];
seWepdGoodsName->Text=p->ColData[3];
scWepdBatch->LocateKey(p->ColData[8]);
seWepdSod->Text=p->ColData[6];
seWepdSodLine->Text=p->ColData[7];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::sbPmuClick(TObject *Sender)
{
TfrmPmu *p;
if(comServer->ItemCount<1)
{
Application->MessageBox("当前没有日报记录信!","提示信息" ,MB_ICONINFORMATION);
return;
}
try
{
StartWaitForm("正在启动,请稍候...");
p=new TfrmPmu(this,chkWephCheck->Checked,GetHeadValue(fiWephCode),GetDetailValue(fiWepdLine).ToInt(),GetDetailValue(fiWepdWo));
}
__finally
{
EndWaitForm();
}
p->ShowModal();
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmWeph::seWepdLocButtonClick(TObject *Sender)
{
AnsiString SqlStr;
TfrmWnQuery *p;
SqlStr="004[当前月份][货位编码][货位名称][当前库存]";
SqlStr+="select MaccFmonth,MaccLoc,LocName,MaccAoyQty from sdMacc,sdLg,sdLoc where LocCode=lgLocCode and LocCode=MaccLoc";
SqlStr+=" and LgGoodsCode=MaccGoods and MaccFmonth='"+g_sdMMonth+"'";
SqlStr+=" and MaccGoods='"+seWepdGoods->Text+"' order by LocCode";
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"存储货位库存查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seWepdLoc->LocateKey(p->ColData[2]);
}
delete p;
}
//---------------------------------------------------------------------------
/*
if(g_sdQuality)
FillEdit(seWepdLoc,"select LocName,LocCode from sdLoc where LocType=3 order by LocName","LocName","LocCode");
else
FillEdit(seWepdLoc,"select LocName,LocCode from sdLoc where LocType=1 order by LocName","LocName","LocCode");
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -