qccoll.cpp

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

CPP
779
字号
//    FormIniFile="D:\Test.Ini";
//    SetGridWidth(Name,sgQcsh,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcColl::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TGenBaseForm::FormClose(Sender,Action);
//    WriteGridWidth(Name,sgQcsh,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcColl::FormShow(TObject *Sender)
{
//    InitEditControl();
    ClearControl(1,false); // Head
    ClearControl(2,false); // Detail
    ChangeToBrowseState();
    MoveToFirst();//comserver的第一条头记录
    CurLineCount=comServer->ItemCount; //当前明细行数
}
//---------------------------------------------------------------------------


void __fastcall TfrmQcColl::ChangeToBrowseState(bool Browse)
{
     sgQcsh->Visible=true;
     fpQcsdDetail->Visible=false;
     if(Browse==false)
      sgQcsh->SetFocus();

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

void __fastcall TfrmQcColl::btnOKClick(TObject *Sender)
{
    if(seQcsdLine->Text=="")
      throw Exception("质检行号不能为空,且不能重复");
    try
    {
       if (CurrentState==caAddDetail||CurrentState==caAddBill)
       {
          if(DetailState==caAddDetail)
             comServer->AddItem();
          SendDataToComObject(2);
          comServer->AddToObject();
          ClearControl(2,false);
//          seQcsdFLine->SetFocus();
       }
       else
          ChangeToBrowseState();
    }catch(Exception & E)
    {
       throw Exception(E.Message);
    }
    ClearControl(2,true);//自动编号
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcColl::btnCancelClick(TObject *Sender)
{
     CancelChange();
}

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

void __fastcall TfrmQcColl::RefreshUpdateData(int MsgSrc,int MsgType)
{
/*
  switch(MsgSrc)
  {
   case euSdQcm:
   {
    if(ShowUpdateMessage(MsgSrc,MsgType))
      FillComboBox(Handle,scQcshUser,"SELECT UserName memo,QcmCode FROM sdQcm,sdUser where QcmCode=UserCode order by QcmCode","memo","QcmCode");
    break;
   }
   case euSdTrd:
   {
    if(ShowUpdateMessage(MsgSrc,MsgType))
      FillComboBox(Handle,scQcsdTrd,"select TrdName memo,TrdCode from sdTrd order by TrdCode","memo","TrdCode");
    break;
   }
   default:
    break;
  }
*/
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcColl::seQcshCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    if(Key==13 && CurrentState==caNormal)
    {
      comServer->LocateByKey(WideString(seQcshCode->Text));
      DisplayBill();
    }
}

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

void __fastcall TfrmQcColl::GenrateBill()
{
/* DONE -chead : GenrateBill   注释掉*/
/*    int TempCount;
    TempCount = comServer->ItemCount;

    SetControlState(caAddBill);
    TfrmQcProcD *p=new TfrmQcProcD(this,g_ClientHandle, "","", comServer);
    try
    {
      p->ShowModal();
    }
    __finally
    {
       delete p;
    }

    if (TempCount < comServer->ItemCount)
      TGenBaseForm::tbSaveClick(NULL);
    else
      CancelChange();
*/      
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcColl::seQcshDocCodeButtonClick(TObject *Sender)
{
/* DONE -chead : seQcshDocCodeButtonClick批号查询*/
  AnsiString SqlStr;
    SqlStr  = "005[批号代码][批号说明][批号数量][有效期][失效期]";
    SqlStr += " select BatchCode,isnull(BatchDesc,''),isnull(BatchQty,''),BatchEffectDate,BatchAbateDate from sdBatch";
    SqlStr += " order by BatchCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"批号查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seQcshDocCode->Text = p->ColData[1];//返回值,代码
  }
  delete p;
}


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

void __fastcall TfrmQcColl::seQcsdGoodsButtonClick(TObject *Sender)
{
/* TODO -chead : seQcsdGoodsButtonClick物料查询 */
    if(OpenGoodsForm("")) //新的物料查询,过滤条件
    {         
      seQcsdGoods->Text=    GetGoodsValue(gtOpenForm,"GoodsCode");
      seQcsdGoodsName->Text=GetGoodsValue(gtOpenForm,"GoodsName");//readonly
      seQcsdGoodsSpec->Text=GetGoodsValue(gtOpenForm,"GoodsSpec");//readonly
    }

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

void __fastcall TfrmQcColl::sgQcshDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgQcsh->Row;
    if (iRow == 0)
    {
       return;
    }
    if (comServer->ItemCount >0)
    {
       GetDataFromComObject(2);
       sgQcsh->Visible=false;
       fpQcsdDetail->Visible=true;
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcColl::seQcCkupHSupplyButtonClick(TObject *Sender)
{
/* DONE -chead : seQcCkupHSupplyButtonClick供应商查询*/
  AnsiString SqlStr;
  SqlStr  = "003[供应商代码][供应商名称][备注]";
  SqlStr += " select SupplyCode,isnull(SupplyName,''),isnull(SupplyDesc,'') From sdSupply";
  SqlStr += " order by SupplyCode,SupplyName";

  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"供应商查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seQcCkupHSupply->Text = p->ColData[1];//返回值,代码
  }
  delete p;

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

void __fastcall TfrmQcColl::seQcCkupHProcButtonClick(TObject *Sender)
{
/* DONE -chead : seQcCkupHProcButtonClick工序查询*/
  AnsiString SqlStr;
    SqlStr  = "004[工序代码][工序名称][工作中心][在制货位]";
    SqlStr += " select ProcessCode,isnull(ProcessName,''),isnull(ProcessWc,''),isnull(ProcessLoc,'') from sdProcess ";
    SqlStr += " order by ProcessCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"工序查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seQcCkupHProc->Text = p->ColData[1];//返回值,代码
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcColl::seCkupCQtyExit(TObject *Sender)
{
/* DONE -chead&&detail : seCkupCQtyExit头数量 */
      double DQty,CQty,PQty,PRate;
      DQty=StrToFloat( seCkupDQty->Text);//报检
      CQty=StrToFloat( seCkupCQty->Text);//实检
      PQty=StrToFloat( seCkupPQty->Text);//合格检
      if (CQty>DQty )
      {
        throw Exception("实检数量不能大于报检数量");
      }
      else if(PQty>CQty || PQty>DQty)
      {
        throw Exception("合格数量不能大于实检数量");
       }

      if (CQty<=0)
      {
       PRate=0;
      }
      else
      {
       PRate=PQty/CQty*100;
      }
      seCkupPRate->Text=FloatToStr(DataCarry(PRate,2,0));
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcColl::seCkupPQtyExit(TObject *Sender)
{
    TObject *tempSender;
    try
    {
      tempSender= new TObject();
      this->seCkupCQtyExit(Sender);
    }
    __finally
    {
      delete tempSender;
    }

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


void __fastcall TfrmQcColl::seCkupDQtyExit(TObject *Sender)
{
    TObject *tempSender;
    try
    {
      tempSender= new TObject();
      this->seCkupCQtyExit(Sender);
    }
    __finally
    {
      delete tempSender;
    }

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

void __fastcall TfrmQcColl::seQcsdDQtyExit(TObject *Sender)
{
/* DONE -chead&&detail : seQcsdDQtyExit行数量 */
      double CQty ,LCQty,LPQty;
      CQty=StrToFloat( seCkupCQty->Text); //总实检
      LCQty=StrToFloat( seQcsdDQty->Text); //行实检
      LPQty=StrToFloat( seQcsdCQty->Text); //合格检
      if (LCQty>CQty)
      {
       throw Exception("明细检验数量不能大于总实检数量");
      }

      if (LPQty>LCQty )
      {
        throw Exception("合格数量不能大于实检数量");
       }
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcColl::seQcsdCQtyExit(TObject *Sender)
{
    TObject *tempSender;
    try
    {
      tempSender= new TObject();
      this->seQcsdDQtyExit(Sender);
    }
    __finally
    {
      delete tempSender;
    }

}
//---------------------------------------------------------------------------
bool __fastcall TfrmQcColl::BeforeCheck()
{
/* TODO -chead : 审核 */
   SetHeadValue("CkupHCheck",1);
   SetHeadValue("CkupHChecker",g_sdUserCode);
   SetHeadValue("CkupHCheckDate",g_sdCurDate);
   return true;

}
//---------------------------------------------------------------------------
bool __fastcall TfrmQcColl::BeforeUnCheck()
{
/* TODO -chead : 反审核 */
   SetHeadValue("CkupHCheck",0);
   SetHeadValue("CkupHChecker",g_sdUserCode);
   SetHeadValue("CkupHCheckDate",g_sdCurDate);
   return true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcColl::sgQcshClick(TObject *Sender)
{
/* DONE -cdetail : sgQcshSelectCell定位当前明细表记录行 */
     if (sgQcsh->Row == 0)
      {
       return;
       }
    comServer->LocateItemByKey(GetHeadValue("CkupHCode")+"\t"+sgQcsh->TextMatrix[sgQcsh->Row][1]+"\t");//注意在明细表中,关键字段的顺序对应
    GetDataFromComObject(2);
}
//---------------------------------------------------------------------------



void __fastcall TfrmQcColl::seQcsdGoodsKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
  if (Key==VK_RETURN)
  {
    if (seQcsdGoods->Text=="")
       return;
    try
    {
    if(InitRsGoods(seQcsdGoods->Text)) //新的物料查询,过滤条件
      {
        seQcsdGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");//readonly
        seQcsdGoodsSpec->Text=GetGoodsValue(gtInitRs,"GoodsSpec");//readonly
      }
    }
    __finally
    {

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

⌨️ 快捷键说明

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