sgd.cpp

来自「科思ERP部分源码及控件」· C++ 代码 · 共 201 行

CPP
201
字号
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Sgd.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "RecBaseForm"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
TfrmSgd *frmSgd;

void __fastcall TfrmSgd::ClearControl(bool BringToNext)
{
    // BringToNext为真时,不清空
    if(BringToNext)
        return;

    seSgdCode->Text         =   "";
    seSgdName->Text         =   "";
    seSgdGoods->Text    =   "";
}

void __fastcall TfrmSgd::GetDataFromComObject()
{
    seSgdCode->Text         =   GetFieldValue("SgdCode");
    seSgdName->Text         =   GetFieldValue("SgdName");
    seSgdGoods->Text    =   GetFieldValue("SgdGoodsCode");
    sgSgd->LocateGrid(1,seSgdGoods->Text);
}

void __fastcall TfrmSgd::SendDataToComObject()
{
    AnsiString s;

    if (seSgdCode->Text.IsEmpty() )
        throw Exception("必须录入 客户货物代码 !");
    SetFieldValue("SgdClientCode",WideString(cbSgdClientCode->ItemData[cbItem2]));
    SetFieldValue("SgdCode",WideString(seSgdCode->Text));
    SetFieldValue("SgdName",WideString(seSgdName->Text));
    SetFieldValue("SgdGoodsCode",WideString(seSgdGoods->Text));
 }

void __fastcall TfrmSgd::WaitUserInput()
{
    if(seSgdGoods->Enabled)
    seSgdGoods->SetFocus();
}

AnsiString __fastcall TfrmSgd::GetDataToGrid()
{
    AnsiString  s;

    s   =   "\t" + GetFieldValue("SgdGoodsCode")+
            "\t" + GetFieldValue("SgdCode") +
            "\t" + GetFieldValue("SgdName");
    return(s);
}

void __fastcall TfrmSgd::RefreshGridData(int mAction)
{
    AnsiString ItemStr;

    ItemStr =   GetDataToGrid();
    // 新增
    if (mAction ==  0)
    {
        sgSgd->AddItem(ItemStr);
        sgSgd->Row=sgSgd->RowCount-1;
    }
    // 修改
    else if(mAction ==  1)
    {
     sgSgd->ChangeItem(ItemStr,sgSgd->Row);
     }
    // 删除
    else if(mAction ==  2)
    {
        sgSgd->RemoveItem(sgSgd->Row);
    }
    sgSgd->LocateGrid(1,seSgdGoods->Text);
}



void __fastcall TfrmSgd::FillGridWithData()
{
    AnsiString ItemStr;

    comServer->MoveFirst();
    sgSgd->RowCount    =   1;

    while (comServer->Eof   ==  0)
    {
        ItemStr =   GetDataToGrid();
        sgSgd->AddItem(ItemStr);
        comServer->MoveNext();
    }
}

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

void __fastcall TfrmSgd::InitEditControl()
{
	ClientGroup->AddComponent(2,true,true,false, sgSgd,sgSgd->Name);
	ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
	ClientGroup->AddComponent(2,true,true,false, FloatPanel2,FloatPanel2->Name);
//    FillComboBox(Handle,scSgdGoodsCode,"","GoodsCode","GoodsName");
}
//---------------------------------------------------------------------------

__fastcall TfrmSgd::TfrmSgd(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
    : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{
   FillComboBox(Handle,cbSgdClientCode,"select ClientCode,ClientName from sdClient where ClientCancel=0 order by ClientCode","ClientName","ClientCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmSgd::cbSgdClientCodeClick(TObject *Sender)
{
   if(cbSgdClientCode->ItemData[cbItem2]!=ClientValue)
     {
         WideString s;

          s   =   "SgdClientCode = '" + cbSgdClientCode->ItemData[cbItem2] + "'";
          comServer->FilterString =   s;
          comServer->Query();

          FillGridWithData();
          comServer->MoveFirst();
          GetDataFromComObject();
          ClientValue=cbSgdClientCode->ItemData[cbItem2];
      }
}
//---------------------------------------------------------------------------


void __fastcall TfrmSgd::SetClientValue(AnsiString value)
{
        if(FClientValue != value) {
                FClientValue = value;
        }
}
AnsiString __fastcall TfrmSgd::GetClientValue()
{
        return FClientValue;
}
void __fastcall TfrmSgd::FormShow(TObject *Sender)
{
  cbSgdClientCodeClick(Sender);
}
//---------------------------------------------------------------------------

void __fastcall TfrmSgd::sgSgdClick(TObject *Sender)
{
    if (sgSgd->Row    >   0)
		 comServer->LocateByKey(cbSgdClientCode->ItemData[cbItem2]+"\t"+sgSgd->TextMatrix[sgSgd->Row][1]+"\t");
    if (!comServer->Eof)
         GetDataFromComObject();

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

void __fastcall TfrmSgd::seSgdGoodsButtonClick(TObject *Sender)
{
// Fix 2003-01-14 [Fengji]
//    AnsiString SqlStr;
//    SqlStr="003[货物编码][货物名称][单位]";
//    SqlStr+="Select GoodsCode,GoodsName,GoodsUnitCode from sdGoods where GoodsSale=1";
//    SqlStr+=" order by GoodsCode";
//    TfrmWnQuery *p;
//    try
//    {
//       StartWaitForm("正在查询,请稍候...");
//       p=new TfrmWnQuery(this,"客户货物查询",SqlStr);
//    }
//    __finally
//    {
//       EndWaitForm();
//    }
//    if(p->ShowModal()==mrOk)
//    {
//     seSgdGoods->Text=p->ColData[1];
//     seSgdCode->Text=(p->ColData[2]);
//     seSgdName->Text=(p->ColData[3]);
//    }
//    delete p;

    if(OpenGoodsForm("")) //过滤条件
    {
      seSgdGoods->Text=l_RsGoods->FieldValues["GoodsCode"];
    }

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


⌨️ 快捷键说明

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