unit9.cpp
来自「CBUILDER+SQL的实现」· C++ 代码 · 共 57 行
CPP
57 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit9.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm9 *Form9;
//---------------------------------------------------------------------------
__fastcall TForm9::TForm9(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm9::BitBtn2Click(TObject *Sender)
{
LabeledEdit1->Text="";
LabeledEdit2->Text="";
LabeledEdit3->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm9::BitBtn1Click(TObject *Sender)
{
Query1->Close();
Query1->SQL->Clear();
AnsiString strSQL="select password from Users ";
strSQL+="where user_name='"+Label1->Caption+"'";
Query1->SQL->Add(strSQL);
Query1->Prepare();
Query1->Open();
if(Query1->FieldByName("password")->AsString!=LabeledEdit1->Text)
{ //旧密码错误
MessageBox(Handle,"请重新输入","密码错误",MB_OK);
}
else if(LabeledEdit2->Text==LabeledEdit3->Text)//修改密码
{
Query1->Close();
Query1->SQL->Clear();
strSQL="update Users set password='"+LabeledEdit2->Text+"'";
strSQL+=" where user_name='"+Label1->Caption+"'";
Query1->SQL->Add(strSQL);
Query1->Prepare();
//Query1->Open();
ShowMessage("密码修改成功!");
}
else
{
MessageBox(Handle,"密码不一至!","信息提示",MB_OK);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?