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

📄 smhdl.cpp

📁 邮 电 公 司 erp源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
      m_StoredProc->Parameters->CreateParameter("@W_SohCode",ftString,pdInput,18,b_SohCode);
      m_StoredProc->Parameters->CreateParameter("@SohCancel",ftInteger,pdInput,1,m_SohCancel);
      m_StoredProc->Parameters->CreateParameter("@SohCancelDate",ftString,pdInput,10,m_SohCancelDate);
      m_StoredProc->ExecProc();
    }
    TsdSoh *p=(TsdSoh*)Records(CurRecNo);
    p->Assign(this);
  }
  catch(Exception &e)
   {
      m_SohCancel=b_SohCancel;
      m_SohCancelDate=b_SohCancelDate;
     throw Exception(e.Message);
    }
  }
}

void TsdSoh::Close(int IsClose)
{
  if(this->Count>0)
  {
    try{
    AnsiString m_SohCloseDate="" ;
    m_StoredProc->Close();
    m_StoredProc->ProcedureName="sdSoh_Close";
    m_StoredProc->Parameters->Clear();
    if(IsClose==0)
    {
      SohClose=0;
      m_StoredProc->Parameters->CreateParameter("@W_SohCode",ftString,pdInput,18,b_SohCode);
      m_StoredProc->Parameters->CreateParameter("@W_SodLine",ftInteger,pdInput,10,0);
      m_StoredProc->Parameters->CreateParameter("@SohClose",ftInteger,pdInput,1,m_SohClose);
      m_StoredProc->Parameters->CreateParameter("@SohCloseDate",ftString,pdInput,10,m_SohCloseDate);
      m_StoredProc->ExecProc();
      for(int i=0;i<ItemCount;i++)
      {
        LocateItemByIndex(i);
        SetItemValue(fiSodClose,"0");
        SetItemValue(fiSodCloseDate,"");
        AddToObject();
      }
    }
    else if(IsClose==1)
    {
      SohClose=1;
      m_SohCloseDate=g_sdCurDate;
      m_StoredProc->Parameters->CreateParameter("@W_SohCode",ftString,pdInput,18,b_SohCode);
      m_StoredProc->Parameters->CreateParameter("@W_SodLine",ftInteger,pdInput,10,0);
      m_StoredProc->Parameters->CreateParameter("@SohClose",ftInteger,pdInput,1,m_SohClose);
      m_StoredProc->Parameters->CreateParameter("@SohCloseDate",ftString,pdInput,10,m_SohCloseDate);
      m_StoredProc->ExecProc();
      for(int i=0;i<ItemCount;i++)
      {
        LocateItemByIndex(i);
        SetItemValue(fiSodClose,"1");
        SetItemValue(fiSodCloseDate,g_sdCurDate);
        AddToObject();
      }
    }
    else
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("Select SalerCode,SalerCheck,SalerClose from sdSaler where SalerCode='"+g_sdUserCode+"'");
      m_Query->Open();
      if(m_Query->RecordCount<1)
      {
       m_Query->Close();
         throw Exception("您没在销售员表中定义!");
       }
       else
       {
       if(m_Query->FieldValues["SalerClose"]==0)
         {
          m_Query->Close();
          throw Exception("您没有结清/反结清权限");
         }
       }
    if(IsClose==2)
    {
     m_StoredProc->Parameters->CreateParameter("@W_SohCode",ftString,pdInput,18,b_SohCode);
     m_StoredProc->Parameters->CreateParameter("@W_SodLine",ftInteger,pdInput,10,StrToInt(this->GetItemValue(fiSodLine)));
     m_StoredProc->Parameters->CreateParameter("@SohClose",ftInteger,pdInput,1,2);
     m_StoredProc->Parameters->CreateParameter("@SohCloseDate",ftString,pdInput,10,m_SohCloseDate);
     m_StoredProc->ExecProc();
     SetItemValue(fiSodClose,"0");
     SetItemValue(fiSodCloseDate,"");
     AddToObject();
    }
    else if(IsClose==3)
    {
     m_StoredProc->Parameters->CreateParameter("@W_SohCode",ftString,pdInput,18,b_SohCode);
     m_StoredProc->Parameters->CreateParameter("@W_SodLine",ftInteger,pdInput,10,StrToInt(this->GetItemValue(fiSodLine)));
     m_StoredProc->Parameters->CreateParameter("@SohClose",ftInteger,pdInput,1,3);
     m_StoredProc->Parameters->CreateParameter("@SohCloseDate",ftString,pdInput,10,g_sdCurDate);
     m_StoredProc->ExecProc();
     SetItemValue(fiSodClose,"1");
     SetItemValue(fiSodCloseDate,g_sdCurDate);
     AddToObject();
     }
    }
    TsdSoh *p=(TsdSoh*)Records(CurRecNo);
    p->Assign(this);
    BackupValue();
  }
  catch(Exception &e)
  {
      m_SohClose=b_SohClose;
    throw Exception(e.Message);
   }
 }
 else
    throw Exception("没有单据可以结清");
}



//--------------------------------------------------------------------------

void TsdSoh::BackupValue()
{
     b_sdSod                 =m_sdSod;
     b_SohCode               =m_SohCode;
     b_SohType               =m_SohType;
     b_SohDate               =m_SohDate;
     b_SohClient             =m_SohClient;
     b_SohSaler              =m_SohSaler;
     b_SohContract           =m_SohContract;
     b_SohCurrency           =m_SohCurrency;
     b_SohEnrate             =m_SohEnrate;
     b_SohTaxCode            =m_SohTaxCode;
     b_SohSettleMode         =m_SohSettleMode;
     b_SohDeliver            =m_SohDeliver;
     b_SohSsite              =m_SohSsite;
     b_SohTransMode          =m_SohTransMode;
     b_SohDj                 =m_SohDj;
     b_SohCrCode             =m_SohCrCode;
     b_SohCancel             =m_SohCancel;
     b_SohCancelDate         =m_SohCancelDate;
     b_SohCheck              =m_SohCheck;
     b_SohChecker            =m_SohChecker;
     b_SohCheckDate          =m_SohCheckDate;
     b_SohDesc               =m_SohDesc;
     b_SohUser               =m_SohUser;
     b_SohSysDate            =m_SohSysDate;
     b_SohClose              =m_SohClose;
}
//---------------------------------------------------------------------------
void TsdSoh::RestoreItem()
{
    m_sdSod->RestoreValue();
}

void TsdSoh::RestoreValue()
{
     m_SohCode               =b_SohCode;
     m_SohType               =b_SohType;
     m_SohDate               =b_SohDate;
     m_SohClient             =b_SohClient;
     m_SohSaler              =b_SohSaler;
     m_SohContract           =b_SohContract;
     m_SohCurrency           =b_SohCurrency;
     m_SohEnrate             =b_SohEnrate;
     m_SohTaxCode            =b_SohTaxCode;
     m_SohSettleMode         =b_SohSettleMode;
     m_SohDeliver            =b_SohDeliver;
     m_SohSsite              =b_SohSsite;
     m_SohTransMode          =b_SohTransMode;
     m_SohDj                 =b_SohDj;
     m_SohCrCode             =b_SohCrCode;
     m_SohCancel             =b_SohCancel;
     m_SohCancelDate         =b_SohCancelDate;
     m_SohCheck              =b_SohCheck;
     m_SohChecker            =b_SohChecker;
     m_SohCheckDate          =b_SohCheckDate;
     m_SohDesc               =b_SohDesc;
     m_SohUser               =b_SohUser;
     m_SohSysDate            =b_SohSysDate;
}
//---------------------------------------------------------------------------

TsdSoh::~TsdSoh()
{
  try{
    for(int i=0;i<this->Count;i++)
     {
        this->LocateByIndex(i);
        this->AssignValue();
        delete m_sdSod;
      }
  }
  catch(...)
  {
    throw Exception("析构函数出错");
  }
}

////////////////////////////////////////////////////
//*********销售订单单行明细维护(TSdSod)*************
////////////////////////////////////////////////////

void __fastcall TsdSod::SetSodCode(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("订单号不能为空");
    if(value.Length()>18)
      throw Exception("订单号长度不能大于18");
    m_SodCode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSod::SetSodLine(int value)
{

    if(value<=0)
      throw Exception("行号不能小于零!");
    if(value!=m_SodLine)
    {
      if(FindKey(AnsiString(value)))
       throw Exception("行号已存在!");
    }
    m_SodLine = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSod::SetSodGoods(AnsiString value)
{
    if(value.IsEmpty())
       throw Exception("销售订单的货物编码不能为空!");
    if(value.Length()>18)
      throw Exception("物料编码长度不能大于18");
    if(value != m_SodGoods)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select GoodsCode,GoodsUnitCode,GoodsMunit,GoodsSale,GoodsCancel from sdGoods where GoodsCode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("该物料编码:'"+value+"'不存在!");
      }
      else
      {
        if(m_Query->FieldValues["GoodsCancel"]==1)
        {
          m_Query->Close();
          throw Exception("该货品'"+value+"'已取消");
        }
        if(m_Query->FieldValues["GoodsSale"]==0)
        {
          m_Query->Close();
          throw Exception("该货品'"+value+"'不可销售");
        }
        m_Query->Close();
      }
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select sgdcode from sdsgd where sgdclientcode='"+sdParent->GetFieldValue(fiSohClient)+"' and sgdgoodscode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<1)
      {
        m_Query->Close();
        throw Exception("客户物料未定义");
      }
      m_Query->Close();
    }
    m_SodGoods = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdSod::SetSodUnit(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("计量单位不能为空");
    if(value.Length()>18)
      throw Exception("计量单位长度不能大于18");
    if(m_SodGoods.IsEmpty())
      throw Exception("销售物料不能为空");
    if(value!=m_SodUnit)
    {
      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("计量单位:"+value+"不存在");
      }
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select goodsunitcode,goodsmunit from sdgoods where goodscode='"+m_SodGoods+"'");
      m_Query->Open();
      if(m_Query->RecordCount<1)
      {
        m_Query->Close();
        throw Exception("当前物料未在物料主文件中定义");
      }
      if(m_Query->FieldValues["GoodsMunit"]==0)
      {
        m_SodUnit=m_Query->FieldValues["GoodsUnitCode"];
        m_SodConv=1;
      }
      m_Query->Close();
    }
    m_SodUnit = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSod::SetSodConv(double value)
{
    if(value<=0)
      throw Exception("换算系数不能小于零");
    if(m_SodGoods.IsEmpty())
      throw Exception("销售物料不能为空");
    if(m_SodConv!=value)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select goodsunitcode,goodsmunit from sdgoods where goodscode='"+m_SodGoods+"'");
      m_Query->Open();
      if(m_Query->RecordCount<1)
      {
        m_Query->Close();
        throw Exception("当前物料未在物料主文件中定义");
      }
      if(m_Query->FieldValues["GoodsMunit"]==0)
      {
        m_SodUnit=m_Query->FieldValues["GoodsUnitCode"];
        m_SodConv=1;
      }
      else
        m_SodConv=value;
    }
}
//---------------------------------------------------------------------------
void __fastcall TsdSod::SetSodQty(double value)
{
    if(value<=0)
       throw Exception("销售订单行的数量不能小于等于零.");
    if(m_SodGoods.IsEmpty())
      throw Exception("销售物料不能为空");
    if(m_SodUnit.IsEmpty())
      throw Exception("计量单位不能为空");
    m_SodQty=value;

}
//---------------------------------------------------------------------------
void __fastcall TsdSod::SetSodSptCode(AnsiString value)
{

    if(value.IsEmpty())
      throw Exception("价格类型不能为空");
    if(value.Length()>18)
      throw Exception("价格类型长度不能大于18");
    if(value.IsEmpty()==false && value!=m_SodSptCode)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select sptcode from sdspt where sptcode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("价格类型代码:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_SodSptCode = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSod::SetSodPrice(double value)
{
    if(value<0)
       throw Exception("销售订单行的单价不能小于零.");
    if(m_SodGoods.IsEmpty())
      throw Exception("销售物料不能为空");
    m_SodPrice = value;
}
//---------------------------------------------------------------------------
void __fastcall TsdSod::SetSodDisc(double value)
{
    if(value<0||value>1)
      throw Exception("折扣率应该在[0,1]之间");
    m_SodDisc = value;
}

void __fastcall TsdSod::SetSodDAmt(double value)
{
    if(value<0)
      throw Exception("折扣额不能小于零");
    m_SodDAmt=value;
}


void __fastcall TsdSod::SetSodAmt(double value)
{

⌨️ 快捷键说明

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