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

📄 imhdl.cpp

📁 邮 电 公 司 erp源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        m_Query->First();
        while(!m_Query->Eof)
        {
            BatchLetValue();
            NewDetail();
            m_sdAlfd->FilterString=" AlfdCode='"+m_AlfhCode+"'";
            m_sdAlfd->OrderString=" AlfdLine ";
            m_sdAlfd->Query();
            TsdAlfh *p=new TsdAlfh();
            SetActionID(1);
            p->Assign(this);
            AddRecord((void *)p,p->AlfhCode);
            m_Query->Next();
        }
        MoveFirst();
    }
    m_Query->Close();
    return Count;
}
//---------------------------------------------------------------------------

bool TsdAlfh::Find(AnsiString WhereStr)
{
    AnsiString m_SqlStr;
    if(WhereStr.IsEmpty()==true)
        throw Exception("查找表达式不能为空");
    m_SqlStr="select * from sdAlfh 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_sdAlfd->FilterString=" AlfdCode='"+m_AlfhCode+"'";
        m_sdAlfd->OrderString=" AlfdLine ";
        m_sdAlfd->Query();
        m_Query->Close();
        return true;
    }
}
//---------------------------------------------------------------------------

void TsdAlfh::Check(int IsCheck)
{
    if(this->Count>0)
    {
      try
      {
        m_StoredProc->ProcedureName="sdAlfh_Check";
        m_StoredProc->Parameters->Clear();


        if(IsCheck==1)
        {
          AlfhCheck=1;
          AlfhChecker=g_sdUserCode;
          AlfhCheckDate=g_sdCurDate;
          m_StoredProc->Parameters->CreateParameter("@W_AlfhCode",ftString,pdInput,20,b_AlfhCode);
          m_StoredProc->Parameters->CreateParameter("@AlfhCheck",ftSmallint,pdInput,2,1);
          m_StoredProc->Parameters->CreateParameter("@AlfhChecker",ftString,pdInput,20,g_sdUserCode);
          m_StoredProc->Parameters->CreateParameter("@AlfhCheckDate",ftString,pdInput,10,g_sdCurDate);
          m_StoredProc->Parameters->CreateParameter("@AlfhInvFlg",ftInteger,pdOutput,2,m_AlfhInvFlg);

          m_StoredProc->ExecProc();
          m_AlfhInvFlg=m_StoredProc->Parameters->ParamValues["@AlfhInvFlg"];
          m_StoredProc->Close();
         }
         else
         {
          AlfhCheck=0;
          AlfhChecker="";
          AlfhCheckDate="";
          AnsiString temp="";
          m_StoredProc->Parameters->CreateParameter("@W_AlfhCode",ftString,pdInput,20,b_AlfhCode);
          m_StoredProc->Parameters->CreateParameter("@AlfhCheck",ftSmallint,pdInput,2,0);
          m_StoredProc->Parameters->CreateParameter("@AlfhChecker",ftString,pdInput,20,temp);
          m_StoredProc->Parameters->CreateParameter("@AlfhCheckDate",ftString,pdInput,10,temp);
          m_StoredProc->Parameters->CreateParameter("@AlfhInvFlg",ftInteger,pdOutput,2,m_AlfhInvFlg);

          m_StoredProc->ExecProc();
          m_AlfhInvFlg=m_StoredProc->Parameters->ParamValues["@AlfhInvFlg"];
          m_StoredProc->Close();
          }
         TsdAlfh *p=(TsdAlfh*)Records(CurRecNo);
         p->Assign(this);
         BackupValue();
       }
       catch(Exception &e)
       {
         m_AlfhCheck=b_AlfhCheck;
         m_AlfhChecker=b_AlfhChecker;
         m_AlfhCheckDate=b_AlfhCheckDate;
         throw Exception(e.Message);
        }
     }
     else
      throw Exception("没有单据可以审核");
}

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

AnsiString TsdAlfh::GetItemValue(euAlfd FieldName)
{
    return m_sdAlfd->GetFieldValue(FieldName);
}
//---------------------------------------------------------------------------

void TsdAlfh::SetItemValue(euAlfd FieldName, AnsiString Value)
{
    m_sdAlfd->SetFieldValue(FieldName,Value);
}
//---------------------------------------------------------------------------

int __fastcall TsdAlfh::GetItemCount()
{
  try{
    return m_sdAlfd->Count;
  }
  catch(...)
  {
    return 0;
  }
}
//---------------------------------------------------------------------------
int __fastcall TsdAlfh::GetCurItemNo()
{
    return m_sdAlfd->CurRecNo;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TsdAlfh::GetItemBookMark()
{
    return m_sdAlfd->BookMark;
}
//---------------------------------------------------------------------------
char __fastcall TsdAlfh::GetCurItemStatus()
{
    return m_sdAlfd->CurStatus;
}
//---------------------------------------------------------------------------

//**************************************
//     (TsdAlfd)调拨单单行维护
//**************************************

void __fastcall TsdAlfd::SetAlfdCode(AnsiString value)
{
    if(value.IsEmpty())
       throw Exception("调拔单号不能为空!");
    if(value.Length()>18)
      throw Exception("调拔单号长度不能大于18");
    m_AlfdCode=value;
}

void __fastcall TsdAlfd::SetAlfdOLoc(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("转出货位不能为空");
    if(value.Length()>18)
      throw Exception("转出货位编码长度不能大于18");
    if(value==m_AlfdILoc)
      throw Exception("转出货位不能与转入货位相同");
    if(value!=m_AlfdOLoc)
    {
      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<=0)
      {
        m_Query->Close();
        throw Exception("货位编码:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_AlfdOLoc=value;
}

void __fastcall TsdAlfd::SetAlfdILoc(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("转入货位不能为空");
    if(value.Length()>18)
      throw Exception("转入货位编码长度不能大于18");
    if(value==m_AlfdOLoc)
      throw Exception("转入货位不能与转出货位相同");
    if(value!=m_AlfdILoc)
    {
      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<=0)
      {
        m_Query->Close();
        throw Exception("货位编码:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_AlfdILoc=value;
}

void __fastcall TsdAlfd::SetAlfdGoods(AnsiString value)
{
    if(m_AlfdOLoc.IsEmpty())
      throw Exception("转出货位不能为空");
    if(m_AlfdILoc.IsEmpty())
      throw Exception("转入货位不能为空");
    if(value.IsEmpty())
      throw Exception("物料编码不能为空");
    if(value.Length()>18)
      throw Exception("物料编码长度不能大于18");
    if(value!=m_AlfdGoods)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add(" select goodscode,goodsunitcode from sdgoods,sdlg where lgstate=1  and goodscode=lggoodscode and ");
      m_Query->SQL->Add(" goodscode='"+value+"' and lgloccode='"+m_AlfdOLoc+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("物料编码:"+value+"无效,或转出货位:"+m_AlfdOLoc+"未定义该物料");
      }
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add(" select goodscode,goodsunitcode from sdgoods,sdlg where lgstate=1  and goodscode=lggoodscode and ");
      m_Query->SQL->Add(" goodscode='"+value+"' and lgloccode='"+m_AlfdILoc+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("物料编码:"+value+"无效,或转入货位:"+m_AlfdILoc+"未定义该物料");
      }
      m_AlfdUnit=m_Query->FieldValues["goodsunitcode"];
      m_AlfdConv=1;
      m_Query->Close();
    }
    m_AlfdGoods=value;
}


void __fastcall TsdAlfd::SetAlfdLine(int value)
{
    if(value<=0)
      throw Exception("调拨单行号不能小于等于零");
    if(value !=m_AlfdLine)
      if(this->FindKey(AnsiString(value)))
        throw Exception("行号已存在,行号不能重复");
    m_AlfdLine=value;
}

void __fastcall TsdAlfd::SetAlfdUnit(AnsiString value)
{
    if(m_AlfdGoods.IsEmpty())
      throw Exception("物料编码不能为空");
    if(value.IsEmpty())
      throw Exception("计量单位不能为空");
    if(value.Length()>18)
      throw Exception("计量单位长度不能大于18");
    m_Query->Close();
    m_Query->SQL->Clear();
    if(value!=m_AlfdUnit)
    {
      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_AlfdUnit=value;
}

void __fastcall TsdAlfd::SetAlfdConv(double value)
{
    m_AlfdConv=1;
}


void __fastcall TsdAlfd::SetAlfdQty(double value)
{
    if(m_AlfdOLoc.IsEmpty())
      throw Exception("转出货位不能为空");
    if(m_AlfdILoc.IsEmpty())
      throw Exception("转入货位不能为空");
    if(m_AlfdGoods.IsEmpty())
      throw Exception("调拔物料不能为空");
    double FQty;
    if(value<=0)
      throw Exception("调拨数量必须大于零");
    m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add("select MaccAoyQty from sdMacc where MaccFmonth='"+sdParent->g_sdIMonth+"' and MaccGoods='"+m_AlfdGoods+"' and MaccInitFlg=1 and MaccLoc='"+m_AlfdOLoc+"'");
    m_Query->Open();
    if(m_Query->RecordCount>0)
    {
      FQty=m_Query->FieldValues["MaccAoyQty"];
      m_Query->Close();
      if(value>FQty)
        throw Exception("转出货位物料数量不够");
    }
    else
    {
      m_Query->Close();
      throw Exception("转出货位物料没建帐或帐未初始化");
    }
    m_Query->SQL->Clear();
    m_Query->SQL->Add("select MaccAoyQty from sdMacc where MaccFmonth='"+sdParent->g_sdIMonth+"' and MaccGoods='"+m_AlfdGoods+"' and MaccInitFlg=1 and MaccLoc='"+m_AlfdILoc+"'");
    m_Query->Open();
    if(m_Query->RecordCount<=0)
    {
      m_Query->Close();
      throw Exception("转入货位物料没建帐或帐未初始化");
    }
    m_AlfdQty=value;
}


void __fastcall TsdAlfd::SetAlfdSBatch(AnsiString value)
{
    int IsBatch;
    if(m_AlfdGoods.IsEmpty())
      throw Exception("调拔物料不能为空");
    if(value.Length()>18)
      throw Exception("批号编码长度不能大于18");
        m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add("select GoodsBatch from sdgoods where goodscode='"+m_AlfdGoods+"'");
    m_Query->Open();
    if(m_Query->RecordCount<=0)
    {
      m_Query->Close();
      throw Exception("调拔物料不存在");
    }
    else
    {
      IsBatch=m_Query->FieldValues["GoodsBatch"];
      m_Query->Close();
    }
    if(IsBatch==0)
    {
      if(!value.IsEmpty())
        throw Exception("物料:"+m_AlfdGoods+" 不需批次管理");
    }
    if(value.IsEmpty()==false && value!=m_AlfdSBatch)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select Batchcode from sdBatch where Batchcode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("批号编码:"+value+"未定义");
      }
      m_Query->Close();
    }
    m_AlfdSBatch=value;
}


void __fastcall TsdAlfd::SetAlfdSSo(AnsiString value)
{
    int TrackSo;
    if(m_AlfdGoods.IsEmpty())
      throw Exception("调拔物料不能为空");
    if(value.Length()>18)
      throw Exception("订单号长度不能大于18");
    m_Query->Close();
    m_Query->SQL->Clear();
    m_Query->SQL->Add("select GoodsTrackSo from sdgoods where goodscode='"+m_AlfdGoods+"'");
    m_Query->Open();
    if(m_Query->RecordCount<=0)
    {
      m_Query->Close();
      throw Exception("调拔物料不存在");
    }
    else
    {
      TrackSo=m_Query->FieldValues["GoodsTrackSo"];
      m_Query->Close();
    }
    if(TrackSo==0)
    {
      if(!value.IsEmpty())
        throw Exception("物料:"+m_AlfdGoods+" 不需跟踪订单管理");
    }
    if(value.IsEmpty()==false && value!=m_AlfdSSo)
    {
      m_Query->Close();
      m_Query->SQL->Clear();
      m_Query->SQL->Add("select Sohcode from sdSoh where Sohcode='"+value+"'");
      m_Query->Open();
      if(m_Query->RecordCount<=0)
      {
        m_Query->Close();
        throw Exception("订单:"+value+"不存在");
      }
      m_Query->Close();
    }
    m_AlfdSSo=value;
}


void __fastcall TsdAlfd::SetAlfdSSodLine(int value)
{
    if(m_AlfdSSo.IsEmpty()==false)
    {
      if(value<=0)
        throw Exception("订单行号不存在");
      if(value!=m_AlfdSSodLine)
      {
        m_Query->Close();
        m_Query->SQL->Clear();
        m_Query->SQL->Add("select Sodcode from sdSod where Sodcode='"+m_AlfdSSo+"' and sodline="+AnsiString(value));
        m_Query->Open();
        if(m_Query->RecordCount<=0)
        {
          m_Query->Close();
          throw Exception("订单行号:"+AnsiString(value)+"不存在");
        }
        m_Query->Close();
      }

⌨️ 快捷键说明

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