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

            }

        }

    }

  • 相关阅读:
    修复PLSQL Developer 与 Office 2010的集成导出Excel 功能
    Using svn in CLI with Batch
    mysql 备份数据库 mysqldump
    Red Hat 5.8 CentOS 6.5 共用 输入法
    HP 4411s Install Red Hat Enterprise Linux 5.8) Wireless Driver
    变更RHEL(Red Hat Enterprise Linux 5.8)更新源使之自动更新
    RedHat 5.6 问题简记
    Weblogic 9.2和10.3 改密码 一站完成
    ExtJS Tab里放Grid高度自适应问题,官方Perfect方案。
    文件和目录之utime函数
  • 原文地址:https://www.cnblogs.com/lockzy/p/9520288.html
Copyright © 2011-2022 走看看