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

📄 crphdl.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
}
//---------------------------------------------------------------------------

//********************************
//  Class:TsdMpc                 *
//  Decrption:产品生产能力       *
//  Created on 2001-02-16        *
//********************************
//---------------------------------------------------------------------------
void __fastcall TsdMpc:: SetMpcGoods(AnsiString value)
{
    if(value.IsEmpty())
       throw Exception("产品编码不能为空!");
    if(value.Length()>18)
       throw Exception("产品编码的长度不能大于18!");
    if(value!=m_MpcGoods)
    {
       //唯一性
       if(this->FindKey(value))
          throw Exception("产品编码:'"+value+"'的能力资料已经存在!");
       //存在性
       m_Query->Close();
       m_Query->SQL->Clear();
       m_Query->SQL->Add("select GoodsCode from sdGoods where (GoodsType=1 or GoodsType=2) and GoodsFrom=2 and GoodsCode='"+value+"'");
       m_Query->Open();
       if(m_Query->RecordCount<=0)
       {
          m_Query->Close();
          throw Exception("产品编码:'"+value+"'不存在或不符合条件!");
       }
       m_Query->Close();
    }
    m_MpcGoods=value;
}
//---------------------------------------------------------------------------
void __fastcall TsdMpc:: SetMpcQty(double  value)
{
    if(value<0 || value==0)
       throw Exception("产品的加工能力不能小于和等于零!");
    m_MpcQty=value;
}
//---------------------------------------------------------------------------
AnsiString TsdMpc::GetFieldValue(euMpc sdFieldName)
{
    switch(sdFieldName)
    {
      case fiMpcGoods:
         return MpcGoods;
      case fiMpcQty:
         return MpcQty;
      default:
         throw Exception("该字段未定义可取值!");
    }
}
//---------------------------------------------------------------------------
void TsdMpc::SetFieldValue(euMpc sdFieldName, AnsiString value)
{
    value=Trim(value);
    switch(sdFieldName)
    {
      case fiMpcGoods:
        MpcGoods=value;
        break;
      case fiMpcQty:
        MpcQty=value.ToDouble();
        break;
      default:
        throw Exception("该字段未定义可赋值!");
    }
}
//---------------------------------------------------------------------------
TsdMpc::TsdMpc(TDataComm *DC)
      :TsdStandard(DC)
{
    try
    {
        QueryString="SELECT * FROM sdMpc";
        FilterString="";
        OrderString="MpcGoods";
        EmptyValue(0);
        EmptyValue(1);
    }
    catch(Exception &e)
    {
        throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------
TsdMpc::TsdMpc()
      :TsdStandard()
{
    try
    {
        QueryString="SELECT * FROM sdMpc";
        FilterString="";
        OrderString="MpcGoods";
        EmptyValue(0);
        EmptyValue(1);
    }
    catch(Exception &e)
    {
        throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------

TsdMpc::~TsdMpc()
{
    try{
    }
    catch(...)
    {
       throw Exception("析构函数出错!");
    }
}
//---------------------------------------------------------------------------
void TsdMpc::BackupValue()
{
    b_MpcGoods=m_MpcGoods;
    b_MpcQty=m_MpcQty;
}
//---------------------------------------------------------------------------
void TsdMpc::RestoreValue()
{
    m_MpcGoods=b_MpcGoods;
    m_MpcQty=b_MpcQty;
}
//---------------------------------------------------------------------------
void TsdMpc::EmptyValue(int Index)
{
    switch(Index)
    {
      case 0:
        m_MpcGoods="";
        m_MpcQty=0;
        break;
      case 1:
        b_MpcGoods="";
        b_MpcQty=0;
        break;
    }
}
//---------------------------------------------------------------------------
void TsdMpc::BatchLetValue()
{
    m_MpcGoods=m_Query->FieldValues["MpcGoods"];
    m_MpcQty=m_Query->FieldValues["MpcQty"];
    BackupValue();
}
//---------------------------------------------------------------------------
void TsdMpc::Update()
{
    if(CurStatus==0||CurStatus==1)
       throw Exception("当前不是编辑状态,不能进行存盘操作!");
    if(m_MpcGoods.IsEmpty()==true)
       throw Exception("单号不能为空!");
    m_StoredProc->Close();
    if(CurStatus==2||CurStatus==4)
    {
        m_StoredProc->ProcedureName="sdMpc_Insert";
        m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@MpcGoods",ftString,pdInput,18,m_MpcGoods);
        m_StoredProc->Parameters->CreateParameter("@MpcQty",ftFloat,pdInput,12,m_MpcQty);
        m_StoredProc->ExecProc();
        m_StoredProc->Close();
    }
    else
    {
        m_StoredProc->ProcedureName="sdMpc_Update";
        m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@W_MpcGoods",ftString,pdInput,18,b_MpcGoods);
        m_StoredProc->Parameters->CreateParameter("@MpcGoods",ftString,pdInput,18,m_MpcGoods);
        m_StoredProc->Parameters->CreateParameter("@MpcQty",ftFloat,pdInput,12,m_MpcQty);
        m_StoredProc->ExecProc();
        m_StoredProc->Close();
    }
    m_StoredProc->Close();
    TsdMpc *p=new TsdMpc();
    if(CurStatus==2)
    {
       SetActionID(1);
       p->Assign(this);
       AddRecord((void *)p,p->MpcGoods);
    }
    else
    {
       SetActionID(1);
       p->Assign(this);
       ChangeRecord((void *)p,p->MpcGoods,this->b_MpcGoods);
    }
}
//---------------------------------------------------------------------------
void TsdMpc::Delete()
{
    if(CurStatus!=1)
      throw Exception("当前状态不能进行删除操作!");
    if(m_MpcGoods.IsEmpty()==true)
      throw Exception("当前没有记录可以删除!");
    m_StoredProc->Close();
    m_StoredProc->ProcedureName="sdMpc_Delete";
    m_StoredProc->Parameters->Clear();
    m_StoredProc->Parameters->CreateParameter("@W_MpcGoods",ftString,pdInput,18,b_MpcGoods);
    m_StoredProc->ExecProc();
    m_StoredProc->Close();
    DeleteRecord(this->b_MpcGoods);
}
//---------------------------------------------------------------------------
void TsdMpc::Assign(TsdMpc *p)
{
    this->SetActionID(p->CurStatus);
    this->m_MpcGoods=p->m_MpcGoods;
    this->m_MpcQty=p->m_MpcQty;
    this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdMpc::AssignValue()
{
    TsdMpc *p=(TsdMpc *)Records(CurRecNo);
    Assign(p);
}
//---------------------------------------------------------------------------
int TsdMpc::Query()
{
    AnsiString m_SqlStr;
    m_SqlStr=QueryString;
    if(FilterString.IsEmpty()==false)
       m_SqlStr=m_SqlStr+" where  "+FilterString;
    if(OrderString.IsEmpty()==false)
       m_SqlStr=m_SqlStr+" Order by "+OrderString;
    m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add(m_SqlStr);
    m_Query->Open();
    ClearRecord();
    if(m_Query->RecordCount>0)
    {
        m_Query->First();
        while(!m_Query->Eof)
        {
            BatchLetValue();
            TsdMpc *p=new TsdMpc();
            SetActionID(1);
            p->Assign(this);
            AddRecord((void *)p,p->MpcGoods);
            m_Query->Next();
        }
        MoveFirst();
    }
    m_Query->Close();
    return Count;
}
//---------------------------------------------------------------------------
bool TsdMpc::Find(AnsiString WhereStr)
{
    AnsiString m_SqlStr;
    if(WhereStr.IsEmpty()==true)
      throw Exception("查找表达式不能为空!");
    m_SqlStr="select * from sdMpc where  "+WhereStr;
    m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add(m_SqlStr);
    m_Query->Open();
    if(m_Query->RecordCount!=1)
    {
       m_Query->Close();
       return false;
    }
    else
    {
       BatchLetValue();
       m_Query->Close();
       return true;
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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