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

📄 bomha.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    scBomdProcess->LocateKey(s1);
    scBomdUnit->LocateKey(s2);
    s_ItemStr = GetDetailValue("BomdSn")+
                "\t"+GetDetailValue("BomdGoods")+
                "\t"+scBomdUnit->ItemData[0]+
                "\t"+GetDetailValue("BomdQty")+
                "\t"+GetDetailValue("BomdShl")+
                "\t"+scBomdProcess->ItemData[2];
    return s_ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::DisplayBill()
{
    if(comServer->RecordCount>0)
    {
       GetDataFromComObject(1);
       FillGridWithData();
       if(sgBomh->RowCount >1)
       {
         AnsiString Keystr;
         Keystr=seBomhGoods->Text+"\t"+sgBomh->Cells[1][sgBomh->Row];
         comServer->LocateItemByKey(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);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    delete l_RsGoods;
    TBillBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
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(seBomhGoods->Text+"\t"+sgBomh->TextMatrix[ARow][1]);
       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];
    scBomhType->ItemIndex=StrToInt(p->ColData[5])-1;
    scBomhUnit->LocateKey(p->ColData[6]);
    seBomhEoq->Text=p->ColData[7];
  }
  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];
    scBomdType->ItemIndex=StrToInt(p->ColData[5])-1;
    scBomdFrom->ItemIndex=StrToInt(p->ColData[6])-1;
    scBomdUnit->LocateKey(p->ColData[7]);
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::seBomhGoodsExit(TObject *Sender)
{
    AnsiString tempS;
    tempS=seBomhGoods->Text;
    if(tempS.IsEmpty())
       return;
    if(CurrentState==caAddHead)
    {
      if(l_RsGoods->LocateByKey(tempS)==0)
      {
        seBomhGoods->Text=GetGoodsValue(gtInitRs,"GoodsCode");
        seBomhGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
        seBomhVer->Text=GetGoodsValue(gtInitRs,"GoodsVer");
        seBomhModel->Text=GetGoodsValue(gtInitRs,"GoodsModel");
        scBomhType->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsType"))-1;
        scBomhUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));
        seBomhEoq->Text=GetGoodsValue(gtInitRs,"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(l_RsGoods->LocateByKey(tempS)==0)
         {
           seBomdGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
           seBomdVer->Text=GetGoodsValue(gtInitRs,"GoodsVer");
           seBomdModel->Text=GetGoodsValue(gtInitRs,"GoodsModel");
           scBomdType->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsType"))-1;
           scBomdFrom->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsFrom"))-1;
           scBomdUnit->LocateKey(GetGoodsValue(gtInitRs,"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(pStr);
       DisplayBill();
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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