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

📄 bomhcopy.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{
    bool iRow;
    iRow=comServer->Find("BomhCode='"+BillID+"'");
    if(iRow)
       DisplayBill();
    else
    {
      if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
         AddHeadRecord();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgBomhCopy->RowCount=1;
    if(comServer->RecordCount>0)
    {
      for(i=0;i<comServer->ItemCount;i++)
      {
        comServer->LocateItemByIndex(i);
        RefreshGridData(0);
      }
    }
    else
      ClearControl(2,false);
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmBomhCopy::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmBomhCopy::GetDetailValue(int Index)
{
    return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------

void __fastcall TfrmBomhCopy::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::FormCreate(TObject *Sender)
{
    FormIniFile="D:\Test.Ini";
    SetGridWidth(Name,sgBomhCopy,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmBomhCopy::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TGenBaseForm::FormClose(Sender,Action);
    WriteGridWidth(Name,sgBomhCopy,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmBomhCopy::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    //无单据审核功能;
    tbCheck->Visible=false;
    //无修改明细行功能;
    tbEditDetail->Visible=false;
    muEditDetail->Visible=false;
    TGenBaseForm::MoveToFirst();
    ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::sgBomhCopySelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if(ARow > 0)
       comServer->LocateItemByKey(WideString(sgBomhCopy->TextMatrix[ARow][1]));
    if(!comServer->Eof)
       GetDataFromComObject(2);
}
//---------------------------------------------------------------------------

void __fastcall TfrmBomhCopy::sgBomhCopyDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgBomhCopy->Row;
    if(iRow == 0)
       return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------

void __fastcall TfrmBomhCopy::ChangeToBrowseState(bool agree)
{
    if(agree)
    {
       sgBomhCopy->Visible=true;
       FloatPanel2->Visible=false;
       sgBomhCopy->Align=alClient;
       FloatPanel2->Align=alNone;
    }
    else
    {
       sgBomhCopy->Visible=false;
       FloatPanel2->Visible=true;
       sgBomhCopy->Align=alNone;
       FloatPanel2->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::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 TfrmBomhCopy::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::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 TfrmBomhCopy::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 TfrmBomhCopy::GenrateBill()
{
    int BefoICount=comServer->ItemCount;
    try
    {
      StartWaitForm("正在启动<物料单复制>界面...");
      BomdCopyfrm = new TfrmBomdCopy(this);
      BomdCopyfrm->SetcomServer(comServer);
      BomdCopyfrm->BomhGoods=seBomhGoods->Text;
      BomdCopyfrm->BomhGoodsName=seBomhGoodsName->Text;
      EndWaitForm();
      BomdCopyfrm->ShowModal();
      if(comServer->ItemCount>BefoICount)
        TGenBaseForm::SaveRecord();
      else
        CancelChange();
    }
    __finally
    {
       delete BomdCopyfrm;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomhCopy::seBomhGoodsExit(TObject *Sender)
{
    AnsiString tempS;
    tempS=seBomhGoods->Text;
    if(tempS.IsEmpty())
       return;
    if(CurrentState==caAddHead)
    {
      if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
      {
        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 TfrmBomhCopy::seBomdGoodsExit(TObject *Sender)
{
    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->LocateKey(GetGoodsValue("GoodsUnitCode"));
      }
      else
         ::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmBomhCopy::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 + -