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

📄 smdoc.cpp

📁 邮 电 公 司 erp源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    FilterString="";
    OrderString="SgdClientCode,SgdCODE";
        EmptyValue(0);
        EmptyValue(1);

  }
  catch(Exception &e)
  {
    ShowMessage(e.Message);
  }
}

//---------------------------------------------------------------------------
AnsiString TsdSgd::GetFieldValue(euSgd sdFieldName)
{
    switch(sdFieldName)
    {
      case fiSgdClientCode:
        return SgdClientCode;
      case fiSgdCode:
        return SgdCode;
      case fiSgdName:
        return SgdName;
      case fiSgdGoodsCode:
        return SgdGoodsCode;
      default:
        throw Exception("当前字段未定义可取值");  
    }
}
//---------------------------------------------------------------------------
void TsdSgd::SetFieldValue(euSgd sdFieldName, AnsiString Value)
{
     Value=Trim(Value);
    switch(sdFieldName)
    {
      case fiSgdClientCode:
        SgdClientCode=Value;
        break;
      case fiSgdCode:
        SgdCode=Value;
        break;
      case fiSgdName:
        SgdName=Value;
        break;
      case fiSgdGoodsCode:
        SgdGoodsCode=Value;
        break;
      default: 
        throw Exception("当前字段未定义可赋值");  
        
    }
}
//---------------------------------------------------------------------------
void TsdSgd::Update()
{
  if(CurStatus==0||CurStatus==1)
    throw Exception("当前不是编辑状态,不能进行存盘操作!");
  if(m_SgdClientCode.IsEmpty()==true)
    throw Exception("客户编码不能为空!");
  if(m_SgdGoodsCode.IsEmpty())
    throw Exception("物料编码不能为空");
  if(m_SgdCode.IsEmpty()==true)
    throw Exception("客户货物编码不能为空!");
  if(m_SgdName.IsEmpty()==true)
    throw Exception("客户货物名称不能为空!");
  m_StoredProc->Close();
  if(CurStatus==2||CurStatus==4)
  {
        m_StoredProc->ProcedureName="sdSgd_Insert";
        m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@SgdClientCode",ftString,pdInput,18,m_SgdClientCode);
        m_StoredProc->Parameters->CreateParameter("@SgdGoodsCode",ftString,pdInput,18,m_SgdGoodsCode);
        m_StoredProc->Parameters->CreateParameter("@SgdCode",ftString,pdInput,18,m_SgdCode);
        m_StoredProc->Parameters->CreateParameter("@SgdName",ftString,pdInput,20,m_SgdName);

        m_StoredProc->ExecProc();


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

        m_StoredProc->Parameters->CreateParameter("@W_SgdClientCode",ftString,pdInput,18,b_SgdClientCode);
        m_StoredProc->Parameters->CreateParameter("@W_SgdGoodsCode",ftString,pdInput,18,b_SgdGoodsCode);
        m_StoredProc->Parameters->CreateParameter("@SgdGoodsCode",ftString,pdInput,18,m_SgdGoodsCode);        
        m_StoredProc->Parameters->CreateParameter("@SgdCode",ftString,pdInput,18,m_SgdCode);
        m_StoredProc->Parameters->CreateParameter("@SgdName",ftString,pdInput,20,m_SgdName);
 
       m_StoredProc->ExecProc();


   }
    m_StoredProc->Close();
  TsdSgd *p=new TsdSgd();
  if(CurStatus==2)
  {
    SetActionID(1);
    p->Assign(this);
    AddRecord((void *)p,p->SgdClientCode+p->SgdGoodsCode);
  }
  else
  {
    SetActionID(1);
    p->Assign(this);
    ChangeRecord((void *)p,p->SgdClientCode+p->SgdGoodsCode,this->b_SgdClientCode+this->b_SgdGoodsCode);
  }
}
//---------------------------------------------------------------------------

void TsdSgd::Delete()
{

    if(CurStatus!=1)
      throw Exception("当前状态不能进行删除操作!");
    if(m_SgdCode.IsEmpty()==true)
      throw Exception("当前没有记录可以删除!");
    m_StoredProc->Close();
    m_StoredProc->ProcedureName="sdSgd_Delete";
    m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@W_SgdClientCode",ftString,pdInput,18,b_SgdClientCode);
        m_StoredProc->Parameters->CreateParameter("@W_SgdGoodsCode",ftString,pdInput,18,b_SgdGoodsCode);
    m_StoredProc->ExecProc();
    m_StoredProc->Close();
    DeleteRecord(this->b_SgdClientCode+this->b_SgdGoodsCode);

}
//---------------------------------------------------------------------------
void TsdSgd::BackupValue()
{
    b_SgdClientCode=m_SgdClientCode;
    b_SgdCode=m_SgdCode;
    b_SgdName=m_SgdName;
    b_SgdGoodsCode=m_SgdGoodsCode;

}
//---------------------------------------------------------------------------
void TsdSgd::RestoreValue()
{
    m_SgdClientCode=b_SgdClientCode;
    m_SgdCode=b_SgdCode;
    m_SgdName=b_SgdName;
    m_SgdGoodsCode=b_SgdGoodsCode;
}

//---------------------------------------------------------------------------
void TsdSgd::EmptyValue(int Index)
{
   switch(Index)
   {
     case 0:
      m_SgdClientCode="";
      m_SgdCode="";
      m_SgdName="";
      m_SgdGoodsCode="";
      break;
    case 1:
      b_SgdClientCode="";
      b_SgdCode="";
      b_SgdName="";
      b_SgdGoodsCode="";
      break;
    }
}

//---------------------------------------------------------------------------
void TsdSgd::BatchLetValue()
{

  m_SgdClientCode=m_Query->FieldValues["SgdClientCode"];
  m_SgdCode=m_Query->FieldValues["SgdCode"];
  m_SgdName=m_Query->FieldValues["SgdName"];
  m_SgdGoodsCode=m_Query->FieldValues["SgdGoodsCode"];

  BackupValue();
}
//---------------------------------------------------------------------------
void TsdSgd::Assign(TsdSgd *p)
{
    this->SetActionID(p->CurStatus);
    this->m_SgdClientCode=p->m_SgdClientCode;
    this->m_SgdCode=p->m_SgdCode;
    this->m_SgdName=p->m_SgdName;
    this->m_SgdGoodsCode=p->m_SgdGoodsCode;

    this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdSgd::AssignValue()
{
    TsdSgd *p=(TsdSgd *)Records(CurRecNo);
    Assign(p);
}
//---------------------------------------------------------------------------
int TsdSgd::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();
      TsdSgd *p=new TsdSgd();
      SetActionID(1);
      p->Assign(this);
      AddRecord((void *)p,p->SgdClientCode+p->SgdGoodsCode);
      m_Query->Next();
    }
    MoveFirst();
  }
  m_Query->Close();
  return Count;
}
//---------------------------------------------------------------------------
bool TsdSgd::Find(AnsiString WhereStr)
{
  AnsiString m_SqlStr;
  if(WhereStr.IsEmpty()==true)
    throw Exception("查找表达式不能为空");
  m_SqlStr="SELECT * FROM SDSgd 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;
  }
}
//---------------------------------------------------------------------------

TsdSgd::~TsdSgd()
{
  try{
  }
  catch(...)
  {
    throw Exception("析构函数出错");
  }
}
//====================================================================
//                           (TsdSquote)销售货物报价单
//===================================================================
//**************************************
//     TsdSquote
//**************************************
//--------------------------------------------------------------
void __fastcall TsdSquote::SetSquoteClient(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("客户代码不能为空");
    if(value.Length()>18)
      throw Exception("客户编码长度不能大于18");
    if(value!=m_SquoteClient)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("SELECT ClientCODE FROM SDClient WHERE ClientCODE='" +value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("客户编码'"+value+"'不存在");
      }
      m_Query->Close();
    }
    m_SquoteClient = value;
}

void __fastcall TsdSquote::SetSquoteGoods(AnsiString value)
{
  if(value.IsEmpty())
    throw Exception("物料编码不能为空");
  if(value.Length()>18)
    throw Exception("物料编码长度不能大于18");
  if(value!=m_SquoteGoods)
  {
/*    m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add("SELECT SgdGoodsCODE FROM SDSgd WHERE SgdGoodsCODE='" +value+"' and SgdClientCode='"+m_SquoteClient+"'");
    m_Query->Open();
    if(m_Query->RecordCount<=0)
    {
      m_Query->Close();
      throw Exception("客户无此物料,先到客户货物里定义");
    }  */
//    if(CurStatus==2||CurStatus==4)
//    {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("SELECT SquoteGoods FROM sdSquote WHERE SquoteClient='"+m_SquoteClient+"' and SquoteGoods='"+value+"' and SquoteCurrency='"+m_SquoteCurrency+"'");
        m_Query->Open();
        if(m_Query->RecordCount>0)
        {
          m_Query->Close();
          throw Exception("客户"+m_SquoteClient+"物料"+value+"币种为:"+m_SquoteCurrency+"已有报价");
        }
//    }
    m_Query->Close();
  }
  m_Query->Close();
  m_Query->SQL->Clear();
  m_Query->SQL->Add("SELECT GoodsUnitCode,GoodsCancel,GoodsSale FROM SdGoods WHERE GoodsCODE='" +value+"'");
  m_Query->Open();
  if(m_Query->RecordCount>0)
    {
     if(m_Query->FieldValues["GoodsCancel"]==1)
        {
        m_Query->Close();
         throw Exception("物料编码"+value+"已取消");
        }
     if(m_Query->FieldValues["GoodsSale"]!=1)
        {
        m_Query->Close();
         throw Exception("物料编码"+value+"不可销售");
        }
     m_SquoteUnit=m_Query->FieldValues["GoodsUnitCode"];
     m_Query->Close();
    }
  else
  throw Exception("物料编码"+value+"不存在");
   m_SquoteGoods = value;
}

void __fastcall TsdSquote::SetSquoteCurrency(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("交易币种不能为空");
    if(value.Length()>18)
    	throw Exception("不能大于18");
    if(value!=m_SquoteCurrency)
    {
      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("币种未定义");
      }
      m_SquoteCurrency=value;
    }

}


void __fastcall TsdSquote::SetSquoteUnit(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("计量单位不能为空");
  	if(value.Length()>18)
    	throw Exception("不能大于18");
    if(value!=m_SquoteUnit)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("SELECT UnitCode FROM sdUnit WHERE UnitCode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("计量单位未定义");
      }
      m_Query->Close();
    }
    m_SquoteUnit   =   value;
}


void __fastcall TsdSquote::SetSquoteSdate(AnsiString value)
{
 if(value.IsEmpty())
   throw Exception("生效日期不能为空!");
/* if(m_SquoteSysDate.IsEmpty())
   {
   if(Validate(value)<g_sdCurDate)
    throw Exception("生效日期不能小于制单日期");
   }
 else
  {
   if(Validate(value)<FormatDateTime("YYYY-MM-DD",StrToDateTime(m_SquoteSysDate)))
    throw Exception("生效日期不能小于制单日期");
  }*/
    m_SquoteSdate   =   Validate(value);
}

void __fastcall TsdSquote::SetSquoteDesc(AnsiString value)
{
    m_SquoteDesc=value;
}
void __fastcall TsdSquote::SetSquoteEdate(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("失效日期不能为空!");
    if(Validate(value)<=Validate(m_SquoteSdate))
      throw Exception("失效日期不能小于等于生效日期");
    m_SquoteEdate   =   Validate(value);
}
void __fastcall TsdSquote::SetSquoteSpt(AnsiString value)
{
	

⌨️ 快捷键说明

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