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 { //string oldmsid = Request["oldmsid"]; 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 }); //return RedirectToAction("List"); } } } }
//[HttpGet] //public ActionResult Add() //{ // ViewBag.Ifboss = Session["Ifboss"].ToString(); // ViewBag.Msid = Session["Msid"].ToString(); // sublevel1 col = new sublevel1(); // return View(col); //} //[HttpPost] public ActionResult add(sublevel1 col, 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 qsublevelname = ""; if (!string.IsNullOrWhiteSpace(Request["qsublevelname"])) { qsublevelname = Request["qsublevelname"].Trim(); ViewBag.qsublevelname = qsublevelname; } if (sysflag != "A") { sublevel1 newcol = new sublevel1(); return(View(newcol)); } else { if (!ModelState.IsValid) { return(View(col)); } else { Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon(); SqlConnection conn = dbobj.get_conn("Aitag_DBContext"); SqlDataReader dr; SqlCommand sqlsmd = new SqlCommand(); sqlsmd.Connection = conn; string sqlstr = "select * from sublevel1 where 1<>1 "; sqlsmd.CommandText = sqlstr; dr = sqlsmd.ExecuteReader(); if (dr.Read()) { ModelState.AddModelError("", "重複!"); return(View(col)); } dr.Close(); dr.Dispose(); sqlsmd.Dispose(); conn.Close(); conn.Dispose(); col.lid = "2"; col.uplink = Int32.Parse(Request["psid"]); col.counttype = "00"; col.subread = "2"; //全部 col.subadd = "2"; //全部 col.submod = "2"; //個人 col.subdel = "2"; //個人 col.comid = Session["comid"].ToString(); col.BMODID = Session["tempid"].ToString(); col.BMODDATE = DateTime.Now; using (Aitag_DBContext con = new Aitag_DBContext()) { con.sublevel1.Add(col); 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 = "主目錄名稱:" + col.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/List' 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 += "</form>"; tmpform += "</body>"; return(new ContentResult() { Content = @"" + tmpform }); // return RedirectToAction("List"); } } }
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 add1(sublevel1 col, 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 = ""; 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; if (sysflag != "A") { sublevel1 newcol = new sublevel1(); return(View(newcol)); } else { if (!ModelState.IsValid) { return(View(col)); } else { Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon(); col.lid = "3"; col.uplink = Int32.Parse(uplink); col.counttype = "00"; col.subread = "2"; //全部 col.subadd = "2"; //全部 col.submod = "2"; //個人 col.subdel = "2"; //個人 col.comid = Session["comid"].ToString(); col.BMODID = Session["tempid"].ToString(); col.BMODDATE = DateTime.Now; using (Aitag_DBContext con = new Aitag_DBContext()) { con.sublevel1.Add(col); 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 = "主目錄名稱:" + col.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 = @"<script>alert('新增成功!!');</script>" + tmpform }); // return RedirectToAction("List"); } } }