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

📄 cmhdl.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
          l_StoredProc->Parameters->CreateParameter("@AdjCohCheckDate",ftString,pdInput,10,temp);
          l_StoredProc->ExecProc();
          l_StoredProc->Close();
          }
         TKSAdjCoh *p=(TKSAdjCoh*)Records(CurRecNo);
         p->Assign(this);
         BackupValue();
       }
       catch(...)
       {
         l_AdjCohCheck=b_AdjCohCheck;
         l_AdjCohChecker=b_AdjCohChecker;
         l_AdjCohCheckDate=b_AdjCohCheckDate;
         throw Exception("审核/反审核失败");
        }
     }
}
//---------------------------------------------------------------------------
void TKSAdjCoh::Delete()
{
    if(CurStatus!=1)
        throw Exception("当前状态不能进行删除操作!");
    if(l_AdjCohCode.IsEmpty()==true)
        throw Exception("当前没有记录可以删除!");
    l_StoredProc->Close();
    l_StoredProc->ProcedureName="sdAdjCoh_Delete";
    l_StoredProc->Parameters->Clear();
    l_StoredProc->Parameters->CreateParameter("@W_AdjCohCode",ftString,pdInput,18,b_AdjCohCode);
    l_StoredProc->ExecProc();
    l_StoredProc->Close();
    delete l_sdAdjCod;
    DeleteRecord(this->b_AdjCohCode);
}
//---------------------------------------------------------------------------
void TKSAdjCoh::AddItem()
{
    l_sdAdjCod->AddNew();
    if(CurStatus!=2)
        SetActionID(5);
}
//---------------------------------------------------------------------------
void TKSAdjCoh::InsertItem()
{
/*  l_sdField->AddNew();
  TKSField *p=new TKSField(l_SessionName,l_DatabaseName);
  p->Assign(l_sdField);
  if(CurStatus==2)
    l_sdField->AddRecord((void *)p,p->GetFieldValue(fiFieldName));
  else
    l_sdField->Update();
*/
}
//---------------------------------------------------------------------------
void TKSAdjCoh::EditItem()
{
    l_sdAdjCod->Edit();
    if(CurStatus==1)
    {
        SetActionID(6);
    }
}
//---------------------------------------------------------------------------
void TKSAdjCoh::DeleteItem()
{
    if(CurStatus==2||CurStatus==5)
        l_sdAdjCod->DeleteRecord(l_sdAdjCod->Key);
    else
        l_sdAdjCod->Delete();
}
//---------------------------------------------------------------------------
void TKSAdjCoh::RemoveItem()
{
    if(CurStatus==2)
        l_sdAdjCod->RemoveRecord(l_sdAdjCod->Index);
    else
        l_sdAdjCod->Delete();
}
//---------------------------------------------------------------------------
void TKSAdjCoh::ClearItem()
{
    int iCount;
    if(CurStatus==2)
        l_sdAdjCod->ClearRecord();
    else
    {
        iCount=l_sdAdjCod->Count;
        for(int i=0;i<iCount;i++)
        {
            l_sdAdjCod->LocateByIndex(0);
            l_sdAdjCod->Delete();
        }
    }
}
//---------------------------------------------------------------------------
void TKSAdjCoh::CancelItem()
{
    l_sdAdjCod->Cancel();
}
//---------------------------------------------------------------------------
void TKSAdjCoh::AddToObject()
{
    TKSAdjCod *p=new TKSAdjCod();
    p->Assign(l_sdAdjCod);
    if(l_sdAdjCod->FindKey(l_sdAdjCod->GetOldFieldValue(fiAdjCodGoods)))
        l_sdAdjCod->ChangeRecord((void*)p,p->GetFieldValue(fiAdjCodGoods),l_sdAdjCod->GetOldFieldValue(fiAdjCodGoods));
    else
        l_sdAdjCod->AddRecord((void *)p,p->GetFieldValue(fiAdjCodGoods));
}
//---------------------------------------------------------------------------
bool TKSAdjCoh::LocateItemByIndex(int Index)
{
    return l_sdAdjCod->LocateByIndex(Index);
}
//---------------------------------------------------------------------------
bool TKSAdjCoh::LocateItemByKey(AnsiString Key)
{
    return l_sdAdjCod->LocateByKey(Key);
}
//---------------------------------------------------------------------------
void TKSAdjCoh::BackupValue()
{
     b_sdAdjCod=l_sdAdjCod;
     b_AdjCohCode=l_AdjCohCode;
     b_AdjCohDate=l_AdjCohDate;
     b_AdjCohFmonth=l_AdjCohFmonth;
     b_AdjCohPosType=l_AdjCohPosType;
     b_AdjCohDesc=l_AdjCohDesc;
     b_AdjCohKeeper=l_AdjCohKeeper;
     b_AdjCohUser=l_AdjCohUser;
     b_AdjCohCheck=l_AdjCohCheck;
     b_AdjCohChecker=l_AdjCohChecker;
     b_AdjCohCheckDate=l_AdjCohCheckDate;
     b_AdjCohPost=l_AdjCohPost;
     b_AdjCohPoster=l_AdjCohPoster;
     b_AdjCohPostDate=l_AdjCohPostDate;
     b_AdjCohSysDate=l_AdjCohSysDate;
}
//---------------------------------------------------------------------------
void TKSAdjCoh::RestoreValue()
{
    l_sdAdjCod= b_sdAdjCod;
    l_AdjCohCode=b_AdjCohCode;
    l_AdjCohDate=b_AdjCohDate;
    l_AdjCohFmonth=b_AdjCohFmonth;
    l_AdjCohPosType=b_AdjCohPosType;
    l_AdjCohDesc=b_AdjCohDesc;
    l_AdjCohKeeper=b_AdjCohKeeper;
    l_AdjCohUser=b_AdjCohUser;
    l_AdjCohCheck=b_AdjCohCheck;
    l_AdjCohChecker=b_AdjCohChecker;
    l_AdjCohCheckDate=b_AdjCohCheckDate;
    l_AdjCohPost=b_AdjCohPost;
    l_AdjCohPoster=b_AdjCohPoster;
    l_AdjCohPostDate=b_AdjCohPostDate;
    l_AdjCohSysDate=b_AdjCohSysDate;
}
//---------------------------------------------------------------------------
void TKSAdjCoh::RestoreItem()
{
    l_sdAdjCod->RestoreValue();
}
//---------------------------------------------------------------------------
void TKSAdjCoh::EmptyValue(int Index)
{
   switch(Index)
   {
    case 0:
     l_AdjCohCode="";
     l_AdjCohDate="";
     l_AdjCohFmonth="";
     l_AdjCohPosType="";
     l_AdjCohDesc="";
     l_AdjCohKeeper="";
     l_AdjCohUser="";
     l_AdjCohCheck=0;
     l_AdjCohChecker="";
     l_AdjCohCheckDate="";
     l_AdjCohPost=0;
     l_AdjCohPoster="";
     l_AdjCohPostDate="";
     l_AdjCohSysDate="";
    break;
    case 1:
    b_AdjCohCode="";
    b_AdjCohDate="";
    b_AdjCohFmonth="";
    b_AdjCohPosType="";
    b_AdjCohDesc="";
    b_AdjCohKeeper="";
    b_AdjCohUser="";
    b_AdjCohCheck=0;
    b_AdjCohChecker="";
    b_AdjCohCheckDate="";
    b_AdjCohPost=0;
    b_AdjCohPoster="";
    b_AdjCohPostDate="";
    b_AdjCohSysDate="";
      break;
    }
}
//---------------------------------------------------------------------------
void TKSAdjCoh::BatchLetValue()
{
     l_AdjCohCode=l_Query->FieldValues["AdjCohCode"];
     l_AdjCohDate=l_Query->FieldValues["AdjCohDate"];
     l_AdjCohFmonth=l_Query->FieldValues["AdjCohFmonth"];
     l_AdjCohPosType=l_Query->FieldValues["AdjCohPosType"];
     l_AdjCohDesc=l_Query->FieldValues["AdjCohDesc"];
     l_AdjCohKeeper=l_Query->FieldValues["AdjCohKeeper"];
     l_AdjCohUser=l_Query->FieldValues["AdjCohUser"];
     l_AdjCohCheck=l_Query->FieldValues["AdjCohCheck"];
     l_AdjCohChecker=l_Query->FieldValues["AdjCohChecker"];
     l_AdjCohCheckDate=l_Query->FieldValues["AdjCohCheckDate"];
     l_AdjCohPost=l_Query->FieldValues["AdjCohPost"];
     l_AdjCohPoster=l_Query->FieldValues["AdjCohPoster"];
     l_AdjCohPostDate=l_Query->FieldValues["AdjCohPostDate"];
     l_AdjCohSysDate=l_Query->FieldValues["AdjCohSysDate"];
    BackupValue();
}
//---------------------------------------------------------------------------
void TKSAdjCoh::Assign(TKSAdjCoh *p)
{
    this->SetActionID(p->CurStatus);
    this->l_sdAdjCod=p->l_sdAdjCod;
    this->l_AdjCohCode=p->l_AdjCohCode;
    this->l_AdjCohDate=p->l_AdjCohDate;
    this->l_AdjCohFmonth=p->l_AdjCohFmonth;
    this->l_AdjCohPosType=p->l_AdjCohPosType;
    this->l_AdjCohDesc=p->l_AdjCohDesc;
    this->l_AdjCohKeeper=p->l_AdjCohKeeper;
    this->l_AdjCohUser=p->l_AdjCohUser;
    this->l_AdjCohCheck=p->l_AdjCohCheck;
    this->l_AdjCohChecker=p->l_AdjCohChecker;
    this->l_AdjCohCheckDate=p->l_AdjCohCheckDate;
    this->l_AdjCohPost=p->l_AdjCohPost;
    this->l_AdjCohPoster=p->l_AdjCohPoster;
    this->l_AdjCohPostDate=p->l_AdjCohPostDate;
    this->l_AdjCohSysDate=p->l_AdjCohSysDate;
    if(this->CurStatus==3)
    {
      this->b_sdAdjCod=p->b_sdAdjCod;
      this->b_AdjCohCode=p->b_AdjCohCode;
      this->b_AdjCohDate=p->b_AdjCohDate;
      this->b_AdjCohFmonth=p->b_AdjCohFmonth;
      this->b_AdjCohPosType=p->b_AdjCohPosType;
      this->b_AdjCohDesc=p->b_AdjCohDesc;
      this->b_AdjCohKeeper=p->b_AdjCohKeeper;
      this->b_AdjCohUser=p->b_AdjCohUser;
      this->b_AdjCohCheck=p->b_AdjCohCheck;
      this->b_AdjCohChecker=p->b_AdjCohChecker;
      this->b_AdjCohCheckDate=p->b_AdjCohCheckDate;
      this->b_AdjCohPost=p->b_AdjCohPost;
      this->b_AdjCohPoster=p->b_AdjCohPoster;
      this->b_AdjCohPostDate=p->b_AdjCohPostDate;
      this->b_AdjCohSysDate=p->b_AdjCohSysDate;
    }
    else
      this->BackupValue();
}
//---------------------------------------------------------------------------
void TKSAdjCoh::AssignValue()
{
    TKSAdjCoh *p=(TKSAdjCoh *)Records(CurRecNo);
    Assign(p);
}
//---------------------------------------------------------------------------
int TKSAdjCoh::Query()
{
    AnsiString l_SqlStr;
    l_SqlStr=QueryString;
    if(FilterString.IsEmpty()==false)
        l_SqlStr=l_SqlStr+" where "+FilterString;
    if(OrderString.IsEmpty()==false)
        l_SqlStr=l_SqlStr+" Order by "+OrderString;
    l_Query->Close();
    l_Query->SQL->Clear();
    l_Query->SQL->Add(l_SqlStr);
    l_Query->Open();
    for(int i=0;i<this->Count;i++)
    {
        this->LocateByIndex(i);
        this->AssignValue();
        delete l_sdAdjCod;
      }

    ClearRecord();
    if(l_Query->RecordCount>0)
    {
        l_Query->First();
        while(!l_Query->Eof)
        {
            BatchLetValue();
            NewDetail();
            l_sdAdjCod->FilterString="AdjCodCode='"+l_AdjCohCode+"'";
            l_sdAdjCod->Query();
            TKSAdjCoh *p=new TKSAdjCoh();
            SetActionID(1);
            p->Assign(this);
            AddRecord((void *)p,p->AdjCohCode);
            l_Query->Next();
        }
        MoveFirst();
    }
    l_Query->Close();
    return Count;
}
//---------------------------------------------------------------------------
bool TKSAdjCoh::Find(AnsiString WhereStr)
{
    AnsiString l_SqlStr;
    if(WhereStr.IsEmpty()==true)
        throw Exception("查找表达式不能为空");
    l_SqlStr="select * from sdAdjCoh where "+WhereStr;
    l_Query->Close();
    l_Query->SQL->Clear();
    l_Query->SQL->Add(l_SqlStr);
    l_Query->Open();
    if(l_Query->RecordCount!=1)
    {
        l_Query->Close();
        return false;
    }
    else
    {
        BatchLetValue();
        l_sdAdjCod->FilterString="AdjCodCode='"+l_AdjCohCode+"'";
        l_sdAdjCod->OrderString="AdjCodLine";
        l_sdAdjCod->Query();
        l_Query->Close();
        return true;
    }
}
//---------------------------------------------------------------------------
AnsiString TKSAdjCoh::GetItemValue(euAdjCod FieldName)
{
    return l_sdAdjCod->GetFieldValue(FieldName);
}
//---------------------------------------------------------------------------
void TKSAdjCoh::SetItemValue(euAdjCod FieldName, AnsiString value)
{
    l_sdAdjCod->SetFieldValue(FieldName,value);
}
//---------------------------------------------------------------------------
int __fastcall TKSAdjCoh::GetItemCount()
{
  if(l_sdAdjCod->Count)
     return l_sdAdjCod->Count;
  else
     return 0;

}
//---------------------------------------------------------------------------
int __fastcall TKSAdjCoh::GetCurItemNo()
{
    return l_sdAdjCod->CurRecNo;
}
//---------------------------------------------------------------------------
char __fastcall TKSAdjCoh::GetCurItemStatus()
{
    return l_sdAdjCod->CurStatus;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TKSAdjCoh::GetItemBookMark()
{
    return l_sdAdjCod->BookMark;
}
//---------------------------------------------------------------------------
void TKSAdjCoh::NewDetail()
{
  l_sdAdjCod=new TKSAdjCod(DataComm);
  l_sdAdjCod->sdParent=this;

}

void TKSAdjCoh::DeleteDetail()
{
  delete l_sdAdjCod;
  l_sdAdjCod=NULL;
}
//=============================================
//		(TKSAdjCod)入库调整单明细
//=============================================
void __fastcall TKSAdjCod:: SetAdjCodCode(AnsiString value)
{
    if(value.IsEmpty())
         throw Exception("入库调整单不能为空");
      l_AdjCodCode=value;
}
void __fastcall TKSAdjCod:: SetAdjCodLine(int    value)
{
    if(l_AdjCodCode.IsEmpty())
         throw Exception("入库调整单不能为空");
    if(value<0)
         throw Exception("行号不能小于零");
     l_AdjCodLine=value;
}
void __fastcall TKSAdjCod:: SetAdjCodGoods(AnsiString value)
{
    if(value.IsEmpty())
      throw Exception("物料编码不能为空");
    if(value.Length()>18)
      throw Exception("物料编码长度不能大于18");
    if(value!=l_AdjCodGoods)
    {
      l_Query->Close();
      l_Query->SQL->Clear();
      l_Query->SQL->Add("select GOODSCODE,GoodsName,GoodsUnitCode from Sdcd,sdgoods,sdstock where goodscode=stockgoodscode and cdgoods=goodscode and GOODSCODE='"+value+"'");
      l_Query->Open();

⌨️ 快捷键说明

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