最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

mvc C# JavaScript LigerUI oracle實現(xiàn)用戶的注冊、登陸驗證、登陸

 更新時間:2021年09月22日 10:08:03   投稿:mrr  
這篇文章主要介紹了mvc C# JavaScript LigerUI oracle實現(xiàn)用戶的注冊、登陸驗證、登陸的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

一、登錄數(shù)據(jù)庫,在數(shù)據(jù)庫中創(chuàng)建表User00,并且插入數(shù)據(jù)。

表的字段分別為:

Id(編號)、Name(姓名)、Grid(級別)、Score(積分)、Password(密碼)、Age(年齡)、Code(邀請碼)。(其中編號是自動編號)

部分命令如下:

select * from User00; /*查詢User00*/
insert into User00 values('one','優(yōu)',10000,'123',24); /*插入一行數(shù)據(jù)*/
update User00 set Grid='優(yōu)' where Id=001; /*更新已存在數(shù)據(jù)*/
delete from User00; /*刪除表里所有數(shù)據(jù)*/
alter table User00 rename Code to Code; /*更改字段名*/
update User00 set Code =null; /*刪除某一列所有數(shù)據(jù)*/
alter table User00 add Age number; /* user00中插入一列*/
alter table User00 modify Age varchar2(4); /*更改某字段類型*/
delete from User00 where Score is null; /*刪除密碼為空的所有行*/

二、新建mvc項目kaohe00,添加一個控制器Home。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Model;
using log4net;
using System.Reflection;
//using Bll;
namespace kaohe00.Models
{
public class HomeController : Controller
{
//
//數(shù)據(jù)庫 數(shù)據(jù)庫的
private static Bll.Test00 test00 = new Bll.Test00("Data Source=YWW;User Id=Test00;Password=Test00;"); //連接數(shù)據(jù)庫
// GET: /Home/
public ActionResult Index() //顯示主頁的動作方法
{
return View();
}
public JsonResult ShowInfo() //把數(shù)據(jù)庫里的表的數(shù)據(jù)發(fā)送到前臺的方法
{
var list = test00.GetList(); //
return Json(new { Rows = list, Total = list.Count }, JsonRequestBehavior.AllowGet);
}
public ActionResult Register() //注冊的動作方法
{
return View();
}
}
} 

三、為Home的Index添加一個視圖,顯示主頁的信息,將數(shù)據(jù)庫的表User00的數(shù)據(jù)放到主頁視圖的表格中。

1、主頁視圖代碼:

@{
ViewBag.Title = "Index";
}
<script src="~/Content/jquery/jquery-1.9.0.min.js"></script>
<script src="~/Content/script/common.js"></script>
<script src="~/Content/ligerui/ligerui.all.js"></script>
<link href="~/Content/ligerui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" />
<head>
<title>我的主頁</title>
</head>
<div id="maingrid"></div>
<script type="text/javascript">
$(function () {
$("#maingrid").ligerGrid({
columns: [
{ display: '編號', name: 'Id',heigth:100,width:250 },
{ display: '姓名', name: 'Name', heigth: 100, width: 250 },
{ display: '積分', name: 'Score', heigth: 100, width: 250 },
{ display: '密碼', name: 'Password', heigth: 100, width: 250 },
{ display: '級別', name: 'Grid', heigth: 100, width: 250 },
{ display: '邀請碼', name: 'Code', heigth: 100, width: 250 }
],
url: "/Home/ShowInfo", //調(diào)用顯示自己信息的動作方法
});
});
</script> 

2、主頁視圖界面:

四、實現(xiàn)登錄功能

1、添加一個Login控制器。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace kaohe00.Controllers
{
public class LoginController : Controller
{
//
// GET: /Login/
//數(shù)據(jù)庫
private static Bll.Test00 test00 = new Bll.Test00("Data Source=YWW;User Id=Test00;Password=Test00;"); //連接數(shù)據(jù)庫
public ActionResult Index()
{
return View();
}
public JsonResult LoginTest(string Id ,string Password) //登錄驗證動作方法
{
var succ = test00.LoginTest(Id, Password);
return Json(new { Succ = succ });
}
}
}

2.1、為Login的Index添加一個視圖

視圖代碼:

@{
ViewBag.Title = "Index";
}
<script src="~/Content/jquery/jquery-1.9.0.min.js"></script>
<script src="~/Content/script/common.js"></script>
<script src="~/Content/ligerui/ligerui.all.js"></script>
<link href="~/Content/ligerui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" />
<head>
<title>登錄</title>
</head>
<div id="login">
<div id="Lform"></div>
</div>
<script type="text/javascript">
$(function () {
$("#Lform").ligerForm({
fields: [
{ display: "編號", name: "Id", newline: false, type: "text", },
{ display: "密碼", name: "Password", newline: true, type: "password", }
],
});
$.ligerDialog.open({
target: $("#login"),
title: "登錄",
allowClose: false,
buttons: [
{
text: '登錄', onclick: function (item, dialog) {
var form = liger.get("Lform");
var data = form.getData();
if(data.Id==""||data.Password=="")
{
alert("用戶名或密碼不能為空");
return false;
}
$.post("/Login/LoginTest", data, function (result) {
//alert(result.Succ);
if(result.Succ == true) {
window.document.location.href = "/Home/Index";
}
else {
alert("登錄失敗");
return false;
}
});
}
},
{
text: '注冊', onclick: function (item, dialog) {
window.document.location.href = "/Register/Index";
}
},
]
});
});
</script>

2.2、登錄視圖的界面:

五、實現(xiàn)注冊功能

1、添加一個注冊控制器Register

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Model;
using log4net;
using System.Reflection;
namespace kaohe00.Controllers
{
public class RegisterController : Controller
{
//數(shù)據(jù)庫
private static Bll.Test00 test00 = new Bll.Test00("Data Source=YWW;User Id=Test00;Password=Test00;");
//
// GET: /Register/
public ActionResult Index()
{
return View();
}
public JsonResult Register(User00 user00)
{ 
var succ=test00.AddNew(user00)>0?1:0;
return Json(new { Succ = succ }, JsonRequestBehavior.AllowGet);
}
}
}

2.1、為注冊控制器Register的index添加一個視圖

@{
ViewBag.Title = "Index";
}
<script src="~/Content/jquery/jquery-1.9.0.min.js"></script>
<script src="~/Content/script/common.js"></script>
<script src="~/Content/ligerui/ligerui.all.js"></script>
<link href="~/Content/ligerui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" />
<script src="scripts/jquery.validate.js" type="text/javascript"></script>
<head>
<title>注冊頁面</title>
</head>
<div id="reform"></div>
<div id="rebutton"><input style="margin-left:100px" type="button" value="注冊" onclick="register()"></div>
<script type="text/javascript">
function register() {
// alert("test");
var form = liger.get("reform");
// alert(form.name.getData);
var data = form.getData();
if (data.Name == "" || data.Password == ""||data.Grid == "")
{
alert("請完整填寫必填信息");
return false;
}
//alert("test");
$.post("/Register/Register", data,
function (data) {
alert("注冊成功");
window.document.location.href = "/Home/Index";
});
}
$(function () {
$("#reform").ligerForm({
inputWidth: 170, labelWidth: 90, space: 40,
fields: [
{ display: "姓名 ", name: "Name", newline: true, type: "text",validate:{required:true}},
{ display: "密碼", name: "Password", newline: true, type: "password", type: "text", validate: { required: true } },
{ display: "年齡", name: "Age", newline: true, type: "text" },
{ display: "會員級別", name: "Grid", newline: true, type: "text", type: "text", validate: { required: true } },
{ display: "邀請碼", name: "Code", newline: true, type: "text" }
],
});
});
</script> 

2.2注冊視圖的界面

六、為數(shù)據(jù)庫的表建立Model模型實體類,建立一個類文件命名為User00.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Model
{
/// <summary>
/// </summary>
public class User00
{
public int Id { get; set; }
public string Name { get; set; }
public string Grid { get; set; }
public int Score { get; set; }
public string Password { get; set; }
public int Age { get; set; }
public int Code { get; set; }
}
}

七、前文出現(xiàn)的Bll命名空間和類Test00等一些代碼是引用了另外的庫。

1、目錄

2、其中文件Test00的代碼:

using Blocks.Data;
using Blocks.Data.CustomType;
using Blocks.Data.DbProviders.Oracle;
using kaohe00.Mappings;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Bll
{
public class Test00
{
/// <summary>
/// 數(shù)據(jù)庫
/// </summary>
private Database oracle = null;
public Test00(string connectionString) 
{
this.oracle = new Database(new OracleDbProvider(connectionString));
this.oracle.Mappings(typeof(User00Mapping).Assembly);
}
public List<User00> GetList() //定義GetList函數(shù),其功能:獲得一個類型是User00類的列表相當(dāng)于數(shù)組
{
var list = this.oracle.Select<User00>().ToList();
return list;
}
public int AddNew(User00 user00)
{
return this.oracle.Insert(user00);
}
public bool LoginTest(string Id,string Password) //函數(shù)功能:判斷前臺穿的值是否在數(shù)據(jù)庫中的
{
// var search = this.oracle.Select<User00>();
// var list = search.Where(t => t.Id == int.Parse(Id)) && t.Password == Password; 
var search = this.oracle.Select<User00>().Where(t => t.Id == int.Parse(Id) && t.Password == Password);
var list = search.ToList(); //list相當(dāng)于數(shù)組
if (list.Count > 0) //??!!
{
//var user = list.First();
return true;
}
else
{
return false;
}
}
}
}

3、其中的kaohe00.Mappings文件里的User00Mapping.cs的文件的代碼:

using Blocks.Data.Mapping;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace kaohe00.Mappings
{
public class User00Mapping : ClassMap<User00>
{
public User00Mapping() 
{
Map(t => t.Id).AutoNumber();
Map(t => t.Name);
}
}
}

八、設(shè)置路徑: defaults: new { controller = "Login", action = "Index", id = UrlParameter.Optional },使其先執(zhí)行Login。

九、查看效果:

1、點擊登錄后密碼錯誤的情況:

或者

2、輸入正確的編號密碼,進入主頁視圖界面

3、點擊注冊后進入注冊視圖界面

4、在注冊界面輸入內(nèi)容,注冊失敗和成功的情況:

 

或者

注冊成功后點擊確定,進入主頁視圖界面

可以看到主頁視圖界面新添加的信息

好了,關(guān)于mvc C# JavaScript LigerUI oracle實現(xiàn)用戶的注冊、登陸驗證、登陸 的內(nèi)容就給大家介紹到這里,希望對大家有所幫助!

相關(guān)文章

  • WPF基礎(chǔ)教程之元素綁定詳解

    WPF基礎(chǔ)教程之元素綁定詳解

    這篇文章主要給大家介紹了關(guān)于WPF基礎(chǔ)教程之元素綁定的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-01-01
  • c# 委托和事件實例學(xué)習(xí)

    c# 委托和事件實例學(xué)習(xí)

    今天把委托和事件研究了一個,winForm環(huán)境下,一般的小例子都是字符界面,我為了運用一下,寫了winForm
    2009-01-01
  • C#?Unity使用正則表達式去除部分富文本的代碼示例

    C#?Unity使用正則表達式去除部分富文本的代碼示例

    正則表達式在我們?nèi)粘i_發(fā)中的用處不用多說了吧,下面這篇文章主要給大家介紹了關(guān)于C#?Unity使用正則表達式去除部分富文本的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-03-03
  • Unity實現(xiàn)新手引導(dǎo)鏤空效果

    Unity實現(xiàn)新手引導(dǎo)鏤空效果

    這篇文章主要為大家詳細(xì)介紹了Unity實現(xiàn)新手引導(dǎo)的鏤空效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-02-02
  • Expression操作運算符、表達式和操作方法總結(jié)

    Expression操作運算符、表達式和操作方法總結(jié)

    這篇文章詳細(xì)介紹了Expression操作運算符、表達式和操作方法總結(jié),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-01-01
  • 使用C#高效解析HTML的實戰(zhàn)指南

    使用C#高效解析HTML的實戰(zhàn)指南

    在網(wǎng)頁開發(fā)和數(shù)據(jù)處理的場景中,經(jīng)常需要從 HTML 文檔里提取有用的信息,C# 作為一門強大的編程語言,提供了豐富的工具和庫來實現(xiàn) HTML 的解析,這篇博客就帶你深入了解如何使用 C# 高效地解析 HTML
    2025-01-01
  • C# 對XML基本操作代碼總結(jié)

    C# 對XML基本操作代碼總結(jié)

    C# 對XML基本操作包括讀取節(jié)點的數(shù)據(jù),添加節(jié)點。讀取節(jié)點屬性,修改節(jié)點屬性等
    2011-10-10
  • C#實現(xiàn)的自定義郵件發(fā)送類完整實例(支持多人多附件)

    C#實現(xiàn)的自定義郵件發(fā)送類完整實例(支持多人多附件)

    這篇文章主要介紹了C#實現(xiàn)的自定義郵件發(fā)送類,具有支持多人多附件的功能,涉及C#郵件操作的相關(guān)技巧,需要的朋友可以參考下
    2015-12-12
  • C#如何遍歷Dictionary

    C#如何遍歷Dictionary

    這篇文章主要為大家詳細(xì)介紹了C#遍歷Dictionary的方法,.NET中的Dictionary是鍵/值對的集合,使用起來比較方便,Dictionary也可以用KeyValuePair來迭代遍歷,感興趣的小伙伴們可以參考一下
    2016-04-04
  • c# 類型構(gòu)造器

    c# 類型構(gòu)造器

    CLR還支持類型構(gòu)造器,也稱為靜態(tài)構(gòu)造器。c#類型構(gòu)造器可應(yīng)用引用類型和值類型,永遠(yuǎn)沒有參數(shù)
    2012-10-10

最新評論

双城市| 莱州市| 乡城县| 阳信县| 荃湾区| 介休市| 南平市| 色达县| 沂南县| 黔江区| 永平县| 哈尔滨市| 神池县| 油尖旺区| 五常市| 个旧市| 靖江市| 富民县| 孟州市| 九江县| 布拖县| 乐陵市| 水富县| 巨野县| 龙陵县| 苗栗县| 鹰潭市| 叙永县| 林芝县| 玉树县| 庐江县| 宜川县| 辽源市| 漳浦县| 阿瓦提县| 柳河县| 秦皇岛市| 晋城| 民乐县| 临西县| 栖霞市|