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

📄 malfh.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
   AnsiString  m_AlfhCancelDate;
   AnsiString  b_AlfhCancelDate;
   m_AlfhCancelDate=GetMasterValue("AlfhCancelDate");

   m_AlfhCancel=GetMasterValue("AlfhCancel");
    if(m_AlfhCancel==1)
    {
      if(m_AlfhCancelDate.IsEmpty())
        throw Exception("取消日期不能为空");
    }

}
//---------------------------------------------------------------------------
void __fastcall TKSAlfh::ValidItemValues()
{

   AnsiString  m_AlfdCode;
   m_AlfdCode=GetDetailValue("AlfdCode");
    if(m_AlfdCode.IsEmpty())
       throw Exception("调拔单号不能为空!");
    if(m_AlfdCode.Length()>18)
      throw Exception("调拔单号长度不能大于18");

   int m_AlfdLine;
   int b_AlfdLine;
   m_AlfdLine=GetDetailValue("AlfdLine");
   b_AlfdLine=GetDetailOldValue("AlfdLine");
    if(m_AlfdLine<=0)
      throw Exception("调拨单行号不能小于等于零");
   /* if(m_AlfdLine !=b_AlfdLine)
     if(FindKey(AnsiString(m_AlfdLine)))         //???????????????????????????
        throw Exception("行号已存在,行号不能重复");    */

   AnsiString  m_AlfdOLoc;
   AnsiString  b_AlfdOLoc;
   m_AlfdOLoc=GetDetailValue("AlfdOLoc");
   b_AlfdOLoc=GetDetailOldValue("AlfdOLoc");
   AnsiString  m_AlfdILoc;
   m_AlfdILoc=GetDetailValue("AlfdILoc");
    if(m_AlfdOLoc.IsEmpty())
      throw Exception("转出货位不能为空");
    if(m_AlfdOLoc.Length()>18)
      throw Exception("转出货位编码长度不能大于18");
    if(m_AlfdOLoc==m_AlfdILoc)
      throw Exception("转出货位不能与转入货位相同");
    if(m_AlfdOLoc!=b_AlfdOLoc)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select loccode from sdloc where loccode='"+m_AlfdOLoc+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("货位编码:"+m_AlfdOLoc+"未定义");
      }
      Query->Close();
    }


   AnsiString  b_AlfdILoc;
   m_AlfdILoc=GetDetailValue("AlfdILoc");
   b_AlfdILoc=GetDetailOldValue("AlfdILoc");

   m_AlfdOLoc=GetDetailValue("AlfdOLoc");
    if(m_AlfdILoc.IsEmpty())
      throw Exception("转入货位不能为空");
    if(m_AlfdILoc.Length()>18)
      throw Exception("转入货位编码长度不能大于18");
    if(m_AlfdILoc==m_AlfdOLoc)
      throw Exception("转入货位不能与转出货位相同");
    if(m_AlfdILoc!=b_AlfdILoc)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select loccode from sdloc where loccode='"+m_AlfdILoc+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("货位编码:"+m_AlfdILoc+"未定义");
      }
      Query->Close();
    }

   AnsiString  m_AlfdGoods;
   AnsiString  b_AlfdGoods;
   AnsiString  m_AlfdUnit;
   AnsiString  m_AlfdConv;
   m_AlfdGoods=GetDetailValue("AlfdGoods");
   b_AlfdGoods=GetDetailOldValue("AlfdGoods");

   m_AlfdOLoc=GetDetailValue("AlfdOLoc");

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


   AnsiString  b_AlfdUnit;
   m_AlfdUnit=GetDetailValue("AlfdUnit");
   b_AlfdUnit=GetDetailOldValue("AlfdUnit");

   m_AlfdGoods=GetDetailValue("AlfdGoods");
    if(m_AlfdGoods.IsEmpty())
      throw Exception("物料编码不能为空");
    if(m_AlfdUnit.IsEmpty())
      throw Exception("计量单位不能为空");
    if(m_AlfdUnit.Length()>18)
      throw Exception("计量单位长度不能大于18");
    Query->Close();
    Query->SQL->Clear();
    if(m_AlfdUnit!=b_AlfdUnit)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("Select Unitcode from sdUnit where Unitcode='"+m_AlfdUnit+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("计量单位:"+m_AlfdUnit+"不存在");
      }
      Query->Close();
    }

  double m_AlfdQty;
   m_AlfdQty=GetDetailValue("AlfdQty");
    if(m_AlfdQty<=0)
      throw Exception("调拨数量必须大于零");

   AnsiString  m_AlfdSBatch;
   AnsiString  b_AlfdSBatch;


   m_AlfdSBatch=GetDetailValue("AlfdSBatch");
   b_AlfdSBatch=GetDetailOldValue("AlfdSBatch");
   m_AlfdOLoc=GetDetailValue("AlfdOLoc");
  
   m_AlfdGoods=GetDetailValue("AlfdGoods");
   m_AlfdQty=GetDetailValue("AlfdQty");
   int IsBatch;
    if(m_AlfdGoods.IsEmpty())
      throw Exception("调拔物料不能为空");
    if(m_AlfdSBatch.Length()>18)
      throw Exception("批号编码长度不能大于18");
        Query->Close();
    Query->SQL->Clear();
    Query->SQL->Add("select GoodsBatch from sdgoods where goodscode='"+m_AlfdGoods+"'");
    Query->Open();
    if(Query->RecordCount<=0)
    {
      Query->Close();
      throw Exception("调拔物料不存在");
    }
    else
    {
      IsBatch=Query->FieldValues["GoodsBatch"];
      Query->Close();
    }
    if(IsBatch==0)
    {
      if(!m_AlfdSBatch.IsEmpty())
        throw Exception("物料:"+m_AlfdGoods+" 不需批次管理");
    }
    if(IsBatch==1&&m_AlfdSBatch.IsEmpty())
    {
        throw Exception("物料:"+m_AlfdGoods+" 需批次管理,必须填上调出批号");
    }
    if(m_AlfdSBatch.IsEmpty()==false && m_AlfdSBatch!=b_AlfdSBatch)
    {
      AnsiString BatchSSql;
      AnsiString CurFmonth;
    //  CurFmonth=GetCurMonth();
    //  AnsiString CurFmonth;

      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select CSCMMONTH from sdcscm where CSCMClASSID='Inventory'");
      Query->Open();
      CurFmonth=Query->FieldValues["CSCMMONTH"];
      Query->Close();
      Query->SQL->Clear();
    // m_Query->SQL->Add("select Batchcode from sdBatch where Batchcode='"+value+"'");


      BatchSSql="select BthtAoyQty from sdBtht where BthtBatch='"+m_AlfdSBatch+"' and BthtFmonth='"+CurFmonth+"' and BthtLoc='"+m_AlfdOLoc+"' and BthtGoods='"+Trim(m_AlfdGoods)+"'";
      Query->SQL->Add(BatchSSql);
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("批号编码:"+m_AlfdSBatch+"未定义");
      }
      double FQty;
      FQty=Query->FieldValues["BthtAoyQty"];


      if (FQty<m_AlfdQty)
      {
        Query->Close();
        throw Exception("转出货位物料的批次数量不够");
      }  
      Query->Close();

    }

   AnsiString  m_AlfdDesc;
   m_AlfdDesc=GetDetailValue("AlfdDesc");
    if(m_AlfdDesc.Length()>40)
      throw Exception("备注长度不能大于40");
}
//---------------------------------------------------------------------------
void __fastcall TKSAlfh::CmdExec(AnsiString Param)
{
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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