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

📄 cmdoc.cpp

📁 述达erp原代码 述达erp原代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:

bool TsdCc::Find(AnsiString WhereStr)
{
  AnsiString m_SqlStr;

  if(WhereStr.IsEmpty()==true)
    throw Exception("查找表达式不能为空");
  m_SqlStr="SELECT * FROM SDCc 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;
  }
}

TsdCc::~TsdCc()
{
  try{
  }
  catch(...)
  {
    throw Exception("析构函数出错");
  }
}
//===================================================
//      (TsdRwt)定额工时
//===================================================
void __fastcall TsdRwt:: SetRwtGoods(AnsiString value)
{
    if (value.IsEmpty() )
       throw Exception("产品编码不能为空!");
    if(value.Length()>18)
      throw Exception("产品编码长度不能超过18");
    if (value!=m_RwtGoods)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("SELECT GoodsCode FROM sdGoods WHERE GoodsCode='" +value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("产品编码'"+value+"'未定义");
      }
    }
    m_RwtGoods=value;
}
void __fastcall TsdRwt:: SetRwtLoc(AnsiString value)
{
    if(value.IsEmpty()==true)
      throw Exception("货位编码不能为空");
    if(value.Length()>18)
      throw Exception("货位编码长度不能超过18");
    if (value!=m_RwtLoc)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select LocCode from sdLoc where LocCode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<1 )
      {
        m_Query->Close();
        throw Exception("货位编码'"+value+"'未定义");
      }
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("SELECT * FROM sdGoods ,sdlg where ( goodstype='1' or goodstype='2') and GOODSCODE=LGGOODSCODE and LGLOCCODE='"+value+"' and goodscode='"+ m_RwtGoods+"' order by goodscode");
      m_Query->Open();
      if(m_Query->RecordCount<1 )
      {
        m_Query->Close();
        throw Exception("物料编码 '"+ m_RwtGoods+"'不是成品、半成品或不在该货位!");
      }
      m_Query->Close();
    }
    m_RwtLoc=value;
}
void __fastcall TsdRwt:: SetRwtUnit(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("计量单位编码不能为空");
    if(value.Length()>18)
      throw Exception("计量单位编码长度不能超过18");
    if (value!=m_RwtUnit)
    {
      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<1 )
      {
        m_Query->Close();
        throw Exception("计量单位编码'"+value+"'未定义");
      }
      m_Query->Close();
    }
    m_RwtUnit=value;
}
void __fastcall TsdRwt:: SetRwtTime(double  value)
{
    if(value<0)
      throw Exception("定额工时不能小于零");
    m_RwtTime=value;
}
void __fastcall TsdRwt:: SetRwtEdate(AnsiString value)
{
  if(value.IsEmpty())
    throw Exception("生效日期不能为空");
  if(value.Length()>10)
    throw Exception("生效日期长度不能大于10");
    m_RwtEdate=Validate(value);
}
void __fastcall TsdRwt:: SetRwtIdate(AnsiString value)
{
  AnsiString TemDate;
  if(m_RwtEdate.IsEmpty())
    throw Exception("生效日期不能为空");
  if(value.IsEmpty()==false)
  {
   if(value.Length()>10)
     throw Exception("失效日期长度不能大于10");
   TemDate=Validate(value);
   if(TemDate<=m_RwtEdate)
     throw Exception("生效日期不能大于等于失效日期");
   m_RwtIdate=Validate(value);
  }
  else
   m_RwtIdate="";
}
void __fastcall TsdRwt:: SetRwtUser(AnsiString value)
{
  if(value.IsEmpty())
    throw Exception("操作员编码不能为空");
  if(value.Length()>18)
    throw Exception("操作员编码长度不能大于18");
  if(value!=m_RwtUser)
    {
      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_RwtUser=value;
}
//---------------------------------------------------------------------------
AnsiString TsdRwt::GetFieldValue(euRwt sdFieldName)
{
    switch(sdFieldName)
    {
      case fiRwtGoods:
           return RwtGoods;
      case fiRwtLoc:
           return RwtLoc;
      case fiRwtUnit:
           return RwtUnit;
      case fiRwtTime:
           return RwtTime;
      case fiRwtEdate:
           return RwtEdate;
      case fiRwtIdate:
           return RwtIdate;
      case fiRwtUser:
           return RwtUser;
      default:
           throw Exception("当前未定义可取值");
     }
}
//---------------------------------------------------------------------------
void TsdRwt::SetFieldValue(euRwt sdFieldName, AnsiString value)
{
    switch(sdFieldName)
     {
    case fiRwtGoods:
         RwtGoods=value;
          break;
    case fiRwtLoc:
         RwtLoc=value;
          break;
    case fiRwtUnit:  
         RwtUnit=value;
          break;
    case fiRwtTime:  
         RwtTime=value.ToDouble();
          break;
    case fiRwtEdate:  
         RwtEdate=value;
          break;
    case fiRwtIdate:  
         RwtIdate=value;
          break;
    case fiRwtUser:
         RwtUser=value;
          break;
    default:
         throw Exception("当前字段未定义可赋值");
      }
}
//---------------------------------------------------------------------------
TsdRwt::TsdRwt(TDataComm *DC)
                :TsdStandard(DC)
{
    try
    {
        EmptyValue(0);
        EmptyValue(1);
        QueryString="SELECT * FROM sdRwt";
        FilterString="";
        OrderString="RwtGoods,RwtLoc";
    }
    catch(Exception &e)
    {
        ShowMessage(e.Message);
    }
}
//---------------------------------------------------------------------------
TsdRwt::TsdRwt()
       :TsdStandard()
{
    try
    {
        EmptyValue(0);
        EmptyValue(1);
        QueryString="SELECT * FROM sdRwt";
        FilterString="";
        OrderString="RwtGoods,RwtLoc";
    }
    catch(Exception &e)
    {
        ShowMessage(e.Message);
    }
}
//---------------------------------------------------------------------------
TsdRwt::~TsdRwt()
{
  try{
     }
  catch(...)
    {
     throw Exception("析构函数出错");
    }
}
//---------------------------------------------------------------------------
void TsdRwt::BackupValue()
{
      b_RwtGoods=m_RwtGoods;
      b_RwtLoc=m_RwtLoc;
      b_RwtUnit=m_RwtUnit;
      b_RwtTime=m_RwtTime;
      b_RwtEdate=m_RwtEdate;
      b_RwtIdate=m_RwtIdate;
      b_RwtUser=m_RwtUser;
}
//---------------------------------------------------------------------------
void TsdRwt::RestoreValue()
{
      m_RwtGoods=b_RwtGoods;
      m_RwtLoc=b_RwtLoc;
      m_RwtUnit=b_RwtUnit;
      m_RwtTime=b_RwtTime;
      m_RwtEdate=b_RwtEdate;
      m_RwtIdate=b_RwtIdate;
      m_RwtUser=b_RwtUser;
}
//---------------------------------------------------------------------------
void TsdRwt::EmptyValue(int Index)
{
   switch(Index)
   {
    case 0:
        m_RwtGoods="";
        m_RwtLoc="";
        m_RwtUnit="";
        m_RwtTime=0;
        m_RwtEdate="";
        m_RwtIdate="";
        m_RwtUser="";
    break;
    case 1:
        b_RwtGoods="";
        b_RwtLoc="";
        b_RwtUnit="";
        b_RwtTime=0;
        b_RwtEdate="";
        b_RwtIdate="";
        b_RwtUser="";
      break;
     }
}
//---------------------------------------------------------------------------
void TsdRwt::BatchLetValue()
{
    m_RwtGoods=m_Query->FieldValues["RwtGoods"];
    m_RwtLoc=m_Query->FieldValues["RwtLoc"];
    m_RwtUnit=m_Query->FieldValues["RwtUnit"];
    m_RwtTime=m_Query->FieldValues["RwtTime"];
    m_RwtEdate=m_Query->FieldValues["RwtEdate"];
    m_RwtIdate=m_Query->FieldValues["RwtIdate"];
    m_RwtUser=m_Query->FieldValues["RwtUser"];
    BackupValue();
}
//---------------------------------------------------------------------------
void TsdRwt::Update()
{

    if(CurStatus==0||CurStatus==1)
        throw Exception("当前不是编辑状态,不能进行存盘操作!");
    if(m_RwtGoods.IsEmpty()==true)
        throw Exception("产品编码不能为空!");
    m_StoredProc->Close();
    if(CurStatus==2||CurStatus==4)
      {
        RecordDoubuleCh();
        m_StoredProc->ProcedureName="sdRwt_Insert";
        m_StoredProc->Parameters->Clear();
        m_StoredProc->Parameters->CreateParameter("@RwtGoods",ftString,pdInput,18,m_RwtGoods);
        m_StoredProc->Parameters->CreateParameter("@RwtLoc",ftString,pdInput,18,m_RwtLoc);
        m_StoredProc->Parameters->CreateParameter("@RwtUnit",ftString,pdInput,18,m_RwtUnit);
        m_StoredProc->Parameters->CreateParameter("@RwtTime",ftFloat,pdInput,12,m_RwtTime);
        m_StoredProc->Parameters->CreateParameter("@RwtEdate",ftString,pdInput,10,m_RwtEdate);
        m_StoredProc->Parameters->CreateParameter("@RwtIdate",ftString,pdInput,10,m_RwtIdate);
        m_StoredProc->Parameters->CreateParameter("@RwtUser",ftString,pdInput,18,m_RwtUser);

        m_StoredProc->ExecProc();
        m_StoredProc->Close();

   }
  else
    {
       if(m_RwtGoods!=b_RwtGoods)
        RecordDoubuleCh();
       m_StoredProc->ProcedureName="sdRwt_Update";
       m_StoredProc->Parameters->Clear();
       m_StoredProc->Parameters->CreateParameter("@W_RwtGoods",ftString,pdInput,18,b_RwtGoods);
       m_StoredProc->Parameters->CreateParameter("@W_RwtLoc",ftString,pdInput,18,b_RwtLoc);
       m_StoredProc->Parameters->CreateParameter("@RwtGoods",ftString,pdInput,18,m_RwtGoods);
       m_StoredProc->Parameters->CreateParameter("@RwtLoc",ftString,pdInput,18,m_RwtLoc);
       m_StoredProc->Parameters->CreateParameter("@RwtUnit",ftString,pdInput,18,m_RwtUnit);
       m_StoredProc->Parameters->CreateParameter("@RwtTime",ftFloat,pdInput,12,m_RwtTime);
       m_StoredProc->Parameters->CreateParameter("@RwtEdate",ftString,pdInput,10,m_RwtEdate);
       m_StoredProc->Parameters->CreateParameter("@RwtIdate",ftString,pdInput,10,m_RwtIdate);
       m_StoredProc->Parameters->CreateParameter("@RwtUser",ftString,pdInput,18,m_RwtUser);
       m_StoredProc->ExecProc();
       m_StoredProc->Close();


   }
  TsdRwt *p=new TsdRwt();
  if(CurStatus==2)
    {
     SetActionID(1);
     p->Assign(this);
     AddRecord((void *)p,p->RwtGoods+p->RwtLoc);
     }
  else
    {
     SetActionID(1);
     p->Assign(this);
     ChangeRecord((void *)p,p->RwtGoods+p->RwtLoc,this->b_RwtGoods+this->b_RwtLoc);
    }
}
//---------------------------------------------------------------------------
void TsdRwt::RecordDoubuleCh()
{
    m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add("SELECT RWTGOODS,RWTLOC FROM sdrwt WHERE RWTGOODS='"+m_RwtGoods+"' and RWTLOC='"+m_RwtLoc+"'");
    m_Query->Open();
    if(m_Query->RecordCount>0)
    {
      m_Query->Close();
      throw Exception("该记录已存在! 请重新输入");
    }
}
void TsdRwt::Delete()
{
    if(CurStatus!=1)
        throw Exception("当前状态不能进行删除操作!");
    if(m_RwtGoods.IsEmpty()==true)
        throw Exception("当前没有记录可以删除!");
    m_StoredProc->Close();
    m_StoredProc->ProcedureName="sdRwt_Delete";
    m_StoredProc->Parameters->Clear();
    m_StoredProc->Parameters->CreateParameter("@W_RwtGoods",ftString,pdInput,18,b_RwtGoods);
    m_StoredProc->Parameters->CreateParameter("@W_RwtLoc",ftString,pdInput,18,b_RwtLoc);
    m_StoredProc->ExecProc();
    m_StoredProc->Close();
    DeleteRecord(this->b_RwtGoods+this->b_RwtLoc);
}
//---------------------------------------------------------------------------
void TsdRwt::Assign(TsdRwt *p)
{
    this->SetActionID(p->CurStatus);
    this->m_RwtGoods=p->m_RwtGoods;
    this->m_RwtLoc=p->m_RwtLoc;
    this->m_RwtUnit=p->m_RwtUnit;
    this->m_RwtTime=p->m_RwtTime;
    this->m_RwtEdate=p->m_RwtEdate;
    this->m_RwtIdate=p->m_RwtIdate;
    this->m_RwtUser=p->m_RwtUser;
    this->BackupValue();
}
//---------------------------------------------------------------------------
void TsdRwt::AssignValue()
{
    TsdRwt *p=(TsdRwt *)Records(CurRecNo);
    Assign(p);
}
//---------------------------------------------------------------------------
int TsdRwt::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();
            TsdRwt *p=new TsdRwt();
            SetActionID(1);
            p->Assign(this);
            AddRecord((void *)p,p->RwtGoods+p->RwtLoc);
            m_Query->Next();
        }
        MoveFirst();

⌨️ 快捷键说明

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