public ActionResult DeleteConfirmed(int id, string cid, string cid1)
        {
            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                Webmaincontent Webmaincontents = con.Webmaincontents.Find(id);
                con.Webmaincontents.Remove(Webmaincontents);
                con.SaveChanges();

                //系統LOG檔 //================================================= //
                Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                string        syssubname    = "網站管理作業 > 網站內容管理";
                string        sysnote       = "名稱:" + Webmaincontents.AC_Mctitle;
                string        sysflag       = "D";
                SqlConnection sysconn       = dbobj.get_conn("Aitag_DBContext");
                dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                sysconn.Close();
                sysconn.Dispose();
                //=================================================

                if (cid1 == "0")
                {
                    return(RedirectToAction("List", new { cid = cid, cid1 = cid1 }));
                }
                else
                {
                    return(RedirectToAction("List", new { cid = cid1, cid1 = cid }));
                }
            }
        }
        public ActionResult add(schedule col, string sysflag, HttpPostedFileBase sfile)
        {
            ModelState.Clear();

            if (!string.IsNullOrWhiteSpace(Request["year1"]))
            {
                ViewBag.year1 = Request["year1"].ToString();
            }
            else
            {
                ViewBag.year1 = "";
            }

            if (!string.IsNullOrWhiteSpace(Request["month1"]))
            {
                ViewBag.month1 = Request["month1"].ToString();
            }
            else
            {
                ViewBag.month1 = "";
            }


            if (!string.IsNullOrWhiteSpace(Request["qschdate"]))
            {
                ViewBag.qschdate = Request["qschdate"].ToString();
            }
            else
            {
                ViewBag.qschdate = "";
            }



            string schtype = Request["schtype"].ToString();

            ViewBag.schtype = schtype;
            ViewBag.Mflag   = Request["Mflag"].ToString();;

            if (Request["tmpadate"] != "" && Request["tmpadate"] != null)
            {
                ViewBag.tmpadate = Request["tmpadate"].ToString();
            }

            if (sysflag != "A")
            {
                schedule newcol = new schedule();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    string fileName = "";
                    #region  傳
                    if (sfile != null)
                    {
                        String sernonum = "";
                        //重新命名,存入檔案
                        DateTime myDate = DateTime.Now;
                        sernonum = myDate.ToString("yyyyMMddHHmmss");

                        fileName = sfile.FileName.Substring(sfile.FileName.IndexOf("."), sfile.FileName.Length - sfile.FileName.IndexOf("."));

                        if (fileName != ".exe" && fileName != ".asp" && fileName != ".aspx" && fileName != ".jsp" && fileName != ".php")
                        {
                            fileName = "F-" + sernonum.ToString() + fileName;
                            sfile.SaveAs(Server.MapPath("~/upload/") + fileName);
                        }
                        //else
                        //{
                        //    ModelState.AddModelError("Ebpic", "上傳圖片格式錯誤");
                        //    return View(col);
                        //}
                    }
                    #endregion

                    #region
                    Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();

                    schedule mobj;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        mobj         = new schedule();
                        mobj.schtype = schtype;

                        string schtitle = Request["schtitle"].ToString().Trim();
                        schtitle = schtitle.Replace("'", "’");


                        mobj.schtitle   = schtitle;
                        mobj.schcontent = Request["schcontent"].ToString().Trim();
                        mobj.schplace   = Request["schplace"].ToString().Trim();
                        mobj.schowner   = Session["empid"].ToString();
                        mobj.schloginer = Session["empid"].ToString();
                        mobj.schdate    = DateTime.Parse(Request["schdate"].ToString());
                        mobj.schhour    = Request["schhour"].ToString().Trim();
                        mobj.schmin     = Request["schmin"].ToString().Trim();
                        mobj.schehour   = Request["schehour"].ToString().Trim();
                        mobj.schemin    = Request["schemin"].ToString().Trim();
                        mobj.comid      = Session["comid"].ToString();
                        mobj.bmodid     = Session["empid"].ToString();
                        mobj.bmoddate   = DateTime.Now;
                        mobj.sfile      = fileName;

                        con.schedule.Add(mobj);
                        con.SaveChanges();

                        #endregion
                        string tmptitle = "";
                        switch (schtype)
                        {
                        case "0":
                            tmptitle = "個人備忘";
                            break;

                        case "1":
                            tmptitle = "個人行程";
                            break;

                        case "2":
                            tmptitle = "公司行程";
                            break;
                        }

                        //系統LOG檔 //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "分類:" + tmptitle + "<br>標題:" + schtitle + "<br>日期:" + Request["schdate"].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='/schedule/list' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='year1' id='year1' value='" + ViewBag.year1 + "'>";
                    tmpform += "<input type=hidden name='month1' id='month1' value='" + ViewBag.month1 + "'>";
                    tmpform += "<input type=hidden name='Mflag' id='Mflag' value='" + ViewBag.Mflag + "'>";
                    tmpform += "<input type=hidden name='qschdate' id='qschdate' value='" + ViewBag.qschdate + "'>";

                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"<script>alert('新增成功!!');</script>" + tmpform
                    });
                }
            }
        }
        public ActionResult add(Webmaincontent col, HttpPostedFileBase Mcfile, HttpPostedFileBase Mpic)
        {
            ViewBag.Cid  = col.AC_Cid.ToString();
            ViewBag.Ccid = col.AC_Ccid.ToString();

            /*
             * if (Mcfile == null)
             * {
             *  ModelState.AddModelError("Mcfile", "請選擇檔案");
             * }
             */

            if (!ModelState.IsValid)
            {
                return(View(col));
            }

            Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
            //上傳檔案****開始
            int sernonum;

            if (Mcfile != null)
            {
                // Uploadfile.SaveAs(Server.MapPath("~/Uploads/") + Apic.FileName);

                //上傳檔案
                //找序號
                SqlConnection conn = dbobj.get_conn("Aitag_DBContext");
                SqlDataReader dr;
                SqlCommand    sqlsmd = new SqlCommand();
                sqlsmd.Connection = conn;
                string sqlstr = "select sno from Serno where sid=1";
                sqlsmd.CommandText = sqlstr;
                dr = sqlsmd.ExecuteReader();

                if (dr.Read())
                {
                    //重新命名,存入檔案
                    sernonum = int.Parse(dr[0].ToString()) + 1;
                    string fileName = "contente" + sernonum.ToString() + Mcfile.FileName.Substring(Mcfile.FileName.IndexOf("."), Mcfile.FileName.Length - Mcfile.FileName.IndexOf("."));
                    Mcfile.SaveAs(Server.MapPath("~/Upload/") + fileName);
                    col.AC_Mcfile = fileName;

                    //序號+1後存入
                    Aitag.Models.NDcommon dbobj1  = new Aitag.Models.NDcommon();
                    SqlConnection         conn1   = dbobj1.get_conn("Aitag_DBContext");
                    SqlCommand            sqlsmd1 = new SqlCommand();
                    sqlsmd1.Connection = conn1;
                    string sqlstr1 = "UPDATE  Serno SET  sno ='" + sernonum + "' where sid=1";
                    sqlsmd1.CommandText = sqlstr1;
                    sqlsmd1.ExecuteReader();


                    sqlsmd1.Dispose();
                    conn1.Close();
                    conn1.Dispose();
                }


                sqlsmd.Dispose();
                conn.Close();
                conn.Dispose();
            }


            //上傳圖片****開始

            if (Mpic != null)
            {
                //上傳檔案
                //找序號
                SqlConnection conn = dbobj.get_conn("Aitag_DBContext");
                SqlDataReader dr;
                SqlCommand    sqlsmd = new SqlCommand();
                sqlsmd.Connection = conn;
                string sqlstr = "select sno from Serno where sid=1";
                sqlsmd.CommandText = sqlstr;
                dr = sqlsmd.ExecuteReader();

                if (dr.Read())
                {
                    //重新命名,存入檔案
                    sernonum = int.Parse(dr[0].ToString()) + 1;
                    string fileName = "contente" + sernonum.ToString() + Mpic.FileName.Substring(Mpic.FileName.IndexOf("."), Mpic.FileName.Length - Mpic.FileName.IndexOf("."));
                    Mpic.SaveAs(Server.MapPath("~/Upload/") + fileName);
                    col.AC_Mpic = fileName;

                    //序號+1後存入
                    Aitag.Models.NDcommon dbobj1  = new Aitag.Models.NDcommon();
                    SqlConnection         conn1   = dbobj1.get_conn("Aitag_DBContext");
                    SqlCommand            sqlsmd1 = new SqlCommand();
                    sqlsmd1.Connection = conn1;
                    string sqlstr1 = "UPDATE  Serno SET  sno ='" + sernonum + "' where sid=1";
                    sqlsmd1.CommandText = sqlstr1;
                    sqlsmd1.ExecuteReader();


                    sqlsmd1.Dispose();
                    conn1.Close();
                    conn1.Dispose();
                }


                sqlsmd.Dispose();
                conn.Close();
                conn.Dispose();
            }

            col.AC_Baddid   = Session["tempid"].ToString();
            col.AC_Badddate = DateTime.Now;
            col.AC_Bmodid   = Session["tempid"].ToString();
            col.AC_Bmoddate = DateTime.Now;
            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                con.Webmaincontents.Add(col);
                con.SaveChanges();
            }
            //系統LOG檔 //================================================= //
            //Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
            string        syssubname = "網站管理作業 > 網站內容管理";
            string        sysnote    = "名稱:" + col.AC_Mctitle;
            string        sysflag    = "A";
            SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");

            dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
            sysconn.Close();
            sysconn.Dispose();
            //=================================================

            if (col.AC_Ccid != 0)
            {
                return(RedirectToAction("List", new { cid = col.AC_Ccid, cid1 = col.AC_Cid }));
            }
            else
            {
                return(RedirectToAction("List", new { cid = col.AC_Cid, cid1 = 0 }));
            }
        }
Example #4
0
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.Msid = Session["Msid"].ToString();
        //    Checkcode col = new Checkcode();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(Checkcode 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 = "cid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qchkclass = "", qchkitem = "";

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

            if (sysflag != "A")
            {
                Checkcode newcol = new Checkcode();
                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 cid from Checkcode where chkclass = '" + col.chkclass + "' and chkcode = '" + col.chkcode + "'";
                    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.emppasswd = dbobj.Encrypt(col.emppasswd);
                    //col.chkclass = col.emppasswd;
                    //col.baddid = Session["tempid"].ToString();
                    col.bmodid = Session["tempid"].ToString();
                    //col.badddate = DateTime.Now;
                    col.bmoddate = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.Checkcode.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.chkclasstitle + "代碼名稱:" + col.chkitem;
                        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='/Checkcode/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='qchkclass' name='qchkclass' value='" + qchkclass + "'>";
                    tmpform += "<input type=hidden id='qchkitem' name='qchkitem' value='" + qchkitem + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
        public ActionResult subreadwriteadd(subreadwrite 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 = "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;
            }


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

                    col.dptgroup = Request["dptgroup"];
                    col.empgroup = Request["empgroup"];
                    col.sid      = int.Parse(Request["tmpsid"].ToString());
                    col.comid    = Session["comid"].ToString();
                    col.BMODID   = Session["tempid"].ToString();
                    col.BMODDATE = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.subreadwrite.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    = "主目錄id:" + Request["tmpsid"];
                        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 id='tmpsid' name='tmpsid' value='" + Request["tmpsid"] + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";

                    string tgourl = "/sublevel1/List?page=" + page + "&qsublevelname=" + qsublevelname;
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('新增成功!!');</script>" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.Msid = Session["Msid"].ToString();
        //    workitem col = new workitem();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(workitem 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 = "corp_no";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qcorp_no = "", qworkitem = "";

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

            if (sysflag != "A")
            {
                workitem newcol = new workitem();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                    SqlConnection         conn  = dbobj.get_conn("AitagBill_DBContext");
                    SqlDataReader         dr;
                    SqlCommand            sqlsmd = new SqlCommand();
                    sqlsmd.Connection = conn;
                    string sqlstr = "select corp_no from workitem where corp_no = '" + col.corp_no + "' and work_no_code = '" + col.work_no_code + "'";
                    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.comid     = Session["comid"].ToString();
                    col.bmodid    = Session["tempid"].ToString();
                    col.hourgroup = Request["hourgroup"].Trim();
                    col.bmoddate  = DateTime.Now;
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        con.workitem.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.corp_no + "項目代碼:" + col.work_no_code + "項目名稱:" + col.workitemname;
                        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='/workitem/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='qcorp_no' name='qcorp_no' value='" + qcorp_no + "'>";
                    tmpform += "<input type=hidden id='qworkitem' name='qworkitem' value='" + qworkitem + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
Example #7
0
        public ActionResult getallpage(int?page, empfunction emp, string orderdata, string orderdata1)
        {
            Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
            SqlConnection         conn = dbobj.get_conn("Aitag_DBContext");
            SqlConnection         conn2 = dbobj.get_conn("Aitag_DBContext");
            SqlDataReader         dr, dr2;
            SqlCommand            sqlsmd = new SqlCommand();
            SqlCommand            sqlcmd = new SqlCommand();

            //List<empfunction> datalist = new List<empfunction>();
            sqlsmd.Connection  = conn;
            sqlcmd.Connection  = conn2;
            sqlcmd.CommandText = "delete empfunction where empid <> '99999999'";
            sqlcmd.ExecuteNonQuery();
            string sqlstr = "select * from employee where empstatus not in ('3','4') and ifuse='y'";

            sqlcmd.CommandText = sqlstr;
            string qempdid = Request["qempdid"].Trim();
            string funid   = Request["funid"].Trim();

            dr2 = sqlcmd.ExecuteReader();

            if (dr2.HasRows)
            {
                while (dr2.Read())
                {
                    string sql = "select * from empfunction where empid = '99999999' ";
                    sqlsmd.CommandText = sql;
                    dr = sqlsmd.ExecuteReader();
                    while (dr.Read())
                    {
                        emp.empid       = dr2["empid"].ToString();
                        emp.funid       = dr["funid"].ToString();
                        emp.funposition = dr["funposition"].ToString();
                        emp.funorder    = Convert.ToInt32(dr["funorder"]);
                        emp.ifshowalert = dr["ifshowalert"].ToString();
                        emp.funrowcount = Convert.ToInt32(dr["funrowcount"]);
                        emp.comid       = Session["comid"].ToString();
                        emp.bmodid      = Session["tempid"].ToString();
                        emp.bmoddate    = DateTime.Now;
                        using (Aitag_DBContext con = new Aitag_DBContext())
                        {
                            con.empfunction.Add(emp);
                            con.SaveChanges();
                        }
                    }
                    dr.Close();
                    dr.Dispose();
                }
            }
            dr2.Close();
            dr2.Dispose();
            sqlsmd.Dispose();
            sqlcmd.Dispose();
            conn.Close();
            conn.Dispose();
            conn2.Close();
            conn2.Dispose();

            //系統LOG檔 //================================================= //
            SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
            string        sysrealsid = Request["sysrealsid"].ToString();
            string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
            string        sysnote    = "公司代碼::" + Session["comid"].ToString() + "的員工個人化首頁重新產生";
            string        sysflag    = "M";

            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='/empfunction/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='qempdid' name='qempdid' value='" + qempdid + "'>";
            tmpform += "<input type=hidden id='funid' name='funid' value='" + funid + "'>";
            tmpform += "</form>";
            tmpform += "</body>";


            return(new ContentResult()
            {
                Content = @"<script>alert('員工個人化首頁產生成功!!');</script>" + tmpform
            });
        }
Example #8
0
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.Msid = Session["Msid"].ToString();
        //    certifystamp col = new certifystamp();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(certifystamp 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 = "csid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qwtrack = "", qcitemid = "";

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

            if (sysflag != "A")
            {
                certifystamp newcol = new certifystamp();
                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 certifystamp where 1<>1";
                     * sqlsmd.CommandText = sqlstr;
                     * dr = sqlsmd.ExecuteReader();
                     *
                     * if (dr.Read())
                     * {
                     *
                     *  ModelState.AddModelError("", "no");
                     *  return View(col);
                     * }
                     * dr.Close();
                     * dr.Dispose();
                     * sqlsmd.Dispose();
                     * conn.Close();
                     * conn.Dispose();
                     */

                    col.comid  = Session["comid"].ToString();
                    col.bmodid = Session["tempid"].ToString();
                    //col.badddate = DateTime.Now;
                    col.bmoddate = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.certifystamp.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.wtrack;
                        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='/certifystamp/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='qwtrack' name='qwtrack' value='" + qwtrack + "'>";
                    tmpform += "<input type=hidden id='qcitemid' name='qcitemid' value='" + qcitemid + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
Example #9
0
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.comid = Session["comid"].ToString();
        //    Company col = new Company();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(Company col, string sysflag, int?page, string orderdata, string orderdata1, HttpPostedFileBase logopic1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "comid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qcomid = "", qcsno = "", qcomtitle = "";

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

            if (sysflag != "A")
            {
                Company newcol = new Company();
                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 comid from Company where comid = '" + col.comid + "'";
                    sqlsmd.CommandText = sqlstr;
                    dr = sqlsmd.ExecuteReader();

                    if (dr.Read())
                    {
                        ModelState.AddModelError("", "權限代碼重複!");
                        return(View(col));
                    }
                    dr.Close();
                    dr.Dispose();
                    sqlsmd.Dispose();
                    conn.Close();
                    conn.Dispose();

                    if (logopic1.ContentLength > 0)
                    {
                        col.logopic = Request["comid"] + "." + logopic1.FileName.Substring(logopic1.FileName.Length - 3, 3);
                        logopic1.SaveAs(Server.MapPath("/upload/" + col.logopic));
                    }

                    //密碼加密
                    //col.emppasswd = dbobj.Encrypt(col.emppasswd);
                    //col.comid = col.emppasswd;
                    //col.baddid = Session["tempid"].ToString();
                    col.bmodid = Session["tempid"].ToString();
                    //col.badddate = DateTime.Now;
                    col.bmoddate = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.Company.Add(col);
                        try
                        {
                            con.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            throw;
                        }



                        //系統LOG檔 //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "代碼:" + col.comid + "名稱:" + col.comtitle;
                        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='/Company/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='qcomid' name='qcomid' value='" + qcomid + "'>";
                    tmpform += "<input type=hidden id='qcsno' name='qcsno' value='" + qcsno + "'>";
                    tmpform += "<input type=hidden id='qcomtitle' name='qcomtitle' value='" + qcomtitle + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.rsid = Session["rsid"].ToString();
        //    resthourlog col = new resthourlog();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(resthourlog 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 = "rsid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qdptid = "", qempname = "", qaddtype = "", qaddsdate = "", qaddedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qdptid"]))
            {
                qdptid         = Request["qdptid"].Trim();
                ViewBag.qdptid = qdptid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qempname"]))
            {
                qempname         = Request["qempname"].Trim();
                ViewBag.qempname = qempname;
            }
            if (!string.IsNullOrWhiteSpace(Request["qaddtype"]))
            {
                qaddtype         = Request["qaddtype"].Trim();
                ViewBag.qaddtype = qaddtype;
            }
            if (!string.IsNullOrWhiteSpace(Request["qaddsdate"]))
            {
                qaddsdate         = Request["qaddsdate"].Trim();
                ViewBag.qaddsdate = qaddsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qaddedate"]))
            {
                qaddedate         = Request["qaddedate"].Trim();
                ViewBag.qaddedate = qaddedate;
            }

            if (sysflag != "A")
            {
                resthourlog newcol = new resthourlog();
                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 rsid from resthourlog where rsid = '" + col.rsid + "'";
                    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.otlogid  = 0;
                    col.resmoney = 0;
                    col.inout    = "0";
                    col.comid    = Session["comid"].ToString();

                    col.bmodid   = Session["tempid"].ToString();
                    col.bmoddate = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.resthourlog.Add(col);
                        try
                        {
                            con.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            throw;
                        }



                        //系統LOG檔 //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "代碼:" + col.rsid + "名稱:" + col.empid;
                        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='/resthourcheck1/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='qdptid' name='qdptid' value='" + qdptid + "'>";
                    tmpform += "<input type=hidden id='qempname' name='qempname' value='" + qempname + "'>";
                    tmpform += "<input type=hidden id='qaddtype' name='qaddtype' value='" + qaddtype + "'>";
                    tmpform += "<input type=hidden id='qaddsdate' name='qaddsdate' value='" + qaddsdate + "'>";
                    tmpform += "<input type=hidden id='qaddedate' name='qaddedate' value='" + qaddedate + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
Example #11
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");
                }
            }
        }
        //[HttpPost]
        public ActionResult add(mediachannel 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 = "mdno";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qallcomid = "", pmdno = "0", qmdtitle = "";

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

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

            if (sysflag != "A")
            {
                mediaclass newcol = new mediaclass();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                    SqlConnection         conn  = dbobj.get_conn("AitagBill_DBContext");
                    SqlDataReader         dr;
                    SqlCommand            sqlsmd = new SqlCommand();
                    sqlsmd.Connection = conn;
                    string sqlstr = "select mdno from mediachannel where mdno = '" + col.mdno + "'";
                    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.mdno     = DateTime.Now.ToString("yyyyMMddhhmmssfffff");
                    col.pmdno    = pmdno;
                    col.comid    = Session["comid"].ToString();
                    col.bmodid   = Session["tempid"].ToString();
                    col.bmoddate = DateTime.Now;
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        con.mediachannel.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.mdno + "媒體名稱:" + col.mdtitle;
                        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='/mediachannel/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='qallcomid' name='qallcomid' value='" + qallcomid + "'>";
                    tmpform += "<input type=hidden id='pmdno' name='pmdno' value='" + pmdno + "'>";
                    tmpform += "<input type=hidden id='qmdtitle' name='qmdtitle' value='" + qmdtitle + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                }
            }
        }
Example #13
0
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.Msid = Session["Msid"].ToString();
        //    sales_competition col = new sales_competition();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(sales_competition 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 = "ccid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qprodtitle = "", qcusttitle = "";

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

            if (sysflag != "A")
            {
                sales_competition newcol = new sales_competition();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                    SqlConnection         conn  = dbobj.get_conn("AitagBill_DBContext");
                    SqlDataReader         dr;
                    SqlCommand            sqlsmd = new SqlCommand();
                    sqlsmd.Connection = conn;
                    string sqlstr = "select * from sales_competition 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();

                    //找出下一個呈核角色
                    #region 找出下一個呈核角色
                    string tmparolestampid = "";
                    string tmprole         = "";
                    string tmpbillid       = "";
                    if (Request["arolestampid"].ToString() != "")
                    {
                        tmparolestampid = "'" + Request["arolestampid"].ToString() + "'";
                    }

                    string impallstring = dbobj.getnewcheck1("G", tmparolestampid, tmparolestampid, "1", "1", "");
                    tmprole   = impallstring.Split(';')[0].ToString();
                    tmpbillid = impallstring.Split(';')[1].ToString();
                    if (tmprole == "")
                    {
                        ViewBag.ErrMsg = @"<script>alert(""請先至表單流程設定中設定新業務及競業呈核流程!"");</script>";
                        return(View(col));
                    }
                    #endregion

                    col.custlevel1 = Request["custlevel1"];
                    col.custlevel2 = Request["custlevel2"];
                    col.custlevel3 = Request["custlevel3"];
                    col.iflaw      = "";
                    col.iffin      = "";
                    col.corpitem   = Request["corpitem"];
                    if (!string.IsNullOrWhiteSpace(Request["arolestampid"]))
                    {
                        col.arolestampid = Request["arolestampid"];
                    }
                    else
                    {
                        col.arolestampid = Request["arolestampid1"];
                    }

                    col.slogtype       = "1";
                    col.slogstatus     = "0"; // 己簽核:1  :0
                    col.rolestampid    = tmprole;
                    col.rolestampidall = tmparolestampid;
                    col.empstampidall  = "'" + col.empid + "'";
                    col.billflowid     = int.Parse(tmpbillid);
                    col.billtime       = DateTime.Now.ToString();
                    col.ccid           = Decimal.Parse(DateTime.Now.ToString("yyyyMMddhhmmssff"));
                    col.bmodid         = Session["tempid"].ToString();
                    col.bmoddate       = DateTime.Now;
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        con.sales_competition.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.empid + "產品名稱:" + col.prodtitle;
                        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='/sales_competition/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='qcusttitle' name='qcusttitle' value='" + qcusttitle + "'>";
                    tmpform += "<input type=hidden id='qprodtitle' name='qprodtitle' value='" + qprodtitle + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
        public ActionResult Edit(schedule chks, string sysflag, HttpPostedFileBase sfile1)
        {
            if (!string.IsNullOrWhiteSpace(Request["year1"]))
            {
                ViewBag.year1 = Request["year1"].ToString();
            }
            else
            {
                ViewBag.year1 = "";
            }

            if (!string.IsNullOrWhiteSpace(Request["month1"]))
            {
                ViewBag.month1 = Request["month1"].ToString();
            }
            else
            {
                ViewBag.month1 = "";
            }

            if (!string.IsNullOrWhiteSpace(Request["qschdate"]))
            {
                ViewBag.qschdate = Request["qschdate"].ToString();
            }
            else
            {
                ViewBag.qschdate = "";
            }

            ViewBag.schtype = Request["schtype"].ToString();
            ViewBag.Mflag   = Request["Mflag"].ToString();

            int schid = int.Parse(Request["schid"].ToString());

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var      data     = con.schedule.Where(r => r.schid == chks.schid).FirstOrDefault();
                    schedule schedule = con.schedule.Find(chks.schid);
                    if (schedule == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(schedule));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        schedule modobj = con.schedule.Where(r => r.schid == schid).FirstOrDefault();

                        string schtitle = Request["schtitle"].ToString().Trim();
                        schtitle = schtitle.Replace("'", "’");

                        modobj.schtitle   = schtitle;
                        modobj.schcontent = Request["schcontent"].ToString().Trim();
                        modobj.schplace   = Request["schplace"].ToString().Trim();
                        modobj.schdate    = DateTime.Parse(Request["schdate"].ToString());
                        modobj.schhour    = Request["schhour"].ToString().Trim();
                        modobj.schmin     = Request["schmin"].ToString().Trim();
                        modobj.schehour   = Request["schehour"].ToString().Trim();
                        modobj.schemin    = Request["schemin"].ToString().Trim();


                        #region  傳檔案

                        if (sfile1 != null)
                        {
                            string sernonum;
                            //重新命名,存入檔案
                            DateTime myDate = DateTime.Now;
                            sernonum = myDate.ToString("yyyyMMddHHmmss");

                            string fileName = sfile1.FileName.Substring(sfile1.FileName.IndexOf("."), sfile1.FileName.Length - sfile1.FileName.IndexOf("."));

                            if (fileName != ".exe" && fileName != ".asp" && fileName != ".aspx" && fileName != ".jsp" && fileName != ".php")
                            {
                                fileName = "F-" + sernonum.ToString() + fileName;

                                sfile1.SaveAs(Server.MapPath("~/Upload/") + fileName);
                                modobj.sfile = fileName;
                            }
                        }
                        #endregion


                        con.Entry(modobj).State = EntityState.Modified;
                        con.SaveChanges();
                        con.Dispose();

                        Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();

                        //系統LOG檔 //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "分類:" + Request["tmptitle"].ToString() + "<br>標題:" + schtitle + "<br>日期:" + Request["schdate"].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='/schedule/List' method='post'>";
                        tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                        tmpform += "<input type=hidden name='year1' id='year1' value='" + ViewBag.year1 + "'>";
                        tmpform += "<input type=hidden name='month1' id='month1' value='" + ViewBag.month1 + "'>";
                        tmpform += "<input type=hidden name='Mflag' id='Mflag' value='" + ViewBag.Mflag + "'>";
                        tmpform += "<input type=hidden name='qschdate' id='qschdate' value='" + ViewBag.qschdate + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"<script>alert('修改成功!!');</script>" + tmpform
                        });
                    }
                }
            }
        }
Example #15
0
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.empdid = Session["empdid"].ToString();
        //    empfunction col = new empfunction();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(empfunction col, string sysflag, int?page, string orderdata, string orderdata1, string test)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "empdid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qempdid = "", funid = "";

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

            if (sysflag != "A")
            {
                empfunction newcol = new empfunction();
                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;
                    #region 註解
                    //string sqlstr = "select empdid from empfunction where empdid = '" + col.empdid + "'";
                    //sqlsmd.CommandText = sqlstr;
                    //dr = sqlsmd.ExecuteReader();

                    //if (dr.Read())
                    //{

                    //    ModelState.AddModelError("", "權限代碼重複!");
                    //    return View(col);
                    //}
                    //dr.Close();
                    //dr.Dispose();
                    //sqlsmd.Dispose();
                    //conn.Close();
                    //conn.Dispose();
                    #endregion

                    //密碼加密
                    //col.emppasswd = dbobj.Encrypt(col.emppasswd);
                    //col.empdid = col.emppasswd;
                    //col.baddid = Session["tempid"].ToString();
                    col.bmodid = Session["tempid"].ToString();
                    col.empid  = "99999999";
                    //col.badddate = DateTime.Now;
                    col.bmoddate = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.empfunction.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        dbdata     = dbobj.get_dbvalue(sysconn, "select chkitem from checkcode where chkclass='08' and chkcode='" + col.funid + "'");
                        string        sysnote    = "共用首頁設定:" + dbdata + "的資料";
                        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='/empfunction/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='qempdid' name='qempdid' value='" + qempdid + "'>";
                    tmpform += "<input type=hidden id='funid' name='funid' value='" + funid + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
Example #16
0
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.Msid = Session["Msid"].ToString();
        //    holidaycode col = new holidaycode();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(holidaycode 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 = "hdayid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qhdayid = "", qhdaytitle = "";

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

            if (sysflag != "A")
            {
                holidaycode newcol = new holidaycode();
                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 hdayid from holidaycode where hdayid = '" + col.hdayid + "'";
                    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.htype    = Request["htype"];
                    col.bmodid   = Session["tempid"].ToString();
                    col.bmoddate = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.holidaycode.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.hdayid + "假勤名稱:" + col.hdaytitle;
                        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='/holidaycode/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='qhdayid' name='qhdayid' value='" + qhdayid + "'>";
                    tmpform += "<input type=hidden id='qhdaytitle' name='qhdaytitle' value='" + qhdaytitle + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.billid = Session["billid"].ToString();
        //    billflow col = new billflow();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(billflow 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 = "billid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qbillid = "", qcomclass = "";

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

            if (sysflag != "A")
            {
                billflow newcol = new billflow();
                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 billid from billflow 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.billtype = Request["billtype"];
                    col.addr     = Request["addr"];
                    col.bmodid   = Session["tempid"].ToString();
                    col.bmoddate = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.billflow.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        tmpbillidname = dbobj.get_dbvalue(sysconn, "select doctitle from docgroup where docid ='" + Request["billid"].Trim() + "' and comid='" + Session["comid"] + "'");

                        string flowcheck = "";
                        if (!string.IsNullOrWhiteSpace(Request["flowcheck"].Trim()))
                        {
                            string     sqlstr1 = "select roletitle from roleplay where rid in (" + Request["flowcheck"].Trim() + ")";
                            SqlCommand cmd     = new SqlCommand();
                            cmd.Connection  = sysconn;
                            cmd.CommandText = sqlstr1;
                            SqlDataReader dr1 = cmd.ExecuteReader();
                            while (dr1.Read())
                            {
                                flowcheck = flowcheck + dr1["roletitle"].ToString() + " → ";
                            }
                            if (flowcheck != "")
                            {
                                flowcheck = flowcheck.Substring(0, flowcheck.Length - 2);
                            }
                            dr1.Close();
                            dr1.Dispose();
                        }
                        string sysnote = "呈核單類別:" + tmpbillidname + "<br>呈核人員:" + flowcheck;
                        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='/billflow/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='qbillid' name='qbillid' value='" + qbillid + "'>";
                    tmpform += "<input type=hidden id='qcomclass' name='qcomclass' value='" + qcomclass + "'>";
                    tmpform += "</form>";
                    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 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");
                }
            }
        }