📄 labh.cpp
字号:
{
if(comServer->RecordCount>0)
{
GetDataFromComObject(1);
FillGridWithData();
if(sgLabh->RowCount >1)
{
AnsiString Keystr;
Keystr=sgLabh->Cells[1][sgLabh->Row];
comServer->LocateItemByKey(WideString(Keystr));
GetDataFromComObject(2);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::GetBill(AnsiString BillID)
{
bool iRow;
iRow=comServer->Find("LabhCode='"+BillID+"'");
if(iRow) //FIND THIS BILL
DisplayBill();
else
{
if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgLabh->RowCount=1;
if(comServer->RecordCount>0)
{
for(i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmLabh::GetHeadValue(int Index)
{
return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmLabh::GetDetailValue(int Index)
{
return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::FormCreate(TObject *Sender)
{
FormIniFile="D:\Test.Ini";
SetGridWidth(Name,sgLabh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::FormClose(TObject *Sender,
TCloseAction &Action)
{
TBillBaseForm::FormClose(Sender,Action);
WriteGridWidth(Name,sgLabh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
sgLabh->RowCount=1;
TBillBaseForm::MoveToFirst();
ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::sgLabhSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if(ARow > 0)
comServer->LocateItemByKey(WideString(sgLabh->TextMatrix[ARow][1]));
if(!comServer->Eof)
GetDataFromComObject(2);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::sgLabhDblClick(TObject *Sender)
{
int iRow;
iRow=sgLabh->Row;
if(iRow == 0)
return;
ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::ChangeToBrowseState(bool agree)
{
if(agree)
{
sgLabh->Visible=true;
FloatPanel2->Visible=false;
sgLabh->Align=alClient;
FloatPanel2->Align=alNone;
}
else
{
sgLabh->Visible=false;
FloatPanel2->Visible=true;
sgLabh->Align=alNone;
FloatPanel2->Align=alClient;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::btnOKClick(TObject *Sender)
{
try{
if((CurrentState==caAddDetail)||(CurrentState==caAddBill))
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
seLabdLine->SetFocus();
}
else
ChangeToBrowseState();
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::seLabhCodeKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
AnsiString tempS=seLabhCode->Text;
if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
{
comServer->LocateByKey(WideString(tempS));
DisplayBill();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::seLabhTeamButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="002[班组代码][班组名称]SELECT TeamCode,TeamName FROM sdTeam where TeamShopCode=";
SqlStr=SqlStr+"'"+scLabhShop->ItemData[1]+"' ORDER BY TeamCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"班组资料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seLabhTeam->LocateKey(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::seLabdEmployeeButtonClick(TObject *Sender)
{
AnsiString tempS1,tempS2,SqlStr;
tempS1=scLabhShop->ItemData[1];
tempS2=seLabhTeam->ItemData[1];
if(tempS1.IsEmpty())
throw Exception("计时登记时,员工所在的车间不能为空,请输入一个车间的代码.");
if(!tempS2.IsEmpty()){
SqlStr="006[员工编码][员工姓名][性别][部门][工种][职务]SELECT distinct WpeEmployee,EmployeeName,EmployeeSex=";
SqlStr=SqlStr+"(case EmployeeSex when 0 then '男' when 1 then '女' end),EmployeeDept,EmployeeTow,";
SqlStr=SqlStr+"EmployeeRank from sdEmployee,sdWpe where WpeEmployee=EmployeeCode and WpeShop=";
SqlStr=SqlStr+"'"+tempS1+"' and WpeTeam='" +tempS2+"' ORDER BY WpeEmployee";
}
else{
SqlStr="006[员工编码][员工姓名][性别][部门][工种][职务]SELECT distinct WpeEmployee,EmployeeName,EmployeeSex=";
SqlStr=SqlStr+"(case EmployeeSex when 0 then '男' when 1 then '女' end),EmployeeDept,EmployeeTow,";
SqlStr=SqlStr+"EmployeeRank 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)
{
seLabdEmployee->Text=p->ColData[1];
seEmployeeName->Text=p->ColData[2];
seEmployeeSex->Text=p->ColData[3];
scEmployeeDept->LocateKey(p->ColData[4]);
seEmployeeTow->Text=p->ColData[5];
seEmployeeRank->Text=p->ColData[6];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::seLabdWoButtonClick(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)
{
seLabdWo->Text=p->ColData[1];
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh::seLabdProcessButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="003[序号][工序代码][工序名称]SELECT WrgNo,WrgProcess,ProcessName FROM sdWrg,sdProcess ";
SqlStr=SqlStr+"where WrgProcess=ProcessCode and WrgWo='"+seLabdWo->Text+"' ORDER BY WrgNo";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"工序资料查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seLabdProcess->LocateKey(p->ColData[2]);
}
delete p;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -