public ActionResult subreadwriteedit(subreadwrite chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "srwid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "asc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qsublevelname = "";

            if (!string.IsNullOrWhiteSpace(Request["qsublevelname"]))
            {
                qsublevelname         = Request["qsublevelname"].Trim();
                ViewBag.qsublevelname = qsublevelname;
            }

            NDcommon dbobj    = new NDcommon();
            string   tmpsid   = dbobj.checknumber(Request["tmpsid"]);
            int      tmpsid1  = 0;
            int      tmpsrwid = int.Parse(Request["srwid"].ToString());

            if (!string.IsNullOrEmpty(tmpsid))
            {
                tmpsid1 = int.Parse(tmpsid);
            }

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var          data        = con.subreadwrite.Where(r => r.srwid == tmpsrwid).FirstOrDefault();
                    subreadwrite esublevel1s = con.subreadwrite.Find(tmpsrwid);
                    if (esublevel1s == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(esublevel1s));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        chks.sid              = int.Parse(Request["tmpsid"].ToString());
                        chks.dptgroup         = Request["dptgroup"];
                        chks.empgroup         = Request["empgroup"];
                        chks.comid            = Session["comid"].ToString();
                        chks.BMODID           = Session["tempid"].ToString();
                        chks.BMODDATE         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;
                        con.SaveChanges();

                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "調整id:" + Request["tmpsid"].ToString() + "的權限";
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================

                        string tmpform = "";
                        tmpform  = "<body onload=qfr1.submit();>";
                        tmpform += "<form name='qfr1' action='/sublevel1/subreadwritelist' method='post'>";
                        tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                        tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                        tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                        tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                        tmpform += "<input type=hidden id='qsublevelname' name='qsublevelname' value='" + qsublevelname + "'>";
                        tmpform += "<input type=hidden name='tmpsid' id='tmpsid' value='" + Request["tmpsid"].ToString() + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";

                        return(new ContentResult()
                        {
                            Content = @"<script>alert('修改成功!!');</script>" + tmpform
                        });
                    }
                }
            }
        }
        public ActionResult Edit1(sublevel1 chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "corder";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "asc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qsublevelname1 = "";
            string uplink         = "0";

            if (!string.IsNullOrWhiteSpace(Request["qsublevelname1"]))
            {
                qsublevelname1         = Request["qsublevelname1"].Trim();
                ViewBag.qsublevelname1 = qsublevelname1;
            }
            if (string.IsNullOrWhiteSpace(Request["uplink"]))
            {
                uplink = "0";
            }
            else
            {
                uplink = Request["uplink"].Trim();
            }
            ViewBag.uplink = uplink;

            NDcommon dbobj   = new NDcommon();
            string   tmpsid  = dbobj.checknumber(Request["tmpsid"]);
            int      tmpsid1 = 0;

            if (!string.IsNullOrEmpty(tmpsid))
            {
                tmpsid1 = int.Parse(tmpsid);
            }

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var       data        = con.sublevel1.Where(r => r.sid == tmpsid1).FirstOrDefault();
                    sublevel1 esublevel1s = con.sublevel1.Find(tmpsid1);
                    if (esublevel1s == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(esublevel1s));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string oldmsid = Request["oldmsid"];

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        chks.sid              = tmpsid1;
                        chks.lid              = "3";
                        chks.counttype        = "00";
                        chks.uplink           = Int32.Parse(uplink);
                        chks.comid            = Session["comid"].ToString();
                        chks.BMODID           = Session["tempid"].ToString();
                        chks.BMODDATE         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;
                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "主目錄名稱:" + chks.sublevelname;
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================

                        string tmpform = "";
                        tmpform  = "<body onload=qfr1.submit();>";
                        tmpform += "<form name='qfr1' action='/sublevel1/List1' method='post'>";
                        tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                        tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                        tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                        tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                        tmpform += "<input type=hidden name='uplink' id='uplink' value='" + uplink + "'>";
                        tmpform += "<input type=hidden id='qsublevelname1' name='qsublevelname1' value='" + qsublevelname1 + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                        //return RedirectToAction("List");
                    }
                }
            }
        }
        public ActionResult privsublevel1(sublevel1 chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();

            NDcommon dbobj   = new NDcommon();
            string   tmpsid  = dbobj.checknumber(Request["tmpsid"]);
            int      tmpsid1 = 0;

            if (!string.IsNullOrEmpty(tmpsid))
            {
                tmpsid1 = int.Parse(tmpsid);
            }


            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var       data        = con.sublevel1.Where(r => r.sid == tmpsid1).FirstOrDefault();
                    sublevel1 esublevel1s = con.sublevel1.Find(tmpsid1);
                    if (esublevel1s == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(esublevel1s));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        string keysid = tmpsid1.ToString();

                        string sql = "";
                        sql  = "update sublevel1 set ";
                        sql += " subread = '" + Request["subread"] + "', ";
                        sql += " subadd = '" + Request["subadd"] + "', ";
                        sql += " submod = '" + Request["submod"] + "', ";
                        sql += " subdel = '" + Request["subdel"] + "', ";
                        sql += " BMODID = '" + Session["tempid"].ToString() + "', ";
                        sql += " BMODDATE = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' ";
                        sql += " where sid = '" + keysid + "' ";

                        dbobj.dbexecute("Aitag_DBContext", sql);

                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "主目錄名稱:" + chks.sublevelname;
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================

                        string tmpform = "";
                        tmpform  = "<body onload=alert('異動權限修改成功!');window.close();>";
                        tmpform += "</body>";
                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                    }
                }
            }
        }