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();

            }

        }

    }

  • 相关阅读:
    H5页面与ios交互返回上一级
    url传中文参数乱码问题
    获取除当前元素外的所有类名相同的元素
    vue根据id删除某一行
    非对称加密算法
    Linux下nc命来实现文件传输
    linux下挂载第二块硬盘
    libcprops
    android开发环境安装记录
    MD(d)、MT(d)编译选项的区别
  • 原文地址:https://www.cnblogs.com/lockzy/p/9520288.html
Copyright © 2011-2022 走看看