欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

表的字段分別為:

Id(編號(hào))、Name(姓名)、Grid(級(jí)別)、Score(積分)、Password(密碼)、Age(年齡)、Code(邀請(qǐng)碼)。(其中編號(hào)是自動(dòng)編號(hào))

部分命令如下:

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項(xiàng)目kaohe00,添加一個(gè)控制器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ù)庫(kù) 數(shù)據(jù)庫(kù)的
private static Bll.Test00 test00 = new Bll.Test00("Data Source=YWW;User Id=Test00;Password=Test00;"); //連接數(shù)據(jù)庫(kù)
// GET: /Home/
public ActionResult Index() //顯示主頁(yè)的動(dòng)作方法
{
return View();
}
public JsonResult ShowInfo() //把數(shù)據(jù)庫(kù)里的表的數(shù)據(jù)發(fā)送到前臺(tái)的方法
{
var list = test00.GetList(); //
return Json(new { Rows = list, Total = list.Count }, JsonRequestBehavior.AllowGet);
}
public ActionResult Register() //注冊(cè)的動(dòng)作方法
{
return View();
}
}
} 

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

1、主頁(yè)視圖代碼:

@{
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>我的主頁(yè)</title>
</head>
<div id="maingrid"></div>
<script type="text/javascript">
$(function () {
$("#maingrid").ligerGrid({
columns: [
{ display: '編號(hào)', 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: '級(jí)別', name: 'Grid', heigth: 100, width: 250 },
{ display: '邀請(qǐng)碼', name: 'Code', heigth: 100, width: 250 }
],
url: "/Home/ShowInfo", //調(diào)用顯示自己信息的動(dòng)作方法
});
});
</script> 

2、主頁(yè)視圖界面:

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

1、添加一個(gè)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ù)庫(kù)
private static Bll.Test00 test00 = new Bll.Test00("Data Source=YWW;User Id=Test00;Password=Test00;"); //連接數(shù)據(jù)庫(kù)
public ActionResult Index()
{
return View();
}
public JsonResult LoginTest(string Id ,string Password) //登錄驗(yàn)證動(dòng)作方法
{
var succ = test00.LoginTest(Id, Password);
return Json(new { Succ = succ });
}
}
}

2.1、為L(zhǎng)ogin的Index添加一個(gè)視圖

視圖代碼:

@{
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: "編號(hào)", 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: '注冊(cè)', onclick: function (item, dialog) {
window.document.location.href = "/Register/Index";
}
},
]
});
});
</script>

2.2、登錄視圖的界面:

五、實(shí)現(xiàn)注冊(cè)功能

1、添加一個(gè)注冊(cè)控制器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ù)庫(kù)
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、為注冊(cè)控制器Register的index添加一個(gè)視圖

@{
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>注冊(cè)頁(yè)面</title>
</head>
<div id="reform"></div>
<div id="rebutton"><input style="margin-left:100px" type="button" value="注冊(cè)" 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("請(qǐng)完整填寫必填信息");
return false;
}
//alert("test");
$.post("/Register/Register", data,
function (data) {
alert("注冊(cè)成功");
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: "會(huì)員級(jí)別", name: "Grid", newline: true, type: "text", type: "text", validate: { required: true } },
{ display: "邀請(qǐng)碼", name: "Code", newline: true, type: "text" }
],
});
});
</script> 

2.2注冊(cè)視圖的界面

六、為數(shù)據(jù)庫(kù)的表建立Model模型實(shí)體類,建立一個(gè)類文件命名為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等一些代碼是引用了另外的庫(kù)。

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ù)庫(kù)
/// </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ù),其功能:獲得一個(gè)類型是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ù)功能:判斷前臺(tái)穿的值是否在數(shù)據(jù)庫(kù)中的
{
// 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、點(diǎn)擊登錄后密碼錯(cuò)誤的情況:

或者

2、輸入正確的編號(hào)密碼,進(jìn)入主頁(yè)視圖界面

3、點(diǎn)擊注冊(cè)后進(jìn)入注冊(cè)視圖界面

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

 

或者

注冊(cè)成功后點(diǎn)擊確定,進(jìn)入主頁(yè)視圖界面

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

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

相關(guān)文章

  • C#里SuperSocket庫(kù)不能發(fā)現(xiàn)命令的原因

    C#里SuperSocket庫(kù)不能發(fā)現(xiàn)命令的原因

    這篇文章主要介紹C#里SuperSocket庫(kù)不能發(fā)現(xiàn)命令的原因,在使用SuperSocket來(lái)寫服務(wù)器的過(guò)程中,這是一個(gè)非??焖俚拈_發(fā)方式,也非常好用。不過(guò)學(xué)習(xí)的曲線有點(diǎn)高,在使用的過(guò)程中經(jīng)常會(huì)遇到各種各樣的問(wèn)題。下面來(lái)看看學(xué)習(xí)舉例說(shuō)明吧
    2021-10-10
  • C# XML中的轉(zhuǎn)義字符操作

    C# XML中的轉(zhuǎn)義字符操作

    這篇文章主要介紹了C# XML中的轉(zhuǎn)義字符操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-01-01
  • 重溫C# clr 筆記總結(jié)

    重溫C# clr 筆記總結(jié)

    本篇文章是對(duì)以前學(xué)習(xí)C# clr做的一些筆記,現(xiàn)在拿出來(lái)和大家分享下,希望需要的朋友能參考一下
    2013-05-05
  • C#實(shí)現(xiàn)獲取機(jī)器碼的示例詳解

    C#實(shí)現(xiàn)獲取機(jī)器碼的示例詳解

    這篇文章主要為大家詳細(xì)介紹了如何利用C#實(shí)現(xiàn)獲取機(jī)器碼的功能,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下
    2022-12-12
  • C# DoubleClick與MouseDoubleClick區(qū)別,雙擊事件引發(fā)順序

    C# DoubleClick與MouseDoubleClick區(qū)別,雙擊事件引發(fā)順序

    從邏輯上來(lái)說(shuō),由于比MouseDoubleClick 描述更抽象,DoubleClick 事件是控件的更高級(jí)別的事件
    2009-09-09
  • 使用TypeScript開發(fā)微信小程序的方法

    使用TypeScript開發(fā)微信小程序的方法

    TypeScript是C#之父Anders Hejlsberg的又一力作,很多喜歡c#語(yǔ)法的朋友對(duì)typescript都愛(ài)不釋手,今天小編給大家介紹下TypeScript開發(fā)微信小程序的方法,感興趣的朋友一起看看吧
    2016-11-11
  • C#使用post發(fā)送和接收數(shù)據(jù)的方法

    C#使用post發(fā)送和接收數(shù)據(jù)的方法

    這篇文章主要介紹了C#使用post發(fā)送和接收數(shù)據(jù)的方法,涉及C#使用post收發(fā)數(shù)據(jù)的相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-04-04
  • 詳解WPF中值轉(zhuǎn)換器的使用方法

    詳解WPF中值轉(zhuǎn)換器的使用方法

    在WPF(Windows Presentation Foundation)中,值轉(zhuǎn)換器(Value Converter)是一種機(jī)制,允許你在綁定時(shí)轉(zhuǎn)換綁定源和綁定目標(biāo)之間的值,本文給大家介紹了WPF中值轉(zhuǎn)換器的使用方法,需要的朋友可以參考下
    2024-02-02
  • C#利用Refit實(shí)現(xiàn)JWT自動(dòng)續(xù)期詳解

    C#利用Refit實(shí)現(xiàn)JWT自動(dòng)續(xù)期詳解

    Refit?是一個(gè)受到Square的Retrofit庫(kù)(Java)啟發(fā)的自動(dòng)類型安全REST庫(kù),這篇文章主要為大家介紹了C#如何利用Refit實(shí)現(xiàn)JWT自動(dòng)續(xù)期,感興趣的可以了解下
    2023-08-08
  • C#使用ZXing實(shí)現(xiàn)二維碼和條形碼的生成

    C#使用ZXing實(shí)現(xiàn)二維碼和條形碼的生成

    這篇文章主要為大家詳細(xì)介紹了C#如何使用ZXing實(shí)現(xiàn)二維碼和條形碼的生成與識(shí)別,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-11-11

最新評(píng)論