執行程式–>登入介面–>驗證使用者名稱和密碼–>進入主介面
建立乙個cardb資料庫,並使用該資料庫
create database cardb;
use cardb;
建立使用者表(user),並往裡面插入資料
create table user(
id int not null auto_increment primary key,
user varchar(20),
pwd varchar(20)
);insert into user(user,pwd) values('tom','tom');
insert into user(user,pwd) values('djx','djx');
insert into user(user,pwd) values('xiu','xiu');
建立廠商表(factory),並插入資料
create table factory(id int not null auto_increment primary key,
name varchar(255)
)engine=innodb default charset=utf8;
insert into factory(name) values('大眾');
insert into factory(name) values('華晨寶馬');
insert into factory(name) values('東風日產');
insert into factory(name) values('林肯');
建立品牌表(brand),並插入資料
create table brand(id int not null auto_increment primary key,
name varchar(255),fname varchar(255),
color varchar(255),price int not null,
sum int not null,sell int not null,
last int not null
)engine=innodb default charset=utf8;
insert into brand(name,fname,color,price,sum,sell,last) values('甲殼蟲','大眾','白色',20,520,250,270);
insert into brand(name,fname,color,price,sum,sell,last) values('奧迪a6','大眾','金色',20,520,250,270);
insert into brand(name,fname,color,price,sum,sell,last) values('寶馬x3','華晨寶馬','白色',35,520,250,270);
insert into brand(name,fname,color,price,sum,sell,last) values('寶馬x4','華晨寶馬',' 金色,35,520,250,270);
insert into brand(name,fname,color,price,sum,sell,last) values('貴士','東風日產','金色',20,520,250,270);
insert into brand(name,fname,color,price,sum,sell,last) values('林肯mkc','林肯','白色',36,520,250,270);
登入介面如下所示:
鏈結資料庫
bool login::connectdb()
return true;
}
登入按鈕槽函式的實現
void login::on_ulogin_clicked()
if(name.isempty())
bool flag = false;
qsqlquery query;
qstring sql = qstring("select pwd from user where user = '%1'").arg(name);
query.exec(sql);
while(query.next())
}if(flag)else
}
寫配置檔案的函式
//將使用者名稱和密碼寫入到配置檔案中
void login::writeinit(qstring key, qstring value)
退出按鈕的槽函式
void login::on_quit_clicked()
在main函式中判斷,如果登入成功,顯示主頁面。如果是關閉,則終止程式
int main(int argc, char *ar**)
else
}
在主介面函式中讀配置檔案(讀出登入時候寫入配置檔案的使用者名稱和密碼)
void mainwindow::readinit(qstring key, qstring &value)
//從配置檔案中讀取使用者名稱和密碼
void mainwindow::loadcfg()
qt 汽車管理系統
介面設計 執行後介面 資料庫表 connection.h檔案 ifndef connection h define connection h include include include include include static bool createconnection if d.open ...
跨域實現統一登入
很多時候,如果沒有理解原理,做起事來會感覺無從下手 困難重重,一旦把原理想清楚了,做起來就會從容不迫。切入正題 在相同網域名稱下實現統一認證單點登入比較簡單,基於cookie結合共享redis就可以輕鬆實現。在同乙個網域名稱下,不同的系統共享相同的cookie,認證中心可以將會話id 伺服器的ses...
細說學生管理系統(一)
管理系統算是自己敲得第乙個完整的軟體 雖然很爛 雖然它連雞窩都不算 雖然有原始碼參考 但是通過這個小小的軟體還是讓自己學到了很多 學會了如何從乙個程式設計師的角度思考問題 如何站在使用者的角度思考問題.下面就說說自己在做整個軟體過程中的一些收穫 分為三部分 一 前期工作。二 實現過程。三 除錯,打包...