当前位置:网站首页>Simple order management system small exercise
Simple order management system small exercise
2022-07-24 13:35:00 【51CTO】
asp.net mvc Field assignment method
Effect display

The front-end code
<
div
class
=
"container"
>
<
div
class
=
"info"
>
<
p
style
=
"font-size:30px;margin:12px auto;width:300px;"
>
Simple order management system
</
p
>
<
hr
/>
<
a
href
=
"Home/Add"
>
Add order
</
a
>
<
table
class
=
"table table-bordered"
>
<
tr
style
=
"background-color:aquamarine"
>
<
th
>
The order no.
</
th
>
<
th
>
Next single
</
th
>
<
th
>
Order date
</
th
>
<
th
>
The order status
</
th
>
<
th
>
operation
</
th
>
</
tr
>
@foreach (
var
item
in
ViewBag.
Lists)
{
<
tr
>
<
td
>
@item.
OrderID
</
td
>
<
td
>
@item.
UserName
</
td
>
<
td
>
@item.
OrderDate.
ToString(
"yyyy year MM month dd Japan ")
</
td
>
@if (
@item.
OrderState
==
0)
{
<
td
style
=
"background-color:red"
>
Not delivered
</
td
>
<
td
><
a
href
=
"/Home/[email protected]"
>
deliver goods
</
a
></
td
>
}
else
{
<
td
>
Shipped
</
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.
Additive effect

The front-end code
<!
DOCTYPE
html
>
<
html
>
<
head
>
<
meta
name
=
"viewport"
content
=
"width=device-width"
/>
<
title
>
Add order
</
title
>
<
link
href
=
"~/Content/bootstrap.min.css"
rel
=
"stylesheet"
/>
</
head
>
<
body
>
<
div
class
=
"container"
>
<
p
style
=
"font-size:30px;margin-top:30px;"
>
Add order
</
p
>
<
hr
/>
<
form
action
=
"/Home/Add"
method
=
"post"
>
Next single
<
input
type
=
"text"
name
=
"UserName"
id
=
"UserName"
onblur
=
"checkName()"
class
=
"form-control"
style
=
"width:40%"
/><
span
id
=
"Message"
style
=
"color:red"
></
span
><
br
/>
Order date
<
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
=
" add to "
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(){
// Execute the form validation function before submitting the form checkForm
$(
"form").
bind(
"submit",
checkForm);
});
function
checkName() {
if (
$(
"#UserName").
val()
==
"") {
$(
"#Message").
html(
" The next person is required ");
$(
"#UserName").
focus();
return
false;
}
else {
$(
"#Message").
html(
"");
}
return
true;
// Verification passed
}
function
checkDate() {
if (
$(
"#OrderDate").
val()
==
"") {
$(
"#Messagedate").
html(
" Order date is required ");
$(
"#OrderDate").
focus();
return
false;
}
else {
$(
"#Messagedate").
html(
"");
}
return
true;
// Verification passed
}
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.
Background code
[
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
=
" Add failure ";
return
View();
}
}
ViewBag.
message
=
" Value is empty ";
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.
Shipment background code
边栏推荐
- How can the easycvr platform access special devices without authentication?
- Windivert:可抓包,修改包
- Spelling words~
- Representation and basic application of regular expressions
- [acm/ two points] two points clear entry-level explanation
- Redis(13)----浅谈Redis的主从复制
- 【论文阅读】TEMPORAL ENSEMBLING FOR SEMI-SUPERVISED LEARNING
- Dtcloud uses custom fonts
- C code specification
- Research on data governance quality assurance
猜你喜欢

How to draw Bezier curve and spline curve?

网络安全——WAR后门部署

网络安全——报错注入

网络安全——Cookie注入

How to generate expected data? Emory University and others' latest "deep learning controllable data generation" review, 52 page PDF, covering 346 documents, comprehensively expounds the controllable g

Thread multithreading

2022.07.21

Vscode configuration user code snippet (including deletion method)

EAS approval process related table

网络安全——Web信息收集
随机推荐
From cloud native to intelligent, in-depth interpretation of the industry's first "best practice map of live video technology"
Summary of embedded network problems (packet loss of network card, unrecognized network card)
Data + AI summit 2022 PPT download
Easycvr platform security scanning prompt go pprof debugging information leakage solution
The core capability of accelerating enterprise data application innovation flexibility
支持鹏程系列开源大模型应用生态演化的可持续学习能力探索
EAS environment structure directory
Selenium environment configuration and eight elements positioning
Can communication protocol (I)
群体知识图谱:分布式知识迁移与联邦式图谱推理
基于典型相关分析的多视图学习方法综述
指针进阶部分(1)
Finclip's "applet export app" function has been updated again by the company
网络安全——WAR后门部署
简易订单管理系统小练习
Embedded problem troubleshooting methods, network problems, SD card problems, device startup problems, serial port problems, I2C problems, SPI problems, PCIe problems, etc
I realize large top stack with C I
Implementation of dynamic columns in EAS BOS doc list
脑注意力机制启发的群体智能协同避障方法
FinClip 「小程序导出 App 」功能又双叒叕更新了