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

📄 qmdoc.cpp

📁 邮 电 公 司 erp源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        m_QccDesc="";
    break;
    case 1:
        b_QccCode="";
        b_QccName="";
        b_QccDesc="";
      break;
     }
}
//---------------------------------------------------------------------------
void TsdQcc::BatchLetValue()
{
    m_QccCode=m_Query->FieldValues["QccCode"];
    m_QccName=m_Query->FieldValues["QccName"];
    m_QccDesc=m_Query->FieldValues["QccDesc"];
    BackupValue();
}
//---------------------------------------------------------------------------
void TsdQcc::Update()
{
    if(CurStatus==0||CurStatus==1)
        throw Exception("当前不是编辑状态,不能进行存盘操作!");
    if(m_QccCode.IsEmpty()==true)
        throw Exception("单号不能为空!");
    m_StoredProc->Close();
    if(CurStatus==2||CurStatus==4)
      {
        m_StoredProc->ProcedureName="sdQcc_Insert";
        m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@QccCode",ftString,pdInput,18,m_QccCode);
        m_StoredProc->Parameters->CreateParameter("@QccName",ftString,pdInput,20,m_QccName);
        m_StoredProc->Parameters->CreateParameter("@QccDesc",ftString,pdInput,40,m_QccDesc);

        m_StoredProc->ExecProc();
   }
   else
    {
        m_StoredProc->ProcedureName="sdQcc_Update";
        m_StoredProc->Parameters->Clear();

        m_StoredProc->Parameters->CreateParameter("@W_QccCode",ftString,pdInput,18,b_QccCode);
        m_StoredProc->Parameters->CreateParameter("@QccCode",ftString,pdInput,18,m_QccCode);
        m_StoredProc->Parameters->CreateParameter("@QccName",ftString,pdInput,20,m_QccName);
        m_StoredProc->Parameters->CreateParameter("@QccDesc",ftString,pdInput,40,m_QccDesc);

       m_StoredProc->ExecProc();
   }
    m_StoredProc->Close();
  TsdQcc *p=new TsdQcc();
  if(CurStatus==2)
    {
     SetActionID(1);
     p->Assign(this);
     AddRecord((void *)p,p->QccCode);
     }
  else
    {
     SetActionID(1);
     p->Assign(this);
     ChangeRecord((void *)p,p->QccCode,this->b_QccCode);
    }
}
//---------------------------------------------------------------------------
void TsdQcc::Delete()
{
    if(CurStatus!=1)
        throw Exception("当前状态不能进行删除操作!");
    if(m_QccCode.IsEmpty()==true)
        throw Exception("当前没有记录可以删除!");
    m_StoredProc->Close();
    m_StoredProc->ProcedureName="sdQcc_Delete";
    m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@W_QccCode",ftString,pdInput,18,b_QccCode);
    m_StoredProc->ExecProc();
    m_StoredProc->Close();
    DeleteRecord(this->b_QccCode);
}
//---------------------------------------------------------------------------
void TsdQcc::Assign(TsdQcc *p)
{
    this->SetActionID(p->CurStatus);
    this->m_QccCode=p->m_QccCode;
    this->m_QccName=p->m_QccName;
    this->m_QccDesc=p->m_QccDesc;
    this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdQcc::AssignValue()
{
    TsdQcc *p=(TsdQcc *)Records(CurRecNo);
    Assign(p);
}
//---------------------------------------------------------------------------
int TsdQcc::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();
            TsdQcc *p=new TsdQcc();
            SetActionID(1);
            p->Assign(this);
            AddRecord((void *)p,p->QccCode);
            m_Query->Next();
        }
        MoveFirst();
    }
    m_Query->Close();
    return Count;
}
//---------------------------------------------------------------------------
bool TsdQcc::Find(AnsiString WhereStr)
{
    AnsiString m_SqlStr;
    if(WhereStr.IsEmpty()==true)
        throw Exception("查找表达式不能为空");
    m_SqlStr="select * from sdQcc 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;
    }
}
//完成

//类体
//**************************************
//     TsdQcl    质检等级
//**************************************
//--------------------------------------------------------------
void __fastcall TsdQcl:: SetQclCode(AnsiString value)
{
       if(value.IsEmpty())
         throw Exception("质检等级内容代码不能为空");
       if(value.Length()>18)
         throw Exception("质检等级代码不能大于18");
       if(value.UpperCase() !=m_QclCode.UpperCase())
       {
            m_Query->Close();
            m_Query->SQL->Clear();
            m_Query->SQL->Add("select QclCode from sdQcl where QclCode='"+value+"'");
            m_Query->Open();
            if(m_Query->RecordCount>0)
            {
                 m_Query->Close();
                 throw Exception("质检等级代码"+value+"已存在");
            }
            m_Query->Close();
       }

       m_QclCode=value;
}
void __fastcall TsdQcl:: SetQclName(AnsiString value)
{
       if(value.Length()>20)
         throw Exception("质检等级名称不能大于20");
       if(value != m_QclName)
       {
            m_Query->Close();
            m_Query->SQL->Clear();
            m_Query->SQL->Add("select QclName from sdQcl where QclName='"+value+"'");
            m_Query->Open();
            if(m_Query->RecordCount>0)
            {
                 m_Query->Close();
                 throw Exception("质检等级名称 "+value+" 已存在");
            }
            m_Query->Close();
       }
       m_QclName=value;
}
void __fastcall TsdQcl:: SetQclDesc(AnsiString value)
{
       if(value.Length()>20)
         throw Exception("备注长度不能大于40");

       m_QclDesc=value;
}
//---------------------------------------------------------------------------
AnsiString TsdQcl::GetFieldValue(euQcl sdFieldName)
{
    switch(sdFieldName)
    {
      case fiQclCode:
           return QclCode;
      case fiQclName:
           return QclName;
      case fiQclDesc:
           return QclDesc;
      default:
           throw Exception("当前未定义返可取值");
     }
}
//---------------------------------------------------------------------------
void TsdQcl::SetFieldValue(euQcl sdFieldName, AnsiString value)
{
    value=Trim(value);
    switch(sdFieldName)
     {
    case fiQclCode:
         QclCode=value;
          break;
    case fiQclName:
         QclName=value;
          break;
    case fiQclDesc:
         QclDesc=value;
          break;
    default:
         throw Exception("当前字段未定义可赋值");
    }
}
//---------------------------------------------------------------------------
TsdQcl::TsdQcl(TDataComm *DC)
                :TsdStandard(DC)
{
    try
    {
        QueryString="SELECT * FROM sdQcl";
        FilterString="";
        OrderString="QclCode";
        EmptyValue(0);
        EmptyValue(1);
    }
    catch(Exception &e)
    {
        ShowMessage(e.Message);
    }
}
TsdQcl::TsdQcl()
                :TsdStandard()
{
    try
    {
        QueryString="SELECT * FROM sdQcl";
        FilterString="";
        OrderString="QclCode";
        EmptyValue(0);
        EmptyValue(1);
    }
    catch(Exception &e)
    {
        ShowMessage(e.Message);
    }
}
//---------------------------------------------------------------------------
TsdQcl::~TsdQcl()
{
  try{
     }
  catch(...)
    {
     throw Exception("析构函数出错");
    }
}
//---------------------------------------------------------------------------
void TsdQcl::BackupValue()
{
      b_QclCode=m_QclCode;
      b_QclName=m_QclName;
      b_QclDesc=m_QclDesc;
}
//---------------------------------------------------------------------------
void TsdQcl::RestoreValue()
{
      m_QclCode=b_QclCode;
      m_QclName=b_QclName;
      m_QclDesc=b_QclDesc;
}
//---------------------------------------------------------------------------
void TsdQcl::EmptyValue(int Index)
{
   switch(Index)
   {
    case 0:
        m_QclCode="";
        m_QclName="";
        m_QclDesc="";
    break;
    case 1:
        b_QclCode="";
        b_QclName="";
        b_QclDesc="";
      break;
     }
}
//---------------------------------------------------------------------------
void TsdQcl::BatchLetValue()
{
    m_QclCode=m_Query->FieldValues["QclCode"];
    m_QclName=m_Query->FieldValues["QclName"];
    m_QclDesc=m_Query->FieldValues["QclDesc"];
    BackupValue();
}
//---------------------------------------------------------------------------
void TsdQcl::Update()
{
    if(CurStatus==0||CurStatus==1)
        throw Exception("当前不是编辑状态,不能进行存盘操作!");
    if(m_QclCode.IsEmpty()==true)
        throw Exception("单号不能为空!");
    m_StoredProc->Close();
    if(CurStatus==2||CurStatus==4)
      {
        m_StoredProc->ProcedureName="sdQcl_Insert";
        m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@QclCode",ftString,pdInput,18,m_QclCode);
        m_StoredProc->Parameters->CreateParameter("@QclName",ftString,pdInput,20,m_QclName);
        m_StoredProc->Parameters->CreateParameter("@QclDesc",ftString,pdInput,40,m_QclDesc);

        m_StoredProc->ExecProc();
   }
  else
    {
        m_StoredProc->ProcedureName="sdQcl_Update";
        m_StoredProc->Parameters->Clear();

        m_StoredProc->Parameters->CreateParameter("@W_QclCode",ftString,pdInput,18,b_QclCode);
        m_StoredProc->Parameters->CreateParameter("@QclCode",ftString,pdInput,18,m_QclCode);
        m_StoredProc->Parameters->CreateParameter("@QclName",ftString,pdInput,20,m_QclName);
        m_StoredProc->Parameters->CreateParameter("@QclDesc",ftString,pdInput,40,m_QclDesc);

       m_StoredProc->ExecProc();


   }
    m_StoredProc->Close();
  TsdQcl *p=new TsdQcl();
  if(CurStatus==2)
    {
     SetActionID(1);
     p->Assign(this);
     AddRecord((void *)p,p->QclCode);
     }
  else
    {
     SetActionID(1);
     p->Assign(this);
     ChangeRecord((void *)p,p->QclCode,this->b_QclCode);
    }
}
//---------------------------------------------------------------------------
void TsdQcl::Delete()
{
    if(CurStatus!=1)
        throw Exception("当前状态不能进行删除操作!");
    if(m_QclCode.IsEmpty()==true)
        throw Exception("当前没有记录可以删除!");
    m_StoredProc->Close();
    m_StoredProc->ProcedureName="sdQcl_Delete";
    m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@W_QclCode",ftString,pdInput,18,b_QclCode);
    m_StoredProc->ExecProc();
    m_StoredProc->Close();
    DeleteRecord(this->b_QclCode);
}
//---------------------------------------------------------------------------
void TsdQcl::Assign(TsdQcl *p)
{
    this->SetActionID(p->CurStatus);
    this->m_QclCode=p->m_QclCode;
    this->m_QclName=p->m_QclName;
    this->m_QclDesc=p->m_QclDesc;
    this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdQcl::AssignValue()
{
    TsdQcl *p=(TsdQcl *)Records(CurRecNo);
    Assign(p);
}
//---------------------------------------------------------------------------
int TsdQcl::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();
            TsdQcl *p=new TsdQcl();
            SetActionID(1);
            p->Assign(this);
            AddRecord((void *)p,p->QclCode);
            m_Query->Next();
        }
        MoveFirst();
    }
    m_Query->Close();
    return Count;
}
//---------------------------------------------------------------------------
bool TsdQcl::Find(AnsiString WhereStr)
{
    AnsiString m_SqlStr;
    if(WhereStr.IsEmpty()==true)
        throw Exception("查找表达式不能为空");
    m_SqlStr="select * from sdQcl 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;
    }
}
//完成

//类体
//**************************************
//     TsdQdl     缺陷等级
//**************************************
//--------------------------------------------------------------

⌨️ 快捷键说明

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