📄 pieceh_t.cpp
字号:
break;
case 2:
sgPieceh->RemoveItem(sgPieceh->Row);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPieceh_T::GetItemStringToGrid()
{
AnsiString s_ItemStr,s;
s_ItemStr=GetDetailValue(fiPiecedLine)+
"\t"+GetDetailValue(fiPiecedEmployee)+
"\t"+GetDetailValue(fiPiecedWo)+
"\t"+GetDetailValue(fiPiecedProcess)+
"\t"+GetDetailValue(fiPiecedQty)+
"\t"+GetDetailValue(fiPiecedPrice);
return s_ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::DisplayBill()
{
if(comServer->RecordCount>0)
{
GetDataFromComObject(1);
FillGridWithData();
if(sgPieceh->RowCount >1)
{
AnsiString Keystr;
Keystr=sgPieceh->Cells[1][sgPieceh->Row];
comServer->LocateItemByKey(WideString(Keystr));
GetDataFromComObject(2);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::GetBill(AnsiString BillID)
{
bool iRow;
iRow=comServer->Find("PiecehCode='"+BillID+"'");
if(iRow) //FIND THIS BILL
DisplayBill();
else
{
if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgPieceh->RowCount=1;
if(comServer->RecordCount>0)
{
for(i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPieceh_T::GetHeadValue(int Index)
{
return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPieceh_T::GetDetailValue(int Index)
{
return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::FormCreate(TObject *Sender)
{
FormIniFile="D:\Test.Ini";
SetGridWidth(Name,sgPieceh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::FormClose(TObject *Sender,
TCloseAction &Action)
{
TGenBaseForm::FormClose(Sender,Action);
WriteGridWidth(Name,sgPieceh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
tbAddDetail->Visible=false;
sgPieceh->RowCount=1;
TGenBaseForm::MoveToFirst();
ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sgPiecehSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if(ARow > 0)
comServer->LocateItemByKey(WideString(sgPieceh->TextMatrix[ARow][1]));
if(!comServer->Eof)
GetDataFromComObject(2);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sgPiecehDblClick(TObject *Sender)
{
int iRow;
iRow=sgPieceh->Row;
if(iRow == 0)
return;
ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::ChangeToBrowseState(bool agree)
{
if(agree)
{
sgPieceh->Visible=true;
FloatPanel2->Visible=false;
sgPieceh->Align=alClient;
FloatPanel2->Align=alNone;
}
else
{
sgPieceh->Visible=false;
FloatPanel2->Visible=true;
sgPieceh->Align=alNone;
FloatPanel2->Align=alClient;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::btnOKClick(TObject *Sender)
{
try{
if((CurrentState==caAddDetail)||(CurrentState==caAddBill))
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
sePiecedLine->SetFocus();
}
else
ChangeToBrowseState();
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::GenrateBill()
{
int BefoICount=comServer->ItemCount;
try
{
StartWaitForm("正在启动<团体计件单明细生成>界面...");
AnsiString v_PiecehShop=scPiecehShop->ItemData[cbItem2];
AnsiString v_PiecehTeam=sePiecehTeam->ItemData[cbItem2];
Pieced_Tfrm = new TfrmPieced_T(this,v_PiecehShop,v_PiecehTeam);
Pieced_Tfrm->SetcomServer(comServer);
EndWaitForm();
Pieced_Tfrm->ShowModal();
if(comServer->ItemCount>BefoICount)
{
TGenBaseForm::SaveRecord();
}
else
CancelChange();
}
__finally
{
delete Pieced_Tfrm;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecehCodeKeyDown(TObject *Sender,
WORD &Key, TShiftState Shift)
{
AnsiString tempS=sePiecehCode->Text;
if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
{
comServer->LocateByKey(WideString(tempS));
DisplayBill();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecehTeamButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="002[班组代码][班组名称]SELECT TeamCode,TeamName FROM sdTeam where TeamShopCode=";
SqlStr=SqlStr+"'"+scPiecehShop->ItemData[1]+"' ORDER BY TeamCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"班组资料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePiecehTeam->LocateKey(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecedEmployeeButtonClick(TObject *Sender)
{
AnsiString tempS1,tempS2,SqlStr;
tempS1=scPiecehShop->ItemData[1];
tempS2=sePiecehTeam->ItemData[1];
if(tempS1.IsEmpty())
throw Exception("计时登记时,员工所在的车间不能为空,请输入一个车间的代码.");
if(!tempS2.IsEmpty()){
SqlStr="004[员工编码][员工姓名][性别][工种]SELECT distinct WpeEmployee,EmployeeName,EmployeeSex=";
SqlStr=SqlStr+"(case EmployeeSex when 0 then '男' when 1 then '女' end),EmployeeTow ";
SqlStr=SqlStr+"from sdEmployee,sdWpe where WpeEmployee=EmployeeCode and WpeShop=";
SqlStr=SqlStr+"'"+tempS1+"' and WpeTeam='" +tempS2+"' ORDER BY WpeEmployee";
}
else{
SqlStr="004[员工编码][员工姓名][性别][工种]SELECT distinct WpeEmployee,EmployeeName,EmployeeSex=";
SqlStr=SqlStr+"(case EmployeeSex when 0 then '男' when 1 then '女' end),EmployeeTow ";
SqlStr=SqlStr+"from sdEmployee,sdWpe where WpeEmployee=EmployeeCode and WpeShop=";
SqlStr=SqlStr+"'"+tempS1+"' ORDER BY WpeEmployee";
}
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"员工资料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePiecedEmployee->Text=p->ColData[1];
seEmployeeName->Text=p->ColData[2];
seEmployeeSex->Text=p->ColData[3];
seEmployeeTow->Text=p->ColData[4];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecedWoButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="006[加工单号][加工件码][要求数量][要求日期][订单单号][订单行号]SELECT WoCode,WoGoods,WoQty,WoRDate,";
SqlStr=SqlStr+"WoSoCode,WoSodLine from sdWo where WoCheck=1 and WoClose=0 ORDER BY WoCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"加工订单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePiecedWo->Text=p->ColData[1];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecedProcessButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="003[序号][工序代码][工序名称]SELECT WrgNo,WrgProcess,ProcessName FROM sdWrg,sdProcess ";
SqlStr=SqlStr+"where WrgProcess=ProcessCode and WrgWo='"+sePiecedWo->Text+"' ORDER BY WrgNo";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"工序资料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
sePiecedProcess->LocateKey(p->ColData[2]);
}
delete p;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -