📄 query5_2.cpp
字号:
#include"DispensaryManage.h"
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Query5_2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
extern void HISQuery(TQuery*qPtr,String&s,bool b);
extern void showMedType(TQuery* obj1,TComboBox* obj2);
extern void showMedicine(TQuery* obj1,TComboBox* obj2,String s);
bool isDouble(AnsiString str)
{
bool b=false;
str=str.TrimLeft().TrimRight();
if(!str.IsEmpty())
{
int i=1,point=0,l=str.Length();
if(!(l==1&&(str=="."||str=="-")))
{
char c;
i=1;
while(i<=1)
{
c=str[i];
if((c>47&&c<58)||c==45||c==46)
{
if(c==45)
{if(i!=1)break;}
if(c==46)
{if((++point)==2)break;}
++i;
}
else break;
}
if(i>1)b=true;
}
}
return b;
}
TQueryForm5_2 *QueryForm5_2;
//---------------------------------------------------------------------------
__fastcall TQueryForm5_2::TQueryForm5_2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TQueryForm5_2::FormActivate(TObject *Sender)
{
RadioGroup1->ItemIndex=0;
RadioGroup2->ItemIndex=0;
}
//---------------------------------------------------------------------------
void __fastcall TQueryForm5_2::RadioGroup1Click(TObject *Sender)
{
if(RadioGroup1->ItemIndex==0)
{
String sql="select ID,name,price,factory from StorageGoods";
HISQuery(Query1,sql,true);
}
}
//---------------------------------------------------------------------------
void __fastcall TQueryForm5_2::RadioGroup2Click(TObject *Sender)
{
int i=RadioGroup2->ItemIndex;
if(i==0)
{Label2->Caption="输入系数(例如0.9或1.1):";}
else if(i==1)
{Label2->Caption="输入具体值(例如1或-1):";}
}
//---------------------------------------------------------------------------
void __fastcall TQueryForm5_2::Button2Click(TObject *Sender)
{
TDataSet* pDS=DBGrid1->DataSource->DataSet;
int i,choice1=RadioGroup1->ItemIndex,choice2=RadioGroup2->ItemIndex;
String sql="",s1,s2="";
if(choice1>=0&&choice2>=0)
{
if(isDouble(Edit1->Text))
{
if(choice1==1)
{
s2=pDS->Fields->Fields[0]->AsString;
s2="where ID='"+s2+"'" ;
}
if(choice2==0)s1="*";
else s1="+";
sql="update StorageGoods set price=price"+s1+"("+Edit1->Text+")"+s2;
HISQuery(Query1,sql,false);
sql="select ID,name,price,factory from StorageGoods";
{HISQuery(Query1,sql,true);}
}
else
{ShowMessage("输入非法数值!");}
}
else
{ShowMessage("请选择调价纪录范围以及调价方式!");}
}
//---------------------------------------------------------------------------
void __fastcall TQueryForm5_2::Button1Click(TObject *Sender)
{
this->Close();
RadioGroup1->ItemIndex=-1;
RadioGroup2->ItemIndex=-1;
Edit1->Text="";
DispensaryManageForm->Visible=true;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -