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

📄 bomdcopy.cpp

📁 科思ERP部分源码及控件
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "BomdCopy.h"
#include "BomhCopy.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma resource "*.dfm"

TfrmBomdCopy *frmBomdCopy;
//---------------------------------------------------------------------------
__fastcall TfrmBomdCopy::TfrmBomdCopy(TComponent* Owner)
    : TStdBaseForm(Owner)
{
    sgBomd->RowCount=1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::scBomhGoodsFClick(TObject *Sender)
{
    if(scBomhGoodsF->ItemIndex==-1)
    {
       ::MessageBox(Handle,"生成时的来源父件编码不能为空!","错误",MB_OK|MB_ICONSTOP);
       return;
    }
    else
    {
       sgBomd->RowCount=1;
       AnsiString s_GoodsF=Trim(scBomhGoodsF->ItemData[1]);
       seBomhGoodsNameF->Text=scBomhGoodsF->ItemData[2];
       FillGridWithData(s_GoodsF);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::FillGridWithData(AnsiString s_GoodsCode)
{
    AnsiString tempSQL,ItemStr;
    Rst=new  TComResultSet(Handle,g_ClientHandle);
    tempSQL=AnsiString("Select BomdSn,BomdGoods,GoodsName,BomdUnit,BomdType,BomdFrom,")+
            AnsiString("BomdQty,BomdShl,BomdOp,BomdPp,BomdProcess,BomdCfg,BomdLot,BomdRepFlg,BomdLlc ")+
            AnsiString("from sdBomd,sdGoods Where BomdGoods=GoodsCode and BomdPgoods='"+s_GoodsCode+"' Order By BomdSn");
    Rst->Open(WideString(tempSQL),WideString("BomdSn"));
    Rst->MoveFirst();
    while( Rst->Eof == 0 )
    {
        ItemStr=AnsiString("√") +
                "\t"+ Rst->FieldByName("BomdSn")+
                "\t"+ Rst->FieldByName("BomdGoods")+
                "\t"+ Rst->FieldByName("GoodsName")+
                "\t"+ Rst->FieldByName("BomdUnit")+
                "\t"+ Rst->FieldByName("BomdQty")+
                "\t"+ Rst->FieldByName("BomdShl");
        sgBomd->AddItem(ItemStr);
        Rst->MoveNext();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::SetcomServer(TComServer *value)
{
    comServer=value;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::sgBomdSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if(ARow>0 && ACol==0)
    {
       if(sgBomd->Cells[0][ARow]=="")
          sgBomd->Cells[0][ARow]="√";
       else
          sgBomd->Cells[0][ARow]="";
    }
    if(ARow>0)
    {
      AnsiString m_Key;
      m_Key=sgBomd->Cells[1][ARow];
      Rst->LocateByKey(WideString(m_Key));
      SetValueToControl();
    }
    else
      CanSelect=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::SetValueToControl()
{
    scBomdFrom->ItemIndex=StrToInt(Rst->FieldByName("BomdFrom"))-1;
    scBomdOp->ItemIndex=StrToInt(Rst->FieldByName("BomdOp"))-1;
    scBomdPp->ItemIndex=StrToInt(Rst->FieldByName("BomdPp"))-1;
    scBomdProcess->LocateKey(Rst->FieldByName("BomdProcess"));
    scBomdCfg->ItemIndex=StrToInt(Rst->FieldByName("BomdCfg"))-1;
    seBomdLot->Text=Rst->FieldByName("BomdLot");
    chkBomdRepFlg->Checked=Rst->FieldByName("BomdRepFlg")=="1";
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::btnCancelClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::FormShow(TObject *Sender)
{
    seBomhGoodsT->Text = FBomhGoods;
    seBomhGoodsNameT->Text = FBomhGoodsName;
    seBomhGoodsT->Enabled=false;
    seBomhGoodsNameT->Enabled=false;
    seBomhGoodsNameF->Enabled=false;
    Panel1->Enabled=false;
    FillComboBox(Handle,scBomhGoodsF,"select memo='('+GoodsCode+')'+space(1)+GoodsName,GoodsCode,GoodsName from sdGoods,sdBomh where BomhGoods=GoodsCode order by GoodsCode ","memo","GoodsCode","GoodsName");
    FillComboBox(Handle,scBomdProcess,"Select ProcessCode,memo='('+ProcessCode+')'+space(1)+ProcessName from sdProcess order by ProcessCode","memo","ProcessCode");
    InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::InitEditControl()
{
    scBomhGoodsF->ItemIndex=-1;
    seBomhGoodsNameF->Text="";
    scBomdFrom->ItemIndex=-1;
    scBomdOp->ItemIndex=-1;
    scBomdPp->ItemIndex=-1;
    scBomdProcess->ItemIndex=-1;
    scBomdCfg->ItemIndex=-1;
    seBomdLot->Text="";
    chkBomdRepFlg->Checked=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::btnOKClick(TObject *Sender)
{
    int j;
    j=comServer->ItemCount-1;
    if(j>0)
    {
       comServer->LocateItemByIndex(j);
       j=GetDetailValue("BomdSn").ToInt();
       j=j+1;
    }
    else
       j=1;
    for(int i=1;i<sgBomd->RowCount;i++)
    {
      if(sgBomd->Cells[0][i]=="√")
      {
          AnsiString m_Keystr;
          m_Keystr=sgBomd->Cells[1][i];
          Rst->LocateByKey(m_Keystr);
          comServer->AddItem();
          SetDetailValue("BomdPgoods",BomhGoods);
          SetDetailValue("BomdSn",AnsiString(j));
          SetDetailValue("BomdGoods",Rst->FieldByName("BomdGoods"));
          SetDetailValue("BomdUnit",Rst->FieldByName("BomdUnit"));
          SetDetailValue("BomdType",Rst->FieldByName("BomdType"));
          SetDetailValue("BomdFrom",Rst->FieldByName("BomdFrom"));
          SetDetailValue("BomdQty",Rst->FieldByName("BomdQty"));
          SetDetailValue("BomdShl",Rst->FieldByName("BomdShl"));
          SetDetailValue("BomdOp",Rst->FieldByName("BomdOp"));
          SetDetailValue("BomdPp",Rst->FieldByName("BomdPp"));
          SetDetailValue("BomdProcess",Rst->FieldByName("BomdProcess"));
          SetDetailValue("BomdCfg",Rst->FieldByName("BomdCfg"));
          SetDetailValue("BomdLot",Rst->FieldByName("BomdLot"));
          SetDetailValue("BomdRepFlg",Rst->FieldByName("BomdRepFlg"));
          try
          {
             comServer->AddToObject();
          }
          catch(Exception &e)
          {
             comServer->Cancel();
             this->ModalResult=0;
             throw Exception(e.Message);
          }
          j=j+1;
      }
    }
    Close(); /*关闭窗口*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmBomdCopy::FormClose(TObject *Sender,
      TCloseAction &Action)
{
   delete Rst;
   Close();
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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