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

📄 ppc.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Ppc.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"

TfrmPpc *frmPpc;
//---------------------------------------------------------------------------
__fastcall TfrmPpc::TfrmPpc(TComponent* Owner)
    : TRecBaseForm(Owner,euSdPpc,"")
{
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPpc::GetFieldValue(int iFieldIndex)
{
    return ReadFieldValue(comServer,iFieldIndex);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPpc::SetFieldValue(int iFieldIndex,AnsiString sFieldValue)
{
    WriteFieldValue(comServer,iFieldIndex,sFieldValue);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPpc::GetDataToGrid()
{
    AnsiString s;
    s = GetFieldValue(fiPpcGoods)+
        "\t" + GetFieldValue(fiPpcQty);
    return (s);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::InitEditControl()
{
     ClientGroup->AddComponent(2,false,false,true, fpPpc,fpPpc->Name);
     ClientGroup->AddComponent(2,true,true,false, sgPpc,sgPpc->Name);
     ClientGroup->AddComponent(2,true,true,true, sePpcGoodsName,sePpcGoodsName->Name);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::ClearControl(bool BringToNext)
{
    if(!BringToNext)
      EmptyAll(fpPpc);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::WaitUserInput()
{
    if(sePpcGoods->Enabled)
      sePpcGoods->SetFocus();
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::GetDataFromComObject()
{
    AnsiString tempS = GetFieldValue(fiPpcGoods);
    sePpcGoods->Text = tempS;
    //MoveFirst,MovePrority,MoveNext,MoveLast
    sgPpc->LocateGrid(0,tempS);
    if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
       sePpcGoodsName->Text=GetGoodsValue("GoodsName");
    sePpcQty->Text=GetFieldValue(fiPpcQty);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::SendDataToComObject()
{
    SetFieldValue(fiPpcGoods,sePpcGoods->Text);
    SetFieldValue(fiPpcQty,sePpcQty->Text);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::RefreshGridData(int mAction)
{
    AnsiString sGridItem;
    sGridItem=GetDataToGrid();
    int i;
    switch(mAction)
    {
      case 0:     //新增
         sgPpc->AddItem(sGridItem);
         sgPpc->Row=sgPpc->RowCount-1;
         break;
      case 1:     //修改
          sgPpc->ChangeItem(sGridItem,sgPpc->Row);
          break;
      case 2:     //删除
         sgPpc->RemoveItem(sgPpc->Row);
    } ;
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::FillGridWithData()
{
    AnsiString ItemStr;
    comServer->MoveFirst();
    sgPpc->RowCount = 1;
    while (comServer->Eof == 0)
    {
      ItemStr = GetDataToGrid();
      sgPpc->AddItem(ItemStr);
      comServer->MoveNext();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::FormShow(TObject *Sender)
{
    if(comServer->RecordCount>0)
    {
      FillGridWithData();
      comServer->MoveFirst();
      GetDataFromComObject();
    }
    else
    {
      ClearControl(false);
      sgPpc->RowCount=1;
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::FormClose(TObject *Sender,
      TCloseAction &Action)
{
      TRecBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::sgPpcClick(TObject *Sender)
{
    int ARow;
    ARow=sgPpc->Row;
    if(ARow > 0)
       comServer->LocateByKey(WideString(sgPpc->TextMatrix[ARow][0]));
    if(!comServer->Eof)
       GetDataFromComObject();
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::sePpcGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="004[物料编码][物料名称][计量单位][批量]";
  SqlStr+="Select GoodsCode,GoodsName,GoodsUnitCode,GoodsEoq from sdGoods where GoodsFrom=1 order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"材料数据查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    sePpcGoods->Text=p->ColData[1];
    sePpcGoodsName->Text =  p->ColData[2];
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmPpc::sePpcGoodsExit(TObject *Sender)
{
    AnsiString tempGoods;
    tempGoods=sePpcGoods->Text;
    if(!tempGoods.IsEmpty())
    {
      if(g_sdRsGoods->LocateByKey(WideString(tempGoods))==0)
         sePpcGoodsName->Text=GetGoodsValue("GoodsName");
      else
         ShowMessage("录入的零件编码:'"+tempGoods+"'不存在!");
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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