当前位置:网站首页>简易订单管理系统小练习
简易订单管理系统小练习
2022-07-24 13:29:00 【51CTO】
asp.net mvc 字段赋值方式
效果展示

前端代码
<
div
class
=
"container"
>
<
div
class
=
"info"
>
<
p
style
=
"font-size:30px;margin:12px auto;width:300px;"
>
简易订单管理系统
</
p
>
<
hr
/>
<
a
href
=
"Home/Add"
>
添加订单
</
a
>
<
table
class
=
"table table-bordered"
>
<
tr
style
=
"background-color:aquamarine"
>
<
th
>
订单编号
</
th
>
<
th
>
下单人
</
th
>
<
th
>
订单日期
</
th
>
<
th
>
订单状态
</
th
>
<
th
>
操作
</
th
>
</
tr
>
@foreach (
var
item
in
ViewBag.
Lists)
{
<
tr
>
<
td
>
@item.
OrderID
</
td
>
<
td
>
@item.
UserName
</
td
>
<
td
>
@item.
OrderDate.
ToString(
"yyyy年MM月dd日")
</
td
>
@if (
@item.
OrderState
==
0)
{
<
td
style
=
"background-color:red"
>
未发货
</
td
>
<
td
><
a
href
=
"/Home/[email protected]"
>
发货
</
a
></
td
>
}
else
{
<
td
>
已发货
</
td
>
<
td
></
td
>
}
</
tr
>
}
</
table
>
</
div
>
</
div
>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
添加效果

前端代码
<!
DOCTYPE
html
>
<
html
>
<
head
>
<
meta
name
=
"viewport"
content
=
"width=device-width"
/>
<
title
>
添加订单
</
title
>
<
link
href
=
"~/Content/bootstrap.min.css"
rel
=
"stylesheet"
/>
</
head
>
<
body
>
<
div
class
=
"container"
>
<
p
style
=
"font-size:30px;margin-top:30px;"
>
添加订单
</
p
>
<
hr
/>
<
form
action
=
"/Home/Add"
method
=
"post"
>
下单人
<
input
type
=
"text"
name
=
"UserName"
id
=
"UserName"
onblur
=
"checkName()"
class
=
"form-control"
style
=
"width:40%"
/><
span
id
=
"Message"
style
=
"color:red"
></
span
><
br
/>
订单日期
<
input
type
=
"date"
name
=
"OrderDate"
id
=
"OrderDate"
class
=
"form-control"
style
=
"width:40%"
/><
span
id
=
"Messagedate"
style
=
"color:red"
></
span
><
br
/><
br
/>
<
input
type
=
"submit"
class
=
"btn btn-block"
value
=
"添加"
style
=
"width:10%;margin-left:150px;"
/><
br
/>
<
span
>
@ViewBag.
message
</
span
>
</
form
>
</
div
>
<
script
src
=
"~/Scripts/jquery-3.4.1.min.js"
></
script
>
<
script
type
=
"text/javascript"
>
$(
function(){
//提交表单之前执行表单验证函数 checkForm
$(
"form").
bind(
"submit",
checkForm);
});
function
checkName() {
if (
$(
"#UserName").
val()
==
"") {
$(
"#Message").
html(
"下单人是必填项");
$(
"#UserName").
focus();
return
false;
}
else {
$(
"#Message").
html(
"");
}
return
true;
//验证通过
}
function
checkDate() {
if (
$(
"#OrderDate").
val()
==
"") {
$(
"#Messagedate").
html(
"订单日期是必填项");
$(
"#OrderDate").
focus();
return
false;
}
else {
$(
"#Messagedate").
html(
"");
}
return
true;
//验证通过
}
function
checkForm() {
if (
checkName()
&&
checkDate())
return
true;
return
false;
}
</
script
>
</
body
>
</
html
>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
后台代码
[
HttpGet]
public
ActionResult
Add()
{
return
View();
}
[
HttpPost]
public
ActionResult
Add(
OrderInfo
o)
{
if (
o
!=
null)
{
db.
OrderInfo.
Add(
o);
int
a
=
db.
SaveChanges();
if (
a
==
1)
{
return
RedirectToAction(
"Index");
}
else
{
ViewBag.
message
=
"添加失败";
return
View();
}
}
ViewBag.
message
=
"值为空";
return
View();
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
发货后台代码
边栏推荐
- Collection collection framework
- LeadTools 22 kit LeadTools super set
- 基于社会媒体数据增强的交通态势感知研究及进展
- July training (day 24) - segment tree
- EAS approval process related table
- vscode配置用户代码片段(包括删除方法)
- Mass data excel download - the author of this article only tried to download 510000 data, which took 7 seconds
- About the concept of thread (1)
- binary search
- Solution to embedded SD card /u disk read-only problem (fat read-only repair method)
猜你喜欢

Packaging class (mutual conversion between types)
![[datasheet] interpretation of cs5480 data book of metering chip](/img/1a/e8a4ce5c393a6634b6dc8bf6d687e2.png)
[datasheet] interpretation of cs5480 data book of metering chip

Modern data architecture selection: Data fabric, data mesh

开山之作造假!Science大曝Nature重磅论文学术不端,恐误导全球16年

flow

Outdoor billboards cannot be hung up if you want! Guangzhou urban management department strengthens the safety management of outdoor advertising

SSM online examination system including documents

Voice recognition based on MATLAB

爱可可AI前沿推介(7.24)

36. Delete the penultimate node of the linked list
随机推荐
DDD based on ABP -- Entity creation and update
Experience on how to improve the anti-interference of TTL (UART) communication
C code specification
How can flinksql run in perjob mode on yarn? I submit tasks on SqlClient
Atcoder beginer contest 261e / / bitwise thinking + DP
Two stacks implement one queue
Search engine based on boost library
An example of how to save various data types by using esp32 EEPROM library functions under Arduino framework
Research on data governance quality assurance
户外广告牌不能“想挂就挂”!广州城管部门加强户外广告安全管理
Introduction to encryption technology
29. Right view of binary tree
Make a fake! Science has exposed the academic misconduct of nature's heavy papers, which may mislead the world for 16 years
Happy number ~ ~ ~ (in fact, I'm not happy at all) & ugly number
现代数据架构选型:Data Fabric、Data Mesh
SSM online examination system including documents
Introduction to the use of thread (2) thread
Chrome plug-in development tutorial
Introduction of embedded network interface scheme and summary of driver debugging methods
Wang Ping, co-founder of Denglin Technology: Innovation + self research "dual core" drive, gpu+ enabling AI takes root | quantum bit · viewpoint sharing review