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

📄 apmhdl.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    }
    m_Query->Close();
    return Count;
}
//---------------------------------------------------------------------------
bool TsdApivd::Find(AnsiString WhereStr)
{
    AnsiString m_SqlStr;
    if(WhereStr.IsEmpty()==true)
        throw Exception("查找表达式不能为空");
    m_SqlStr="select * from sdApivd 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;
    }
}
//**************************************
//     TsdApivh  应付发票头
//**************************************
void __fastcall TsdApivh:: SetApivhCode(AnsiString value)
{
    if (value.IsEmpty() )
       throw Exception("应付发票号不能为空!");
    if(value.Length()>18)
        throw Exception("应付发票号长度不能大于18!");
    if (value!=m_ApivhCode)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("SELECT ApivhCODE FROM SDApivh WHERE ApivhCODE='" +value+"'");
      m_Query->Open();
      if(m_Query->RecordCount>0)
      {
        m_Query->Close();
        throw Exception("应付发票号'"+value+"'已存在!");
      }
      m_Query->Close();
    }
    m_ApivhCode=value;
}
void __fastcall TsdApivh:: SetApivhFmonth(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("财务月份不能为空!");
    if(value!=m_ApivhFmonth)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select fcmonth from sdfc where fcmonth='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("财务月份:"+value+"未定义");
      }
      m_Query->Close();
    }

    m_ApivhFmonth=value;
}
void __fastcall TsdApivh:: SetApivhDate(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("发票日期不能为空!");
    m_ApivhDate=Validate(value);
}
void __fastcall TsdApivh:: SetApivhSupply(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("供应商编码不能为空!");
    if(value.Length()>18)
      throw Exception("供应商编码长度不能大于18!");
    if(value!=m_ApivhSupply)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select supplycode from sdsupply where supplycode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("供应商'"+value+"'未定义!");
      }
      m_Query->Close();
    }
    m_ApivhSupply=value;
}
void __fastcall TsdApivh:: SetApivhCurrency(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("货币代码不能为空!");
    if(value.Length()>18)
      throw Exception("货币代码长度不能大于18!");
    if(value!=m_ApivhCurrency)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select currencycode from sdcurrency where currencycode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("货币编码'"+value+"'未定义!");
      }
      m_Query->Close();
    }
    m_ApivhCurrency=value;
}
void __fastcall TsdApivh:: SetApivhEnrate(double value)
{
    if(value<=0)
      throw Exception("汇率不能小于等于零!");
    AnsiString FCurrency;
    if(m_ApivhCurrency.IsEmpty())
      throw Exception("币种代码不能为空");
    m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add("select currencycode from sdCurrency where currencylocal=1");
    m_Query->Open();
    if(m_Query->RecordCount<=0)
    {
      m_Query->Close();
      throw Exception("本币未定义");
    }
    FCurrency=m_Query->FieldValues["currencycode"];
    m_Query->Close();
    if(FCurrency.UpperCase()!=m_ApivhCurrency.UpperCase())
      m_ApivhEnrate=value;
    else
      m_ApivhEnrate=1;
}
void __fastcall TsdApivh:: SetApivhDesc(AnsiString value)
{
    if(value.Length()>40)
      throw Exception("备注长度不能大于40!");
    m_ApivhDesc=value;
}
void __fastcall TsdApivh:: SetApivhPDate(AnsiString value)
{
    if(m_ApivhDate.IsEmpty())
      throw Exception("发票日期不能为空!");
    if(value.IsEmpty())
      throw Exception("应付日期不能为空!");
    if(Validate(value)<Validate(m_ApivhDate))
      throw Exception("应付日期不能在发票日期之前!");
    m_ApivhPDate=Validate(value);
}
void __fastcall TsdApivh:: SetApivhRed(double value)
{
    if(value!=-1 && value!=1)
      throw Exception("红字标志只能取值:1-蓝字 -1-红字!");
    m_ApivhRed=value;
}
void __fastcall TsdApivh:: SetApivhUser(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("操作员不能为空!");
    if(value.Length()>18)
      throw Exception("操作员长度不能大于18!");
    if(value!=m_ApivhUser)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select usercode from sduser where usercode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("操作员:"+value+"未定义!");
      }
      m_Query->Close();
    }
    m_ApivhUser=value;
}
void __fastcall TsdApivh:: SetApivhCheck(int value)
{
    if(value!=0 && value!=1)
       throw Exception("审核标志只能取值: 0-未审核 1-已审核!");
    m_ApivhCheck=value;
}
void __fastcall TsdApivh:: SetApivhChecker(AnsiString value)
{
    if(m_ApivhCheck==1)
    {
      if(value.IsEmpty())
        throw Exception("审核员编码不能为空!");
      if(value.Length()>18)
        throw Exception("审核员长度不能大于18!");
      if(value!=m_ApivhChecker)
      {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("select purserCode from sdpurser where purserCheck=1 and pursercode='"+value+"'");
        m_Query->Open();
        if(m_Query->RecordCount<=0)
        {
          m_Query->Close();
          throw Exception("审核员:"+value+"未定义或没有审核权限!");
        }
        m_Query->Close();
      }
      m_ApivhChecker=value;
    }
    else
      m_ApivhChecker="";
}
void __fastcall TsdApivh:: SetApivhCheckDate(AnsiString value)
{
    if(m_ApivhCheck==1)
    {
      if(value.IsEmpty())
        throw Exception("审核日期不能为空!");
      m_ApivhCheckDate=Validate(value);
    }
    else
      m_ApivhCheckDate="";
}
void __fastcall TsdApivh:: SetApivhSysDate(AnsiString value)
{
      m_ApivhSysDate=value;
}
//---------------------------------------------------------------------------
AnsiString TsdApivh::GetFieldValue(euApivh sdFieldName)
{
    switch(sdFieldName)
    {
      case fiApivhCode:
           return  ApivhCode;
      case fiApivhFmonth:
           return  ApivhFmonth;
      case fiApivhDate:
           return  ApivhDate;
      case fiApivhSupply:
           return  ApivhSupply;
      case fiApivhCurrency:
           return  ApivhCurrency;
      case fiApivhEnrate:
           return  ApivhEnrate;
      case fiApivhDesc:
           return  ApivhDesc;
      case fiApivhPDate:
           return  ApivhPDate;
      case fiApivhRed:
           return  ApivhRed;
      case fiApivhUser:
           return  ApivhUser;
      case fiApivhCheck:
           return  ApivhCheck;
      case fiApivhChecker:
           return  ApivhChecker;
      case fiApivhCheckDate:
           return  ApivhCheckDate;
      case fiApivhSysDate:
           return  ApivhSysDate;
        default:
         throw Exception("当前字段未定义可取值");
    }
}
//---------------------------------------------------------------------------
void TsdApivh::SetFieldValue(euApivh sdFieldName, AnsiString value)
{
    value=Trim(value);
    switch(sdFieldName)
    {
     case fiApivhCode:
             ApivhCode=value;
           break;
     case fiApivhFmonth:
             ApivhFmonth=value;
           break;
     case fiApivhDate:
             ApivhDate=value;
           break;
     case fiApivhSupply:
             ApivhSupply=value;
           break;
     case fiApivhCurrency:
             ApivhCurrency=value;
           break;
     case fiApivhEnrate:
             ApivhEnrate=value.ToDouble();
           break;
     case fiApivhDesc:
             ApivhDesc=value;
           break;
     case fiApivhPDate:
             ApivhPDate=value;
           break;
     case fiApivhRed:
             ApivhRed=value.ToDouble();
           break;
     case fiApivhUser:
             ApivhUser=value;
           break;
     case fiApivhCheck:
             ApivhCheck=value.ToInt();
           break;
     case fiApivhChecker:
             ApivhChecker=value;
           break;
     case fiApivhCheckDate:
             ApivhCheckDate=value;
           break;
     case fiApivhSysDate:
             ApivhSysDate=value;
           break;
      default:
         throw Exception("当前字段未定义可赋值");
    }
}
//---------------------------------------------------------------------------
TsdApivh::TsdApivh(TDataComm *DC)
                :TsdHead(DC)
{
    try
    {
        QueryString="SELECT * FROM sdApivh";
        FilterString="";
        OrderString="ApivhCode";
        EmptyValue(0); 
        EmptyValue(1); 
    }
    catch(Exception &e)
    {
        ShowMessage(e.Message);
    }
}
//---------------------------------------------------------------------------
TsdApivh::TsdApivh()
                :TsdHead()
{
    try
    {
        QueryString="SELECT * FROM sdApivh";
        FilterString="";
        OrderString="ApivhCode";
        EmptyValue(0); 
        EmptyValue(1); 
    }
    catch(Exception &e)
    {
        ShowMessage(e.Message);
    }
}
//---------------------------------------------------------------------------
TsdApivh::~TsdApivh()
{
  try{
    for(int i=0;i<this->Count;i++)
    {
      this->LocateByIndex(i);
      this->AssignValue();
      delete m_sdApivd;
     }

  }
  catch(...)
  {
    throw Exception("析构函数出错");
  }
}
//---------------------------------------------------------------------------
void TsdApivh::Update()
{
    if(CurStatus==0||CurStatus==1)
        throw Exception("当前不是编辑状态,不能进行存盘操作!");
    if(m_ApivhCode.IsEmpty()==true)
        throw Exception("发票号不能为空!");
    if(ItemCount<=0)
        throw Exception("单没有定义明细字段");
    m_StoredProc->Close();
    switch(CurStatus)
    {
    case 2:
    case 4:
        m_StoredProc->ProcedureName="sdApivh_Insert";
        m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@ApivhCode",ftString,pdInputOutput,18,m_ApivhCode);
        m_StoredProc->Parameters->CreateParameter("@ApivhFmonth",ftString,pdInput,6,m_ApivhFmonth);
        m_StoredProc->Parameters->CreateParameter("@ApivhDate",ftString,pdInput,10,m_ApivhDate);
        m_StoredProc->Parameters->CreateParameter("@ApivhSupply",ftString,pdInput,18,m_ApivhSupply);
        m_StoredProc->Parameters->CreateParameter("@ApivhCurrency",ftString,pdInput,18,m_ApivhCurrency);
        m_StoredProc->Parameters->CreateParameter("@ApivhEnrate",ftFloat,pdInput,12,m_ApivhEnrate);
        m_StoredProc->Parameters->CreateParameter("@ApivhDesc",ftString,pdInput,40,m_ApivhDesc);
        m_StoredProc->Parameters->CreateParameter("@ApivhPDate",ftString,pdInput,10,m_ApivhPDate);
        m_StoredProc->Parameters->CreateParameter("@ApivhRed",ftFloat,pdInput,5,m_ApivhRed);
        m_StoredProc->Parameters->CreateParameter("@ApivhUser",ftString,pdInput,18,m_ApivhUser);
        m_StoredProc->Parameters->CreateParameter("@ApivhCheck",ftInteger,pdInput,1,m_ApivhCheck);
        m_StoredProc->Parameters->CreateParameter("@ApivhChecker",ftString,pdInput,18,m_ApivhChecker);
        m_StoredProc->Parameters->CreateParameter("@ApivhCheckDate",ftString,pdInput,10,m_ApivhCheckDate);
        m_StoredProc->Parameters->CreateParameter("@ApivhSysDate",ftString,pdOutput,30,m_ApivhSysDate);
 
        m_StoredProc->ExecProc();
        m_ApivhCode=m_StoredProc->Parameters->ParamValues["@ApivhCode"];

⌨️ 快捷键说明

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