msexch.cpp

来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 634 行 · 第 1/2 页

CPP
634
字号
      break;
    case 2:
      ValidSexcdCode();
      break;
    case 3:
      ValidSexcdSretCode();
      break;
    case 4:
      ValidSexcdSretdLine();
      break;
    case 5:
      ValidSexcdGoods();
      break;
    case 6:
      ValidSexcdUnit();
      break;
    case 7:
      ValidSexcdConv();
      break;
    case 8:
      ValidSexcdQty();
      break;
    case 9:
      ValidSexcdPrice();
      break;
    case 10:
      ValidSexcdAmt();
      break;
    case 11:
      ValidSexcdDesc();
      break;
    case 12:
      ValidSexcdExes();
      break;
    case 13:
      ValidSexcdState();
      break;
    case 14:
      ValidSexcdBatch();
      break;
    case 15:
      ValidSexcdLoc();
      break;
  }
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdLine()
{
   int m_SexcdLine;
   m_SexcdLine=ReturnNeedValue(GetDetailValue("SexcdLine"),0);
    if(m_SexcdLine<=0)
      throw Exception("行号不能小于零!");
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdCode()
{
   AnsiString  m_SexcdCode;
   m_SexcdCode=ReturnNeedValue(GetDetailValue("SexcdCode"),"");
  if(m_SexcdCode.IsEmpty())
    throw Exception("换货单号不能为空");
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdSretCode()
{                        /*
   AnsiString  m_SexcdSretCode;
   AnsiString  b_SexcdSretCode;
   m_SexcdSretCode=ReturnNeedValue(GetDetailValue("SexcdSretCode"),"");
   b_SexcdSretCode=ReturnNeedValue(GetDetailOldValue("SexcdSretCode"),"");
    if(m_SexcdSretCode.IsEmpty())
      throw Exception("退货单号不能为空");
    if(m_SexcdSretCode!=b_SexcdSretCode)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select * from sdSreth where SrethCode='"+m_SexcdSretCode+"'");
      Query->Open();
      if(Query->RecordCount<1)
      {
        Query->Close();
        throw Exception("该退货单"+m_SexcdSretCode+"找不到");
      }
      Query->Close();
    }                      */
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdSretdLine()
{
   int m_SexcdSretdLine;
   int b_SexcdSretdLine;
   AnsiString m_SexcdSretCode=ReturnNeedValue(GetDetailValue("SexcdSretCode"),"");
   m_SexcdSretdLine=ReturnNeedValue(GetDetailValue("SexcdSretdLine"),0);
   b_SexcdSretdLine=ReturnNeedValue(GetDetailOldValue("SexcdSretdLine"),0);
    if(m_SexcdSretdLine<0)
      throw Exception("退货单行号需大于零");
    if(m_SexcdSretCode.IsEmpty())
      throw Exception("退货单号不能为空");
    if(m_SexcdSretdLine!=b_SexcdSretdLine)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select SretdGoods,SretdUnit,SretdConv,SretdPrice,SretdLoc from sdSretd where SretdLine="+IntToStr(m_SexcdSretdLine)+" and SretdCode='"+m_SexcdSretCode+"'");
      Query->Open();
      if(Query->RecordCount>0)
      {
       // m_SexcdGoods=Query->FieldValues["SretdGoods"];
       // m_SexcdUnit=Query->FieldValues["SretdUnit"];
       // m_SexcdConv=Query->FieldValues["SretdConv"];
       // m_SexcdPrice=Query->FieldValues["SretdPrice"];
       // m_SexcdLoc=Query->FieldValues["SretdLoc"];
      }
      else
        throw Exception("退货单"+m_SexcdSretCode+"单行号"+IntToStr(m_SexcdSretdLine)+"不存在!");
    }
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdGoods()
{                            /*
   AnsiString  m_SexcdGoods;
   AnsiString  b_SexcdGoods;
   m_SexcdGoods=ReturnNeedValue(GetDetailValue("SexcdGoods"),"");
   b_SexcdGoods=ReturnNeedValue(GetDetailOldValue("SexcdGoods"),"");
    if(m_SexcdGoods.IsEmpty())
       throw Exception("换货单的货物编码不能为空!!!");
    if(m_SexcdGoods!=b_SexcdGoods)
    {
        Query->Close();
        Query->SQL->Clear();
        Query->SQL->Add("select GoodsName,GoodsUnitCode from sdGoods where GoodsCode='"+m_SexcdGoods+"'");
        Query->Open();
        if(Query->RecordCount<1)
        {
           Query->Close();
           throw Exception("货物编码:'"+m_SexcdGoods+"' 不存在!!!");
        }
    }                          //*///
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdUnit()
{                             /*///
   AnsiString  m_SexcdUnit;
   AnsiString  b_SexcdUnit;
   AnsiString m_SexcdGoods=ReturnNeedValue(GetDetailValue("SexcdGoods"),"");
   m_SexcdUnit=ReturnNeedValue(GetDetailValue("SexcdUnit"),"");
   b_SexcdUnit=ReturnNeedValue(GetDetailOldValue("SexcdUnit"),"");
    if(m_SexcdUnit.IsEmpty())
      throw Exception("计量单位不能为空!");
    if(m_SexcdGoods.IsEmpty())
      throw Exception("换货物料不能为空");
    if(m_SexcdUnit!=b_SexcdUnit)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select gmuunit,gmuconv from sdgmu where gmuunit='"+m_SexcdUnit+"' and gmugoods='"+m_SexcdGoods+"'");
      Query->Open();
      if(Query->RecordCount<1)
      {
        Query->Close();
        throw Exception("物料:"+m_SexcdGoods+" 未定义计量单位:"+m_SexcdUnit);
      }
//      SetDetailValue("SexcdConv",Query->FieldValues["gmuconv"]);
      Query->Close();
    }                         //*/
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdConv()
{
  double m_SexcdConv;
   m_SexcdConv=ReturnNeedValue(GetDetailValue("SexcdConv"),-1);
   if(m_SexcdConv<0)
      throw Exception("换算系数非法!");
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdQty()
{
  double m_SexcdQty;
   m_SexcdQty=ReturnNeedValue(GetDetailValue("SexcdQty"),0);
   AnsiString m_SexcdGoods=ReturnNeedValue(GetDetailValue("SexcdGoods"),"");
   AnsiString m_SexcdSretCode=ReturnNeedValue(GetDetailValue("SexcdSretCode"),"");
   int m_SexcdSretdLine=ReturnNeedValue(GetDetailValue("SexcdSretdLine"),0);
    if(m_SexcdQty<=0)
      throw Exception("换货数量需大于零!");
    if(m_SexcdGoods.IsEmpty())
      throw Exception(" 换货物料不能为空!");
    if(m_SexcdSretCode.IsEmpty())
      throw Exception("退货单号不能为空!");
    if(m_SexcdSretdLine<1)
      throw Exception("退货单行号不存在");
    {
        Query->Close();
        Query->SQL->Clear();
        Query->SQL->Add("select SretdQty,SretdEQty from sdSretd where SretdCode='"+m_SexcdSretCode+"' and SretdLine="+IntToStr(m_SexcdSretdLine));
        Query->Open();
        if(Query->RecordCount>0)
        {
          if(Query->FieldValues["SretdQty"]-Query->FieldValues["SretdEQty"]<m_SexcdQty)
          {
            Query->Close();
            throw Exception(" 换货数量不能大于退货数量!");
          }
        }
        else
        {
           Query->Close();
           throw Exception("该退货明细找不到");
        }
        Query->Close();
    }
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdPrice()
{
  double m_SexcdPrice;
   m_SexcdPrice=ReturnNeedValue(GetDetailValue("SexcdPrice"),-1);
   if(m_SexcdPrice<0)
     throw Exception("价格非法!");
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdAmt()
{
  double m_SexcdAmt;
   m_SexcdAmt=ReturnNeedValue(GetDetailValue("SexcdAmt"),-1);
    if(m_SexcdAmt<0)
      throw Exception("金额不能小于零");
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdDesc()
{

}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdExes()
{
  double m_SexcdExes;
   m_SexcdExes=ReturnNeedValue(GetDetailValue("SexcdExes"),-1);
    if(m_SexcdExes<0)
      throw Exception("换货费用不能小于零");
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdState()
{
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdBatch()
{
   AnsiString  m_SexcdBatch;
   AnsiString  b_SexcdBatch;
   AnsiString m_SexcdGoods=ReturnNeedValue(GetDetailValue("SexcdGoods"),"");
   m_SexcdBatch=ReturnNeedValue(GetDetailValue("SexcdBatch"),"");
   b_SexcdBatch=ReturnNeedValue(GetDetailOldValue("SexcdBatch"),"");
    if(m_SexcdBatch.Length()>18)
      throw Exception("批号长度不能大于18");
    if(m_SexcdGoods.IsEmpty())
      throw Exception("换货物料不能为空");
    if(m_SexcdBatch.IsEmpty()==false && m_SexcdBatch!=b_SexcdBatch)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select GoodsBatch from sdgoods where goodscode='"+m_SexcdGoods+"'");
      Query->Open();
      if(Query->RecordCount<1)
      {
        Query->Close();
        throw Exception("换货物料不存在");
      }
      else
      {
        if(Query->FieldValues["GoodsBatch"]!=1)
        {
          Query->Close();
          throw Exception("当前物料不能进行批号管理");
        }
      }
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select batchcode from sdbatch where batchcode='"+m_SexcdBatch+"'");
      Query->Open();
      if(Query->RecordCount<=0)
      {
        Query->Close();
        throw Exception("批号:"+m_SexcdBatch+"未定义");
      }
      Query->Close();
    }
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::ValidSexcdLoc()
{
   AnsiString  m_SexcdLoc;
   AnsiString m_SexcdGoods=ReturnNeedValue(GetDetailValue("SexcdGoods"),"");
   AnsiString  b_SexcdLoc;
   b_SexcdLoc=ReturnNeedValue(GetDetailOldValue("SexcdLoc"),"");
   m_SexcdLoc=ReturnNeedValue(GetDetailValue("SexcdLoc"),"");
    if(m_SexcdLoc.IsEmpty())
      throw Exception("换货货位不能为空!");
    if(m_SexcdGoods.IsEmpty())
      throw Exception("换货物料不能为空");
    if(m_SexcdLoc!=b_SexcdLoc)
    {
      Query->Close();
      Query->SQL->Clear();
      Query->SQL->Add("select loccode from sdLoc,sdLg where loccode=lgloccode and loccode='"+m_SexcdLoc+"' and lggoodscode='"+m_SexcdGoods+"'");
      Query->Open();
      if(Query->RecordCount<1)
      {
        Query->Close();
        throw Exception("货位:"+m_SexcdLoc+"不能存储物料:"+m_SexcdGoods);
      }
      Query->Close();
    }
}
//---------------------------------------------------------------------------
void __fastcall TKSSexch::CmdExec(AnsiString Param)
{

}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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