ulh.cpp

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

CPP
513
字号
void __fastcall TfrmUlh::FormShow(TObject *Sender)
{
     ClearControl(1,false);
    ClearControl(2,false);
    ChangeToBrowseState();
    TGenBaseForm::MoveToFirst();
    tbCheck->Visible =false;
    tbClose->Visible =false;

}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::ChangeToBrowseState(bool Browse)
{
        sgUlh->Visible = true;
        FloatPanel2->Visible = false;
        if(Browse == false)
         sgUlh->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::btnOKClick(TObject *Sender)
{
  try
  {
    if (CurrentState==caAddDetail||CurrentState==caAddBill)
    {
      if(DetailState==caAddDetail)
        comServer->AddItem();
      SendDataToComObject(2);
      comServer->AddToObject();
      ClearControl(2,false);
      if(seUldPoCode->Enabled)
        seUldPoCode->SetFocus();
    }
    else
      ChangeToBrowseState();
  }
  catch(Exception &e)
  {
   throw Exception(e.Message);
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::WaitUserInput(int Section)
{
    if (Section ==1)
    { // Head
        if (CurrentState == caEditHead)
          deUlhDate->SetFocus();
        else
        {
          if(seUlhCode->Enabled)
            seUlhCode->SetFocus();
        }
    }
    else
    { // Detail
        sgUlh->Visible=false;
        FloatPanel2->Visible=true;
        if(seUldPoCode->Enabled)
          seUldPoCode->SetFocus();
    } // if
}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::sgUlhDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgUlh->Row;
    if (iRow == 0)
    {
       return;
    }
    sgUlh->Visible=false;
    FloatPanel2->Visible=true;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmUlh::GetDataToGrid()
{
    AnsiString ItemStr;

    ItemStr="\t"+GetDetailValue("UldLine");              //收货单行号
    ItemStr=ItemStr+"\t"+GetDetailValue("UldPoCode");    //采购单号
    ItemStr=ItemStr+"\t"+GetDetailValue("UldPodLine");   //采购单行号
    ItemStr=ItemStr+"\t"+GetDetailValue("UldGoods");
    ItemStr=ItemStr+"\t"+GetDetailValue("goodsname");
    ItemStr=ItemStr+"\t"+GetDetailValue("Goodsspec");
         //物料编码
    ItemStr=ItemStr+"\t"+GetDetailValue("UldUnit");      //计量单位
    ItemStr=ItemStr+"\t"+GetDetailValue("UldPoQty");     //采购数量
    ItemStr=ItemStr+"\t"+GetDetailValue("UldUrQty");
    ItemStr=ItemStr+"\t"+GetDetailValue("UldRecDate");
    ItemStr=ItemStr+"\t"+GetDetailValue("UldDelay");
    return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::GenrateBill()
{
    int TempCount;
    TempCount = comServer->ItemCount;
    TfrmUld *p;
    p = new TfrmUld(this);
    p->GetComObject(comServer);
    try
    {
     p->ShowModal();
    }
    __finally
    {
     //delete p;
    }
    if (TempCount < comServer->ItemCount)
      TGenBaseForm::SaveRecord();
    else
      CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::RefreshUpdateData(int MsgSrc,int MsgType)
{

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

void __fastcall TfrmUlh::seUldPoCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  TComResultSet * TempRes = new TComResultSet(Handle,g_ClientHandle);
  TempRes->Open("select parametercode,parametervalue from sdparameter where parametercode ='10302' and parametervalue =1","parametercode");
  SqlStr="012[采购单号][行号][物料编码][计量单位][采购数量][欠货数量][交货日期][发货日期][交货地址][拖期天数][采购员][物料编码]";
  SqlStr+="select podcode,podline,podgoods,podunit,PodQty,PodUrQty=PodQty-PodRQty+PodBQty,PodRecDate,PodSendDate,pohpsite,poddelay=datediff(day,podrecdate,getdate()),goodsbuyer,goodscode from sdpod,sdpoh,sdgoods where podcode=pohcode and pohcheck=1 and ";
  SqlStr+=" podclose=0 and pohclose=0 and pohsupply='"+scUlhSupply->ItemData[cbItem2]+"' and podgoods=goodscode and podrecdate<='"+g_sdCurDate+"'";
  if(TempRes->RecordCount >0)
  SqlStr+=" and goodsbuyer = '"+g_sdUserCode+"'";
  SqlStr+=" order by pohdate desc ";
  l_Query->Close();
  l_Query->Open("select goodsname,goodscode,goodsspec from sdgoods","goodscode");
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"采购单查询",SqlStr);
    p->sgResult->ColWidths[12]=0;
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seUldPoCode->Text=p->ColData[1];
    seUldPodLine->Text=p->ColData[2];
    seUldGoods->Text=p->ColData[3];
    seUldUnit->LocateKey(p->ColData[4]);
    seUldPoQty->Text=p->ColData[5];
    if(seUldGoods->Text != "")
    l_Query->LocateByKey(seUldGoods->Text);
    seUldGoodsName->Text=l_Query->FieldByName ("GoodsName");
    GoodsSpec->Text=l_Query->FieldByName ("GoodsSpec");
    seUldUrQty->Text=p->ColData[6];
    deUldRecDate->Text=p->ColData[7];
    deUldSendDate->Text=p->ColData[8];
    seUldPsite->LocateKey(p->ColData[9]);
    seUldDelay->Text=p->ColData[10];
  }
  delete p;
  delete TempRes;

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

void __fastcall TfrmUlh::seUldUrQtyButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="008[采购单号][行号][物料编码][计量单位][采购数量][收货数量][退货数量][欠货数量]";
  SqlStr+="select podcode,podline,podgoods,podunit,PodQty,PodRqty,PodBQty,PodUrQty=PodQty-PodRQty+PodBQty from sdpod where ";
  SqlStr+=" podclose=0 and podcode='"+seUldPoCode->Text+"' and podline="+seUldPodLine->Text;
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"采购单查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  p->ShowModal();
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmUlh::seUlhCodeExit(TObject *Sender)
{
    if(CurrentState==caNormal && seUlhCode->Text != GetHeadValue("UlhCode"))
    {
      comServer->LocateByKey(WideString(seUlhCode->Text));
      DisplayBill();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmUlh::UnDoChange()
{
}
//-
void __fastcall TfrmUlh::FormClose(TObject *Sender, TCloseAction &Action)
{
    TGenBaseForm::FormClose(Sender, Action);
}
//---------------------------------------------------------------------------


void __fastcall TfrmUlh::sgUlhClick(TObject *Sender)
{
 if (sgUlh->Row > 0)
    {
       comServer->LocateItemByKey(WideString(sgUlh->TextMatrix[sgUlh->Row][1]+"\t"+seUlhCode->Text));
       GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmUlh::SupplyCodeButtonButtonClick(TObject *Sender)
{
if(OpenSupplyForm("")==true)
    {
     scUlhSupply->LocateKey(GetSupplyValue(gtOpenForm,"SupplyCode"));
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmUlh::scUlhSupplyExit(TObject *Sender)
{
TComResultSet * TempRes = new TComResultSet(Handle,g_ClientHandle);
    TempRes->Open("select parametercode,parametervalue from sdparameter where parametercode = '10302' and parametervalue =1","parametercode");
    if(TempRes->RecordCount > 0)
    {
       TempRes->Close();
       TempRes->Open("select supplycode,supplyname,supplybuyer from sdsupply where supplybyuer ='"+g_sdUserCode+"' and supplycode ='"+scUlhSupply->Text+"' or supplyname = '"+scUlhSupply->Text+"'","supplycode");
    }
    else
    {
       TempRes->Close();
       TempRes->Open("select supplycode,supplyname,supplybuyer from sdsupply where supplycode = '"+scUlhSupply->Text+"' or supplyname = '"+scUlhSupply->Text+"'", "supplycode");
    }
       if(scUlhSupply->LocateKey(TempRes->FieldByName("supplycode"))==0)
       {
            scUlhSupply->ItemIndex =-1;
       }
       delete TempRes;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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