关于c#购物车的地址的增删改查(mvc,详细注释)
2020-12-24 20:26
标签:cli ring models let sel order b16 main 增删改查 就是简简单单的增删改查,也没什么特殊的或者特别难的业务逻辑,二级联动用一张表的自连接做的,注释都加在代码中了,不多说了,代码如下: 1.首先是我们的实体类数据模型层(model) 地址详情表: 二级联动用的区域表: 2.ado调用: 地址的dal层: 省市及添加,反填的dal层: 这两个ado调用层其实可以写在一块的,具体看您要实现的功能及要求: 3.控制器(视图)如下(这里其实创建一个控制器就好,具体看要求): 4.视图层:(view) 地址显示视图: 地址修改视图: 地址添加视图: 5.还望大佬们多多提一些修改意见,我会努力慢慢去改正的. 关于c#购物车的地址的增删改查(mvc,详细注释) 标签:cli ring models let sel order b16 main 增删改查 原文地址:https://www.cnblogs.com/bwxw/p/13420281.htmlusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace G5.Exam03.Day12.Models
{
public class ShAddress
{
public int AId { get; set; }
public string AName { get; set; }
public string Area { get; set; }
public string Dzhi { get; set; }
public string hanSet { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace G5.Exam03.Day12.Models
{
public class Qy
{
public int Id { get; set; }
public string Name { get; set; }
public int QId { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using G5.Exam03.Day12.Models;
namespace G5.Exam03.Day12.Dal
{
public class AddressDal
{
DBHelper db = new DBHelper();
//地址显示
public List
using G5.Exam03.Day12.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace G5.Exam03.Day12.Dal
{
public class AddDal
{
DBHelper db = new DBHelper();
//省市下拉
public List
using G5.Exam03.Day12.Dal;
using G5.Exam03.Day12.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
namespace G5.Exam03.Day12.Controllers
{
public class AddressController : Controller
{
AddressDal dal = new AddressDal();
// GET: Address
public ActionResult Index()
{
return View();
}
public int Del(int id)
{
return dal.Del(id);
}
[HttpGet]
public JsonResult GetList()
{
return Json(dal.GetList(),JsonRequestBehavior.AllowGet);
}
public ActionResult Upt(int id)
{
ViewBag.id = id;
return View();
}
[HttpPost]
public int Upt(ShAddress model)
{
return dal.Upt(model);
}
//根据id获取地址信息->反填
[HttpPost]
public JsonResult GetId(int id)
{
AddDal add = new AddDal();
return Json(add.GetListId(id), JsonRequestBehavior.AllowGet);
}
}
}
using G5.Exam03.Day12.Dal;
using G5.Exam03.Day12.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace G5.Exam03.Day12.Controllers
{
public class AddController : Controller
{
AddDal add = new AddDal();
// GET: Add
//为添加视图提供方法
public ActionResult Add()
{
return View();
}
//从后台获取到我们要的数据源
[HttpPost]//
public int Add(ShAddress model)
{
return add.Add(model);
}
//为省市提供数据源
[HttpGet]
public JsonResult GetSs(int qid)
{
return Json(add.GetSsList(qid), JsonRequestBehavior.AllowGet);
}
//为区县提供数据源
[HttpGet]
public JsonResult GetQx(int qid)
{
return Json(add.GetSsList(qid), JsonRequestBehavior.AllowGet);
}
}
}
@{
ViewBag.Title = "Index";
}
Index
"button" onclick="Add()" name="name" value="新增收获地址" />
@{
ViewBag.Title = "Upt";
}
Upt
class="table table-bordered">
收货人:
"hidden" id="aid"/>
"aName" type="text" name="name" />
所在地区:
省市:select id="Ss" onfocus="BandQ(this.value)">select>
区:select id="q">select>
地址:
"Dzhi" type="text" name="name" />
手机:
"hanSet" type="text" name="name" />
"2">"button" onclick="Xg()" name="name" value="修改" />
@{
ViewBag.Title = "Add";
}
Add
class="table table-bordered">
收货人:
"aName" type="text" name="name" value="" />
所在地区:
省市:select id="Ss" onfocus="BandQ(this.value)">select>
区:select id="q">select>
地址:
"Dzhi" type="text" name="name" value="" />
手机:
"hanSet" type="text" name="name" value="" />
"2">"button" onclick="Tj()" name="name" value="添加到地址" />
上一篇:C#循环