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

📄 bomh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
         Keystr=sgBomh->Cells[1][sgBomh->Row];
         comServer->LocateItemByKey(WideString(Keystr));
         GetDataFromComObject(2);
       }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::GetBill(AnsiString BillID)
{
    bool iRow;
    iRow=comServer->Find("BomhCode='"+BillID+"'");
    if(iRow)
      DisplayBill();
    else
    {
       if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
          AddHeadRecord();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgBomh->RowCount=1;
    if(comServer->RecordCount>0)
    {
      for(i=0;i<comServer->ItemCount;i++)
      {
         comServer->LocateItemByIndex(i);
         RefreshGridData(0);
      }
    }
    else
      ClearControl(2,false);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmBomh::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmBomh::GetDetailValue(int Index)
{
    return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::FormCreate(TObject *Sender)
{
    FormIniFile="D:\Test.Ini";
    SetGridWidth(Name,sgBomh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TBillBaseForm::FormClose(Sender,Action);
    WriteGridWidth(Name,sgBomh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    //无审核单据功能;
    tbCheck->Visible=false;
    //无修改明细行功能;
    tbEditDetail->Visible=false;
    muEditDetail->Visible=false;
    TBillBaseForm::MoveToFirst();
    ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::sgBomhSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if(ARow > 0)
       comServer->LocateItemByKey(WideString(sgBomh->TextMatrix[ARow][1]));
    if(!comServer->Eof)
       GetDataFromComObject(2);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::sgBomhDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgBomh->Row;
    if(iRow == 0)
       return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::ChangeToBrowseState(bool agree)
{
    if(agree)
    {
       sgBomh->Visible=true;
       FloatPanel2->Visible=false;
       sgBomh->Align=alClient;
       FloatPanel2->Align=alNone;
    }
    else
    {
       sgBomh->Visible=false;
       FloatPanel2->Visible=true;
       sgBomh->Align=alNone;
       FloatPanel2->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::btnOKClick(TObject *Sender)
{
    try
    {
      if((CurrentState==caAddDetail)||(CurrentState==caAddBill))
      {
         if(DetailState==caAddDetail)
            comServer->AddItem();
         SendDataToComObject(2);
         comServer->AddToObject();
         ClearControl(2,false);
         //连续增加时返回焦点
         if(seBomdGoods->Enabled)
            seBomdGoods->SetFocus();
      }
      else
         ChangeToBrowseState(false);
    }
    catch(Exception &e)
    {
         throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::seBomhGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="007[产品编码][产品名称][版本号][型号][类型][计量单位][批量]";
  SqlStr+="Select GoodsCode,GoodsName,GoodsVer,GoodsModel,GoodsType,GoodsUnitCode,GoodsEoq from sdGoods where (GoodsType=1 or GoodsType=2) and GoodsFrom=2 order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"产品数据查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seBomhGoods->Text=p->ColData[1];
    seBomhGoodsName->Text=p->ColData[2];
    seBomhVer->Text=p->ColData[3];
    seBomhModel->Text=p->ColData[4];
    scBomhUnit->LocateKey(p->ColData[6]);
    seBomhEoq->Text=p->ColData[7];
    if(g_sdRsGoods->LocateByKey(WideString(seBomhGoods->Text))==0)
      scBomhType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::seBomdGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="007[物料编码][物料名称][版本号][型号][类型][来源][计量单位]";
  SqlStr+="Select GoodsCode,GoodsName,GoodsVer,GoodsModel,GoodsType,GoodsFrom,GoodsUnitCode from sdGoods where GoodsType<>1 and GoodsCode<>'"+seBomhGoods->Text+"' order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"子件物料数据查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seBomdGoods->Text=p->ColData[1];
    seBomdGoodsName->Text=p->ColData[2];
    seBomdVer->Text=p->ColData[3];
    seBomdModel->Text=p->ColData[4];
    scBomdUnit->Text=p->ColData[7];
    if(g_sdRsGoods->LocateByKey(WideString(seBomdGoods->Text))==0)
    {
      scBomdType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
      scBomdFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
    }
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::seBomhGoodsExit(TObject *Sender)
{
    AnsiString tempS;
    tempS=seBomhGoods->Text;
    if(tempS.IsEmpty())
       return;
    if(CurrentState==caAddHead)
    {
      if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
      {
        seBomhGoods->Text=GetGoodsValue("GoodsCode");
        seBomhGoodsName->Text=GetGoodsValue("GoodsName");
        seBomhVer->Text=GetGoodsValue("GoodsVer");
        seBomhModel->Text=GetGoodsValue("GoodsModel");
        scBomhType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
        scBomhUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
        seBomhEoq->Text=GetGoodsValue("GoodsEoq");
      }
      else
        ::MessageBox(Handle,"录入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::seBomdGoodsExit(TObject *Sender)
{
    if(seBomdGoods->Text.IsEmpty())
       return;
    if(CurrentState!=caNormal)
    {
      AnsiString tempS;
      tempS=seBomdGoods->Text;
      if(!tempS.IsEmpty())
      {
         if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
         {
           seBomdGoodsName->Text=GetGoodsValue("GoodsName");
           seBomdVer->Text=GetGoodsValue("GoodsVer");
           seBomdModel->Text=GetGoodsValue("GoodsModel");
           scBomdType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
           scBomdFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
           scBomdUnit->Text=GetGoodsValue("GoodsUnitCode");
         }
         else
           ::MessageBox(Handle,"录入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
      }
    }
}
//---------------------------------------------------------------------------

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

⌨️ 快捷键说明

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