zoukankan      html  css  js  c++  java
  • mvc通用存储过程

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Web;

    using System.Web.Mvc;

    using Model;

    using BLL;

    using Model.DTO;

    using Newtonsoft.Json;

    using System.Text;

    namespace WebApplication3.Controllers

    {

        public class AdminController : Controller

        {

            ManagerBLL bll = new ManagerBLL();

            // GET: Admin

            public ActionResult Index(int id = 0)

            {

                #region

                ParaModel model = new ParaModel();

                string Xname = Request.Form["Xname"];

                string Rname = Request.Form["Rname"];

                string Hname = Request.Form["Hname"];

                string Lname = Request.Form["Lname"];

                string Sname = Request.Form["Sname"];

                StringBuilder asd = new StringBuilder();

                asd.Append("1=1");

                if (!string.IsNullOrEmpty(Xname))

                {

                    asd.Append(" and  a.Xid=" + Xname);

                }

                if (!string.IsNullOrEmpty(Rname))

                {

                    asd.Append(" and a.Rid=" + Rname);

                }

                if (!string.IsNullOrEmpty(Hname))

                {

                    asd.Append(" and a.Hid=" + Hname);

                }

                if (!string.IsNullOrEmpty(Lname))

                {

                    asd.Append(" and Lname='" + Lname + "'");

                }

                if (!string.IsNullOrEmpty(Sname))

                {

                    asd.Append(" and a.Sid=" + Sname);

                }

                model.StrWhere = asd.ToString();

                model.PageIndex = id;

                PageList<Commodity> list2 = bll.FyShowlist(model);

                //总条数

                ViewBag.totalNum = list2.TotalNum;

                //总页数

                ViewBag.totalPage = list2.TotalPage;

                //当前第几页

                ViewBag.PageIndex = model.PageIndex;

                return View(list2.listData);

                #endregion

            }

            public int Dels(string id)

            {

                id = id.Trim('.');

                int i = bll.Delete(id);

                return i;

            }

            public int Delete(int id)

            {

                int i = bll.Dels(id);

                return i;

            }

            public ActionResult Adection()

            {

                ViewBag.Xid = new SelectList(bll.Xshow(), "Xid", "Xname");

                ViewBag.Sid = new SelectList(bll.Sshow(), "Sid", "Sname");

                ViewBag.Rid = new SelectList(bll.Rshow(), "Rid", "Rname");

                ViewBag.Hid = new SelectList(bll.Hshow(), "Hid", "Hname");

                return View();

            }

            [HttpPost]

            public ActionResult Adection(Commodity asd)

            {

                ViewBag.Xid = new SelectList(bll.Xshow(), "Xid", "Xname");

                ViewBag.Sid = new SelectList(bll.Sshow(), "Sid", "Sname");

                ViewBag.Rid = new SelectList(bll.Rshow(), "Rid", "Rname");

                ViewBag.Hid = new SelectList(bll.Hshow(), "Hid", "Hname");

                int i = bll.Adection(asd);

                if (i > 0)

                {

                    Response.Write("<script>alert('添加成功')</script>");

                }

                return View();

            }

        }

    }

  • 相关阅读:
    Ubuntu18.04 一条命令安装caffe问题
    ubuntu18 + caffe+cpu+anaconda3
    ubuntu18+caffe+cuda
    opencv-python常用接口
    tensorflow-gpu安装
    【LabVIEW】如何给输入控件赋值
    【LabVIEW】控件初始化
    【LabVIEW】程序结构
    【LabVIEW】程序框图中错误输出后status如何调出
    【总线】ARINC 429总线协议
  • 原文地址:https://www.cnblogs.com/lockzy/p/9520288.html
Copyright © 2011-2022 走看看