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

📄 findcustno.cpp

📁 某公司资料管理系统
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "FindCustNo.h"
#include "DataModule.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFindCustNoForm *FindCustNoForm;
//---------------------------------------------------------------------------
__fastcall TFindCustNoForm::TFindCustNoForm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFindCustNoForm::OrderComboxChange(TObject *Sender)
{
    MastData->CustLookup->Close();
    if (OrderCombox->Text == "客户编号")
    {
        SrchFld = DataSource->DataSet->FieldByName("CustomerNo");
        MastData->CustLookup->IndexName="CustomerNo";
    }
    if(OrderCombox->Text == "客户名称")
    {
        SrchFld =DataSource->DataSet->FieldByName("Company");
    MastData->CustLookup->IndexName="Company";
    }
     SearchEdit->Text = "";
    MastData->CustLookup->Open();
}
//---------------------------------------------------------------------------
void __fastcall TFindCustNoForm::FormShow(TObject *Sender)
{

   MastData->CustLookup->Open();
}
//---------------------------------------------------------------------------
void __fastcall TFindCustNoForm::DBGrid1DblClick(TObject *Sender)
{
    ModalResult = mrOk;
}
//---------------------------------------------------------------------------
void __fastcall TFindCustNoForm::SearchEditChange(TObject *Sender)
{
   SearchBtn->Enabled =  !SearchEdit->Text.IsEmpty();
}
//---------------------------------------------------------------------------
void __fastcall TFindCustNoForm::SearchEditKeyPress(TObject *Sender,
      char &Key)
{
    if ((SrchFld!=NULL) && (Key != ' ') &&  !SrchFld->IsValidChar(Key) )
    {
       MessageBeep(0);
       Key = '0';
    }
    else
    {
      if(int(Key)==13)
      {
         SearchBtnClick(Sender);
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TFindCustNoForm::SearchBtnClick(TObject *Sender)
{
  TLocateOptions flags;
  flags << loPartialKey << loCaseInsensitive;
  if (OrderCombox->Text == "客户编号")
  {
      if (!DataSource->DataSet->Locate("CustomerNo", SearchEdit->Text, flags))
      MessageBox(NULL,"查无此记录...", "提示", MB_OK);
  }
  if(OrderCombox->Text == "客户名称")
  {
      if (!DataSource->DataSet->Locate("Company", SearchEdit->Text, flags))
      MessageBox(NULL,"查无此记录...", "提示", MB_OK);
  }

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

⌨️ 快捷键说明

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