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

📄 bomh.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
         seBomhRlt->SetFocus();
    }
    else{
      ChangeToBrowseState(false);
      if(seBomdGoods->Enabled)
         seBomdGoods->SetFocus();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::RefreshGridData(int mAction)
{
    int i;
    AnsiString ItemStr=GetItemStringToGrid();
    switch(mAction)
    {
       case 0:
         sgBomh->AddItem(ItemStr);
         sgBomh->Row=sgBomh->RowCount-1;
         break;
       case 1:
         sgBomh->ChangeItem(ItemStr,sgBomh->Row);
         break;
       case 2:
         sgBomh->RemoveItem(sgBomh->Row);
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmBomh::GetItemStringToGrid()
{
    AnsiString  s_ItemStr,s1,s2,s3;
    s1=GetDetailValue("BomdProcess");
    s2=GetDetailValue("BomdUnit");
    if(GetDetailValue("BomdRepFlg")=="1")
        s3="√" ;
    scBomdProcess->LocateKey(s1);
    scBomdUnit->LocateKey(s2);
    s_ItemStr = GetDetailValue("BomdSn")+
                "\t"+GetDetailValue("BomdGoods")+
                "\t"+GetDetailValue("BomdGoodsname")+
                "\t"+GetDetailValue("BomdGoodsspec")+
                "\t"+scBomdUnit->ItemData[0]+
                "\t"+GetDetailValue("BomdQty")+
                "\t"+GetDetailValue("BomdShl")+
                "\t"+scBomdProcess->ItemData[2]+
                s3;
    return s_ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::DisplayBill()
{
    if(comServer->RecordCount>0)
    {
       GetDataFromComObject(1);
       FillGridWithData();
       if(sgBomh->RowCount >1)
       {
         AnsiString Keystr;
         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 ()
{

    sgBomh->RowCount=1;
    if(comServer->RecordCount>0)
    {
     TComResultSet *RsPmpcG;
     AnsiString l_Sql,s_ItemStr,s3;
     l_Sql =" select * from ksVw_Bomd where bomdpgoods ='"+OldTreeCode+"'";
     RsPmpcG=new TComResultSet(Handle,g_ClientHandle);

     RsPmpcG->Close();
     RsPmpcG->Open(l_Sql,"");
     RsPmpcG->MoveFirst();
     while( RsPmpcG->Eof == 0 )
     {
        if(RsPmpcG->FieldByName("BomdRepFlg")=="1")
        s3="√" ;
        s_ItemStr = AnsiString(RsPmpcG->FieldByName("BomdSn"))+
                "\t"+ AnsiString(RsPmpcG->FieldByName("BomdGoods"))+
                "\t"+ AnsiString(RsPmpcG->FieldByName("BomdGoodsname"))+
                "\t"+ AnsiString(RsPmpcG->FieldByName("BomdGoodsspec"))+
                "\t"+ AnsiString(RsPmpcG->FieldByName("BomdName"))+
                "\t"+ AnsiString(RsPmpcG->FieldByName("BomdQty"))+
                "\t"+ AnsiString(RsPmpcG->FieldByName("BomdShl"))+
                "\t"+ AnsiString(RsPmpcG->FieldByName("BomdProcessName"))+
                "\t"+ AnsiString(s3);

              sgBomh->AddItem(s_ItemStr);
              RsPmpcG->MoveNext();
     }
     RsPmpcG->Close();
    }
     else
      ClearControl(2,false);
  /*  int i;
    AnsiString ItemStr;
    sgBomh->RowCount=1;
    if(comServer->RecordCount>0)
    {
       sgBomh->ScrollBars=ssNone;
       int i= comServer->ItemCount;
      for(i=0;i<comServer->ItemCount;i++)
      {
         comServer->LocateItemByIndex(i);
         RefreshGridData(0);
      }
       sgBomh->ScrollBars=ssBoth;
    }
    else
      ClearControl(2,false);  */
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    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::sgBomhClick(TObject *Sender)
{
    if (sgBomh->Row > 0)
    {
       comServer->LocateItemByKey(sgBomh->TextMatrix[sgBomh->Row][1]+"\t"+GetHeadValue("BomhGoods")+"\t");
       GetDataFromComObject(2);    // Detail
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomh::sgBomhDblClick(TObject *Sender)
{
    int ARow=sgBomh->Row;
    //int ACol=sgBomh->Col;
    if (ARow > 0)
    {
      if (sgBomh->Cells[8][ARow] == "√")
      {
          AnsiString FWhereString;
          FWhereString=seBomhGoods->Text;
          FWhereString=" BomhGoods='"+FWhereString+"' ";
          TfrmRep *frmRep;
          try
          {
              StartWaitForm("正在启动<替换件>界面...");
              frmRep=new TfrmRep(this,g_ClientHandle,"1060203","",FWhereString);
              EndWaitForm();
              frmRep->ShowModal();
           }
           __finally
           {
              delete frmRep;
           }
      }
    }
    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(l_RsGoods->LocateByKey(WideString(seBomhGoods->Text))==0)
      scBomhType->ItemIndex=StrToInt(GetGoodsValue(gtInitRs,"GoodsType"))-1;
  }
  delete p; */
  if(OpenGoodsForm(" (GoodsType=1 or GoodsType=2) and GoodsFrom=2 " ))
    {
      seBomhGoods->Text=GetGoodsValue(gtOpenForm,"GoodsCode");
      seBomhGoodsName->Text=GetGoodsValue(gtOpenForm,"GoodsName");
      seBomhVer->Text=l_RsGoods->FieldValues["GoodsVer"];
      seBomhModel->Text=l_RsGoods->FieldValues["GoodsModel"];
      scBomhType->ItemIndex=StrToInt(l_RsGoods->FieldValues["GoodsType"])-1;
      scBomhUnit->LocateKey(l_RsGoods->FieldValues["GoodsUnitCode"]);
      seBomhEoq->Text=l_RsGoods->FieldValues["GoodsEoq"];
    }
}
//---------------------------------------------------------------------------
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];

⌨️ 快捷键说明

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