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

📄 mmhdl.cpp

📁 邮 电 公 司 erp源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//---------------------------------------------------------------------------
int TsdWo::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();
            TsdWo *p=new TsdWo();
            SetActionID(1);
            p->Assign(this);
            AddRecord((void *)p,p->WoCode);
            m_Query->Next();
        }
        MoveFirst();
    }
    m_Query->Close();
    return Count;
}

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

bool TsdWo::Find(AnsiString WhereStr)
{
    AnsiString m_SqlStr;
    if(WhereStr.IsEmpty()==true)
       throw Exception("查找表达式不能为空!");
    m_SqlStr="SELECT * FROM sdWo 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;
    }
}
//---------------------------------------------------------------------------
TsdWo::~TsdWo()
{
    try
    {
    }
    catch(...)
    {
      throw Exception("析构函数出错!");
    }
}
//---------------------------------------------------------------------------

//************************************
//    Class:TsdRouteh               //
//    Description:工艺路线的头      //
//    Created on 2000/10/12         //
//************************************
TsdRouteh::TsdRouteh(TDataComm *DC)
         :TsdHead(DC)
{
    try
    {
      QueryString="select * from sdRouteh";
      FilterString="";
      OrderString=" RoutehCode";
      m_sdRouted=NULL;
      EmptyValue(0);
      EmptyValue(1);
    }
    catch(...)
    {
      throw Exception("构造函数出错!");
    }
}
//---------------------------------------------------------------------------

TsdRouteh::TsdRouteh()
         :TsdHead()
{
    try
    {
      QueryString="select * from sdRouteh";
      FilterString="";
      OrderString=" RoutehCode";
      m_sdRouted=NULL;
      EmptyValue(0);
      EmptyValue(1);
    }
    catch(...)
    {
      throw Exception("构造函数出错!");
    }
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehCode(AnsiString value)
{
    if(value.IsEmpty())
       throw Exception("工艺路线码的代码不能为空!");
    if(value.Length()>18)
       throw Exception("工艺路线码的代码长度不能大于18!");
    if(value!=m_RoutehCode)
    {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("select RoutehCode from sdRouteh where RoutehCode='"+value+"'");
        m_Query->Open();
        if(m_Query->RecordCount>0)
        {
           m_Query->Close();
           throw Exception("已经存在工艺路线码:'"+value+"',不能重复.");
        }
        m_Query->Close();
    }
    m_RoutehCode = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehName(AnsiString value)
{
    if(value.IsEmpty())
       throw Exception("工艺路线码的名称不能为空!");
    if(value.Length()>20)
       throw Exception("工艺路线码的名称长度不能大于20!");
    m_RoutehName = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehGoods(AnsiString value)
{
    if(value.IsEmpty())
       throw Exception("工艺路线对应的货物编码不能为空!");
    if(value.Length()>18)
       throw Exception("工艺路线对应的货物编码长度不能大于18!");
    if(value!=m_RoutehGoods)
    {
       m_Query->Close();
       m_Query->SQL->Clear();
       m_Query->SQL->Add("select GoodsCode from sdGoods where (GoodsType=1 or GoodsType=2) and GoodsFrom=2 and GoodsCode='"+value+"'");
       m_Query->Open();
       if(m_Query->RecordCount==0)
       {
          m_Query->Close();
          throw Exception("货物编码:'"+value+"'不存在或不符合条件!");
       }
       m_Query->Close();
    }
    m_RoutehGoods = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehKey(int value)
{
    if(m_RoutehGoods.IsEmpty())
       throw Exception("工艺路线对应的货物编码不能为空!");
    if(value!=0 && value!=1)
       throw Exception("关键路线的标志只能为(0-非关键路线,1-关键路线.)");
    if(value==1 && m_RoutehGoods!=b_RoutehGoods)
    {
       m_Query->Close();
       m_Query->SQL->Clear();
       m_Query->SQL->Add("select RoutehGoods from sdRouteh where RoutehGoods='"+m_RoutehGoods+"' and RoutehKey='"+AnsiString(value)+"'");
       m_Query->Open();
       if(m_Query->RecordCount>0)
       {
          m_Query->Close();
          throw Exception("货物编码:'"+m_RoutehGoods+"'已经定义为关键路线!");
       }
       m_Query->Close();
    }
    m_RoutehKey=value;
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehEdate(AnsiString value)
{
    if(value.IsEmpty()==false)
       m_RoutehEdate = Validate(value);
    else
       throw Exception("工艺路线生效的日期不能为空!");
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehIdate(AnsiString value)
{
    if(value.IsEmpty()==false){
       m_RoutehIdate = Validate(value);
       if(m_RoutehIdate<=m_RoutehEdate){
          m_RoutehIdate="";
          throw Exception("失效日期不能小于等于生效日期!");
       }
    }
    else
       m_RoutehIdate = "";
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehUser(AnsiString value)
{
    if(value.IsEmpty())
       throw Exception("操作员的代码不能为空!");
    if(value.Length()>18)
       throw Exception("操作员的代码长度不能大于18!");
    if(value!=m_RoutehUser)
    {
       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_RoutehUser = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehProducter(AnsiString value)
{
    if(value.IsEmpty())
        throw Exception("生管员的代码不能为空!");
    if(value.Length()>18)
        throw Exception("生管员的代码长度不能大于18!");
    if(value!=m_RoutehProducter)
    {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("select ProducterCode from sdProducter where ProducterCode='"+value+"'");
        m_Query->Open();
        if(m_Query->RecordCount==0)
        {
           m_Query->Close();
           throw Exception("生管员的代码:'"+value+"'不存在.");
        }
        m_Query->Close();
    }
    m_RoutehProducter = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehCancel(int value)
{
    if(value!=0 && value!=1)
        throw Exception("工艺路线作废的标识只能是0-未作废,1-已作废.");
    m_RoutehCancel = value;
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehCancelDate(AnsiString value)
{
    if(m_RoutehCancel==1)
    {
       if(value.IsEmpty())
          throw Exception("工艺路线作废时,作废的日期不能为空.");
       else
           m_RoutehCancelDate = Validate(value);
    }
    else
       m_RoutehCancelDate="";
}
//---------------------------------------------------------------------------

void __fastcall TsdRouteh::SetRoutehDesc(AnsiString value)
{
    m_RoutehDesc = value;
}
//---------------------------------------------------------------------------

AnsiString TsdRouteh::GetFieldValue(euRouteh sdFieldName)
{
    switch(sdFieldName)
    {
      case fiRoutehCode:
        return  RoutehCode;
      case fiRoutehName:
        return  RoutehName;
      case fiRoutehGoods:
        return  RoutehGoods;
      case fiRoutehKey:
        return  AnsiString(RoutehKey);
      case fiRoutehEdate:
        return  RoutehEdate;
      case fiRoutehIdate:
        return  RoutehIdate;
      case fiRoutehUser:
         return RoutehUser;
      case fiRoutehProducter:
         return RoutehProducter;
      case fiRoutehCancel:
         return AnsiString(RoutehCancel);
      case fiRoutehCancelDate:
         return RoutehCancelDate;
      case fiRoutehDesc:
        return  RoutehDesc;
      case fiRoutehSysDate:
         return RoutehSysDate;
      default:
         throw Exception("该字段未定义可取值!");
    }
}
//---------------------------------------------------------------------------

void TsdRouteh::SetFieldValue(euRouteh sdFieldName, AnsiString Value)
{
    switch(sdFieldName)
    {
      case fiRoutehCode:
        RoutehCode=Value;
        break;
      case fiRoutehName:
        RoutehName=Value;
        break;
      case fiRoutehGoods:
        RoutehGoods=Value;
        break;
      case fiRoutehKey:
        RoutehKey=Value.ToInt();
        break;
      case fiRoutehEdate:
        RoutehEdate=Value;
        break;
      case fiRoutehIdate:
        RoutehIdate=Value;
        break;
      case fiRoutehUser:
        RoutehUser=Value;
        break;
      case fiRoutehProducter:
        RoutehProducter=Value;
        break;
      case fiRoutehCancel:
        RoutehCancel=Value.ToInt();
        break;
      case fiRoutehCancelDate:
        RoutehCancelDate=Value;
        break;
      case fiRoutehDesc:
        RoutehDesc=Value;
        break;
      default:
        throw Exception("该字段未定义可赋值!");
    }
}
//---------------------------------------------------------------------------
void TsdRouteh::Update()
{
  if(CurStatus==0||CurStatus==1)
     throw Exception("当前不是编辑状态,不能进行存盘操作!");
  if(m_RoutehCode.IsEmpty()==true)
     throw Exception("工艺路线编号不能为空!");
  if(ItemCount<=0)
     throw Exception("工艺路线没有定义行明细字段!");
  m_StoredProc->Close();
  switch(CurStatus)
  {
    case 2:
    case 4:
      m_StoredProc->ProcedureName="sdRouteh_Insert";
      m_StoredProc->Parameters->Clear();
      m_StoredProc->Parameters->CreateParameter("@RoutehCode",ftString,pdInputOutput,18,m_RoutehCode);
      m_StoredProc->Parameters->CreateParameter("@RoutehName",ftString,pdInput,20,m_RoutehName);
      m_StoredProc->Parameters->CreateParameter("@RoutehGoods",ftString,pdInput,18,m_RoutehGoods);
      m_StoredProc->Parameters->CreateParameter("@RoutehKey",ftInteger,pdInput,1,m_RoutehKey);
      m_StoredProc->Parameters->CreateParameter("@RoutehEdate",ftString,pdInput,10,m_RoutehEdate);
      m_StoredProc->Parameters->CreateParameter("@RoutehIdate",ftString,pdInput,10,m_RoutehIdate);
      m_StoredProc->Parameters->CreateParameter("@RoutehDesc",ftString,pdInput,40,m_RoutehDesc);

⌨️ 快捷键说明

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