📄 pieceh.cpp
字号:
sgPieceh->AddItem(ItemStr);
sgPieceh->Row=sgPieceh->RowCount-1;
break;
case 1:
sgPieceh->ChangeItem(ItemStr,sgPieceh->Row);
break;
case 2:
sgPieceh->RemoveItem(sgPieceh->Row);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPieceh::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::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::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::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::GetHeadValue(int Index)
{
return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPieceh::GetDetailValue(int Index)
{
return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh::FormCreate(TObject *Sender)
{
FormIniFile="D:\Test.Ini";
SetGridWidth(Name,sgPieceh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh::FormClose(TObject *Sender,
TCloseAction &Action)
{
TBillBaseForm::FormClose(Sender,Action);
WriteGridWidth(Name,sgPieceh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
sgPieceh->RowCount=1;
TBillBaseForm::MoveToFirst();
ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh::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::sgPiecehDblClick(TObject *Sender)
{
int iRow;
iRow=sgPieceh->Row;
if(iRow == 0)
return;
ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh::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::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::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh::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::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::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::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::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 + -