当前位置:网站首页>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
边栏推荐
- HCIP第十三天
- 爱可可AI前沿推介(7.24)
- Group intelligence decision-making in an open environment: concepts, challenges and leading technologies
- Windivert: capture and modify packages
- 户外广告牌不能“想挂就挂”!广州城管部门加强户外广告安全管理
- vscode配置用户代码片段(包括删除方法)
- 如何画 贝赛尔曲线 以及 样条曲线?
- How to quickly learn Embedded
- 2022.07.21
- Kunyu installation details
猜你喜欢

Group intelligence decision-making in an open environment: concepts, challenges and leading technologies

Handler learning

网络安全——报错注入

ESP32ADC

从云原生到智能化,深度解读行业首个「视频直播技术最佳实践图谱」

汉字风格迁移篇---无监督排版传输

浅谈Node Embedding

Detailed explanation of odoo JS DoAction

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

Overview of multi view learning methods based on canonical correlation analysis
随机推荐
I 用c I 实现 大顶堆
Integer inversion of force deduction questions
Outdoor billboards cannot be hung up if you want! Guangzhou urban management department strengthens the safety management of outdoor advertising
Adjust the array order so that odd numbers precede even numbers
如何用WebGPU流畅渲染百万级2D物体?
How can the easycvr platform access special devices without authentication?
Handler learning
Introduction to single chip microcomputer
网络安全——Cookie注入
LeadTools 22 kit LeadTools super set
为什么函数式接口 Comparator 中有 “两个抽象方法”?
Number of palindromes in Li Kou question
Chinese character style migration --- diversity regularization stargan for Chinese character multi font generation
WSDM 22 | graph recommendation based on hyperbolic geometry
Introduction of embedded network interface scheme and summary of driver debugging methods
Research on data governance quality assurance
网络安全——服务漏洞扫描与利用
EAS environment structure directory
Aggregation measurement of robot swarm intelligence based on group entropy
基于典型相关分析的多视图学习方法综述