📄 gmth_rd.cpp
字号:
//--------------------------------------------------------------------------
#include <vcl.h>
#include "Gmth_R.h"
#include "Gmth_Rd.h"
#include "Dml.h"
//--------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma link "StdBaseForm"
#pragma resource "*.dfm"
TfrmGmth_Rd *frmGmth_Rd;
//-----------------------------------------------------
__fastcall TfrmGmth_Rd::TfrmGmth_Rd(TComponent* Owner,HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TStdBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
__fastcall TfrmGmth_Rd::TfrmGmth_Rd(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr,TComServer *FComServer)
: TStdBaseForm(Owner,chWnd,MidCode,WhereStr)
{
comServer = FComServer;
}
//-----------------------------------------
void __fastcall TfrmGmth_Rd::MiddleForm()
{
Left =(Screen->Width - Width ) / 2;
Top =(Screen->Height - Height) / 2;
}
AnsiString __fastcall TfrmGmth_Rd::GetHeadValue(int Index)
{
return this->comServer->FieldValue[Index];
}
//-----------------------------------------------------
void __fastcall TfrmGmth_Rd::btnOKClick(TObject *Sender)
{
double dPQty,dGQty,dQty,dCQty;
try
{
StartWaitForm("正在生成定额领料单行,请稍候......");
if(sgGmth_Rd->RowCount>1)
{
int j;
j=comServer->ItemCount-1;
if(j>=0)
{
comServer->LocateItemByIndex(j);
j=StrToInt(this->comServer->ItemValue["WsgmSn"]);
j=j+1;
}
else
j=1;
try
{
for(int i=1;i<sgGmth_Rd->RowCount;i++)
{
if(sgGmth_Rd->Cells[1][i]=="√")
{
AnsiString l_dQtyS;
dPQty=StrToFloat(sgGmth_Rd->Cells[7][i]); //定额领量
dGQty=StrToFloat(sgGmth_Rd->Cells[8][i]); //已领量
l_dQtyS=sgGmth_Rd->Cells[9][i];
if (l_dQtyS.IsEmpty())
l_dQtyS=0;
dQty=StrToFloat(l_dQtyS); //本次领量
dCQty=dPQty-dGQty-dQty;
comServer->AddItem();
this->comServer->ItemValue["GmtdCode"] = frmGmth_R->seGmthCode->Text;
this->comServer->ItemValue["GmtdLine"] = IntToStr(j); //定额领单行号
this->comServer->ItemValue["GmtdGoods"] = sgGmth_Rd->Cells[3][i];
this->comServer->ItemValue["GmtdGoodsName"] = sgGmth_Rd->Cells[4][i];
this->comServer->ItemValue["GmtdGoodsSpec"] = sgGmth_Rd->Cells[5][i];
this->comServer->ItemValue["GmtdUnit"] = sgGmth_Rd->Cells[6][i];
this->comServer->ItemValue["GmtdWoCode"] = frmGmth_R->seGmthWo->Text;
this->comServer->ItemValue["GmtdSLoc"] = sgGmth_Rd->Cells[10][i];
this->comServer->ItemValue["GmtdProcess"] = "";
this->comServer->ItemValue["GmtdDLoc"] = "";
this->comServer->ItemValue["GmtdBatch"] = "";
this->comServer->ItemValue["GmtdQty"] = FloatToStr(dQty);;
this->comServer->ItemValue["GmtdDQty"] = "0";
this->comServer->ItemValue["GmtdPQty"] = FloatToStr(dPQty);
this->comServer->ItemValue["GmtdOQty"] = "0";
this->comServer->ItemValue["GmtdCQty"] = FloatToStr(dCQty);
this->comServer->ItemValue["GmtdDesc"] = "";
this->comServer->ItemValue["GmtdIPrice"] = "0";
this->comServer->ItemValue["GmtdIAmt"] = "0";
// this->comServer->ItemValue["GmtdQty"] = StrToFloat(sgGmth_Rd->Cells[7][i]);
// dNQty=dCQty-dYQty;
// this->comServer->ItemValue[fiQcsdNQty] = FloatToStr(dNQty);
// this->comServer->ItemValue[fiQcsdMode] = "1";
comServer->AddToObject();
j=j+1;
}
}
}
catch(Exception &e)
{
comServer->FreeItem();
this->ModalResult=0;
throw Exception(e.Message);
}
}
}
__finally
{
EndWaitForm();
}
Close();
}
//------------------------------------------------
void __fastcall TfrmGmth_Rd::btnCancelClick(TObject *Sender)
{
Close();
}
//-----------------------------------------------------
void __fastcall TfrmGmth_Rd::FormShow(TObject *Sender)
{
MiddleForm();
InitControlGroup();
}
//-------------------------------------------------------
void __fastcall TfrmGmth_Rd::InitControlGroup()
{
sgGmth_Rd->RowCount = 1;
seGmthWo->Text=this->comServer->FieldValue["GmthWoCode"];
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_Rd::FillGridWithData()
{
AnsiString ItemStr,s_SQL;
s_SQL="select WsgmSn,WsgmGoods,GoodsName,GoodsSpec,WsgmUnit,WsgmPQty,WsgmGQty from sdWsgm,sdGoods ";
s_SQL+=" where WsgmGoods=GoodsCode and WsgmPQty-WsgmGQty>0 and WsgmWo='"+seGmthWo->Text+"' order by WsgmSn";
sgGmth_Rd->RowCount=1;
TComResultSet *RsGmth=new TComResultSet(Handle,g_ClientHandle);
// TComResultSet * RsRpod;
// RsRpod=NewResultSet();
RsGmth->Open(s_SQL,"");
AnsiString Qty;
while( RsGmth->Eof == 0)
{
// Qty = RsGmth->FieldByName("Qty");
ItemStr = "\t"+AnsiString(" ") +
"\t"+RsGmth->FieldByName("WsgmSn")+
"\t"+RsGmth->FieldByName("WsgmGoods")+
"\t"+RsGmth->FieldByName("GoodsName")+
"\t"+RsGmth->FieldByName("GoodsSpec")+
"\t"+RsGmth->FieldByName("WsgmUnit")+
"\t"+RsGmth->FieldByName("WsgmPQty")+
"\t"+RsGmth->FieldByName("WsgmGQty")+
"\t"+0;
sgGmth_Rd->AddItem(ItemStr);
RsGmth->MoveNext();
}
RsGmth->Close();
delete RsGmth;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_Rd::SetDetailValue(int Index,AnsiString Value)
{
this->comServer->ItemValue[Index] = Value;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGmth_Rd::GetDetailValue(int Index)
{
return this->comServer->ItemValue[Index];
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_Rd::sgGmth_RdDblClick(TObject *Sender)
{
int ARow=sgGmth_Rd->Row;
int ACol=sgGmth_Rd->Col;
if (ARow > 0 && ACol == 1)
{
if (sgGmth_Rd->Cells[1][ARow] == "√")
sgGmth_Rd->Cells[1][ARow] = " ";
else
sgGmth_Rd->Cells[1][ARow] = "√";
}
if(ARow>0 && ACol==10 && sgGmth_Rd->Cells[1][ARow] == "√")
{
AnsiString SqlStr;
SqlStr="007[当前月份][货位编码][货位名称][物料编码][物料名称][计量单位][当前数量]";
SqlStr+="select MaccFmonth,MaccLoc,LocName,MaccGoods,MaccGoodsName=GoodsName,MaccUnit=GoodsUnitCode,";
SqlStr+=" MaccAoyQty from sdMacc,sdGoods,sdLg,sdLoc where LocCode=lgLocCode and LocCode=MaccLoc";
SqlStr+=" and LgGoodsCode=MaccGoods and GoodsCode=MaccGoods and MaccFmonth='"+g_sdMMonth+"'";
SqlStr+=" and MaccGoods='"+sgGmth_Rd->Cells[3][ARow]+"' and LocType=1 order by LocCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"发料货位查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sgGmth_Rd->Cells[10][ARow]=p->ColData[2];
}
delete p;
}
if(ARow>0 && ACol==3)
{
TfrmDml *Dmlfrm;
try{
StartWaitForm("正在启动<工序材料分摊>界面...");
comServer->LocateItemByKey(frmGmth_R->seGmthCode->Text+"\t"+sgGmth_Rd->Cells[2][ARow]);
AnsiString t_GmthCode=frmGmth_R->seGmthCode->Text;
AnsiString t_GmthCheck=IntToStr(frmGmth_R->chkGmthCheck->Checked);
AnsiString t_GmtdLine=sgGmth_Rd->Cells[2][ARow];
AnsiString t_GmtdWo=frmGmth_R->seGmthWo->Text;
AnsiString t_GmtdGoods=sgGmth_Rd->Cells[3][ARow];
AnsiString t_GmtdQty=sgGmth_Rd->Cells[9][ARow];
AnsiString FWhereString,FParamString;
FWhereString="DmlGmtCode='"+t_GmthCode+"' and DmlGmtdLine='"+t_GmtdLine+"'";
FParamString=t_GmthCode+"\t"+t_GmthCheck+"\t"+t_GmtdLine+"\t"+t_GmtdWo+"\t"+t_GmtdGoods+"\t"+t_GmtdQty;
Dmlfrm=new TfrmDml(this,g_ClientHandle,"1061101",FWhereString,FParamString);
EndWaitForm();
Dmlfrm->ShowModal();
}
__finally{
delete Dmlfrm;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_Rd::bbAllClick(TObject *Sender)
{
if(sgGmth_Rd->RowCount <=1)
return;
for(int i=1;i<sgGmth_Rd->RowCount;i++)
sgGmth_Rd->Cells[1][i] = "√";
btnOK->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_Rd::bbNoneClick(TObject *Sender)
{
for(int i=1;i<sgGmth_Rd->RowCount;i++)
sgGmth_Rd->Cells[1][i] = " ";
btnOK->Enabled = false;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -