⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pbomh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPbomh::GetItemStringToGrid()
{
    AnsiString s_ItemStr,s1;
    s1=GetDetailValue(fiPbomdProcess);
    scPbomdProcess->LocateKey(s1);
    s1=GetDetailValue(fiPbomdUnit);
    scPbomdUnit->LocateKey(s1);
    s_ItemStr=GetDetailValue(fiPbomdSn)+
              "\t"+GetDetailValue(fiPbomdGoods)+
              "\t"+scPbomdUnit->ItemData[0]+
              "\t"+GetDetailValue(fiPbomdQty)+
              "\t"+GetDetailValue(fiPbomdShl)+
              "\t"+GetDetailValue(fiPbomdFcp)+
              "\t"+scPbomdProcess->ItemData[2];
    return s_ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::DisplayBill()
{
    if(comServer->RecordCount>0)
    {
      GetDataFromComObject(1);
      FillGridWithData();
      if(sgPbomh->RowCount >1)
      {
         AnsiString Keystr;
         Keystr=sgPbomh->Cells[0][sgPbomh->Row];
         comServer->LocateItemByKey(WideString(Keystr));
         GetDataFromComObject(2);
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::GetBill(AnsiString BillID)
{
    bool iRow;
    iRow=comServer->Find("PbomhCode='"+BillID+"'");
    if(iRow)      //FIND THIS BILL
       DisplayBill();
    else
    {
       if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
          AddHeadRecord();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPbomh::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgPbomh->RowCount=1;
    for (i=0;i<comServer->ItemCount;i++)
    {
        comServer->LocateItemByIndex(i);
        RefreshGridData(0);
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPbomh::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPbomh::GetDetailValue(int Index)
{
    return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::FormCreate(TObject *Sender)
{
    FormIniFile="D:\Test.Ini";
    SetGridWidth(Name,sgPbomh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TBillBaseForm::FormClose(Sender,Action);
    WriteGridWidth(Name,sgPbomh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    tbCheck->Visible=false;
    TBillBaseForm::MoveToFirst();
    ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::sgPbomhSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if(ARow > 0)
       comServer->LocateItemByKey(WideString(sgPbomh->TextMatrix[ARow][0]));
    if(!comServer->Eof)
       GetDataFromComObject(2);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPbomh::sgPbomhDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgPbomh->Row;
    if(iRow == 0)
       return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPbomh::ChangeToBrowseState(bool agree)
{
    if(agree)
    {
      sgPbomh->Visible=true;
      FloatPanel2->Visible=false;
      sgPbomh->Align=alClient;
      FloatPanel2->Align=alNone;
    }
    else
    {
      sgPbomh->Visible=false;
      FloatPanel2->Visible=true;
      sgPbomh->Align=alNone;
      FloatPanel2->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::btnOKClick(TObject *Sender)
{
    try{
      if((CurrentState==caAddDetail)||(CurrentState==caAddBill))
      {
         if(DetailState==caAddDetail)
            comServer->AddItem();
         SendDataToComObject(2);
         comServer->AddToObject();
         ClearControl(2,false);
         sePbomdSn->SetFocus();
      }
      else
         ChangeToBrowseState(true);
    }
    catch(Exception &e)
    {
        throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::sePbomhGoodsButtonClick(TObject *Sender)
{
    OpenGoodsQuery("select * from sdGoods where (GoodsType=1 or GoodsType=2) and GoodsFrom=2 order by GoodsCode");
    if(QueryStatus==1)
    {
      sePbomhGoods->Text=GetGoodsValue("GoodsCode");
      sePbomhGoodsName->Text=GetGoodsValue("GoodsName");
      sePbomhVer->Text=GetGoodsValue("GoodsVer");
      sePbomhModel->Text=GetGoodsValue("GoodsModel");
      scPbomhType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
      scPbomhUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
      sePbomhEoq->Text=GetGoodsValue("GoodsEoq");
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::sePbomdGoodsButtonClick(TObject *Sender)
{
    OpenGoodsQuery("select * from sdGoods where GoodsType<>1 order by GoodsCode");
    if(QueryStatus==1)
    {
      sePbomdGoods->Text=GetGoodsValue("GoodsCode");
      sePbomdGoodsName->Text=GetGoodsValue("GoodsName");
      sePbomdVer->Text=GetGoodsValue("GoodsVer");
      sePbomdModel->Text=GetGoodsValue("GoodsModel");
      scPbomdType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
      scPbomdFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
      scPbomdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::sePbomhGoodsExit(TObject *Sender)
{
    AnsiString tempS;
    tempS=sePbomhGoods->Text;
    if(tempS.IsEmpty())
       return;
    if(CurrentState==caAddHead)
    {
       if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
       {
         sePbomhGoodsName->Text=GetGoodsValue("GoodsName");
         sePbomhVer->Text=GetGoodsValue("GoodsVer");
         sePbomhModel->Text=GetGoodsValue("GoodsModel");
         scPbomhType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
         scPbomhUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
         sePbomhEoq->Text=GetGoodsValue("GoodsEoq");
       }
       else
         ::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPbomh::sePbomdGoodsExit(TObject *Sender)
{
    AnsiString tempS;
    tempS=sePbomdGoods->Text;
    if(!tempS.IsEmpty())
    {
       if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
       {
          sePbomdGoodsName->Text=GetGoodsValue("GoodsName");
          sePbomdVer->Text=GetGoodsValue("GoodsVer");
          sePbomdModel->Text=GetGoodsValue("GoodsModel");
          scPbomdType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
          scPbomdFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
          scPbomdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
      }
      else
         ::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPbomh::sePbomhGoodsKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    AnsiString pStr=sePbomhGoods->Text;
    if(Key==13 && !pStr.IsEmpty() && CurrentState==caNormal)
    {
       comServer->LocateByKey(WideString(pStr));
       DisplayBill();
    }
}
//---------------------------------------------------------------------------


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -