示例#1
0
        public ActionResult maincontentadd(maincontent 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 = "mcid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qkeyword = "", qsmdate = "", qemdate = "", qmclassid = "";

            if (!string.IsNullOrWhiteSpace(Request["qkeyword"]))
            {
                qkeyword         = Request["qkeyword"].Trim();
                ViewBag.qkeyword = qkeyword;
            }
            if (!string.IsNullOrWhiteSpace(Request["qsmdate"]))
            {
                qsmdate         = Request["qsmdate"].Trim();
                ViewBag.qsmdate = qsmdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qemdate"]))
            {
                qemdate         = Request["qemdate"].Trim();
                ViewBag.qemdate = qemdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qmclassid"]))
            {
                qmclassid         = Request["qmclassid"].Trim();
                ViewBag.qmclassid = qmclassid;
            }

            if (sysflag != "A")
            {
                maincontent newcol = new maincontent();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                    Session["mcid"] = "";


                    SqlConnection conn = dbobj.get_conn("Aitag_DBContext");
                    SqlDataReader dr;
                    SqlCommand    sqlsmd = new SqlCommand();
                    sqlsmd.Connection = conn;
                    string sqlstr = "select * from sublevel1 where sid = '" + Request["realsid"].ToString() + "'";
                    sqlsmd.CommandText = sqlstr;
                    dr = sqlsmd.ExecuteReader();
                    string functype = "";
                    if (dr.Read())
                    {
                        //取得功能代號
                        functype = dr["functype"].ToString();
                    }

                    dr.Close();
                    dr.Dispose();
                    conn.Close();
                    conn.Dispose();

                    int         mcid = 0;
                    maincontent mobj;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        if (Request["mcid"].ToString() != "")
                        {
                            mcid = int.Parse(Request["mcid"].ToString());
                            //sqlstr = "select * from maincontent where mcid = '" +  Request["mcid"].ToString() + "'";
                            var data = con.maincontent.Where(r => r.mcid == mcid).FirstOrDefault();
                            mobj = con.maincontent.Find(mcid);
                        }
                        else
                        {
                            mobj = new maincontent();
                        }
                        mobj.mctype    = functype;
                        mobj.mctitle   = Request["mctitle"].ToString().Trim();
                        mobj.mchttp    = Request["mchttp"].ToString().Trim();
                        mobj.mccontent = Request["mccontent"].ToString().Trim();

                        if (Request["qmcparentid"].ToString() != "")
                        {
                            mobj.mcparentid = int.Parse(Request["mcparentid"].ToString().Trim());
                        }
                        mobj.mcfiletype = Request["mcfiletype"].ToString().Trim();
                        mobj.mclassid   = int.Parse(Request["mclassid"].ToString().Trim());
                        //        mobj.mcplace = Request["mcplace"].ToString().Trim();
                        mobj.sid    = int.Parse(Request["realsid"].ToString().Trim());
                        mobj.mdate  = DateTime.Parse(Request["mdate"].ToString());
                        mobj.mclick = 0;
                        //%>
                        //<!--#include file=addprivtbcount.asp-->
                        //<%
                        mobj.ownman   = Session["empid"].ToString();
                        mobj.comid    = Session["comid"].ToString();
                        mobj.bmodid   = Session["empid"].ToString();
                        mobj.bmoddate = DateTime.Now;
                        if (Request["mcid"].ToString() != "")
                        {
                            con.Entry(mobj).State = EntityState.Modified;
                            con.SaveChanges();
                        }
                        else
                        {
                            con.maincontent.Add(mobj);
                            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    = "類別:";
                        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='/oa/maincontent' 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='qkeyword' name='qkeyword' value='" + qkeyword + "'>";
                    tmpform += "<input type=hidden id='qsmdate' name='qsmdate' value='" + qsmdate + "'>";
                    tmpform += "<input type=hidden id='qemdate' name='qemdate' value='" + qemdate + "'>";
                    tmpform += "<input type=hidden id='qmclassid' name='qmclassid' value='" + qmclassid + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
        public ActionResult fileuploadDB()
        {
            string realsid = Request["realsid"].ToString();
            string mcid    = Request["mcid"].ToString();

            if (mcid == "")
            {
                mcid = Session["mcid"].ToString();
            }
            string qmcparentid = Request["qmcparentid"].ToString();

            string   cfilename = Request["cfilename"].ToString();
            string   vfilename = Request["vfilename"].ToString();
            string   cfilesize = Request["cfilesize"].ToString();
            NDcommon dbobj     = new NDcommon();


            System.IO.File.Copy(Server.MapPath(Imglink + "/upload/" + cfilename), Server.MapPath(Imglink + "/upload/" + vfilename));
            System.IO.File.Delete(Server.MapPath(Imglink + "/upload/" + cfilename));

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                SqlConnection conn = dbobj.get_conn("Aitag_DBContext");
                SqlDataReader dr;
                SqlCommand    sqlsmd = new SqlCommand();
                sqlsmd.Connection = conn;
                //取得功能代號

                string sqlstr = "select * from sublevel1 where sid = '" + realsid + "'";
                sqlsmd.CommandText = sqlstr;
                dr = sqlsmd.ExecuteReader();
                string functype = "";
                if (dr.Read())
                {
                    functype = dr["functype"].ToString();
                }

                dr.Close();
                dr.Dispose();

                if (mcid == "")
                {
                    maincontent mainobj = new maincontent();

                    if (qmcparentid != "")
                    {
                        mainobj.mcparentid = int.Parse(qmcparentid);
                    }
                    mainobj.mctitle    = "";
                    mainobj.mchttp     = "";
                    mainobj.mctype     = functype;
                    mainobj.sid        = int.Parse(realsid);
                    mainobj.readallman = "";
                    mainobj.mdate      = DateTime.Today;
                    mainobj.mclick     = 0;
                    mainobj.ownman     = Session["empid"].ToString();
                    mainobj.comid      = Session["comid"].ToString();
                    mainobj.bmodid     = Session["empid"].ToString();
                    mainobj.bmoddate   = DateTime.Today;
                    con.maincontent.Add(mainobj);
                    con.SaveChanges();

                    sqlstr             = "select top 1 * from maincontent where ownman = '" + Session["empid"].ToString() + "' order by mcid desc";
                    sqlsmd.CommandText = sqlstr;
                    dr = sqlsmd.ExecuteReader();
                    if (dr.Read())
                    {
                        mcid = dr["mcid"].ToString();
                    }

                    dr.Close();
                    dr.Dispose();

                    Session["mcid"] = mcid;
                }

                conn.Close();
                conn.Dispose();

                contupload addobj = new contupload();
                addobj.cfilename  = cfilename;
                addobj.cfilesize  = int.Parse(cfilesize);
                addobj.mcid       = int.Parse(mcid);
                addobj.cfiletitle = cfilename;
                addobj.cupfile    = vfilename;

                addobj.bmodid   = Session["empid"].ToString();
                addobj.bmoddate = DateTime.Now;

                con.contupload.Add(addobj);
                con.SaveChanges();
                con.Dispose();
            }
            string tmpdata = mcid;

            return(new ContentResult()
            {
                Content = @"" + tmpdata
            });
        }
示例#3
0
        public ActionResult maincontentmod(maincontent 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 = "mcid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qkeyword = "", qsmdate = "", qemdate = "", qmclassid = "";
            int    mcid = 0;

            if (!string.IsNullOrWhiteSpace(Request["mcid"]))
            {
                mcid = int.Parse(Request["mcid"].Trim());
                // ViewBag.qkeyword = qkeyword;
            }
            if (!string.IsNullOrWhiteSpace(Request["qkeyword"]))
            {
                qkeyword         = Request["qkeyword"].Trim();
                ViewBag.qkeyword = qkeyword;
            }
            if (!string.IsNullOrWhiteSpace(Request["qsmdate"]))
            {
                qsmdate         = Request["qsmdate"].Trim();
                ViewBag.qsmdate = qsmdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qemdate"]))
            {
                qemdate         = Request["qemdate"].Trim();
                ViewBag.qemdate = qemdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qmclassid"]))
            {
                qmclassid         = Request["qmclassid"].Trim();
                ViewBag.qmclassid = qmclassid;
            }

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

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();
                        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.mcid + "標題名稱:" + chks.mctitle;
                        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='/oa/maincontent' 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='qkeyword' name='qkeyword' value='" + qkeyword + "'>";
                        tmpform += "<input type=hidden id='qsmdate' name='qsmdate' value='" + qsmdate + "'>";
                        tmpform += "<input type=hidden id='qemdate' name='qemdate' value='" + qemdate + "'>";
                        tmpform += "<input type=hidden id='qmclassid' name='qmclassid' value='" + qmclassid + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                        //return RedirectToAction("List");
                    }
                }
            }
        }