基於MVC和Bootstrap的許可權架構解決方案 二.添加增刪改查按鈕

來源:互聯網
上載者:User

標籤:model   trash   action   lis   res   搭建   custom   href   data   

上一期我們已經搭建了架構並且加入了列表的顯示,

本期我們來加入增刪改查按鈕

整體效果如下

HTML部分,在HTML中找到中意的按鈕按查看元素,複製HTML代碼放入工程中

<a class="btn btn-small element" data-original-title="新增" href="/Customer/Add" data-toggle="tooltip" data-placement="top">      <i class="icon-edit"></i></a>
public ActionResult Add(CustomerInfo cus)        {            if (Request.HttpMethod == "POST")            {                BaseBLL<CustomerInfo> bll = new BaseBLL<CustomerInfo>();                if (bll.Add(cus, "") > 0)                {                    //檔案上傳到伺服器                    return ContentJ("添加成功", "CustomerList");                }            }            return View();        }

新增完成

<div class="btn-group">     <a href="/Customer/[email protected]_ID" data-original-title="修改"  class="btn btn-small element"><i class="icon-edit"></i> </a>     <a href="/Customer/[email protected]_ID" data-original-title="刪除"  class="btn btn-small element"><i class="icon-trash"></i> </a>     <a href="/JieKuan/[email protected]_ID" data-original-title="借款錄入"  class="btn btn-small element"><i class="icon-pencil"></i> </a>     <a href="/JieKuan/[email protected]_ID" data-original-title="借款查看"  class="btn btn-small element"><i class="icon-eye-open"></i> </a> </div>
public ActionResult Edit(string cid)        {            BaseBLL<CustomerInfo> bll = new BaseBLL<CustomerInfo>();            CustomerInfo info= bll.GetModel(cid);            return View(info);        }        [HttpPost]        public ActionResult Edit(CustomerInfo cus)        {                BaseBLL<CustomerInfo> bll = new BaseBLL<CustomerInfo>();                bll.Update(cus, "");                return ContentJ("修改成功", "CustomerList");        }        public ActionResult Delete(string cid)        {            BaseBLL<CustomerInfo> bll = new BaseBLL<CustomerInfo>();            if(bll.Delete(cid) > 0)            {                return ContentJ("刪除成功", "/Customer/CustomerList");            }            return View("/Customer/CustomerList");        }

增刪改完成,

 

至此完成增刪改查的所有代碼

 

下一講:為K2架構加入檔案上傳和圖片展示

如對本架構感興趣可加群討論 257749427

 

基於MVC和Bootstrap的許可權架構解決方案 二.添加增刪改查按鈕

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.