shop.cpp

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

CPP
167
字号
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Shop.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"

TfrmShop *frmShop;
//---------------------------------------------------------------------------
__fastcall TfrmShop::TfrmShop(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::ClearControl(bool BringToNext)
{
    if (!BringToNext)
    {
       seShopCode->Text="";
       seShopName->Text="";
       scShopDeptCode->ItemIndex=-1;
       scShopDeptCode->Text="";
       cbShopFitting->Checked=false;
       cbShopAssis->Checked=false;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::WaitUserInput()
{
    seShopCode->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
    ClientGroup->AddComponent(2,true,true,false, sgShop,sgShop->Name);
    FillComboBox(Handle,scShopDeptCode,"SELECT DeptCode,DeptName FROM sdDept where DeptEnd=1 order by DeptCode","DeptName","DeptCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::RefreshUpdateData(int MsgSrc,int MsgType)
{
/*
    try
    {
       AnsiString KeyCode;
       if(MsgSrc==euSdDept)
       {
          if(ShowUpdateMessage(MsgSrc,MsgType))
          {
	          StartWaitForm("正在刷新引用数据!");
             KeyCode=scShopDeptCode->ItemData[1];
             FillComboBox(Handle,scShopDeptCode,"SELECT DeptCode,DeptName FROM sdDept where DeptEnd=1 order by DeptCode","DeptName","DeptCode");
             scShopDeptCode->LocateKey(KeyCode);
	          EndWaitForm();
	       }
       }
    }
    catch(Exception &e)
    {
       throw Exception(e.Message);
    }
*/
}
//---------------------------------------------------------------------

void __fastcall TfrmShop::GetDataFromComObject()
{
    seShopCode->Text=GetFieldValue("ShopCode");
    //MoveFirst,MovePrority,MoveNext,MoveLast
    sgShop->LocateGrid(0,seShopCode->Text);
    seShopName->Text=GetFieldValue("ShopName");
    scShopDeptCode->LocateKey(GetFieldValue("ShopDeptCode"));
    cbShopFitting->Checked=(GetFieldValue("ShopFitting")=="1");
    cbShopAssis->Checked=(GetFieldValue("ShopAssis")=="1");
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::SendDataToComObject()
{
    SetFieldValue("ShopCode",seShopCode->Text);
    SetFieldValue("ShopName",seShopName->Text);
    SetFieldValue("ShopDeptCode",scShopDeptCode->ItemData[cbItem2]);
    SetFieldValue("ShopFitting",cbShopFitting->Checked ? "1":"0");
    SetFieldValue("ShopAssis",cbShopAssis->Checked ? "1":"0");
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmShop::GetDataToGrid()
{
    AnsiString s,s1;
    s1 = GetFieldValue("ShopDeptCode");
    scShopDeptCode->LocateKey(s1);
    s =GetFieldValue("ShopCode")+
       "\t"+GetFieldValue("ShopName")+
       "\t"+scShopDeptCode->ItemData[0];
    return s;
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::RefreshGridData(int mAction)
{
    AnsiString sGridItem;
    sGridItem=GetDataToGrid();
    switch(mAction)
    {
       case 0:     //新增
         sgShop->AddItem(sGridItem);
         sgShop->Row=sgShop->RowCount-1;
         break;
       case 1:     //修改
         sgShop->ChangeItem(sGridItem,sgShop->Row);
         break;
       case 2:     //删除
         sgShop->RemoveItem(sgShop->Row);
    }
}
//---------------------------------------------------------------
void __fastcall TfrmShop::FillGridWithData()
{
    AnsiString ItemStr;
    comServer->MoveFirst();
    sgShop->RowCount=1;
    while (comServer->Eof == 0)
    {
      ItemStr = GetDataToGrid();
      sgShop->AddItem(ItemStr);
      comServer->MoveNext();
    }
}
//---------------------------------------------------------------
void __fastcall TfrmShop::FormShow(TObject *Sender)
{
    if(comServer->RecordCount>0)
    {
      FillGridWithData();
      comServer->MoveFirst();
      GetDataFromComObject();
    }
    else
    {
      ClearControl(false);
      sgShop->RowCount=1;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::FormClose(TObject *Sender, TCloseAction &Action)
{
    TRecBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------

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


⌨️ 快捷键说明

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