Example #1
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
            });
        }
        public ActionResult List(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "empworkdepid,empid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "asc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qdptid = "", qhlogstatus = "", qempname = "", qworksdate = "", qworkedate = "", hdayid = "";

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

            //繞細項用 qhlogstatus qworksdate qworkedate
            if (!string.IsNullOrWhiteSpace(Request["qhlogstatus"]))
            {
                qhlogstatus         = Request["qhlogstatus"].Trim();
                ViewBag.qhlogstatus = qhlogstatus;
            }
            qworksdate         = NullStDate(Request["qworksdate"]);
            ViewBag.qworksdate = qworksdate;
            qworkedate         = NullTeDate(Request["qworkedate"]);
            ViewBag.qworkedate = qworkedate;
            //NullStDate 跟 NullTeDate 會判斷格式,有錯誤就 修改全域的DateEx
            if (DateEx != "")
            {
                ViewBag.DateEx = @"<script>alert(""" + DateEx + @""");</script>";
            }

            if (!string.IsNullOrWhiteSpace(Request["hdayid"]))
            {
                hdayid          = Request["hdayid"].Trim();
                ViewBag.hdayid1 = get_hdaytitle(hdayid);
            }
            else
            {
                hdayid          = "A01,A02,A03,A04,A05,A06";
                ViewBag.hdayid1 = get_hdaytitle(hdayid);
            }

            IPagedList <employee> result;

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                string sqlstr = "select * from employee where empstatus<>'4' and empworkcomp='" + (string)Session["comid"] + "'  and";

                //'部門 組多筆
                if (qdptid != "")
                {
                    string tmpa = "";
                    tmpa   += "'";
                    tmpa   += qdptid.Replace(",", "','");
                    tmpa   += "'";
                    sqlstr += " empworkdepid in (" + tmpa + ")  and";
                }
                if (qempname != "")
                {
                    sqlstr += " empname like N'%" + qempname + "%'  and";
                }

                sqlstr  = sqlstr.Substring(0, sqlstr.Length - 5);
                sqlstr += " order by " + orderdata + " " + orderdata1;

                var query = con.employee.SqlQuery(sqlstr).AsQueryable();

                result = query.ToPagedList <employee>(page.Value - 1, (int)Session["pagesize"]);
            }
            return(View(result));
        }
        public ActionResult battamoneyrpt(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "bsno";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qblogstatus = "", qempname = "", qdptid = "", qblogsdate = "", qblogedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qblogstatus"]))
            {
                qblogstatus         = Request["qblogstatus"].Trim();
                ViewBag.qblogstatus = qblogstatus;
            }
            if (!string.IsNullOrWhiteSpace(Request["qempname"]))
            {
                qempname         = Request["qempname"].Trim();
                ViewBag.qempname = qempname;
            }
            if (!string.IsNullOrWhiteSpace(Request["qdptid"]))
            {
                qdptid         = Request["qdptid"].Trim();
                ViewBag.qdptid = qdptid;
            }
            qblogsdate         = NullStDate(Request["qblogsdate"]);
            qblogsdate         = "2016/03/01";
            ViewBag.qblogsdate = qblogsdate;
            qblogedate         = NullTeDate(Request["qblogedate"]);
            ViewBag.qblogedate = qblogedate;
            //NullStDate 跟 NullTeDate 會判斷格式,有錯誤就 修改全域的DateEx
            if (DateEx != "")
            {
                ViewBag.DateEx = @"<script>alert(""" + DateEx + @""");</script>";
            }

            string Excel = "", Excel2 = "";
            string sqlstr = "";

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                string   viewid = "";
                string[] mpriv  = (string[])Session["priv"];
                //viewid = get_viewpriv(int.Parse(funcpriv(2)), int.Parse(mpriv(realsid, 2)));

                sqlstr = "select * from battalog where (blogtype='1' or (blogtype='2' and (pbsno='' or pbsno is null )) ) and comid='" + (string)Session["comid"] + "'";

                if (viewid != "")
                {
                    sqlstr += " and bmodid = '" + viewid + "'";
                }
                if (qblogstatus != "" && qblogstatus != "all")
                {
                    sqlstr += " and blogstatus = '" + qblogstatus + "'";
                }
                else if (qblogstatus == "")
                {
                    sqlstr += " and blogstatus = '1'";
                    ViewBag.qblogstatus = "1";
                }
                if (qempname != "")
                {
                    sqlstr += " and empname like N'%" + qempname + "%'";
                }
                if (qdptid != "")
                {
                    sqlstr += " and dptid='" + qdptid + "'";
                }

                sqlstr += " and (( blogsdate >= '" + qblogsdate + "' and blogsdate <= '" + qblogedate + "' ) or ";
                sqlstr += "( blogedate >= '" + qblogsdate + "' and blogedate <= '" + qblogedate + "'))";

                sqlstr += " order by " + orderdata + " " + orderdata1;
            }
            #region 組 Excel 格式
            Excel += "<HTML>";
            Excel += "<HEAD>";
            Excel += @"<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">";
            Excel += "</HEAD>";
            Excel += "<body>";
            Excel += "<table  border=1  cellpadding=0 cellspacing=0 bordercolor=#000000 bordercolordark=#ffffff width=900 >";
            Excel += "<tr align=center>";
            Excel += @"<td colspan=""8"" style=""font-size:14pt"">出差明細表";
            Excel += "</td>";
            Excel += "</tr>";
            Excel += "<tr align=center>";
            int count = 7;
            Excel += "<td colspan='" + count + "' ></td><td>列印日期:" + DateTime.Now.ToString("yyyy/MM/dd") + "</td>";
            Excel += "</tr>";
            Excel += "<tr align=center>";
            Excel += "<td>狀態</td>";
            Excel += "<td>核銷</td>";
            Excel += "<td>員工編號</td>";
            Excel += "<td>姓名</td>";
            Excel += "<td>部門</td>";
            Excel += "<td>出差起迄日</td>";
            Excel += "<td>出差天數</td>";
            Excel += "<td>地點</td>";
            Excel += "</tr>";
            Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
            using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
            {
                using (SqlCommand cmd = new SqlCommand(sqlstr, conn))
                {
                    SqlDataReader dr = cmd.ExecuteReader();

                    string dpttitle = "";
                    string empno = "", blogstatus = "", ifhdell = "";
                    string SEtime = "自{0}({1}時)<br>至{2}({3}時)";
                    string chkitem = "", blogsdate = "", blogstime = "", blogedate = "", blogetime = "";
                    int    bloghour = 0;
                    while (dr.Read())
                    {
                        blogstatus = dbobj.get_dbnull2(dr["blogstatus"]);
                        switch (blogstatus)
                        {
                        case "0":
                            blogstatus = "簽核中";
                            break;

                        case "1":
                            blogstatus = "已核准";
                            break;

                        case "2":
                            blogstatus = "退回";
                            break;

                        case "D":
                            blogstatus = "撤回";
                            break;

                        default:
                            break;
                        }
                        ifhdell = dbobj.get_dbnull2(dr["ifhdell"]);
                        if (ifhdell == "y")
                        {
                            ifhdell = "是";
                        }
                        else if (ifhdell == "n")
                        {
                            ifhdell = "否";
                        }
                        using (SqlConnection comconn = dbobj.get_conn("Aitag_DBContext"))
                        {
                            empno    = "select empno from employee where empid='" + dbobj.get_dbnull2(dr["empid"]) + "'"; empno = dbobj.get_dbvalue(comconn, empno);
                            dpttitle = "select dpttitle from Department where dptid='" + dbobj.get_dbnull2(dr["dptid"]) + "' and comid='" + (string)Session["comid"] + "'"; dpttitle = dbobj.get_dbvalue(comconn, dpttitle);

                            blogsdate = Convert.ToDateTime(dbobj.get_dbnull2(dr["blogsdate"])).ToString("yyyy/MM/dd");
                            blogstime = int.Parse(dbobj.get_dbnull2(dr["blogstime"])).ToString("00");
                            blogedate = Convert.ToDateTime(dbobj.get_dbnull2(dr["blogedate"])).ToString("yyyy/MM/dd");
                            blogetime = int.Parse(dbobj.get_dbnull2(dr["blogetime"])).ToString("00");
                            bloghour  = int.Parse("0" + dbobj.get_dbnull2(dr["bloghour"]));

                            if (bloghour > 0)
                            {
                                bloghour = bloghour / 8;
                            }
                            else
                            {
                                bloghour = 0;
                            }
                            chkitem = "select chkitem from checkcode where chkclass = '90' and chkcode = '" + dbobj.get_dbnull2(dr["blogaddr"]) + "'"; chkitem = dbobj.get_dbvalue(comconn, chkitem);
                        }


                        Excel2 += "<tr>";
                        Excel2 += "<td>" + blogstatus + "</td>";
                        Excel2 += "<td>" + ifhdell + "</td>";
                        Excel2 += "<td>" + empno + "</td>";
                        Excel2 += "<td>" + dbobj.get_dbnull2(dr["empname"]) + "</td>";
                        Excel2 += "<td>" + dpttitle + "</td>";
                        Excel2 += "<td>" + String.Format(SEtime, blogsdate, blogstime, blogedate, blogetime) + "</td>";
                        Excel2 += "<td>" + bloghour + "</td>";
                        Excel2 += "<td>" + chkitem;
                        if (dbobj.get_dbnull2(dr["blogplace"]) != "")
                        {
                            Excel2 += dbobj.get_dbnull2(dr["blogplace"]);
                        }
                        Excel2 += "</td>";
                        Excel2 += "</tr>";
                    }
                    if (Excel2 == "")
                    {
                        Excel += "<tr align=left><td colspan=6>目前沒有資料</td></tr>";
                    }
                    else
                    {
                        Excel += Excel2;
                    }
                    dr.Close();
                }
            }


            #endregion
            Excel += "</table>";
            Excel += "</body>";
            Excel += "</HTML>";

            ViewBag.Excel = Excel;
            return(View());
        }
        private void delholidayMode(delholidaylog col, string hdellogstatus)
        {
            NDcommon dbobj = new NDcommon();

            using (SqlConnection comconn = dbobj.get_conn("Aitag_DBContext"))
            {
                if (col.hdayid == "A04")
                {
                    #region  '請補假部分
                    resthourlog chks = new resthourlog();
                    chks.empid      = col.empid;
                    chks.rsdeaddate = col.hlogsdate;

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        var   eresthourlogs = con.resthourlog.Where(r => r.empid == chks.empid && r.rsdeaddate >= chks.rsdeaddate).OrderBy(r => r.rsdeaddate);
                        float tmphloghour   = float.Parse(col.hloghour.ToString());
                        foreach (resthourlog es in eresthourlogs)
                        {
                            var lefthour = es.usehour - tmphloghour;
                            if (lefthour >= 0)
                            {
                                es.usehour -= tmphloghour;
                                using (Aitag_DBContext con2 = new Aitag_DBContext())
                                {
                                    con2.Entry(es).State = EntityState.Modified;
                                    con2.SaveChanges();
                                }
                                if (lefthour == 0)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                es.usehour = 0;
                                using (Aitag_DBContext con2 = new Aitag_DBContext())
                                {
                                    con2.Entry(es).State = EntityState.Modified;
                                    con2.SaveChanges();
                                }
                                tmphloghour = float.Parse(Math.Abs(decimal.Parse(lefthour.ToString())).ToString());
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    #region  事實發生假部分
                    string   mergehdayid = dbobj.get_dbvalue(comconn, "select * from holidaycode where hdayid = '" + col.hdayid + "'");;
                    string   sql         = "";
                    emphdlog chks        = new emphdlog();


                    if (mergehdayid != "")
                    {
                        chks.empid  = col.empid;
                        chks.hdayid = mergehdayid;
                    }
                    else
                    {
                        chks.empid  = col.empid;
                        chks.hdayid = col.hdayid;
                    }
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        emphdlog eemphdlogs = con.emphdlog.Where(r => r.empid == chks.empid && r.hdayid == chks.hdayid).FirstOrDefault();

                        if (eemphdlogs != null)
                        {
                            eemphdlogs.usehour          = eemphdlogs.usehour - decimal.Parse(col.hloghour.ToString());
                            con.Entry(eemphdlogs).State = EntityState.Modified;
                            con.SaveChanges();

                            if (eemphdlogs.usehour == 0)
                            {
                                if (mergehdayid != "")
                                {
                                    sql = "delete emphdlog where empid = '" + col.empid + "' and hdayid = '" + mergehdayid + "'";
                                }
                                else
                                {
                                    sql = "delete emphdlog where empid = '" + col.empid + "' and hdayid = '" + col.hdayid + "'";
                                }
                                dbobj.dbexecute("Aitag_DBContext", sql);
                            }
                        }
                    }
                    #endregion
                }
            }
        }
        public ActionResult logqryEdit(delholidaylog chks, 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 = "hdellogid";
            }

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

            string qhdellogstatus = "", qhlogsdate = "", qhlogedate = "";

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

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    //var data = con.delholidaylog.Where(r => r.hdellogid == chks.hdellogid).FirstOrDefault();
                    delholidaylog edelholidaylogs = con.delholidaylog.Find(chks.hdellogid);
                    if (edelholidaylogs == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(edelholidaylogs));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //NDcommon dbobj = new NDcommon();


                    //using (Aitag_DBContext con = new Aitag_DBContext())
                    //{
                    //    con.Entry(col).State = EntityState.Modified;
                    //    con.SaveChanges();
                    //}

                    //系統LOG檔
                    //string sysnote = "";
                    //if (sysnote.Length > 4000) { sysnote = sysnote.Substring(0, 4000); }
                    ////================================================= //

                    //SqlConnection sysconn = dbobj.get_conn("Aitag_DBContext");
                    //string sysrealsid = Request["sysrealsid"].ToString();
                    //string syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    //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='/delholiday/logqryList' 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='qhdellogstatus' name='qhdellogstatus' value='" + qhdellogstatus + "'>";
                    tmpform += "<input type=hidden id='qhlogsdate' name='qhlogsdate' value='" + qhlogsdate + "'>";
                    tmpform += "<input type=hidden id='qhlogedate' name='qhlogedate' value='" + qhlogedate + "'>";

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

                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                }
            }
        }
Example #6
0
        public ActionResult DeleteConfirmed(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            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;
            }
            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                string tgourl = "/Checkcode/List?page=" + page + "&qchkclass=" + qchkclass + "&qchkitem=" + qchkitem;
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("Aitag_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string eCheckcodes = dbobj.get_dbvalue(conn1, "select chkitem from Checkcode where cid ='" + condtionArr[i].ToString() + "'");

                        sysnote += "代碼名稱:" + eCheckcodes + ",序號:" + condtionArr[i].ToString() + "<br>";

                        dbobj.dbexecute("Aitag_DBContext", "DELETE FROM Checkcode where cid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    string tgourl = "/Checkcode/List?page=" + page + "&qchkclass=" + qchkclass + "&qchkitem=" + qchkitem;
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');location.href='" + tgourl + "'</script>"
                    });

                    //return RedirectToAction("List");
                }
            }
        }
        public ActionResult logcheckEdit(delholidaylog chks, 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 = "hdellogid";
            }

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

            string qhlogsdate = "", qhlogedate = "";

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

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    //var data = con.delholidaylog.Where(r => r.hdellogid == chks.hdellogid).FirstOrDefault();
                    delholidaylog edelholidaylogs = con.delholidaylog.Find(chks.hdellogid);
                    if (edelholidaylogs == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(edelholidaylogs));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    NDcommon      dbobj   = new NDcommon();
                    delholidaylog col     = new delholidaylog();
                    string        sysnote = "";
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        col = con.delholidaylog.Find(chks.hdellogid);
                    }

                    string hdellogstatus = "";
                    if (dbobj.get_dbnull2(Request["hdellogstatus"]) == "1")
                    {
                        string tmprolestampid = col.rolestampid;
                        string rolea_1        = col.rolestampidall;
                        string roleall        = rolea_1 + "," + tmprolestampid; //'簽核過角色(多個)
                        string billflowid     = col.billflowid.ToString();

                        //找出下一個角色是誰
                        string tmprole = dbobj.getnewcheck1("H", tmprolestampid, roleall, "0", "", billflowid);

                        if (tmprole == "'topman'")
                        {
                            tmprole = "";
                        }
                        if (tmprole == "")
                        {
                            hdellogstatus = "1";// '己簽核
                        }
                        else
                        {
                            hdellogstatus = "0";
                            //'找往上呈核長管級數
                            //'==========================
                            string tmpflowlevel = "";
                            using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                            {
                                tmpflowlevel = dbobj.get_dbvalue(conn, "select billflow from flowlevel where bid=" + billflowid);
                            }
                            if (tmpflowlevel == "")
                            {
                                tmpflowlevel = "0";
                            }
                            string[] tmpa      = rolea_1.Split(',');
                            int      tmpacount = tmpa.Length;
                            if (int.Parse(tmpflowlevel) == (tmpacount + 1))
                            {
                                tmprole       = "";
                                hdellogstatus = "1"; // '己簽核
                            }
                            //'==========================
                        }

                        col.hdellogstatus  = hdellogstatus;
                        col.rolestampid    = tmprole;
                        col.rolestampidall = roleall;
                        col.empstampidall  = col.empstampidall + ",'" + (string)Session["empid"] + "'"; //'所有人員帳號
                        col.bmodid         = (string)Session["empid"];
                        col.bmoddate       = DateTime.Now;
                        col.billtime       = col.billtime + "," + DateTime.Now.ToString();

                        if (tmprole != "")
                        {
                            //寄信
                            logcheckEditMail(col, tmprole);
                        }
                        else
                        {
                            //(己通過)  寄信
                            logcheckEditMailPass(col);
                        }
                    }
                    else
                    {
                        col.hdellogstatus = "2";
                        col.delback       = chks.delback;
                        col.bmodid        = (string)Session["empid"];
                        col.bmoddate      = DateTime.Now;
                        //  col.billtime = col.billtime + "," + DateTime.Now.ToString();

                        //(己通過)  寄信
                        logcheckEditMailBack(col);
                    }

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.Entry(col).State = EntityState.Modified;
                        con.SaveChanges();
                    }


                    if (hdellogstatus == "1")
                    {
                        //銷假時數補回
                        delholidayMode(col, hdellogstatus);
                    }



                    //系統LOG檔

                    if (sysnote.Length > 4000)
                    {
                        sysnote = sysnote.Substring(0, 4000);
                    }
                    ////================================================= //

                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        sysrealsid = Request["sysrealsid"].ToString();
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    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='/delholiday/logcheckList' 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='qhlogsdate' name='qhlogsdate' value='" + qhlogsdate + "'>";
                    tmpform += "<input type=hidden id='qhlogedate' name='qhlogedate' value='" + qhlogedate + "'>";

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

                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                }
            }
        }
Example #8
0
        public ActionResult cardbatch(string sysflag)
        {
            ModelState.Clear();

            string sid = "", realsid = "", yhid = "", carddate = "", ctype = "";

            if (!string.IsNullOrWhiteSpace(Request["sid"]))
            {
                sid         = Request["sid"].Trim();
                ViewBag.sid = sid;
            }
            if (!string.IsNullOrWhiteSpace(Request["realsid"]))
            {
                realsid         = Request["realsid"].Trim();
                ViewBag.realsid = realsid;
            }
            if (!string.IsNullOrWhiteSpace(Request["yhid"]))
            {
                yhid         = Request["yhid"].Trim();
                ViewBag.yhid = yhid;
            }
            if (!string.IsNullOrWhiteSpace(Request["carddate"]))
            {
                carddate         = Request["carddate"].Trim();
                ViewBag.carddate = DateTime.Parse(carddate);
            }
            if (!string.IsNullOrWhiteSpace(Request["ctype"]))
            {
                ctype         = Request["ctype"].Trim();
                ViewBag.ctype = ctype;
            }
            if (sysflag != "A")
            {
                return(View());
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                else
                {
                    NDcommon dbobj = new NDcommon();
                    //'取得這類人員的上下班時間
                    string ytstime = "", ydetime = "";
                    using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                    {
                        string sql = "select * from yearholiday where yhid = '" + yhid + "'";
                        using (SqlCommand cmd = new SqlCommand(sql, conn))
                        {
                            SqlDataReader dr = cmd.ExecuteReader();
                            if (dr.HasRows)
                            {
                                dr.Read();
                                ytstime = dbobj.get_dbnull2(dr["ytstime"]);
                                ydetime = dbobj.get_dbnull2(dr["ydetime"]);
                            }
                            dr.Close();
                        }
                    }
                    using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                    {
                        string sql = "select * from employee where empstatus in ('1','2') and yhid = '" + yhid + "'";
                        using (SqlCommand cmd = new SqlCommand(sql, conn))
                        {
                            SqlDataReader dr = cmd.ExecuteReader();

                            string clogtime = "";
                            if (ctype == "1")
                            {
                                clogtime = ytstime;
                            }
                            else
                            {
                                clogtime = ydetime;
                            }
                            var bmoddate = DateTime.Now;
                            while (dr.Read())
                            {
                                cardreallog col = new cardreallog();

                                col.empid    = dbobj.get_dbnull2(dr["empid"]);
                                col.empname  = dbobj.get_dbnull2(dr["empname"]);
                                col.dptid    = dbobj.get_dbnull2(dr["empworkdepid"]);
                                col.clogdate = ViewBag.carddate;
                                col.clogtime = clogtime;

                                col.comid    = Session["comid"].ToString();
                                col.bmodid   = Session["tempid"].ToString();
                                col.bmoddate = bmoddate;

                                using (Aitag_DBContext con = new Aitag_DBContext())
                                {
                                    con.cardreallog.Add(col);
                                    con.SaveChanges();
                                }
                            }
                            dr.Close();
                        }
                    }

                    //系統LOG檔 //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        sysrealsid = Request["sysrealsid"].ToString();
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysnote    = "班別代碼:" + yhid + "<br>產生日期:" + carddate + "的資料";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //=================================================

                    string tmpform = "";
                    tmpform += "<script>";
                    tmpform += "function SetParentOpener() {";
                    tmpform += "alert('刷卡資料批次產生成功!!');";
                    tmpform += "parent.opener.location.href='/cardreallog/List';";
                    tmpform += "window.close();";
                    tmpform += "}";
                    tmpform += "</script>";

                    tmpform += "<body onload=SetParentOpener();>";
                    tmpform += "</body>";
                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                }
            }
        }
Example #9
0
        public ActionResult cardlogtransfer3(string sysflag, conbudgetdet col, HttpPostedFileBase upfile)
        {
            // ViewBag.pid = Request["pid"].ToString();

            if (sysflag != "A")
            {
                return(View());
            }
            else
            {
                NDcommon dbobj  = new NDcommon();
                string   errmsg = "";
                if (upfile != null)
                {
                    String sernonum = "";
                    //重新命名,存入檔案
                    DateTime myDate = DateTime.Now;
                    sernonum = myDate.ToString("yyyyMMddHHmmss");
                    string BasicPath = Server.MapPath("~/upload/");
                    string fileName  = upfile.FileName.Substring(upfile.FileName.IndexOf("."), upfile.FileName.Length - upfile.FileName.IndexOf("."));

                    if (fileName != ".exe" && fileName != ".asp" && fileName != ".aspx" && fileName != ".jsp" && fileName != ".php")
                    {
                        fileName = "cust-" + sernonum.ToString() + fileName;
                        upfile.SaveAs(Server.MapPath("~/upload/") + fileName);

                        string tmppath = BasicPath + fileName;


                        StreamReader sr     = new StreamReader(@tmppath, System.Text.Encoding.Default);
                        string       allstr = sr.ReadToEnd(); //從資料流末端存取檔案
                        sr.Close();

                        string[] tmpstridno; //匯入資料

                        allstr     = allstr.Replace(Environment.NewLine, "\"");
                        allstr     = allstr.Substring(0, allstr.Length - 1);
                        tmpstridno = allstr.Split('\"');

                        //tmpstridno[0] = GetBytesCount1(tmpstridno[0]);


                        #region

                        string        tempcard = "", tempcard1 = "", tempdatetime = "", tmptime = "";
                        SqlConnection comconn = dbobj.get_conn("Aitag_DBContext");
                        foreach (string tmptxt in tmpstridno)
                        {
                            if (tmptxt != "")
                            {
                                tempcard     = tmptxt.Trim().Substring(0, 10);
                                tempcard1    = tmptxt.Trim().Substring(11, 4);
                                tempdatetime = tmptxt.Trim().Substring(16, 8);
                                tmptime      = tmptxt.Trim().Substring(25, 4);

                                if (tempcard != "" && tempcard1 != "" && tempdatetime != "" && tmptime != "")
                                {
                                    string date1 = tempdatetime.Substring(0, 4) + "/" + tempdatetime.Substring(4, 2) + "/" + tempdatetime.Substring(6, 2);
                                    tmptime = tmptime + "00";

                                    string rs1_Open = ""; rs1_Open = dbobj.get_dbvalue(comconn, "select * from cardreallog where clogtime = '" + tmptime + "' and clogdate = '" + date1 + "' and tmpcardno = '" + tempcard1 + "'");
                                    if (rs1_Open == "")
                                    {
                                        using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                                        {
                                            string sql = "select empid,empname,empworkdepid,empworkcomp from employee where empno = '" + tempcard1 + "'";
                                            using (SqlCommand cmd = new SqlCommand(sql, conn))
                                            {
                                                SqlDataReader dr = cmd.ExecuteReader();
                                                if (dr.HasRows)
                                                {
                                                    cardreallog rs = new cardreallog();
                                                    dr.Read();

                                                    rs.empid     = dr["empid"] + "";
                                                    rs.empname   = dr["empname"] + "";
                                                    rs.dptid     = dr["empworkdepid"] + "";
                                                    rs.comid     = dr["empworkcomp"] + "";
                                                    rs.clogdate  = DateTime.Parse(date1);
                                                    rs.clogtime  = tmptime;
                                                    rs.tmpcardno = tempcard1;
                                                    rs.tmpdepid  = dbobj.get_dbvalue(comconn, "select dpttitle from department where dptid='" + dr["empworkdepid"] + "'");

                                                    using (Aitag_DBContext con = new Aitag_DBContext())
                                                    {
                                                        con.cardreallog.Add(rs);
                                                        con.SaveChanges();
                                                    }
                                                }
                                                else
                                                {
                                                    errmsg += tempcard1 + ",";
                                                }
                                                dr.Close();
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        comconn.Close();
                        comconn.Dispose();
                        #endregion
                    }
                    else
                    {
                        ViewBag.AddModelError = @"alert('上傳格式錯誤!');";
                        return(View());
                    }
                }


                string tmpform = "";
                if (errmsg != "")
                {
                    tmpform += "<script>";
                    tmpform += "function SetParentOpener() {";
                    tmpform += "alert('以下員編尚未轉檔,請確認!!" + errmsg + "');";
                    tmpform += "parent.opener.location.href='/cardreallog/List';";
                    tmpform += "window.close();";
                    tmpform += "}";
                    tmpform += "</script>";
                    tmpform += "<body onload=SetParentOpener();>";
                    //tmpform += errmsg;
                    tmpform += "</body>";
                }
                else
                {
                    tmpform += "<script>";
                    tmpform += "function SetParentOpener() {";
                    tmpform += "alert('轉檔成功!!');";
                    tmpform += "parent.opener.location.href='/cardreallog/List';";
                    tmpform += "window.close();";
                    tmpform += "}";
                    tmpform += "</script>";
                    tmpform += "<body onload=SetParentOpener();>";
                    tmpform += "</body>";
                }


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

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

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qdptid = "", qempname = "", qclogsdate = "", qclogedate = "";

            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["qclogsdate"]))
            {
                qclogsdate         = Request["qclogsdate"].Trim();
                ViewBag.qclogsdate = qclogsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qclogedate"]))
            {
                qclogedate         = Request["qclogedate"].Trim();
                ViewBag.qclogedate = qclogedate;
            }

            if (sysflag != "A")
            {
                cardreallog newcol = new cardreallog();

                ViewBag.cloghour = ViewBagcloghour("");
                ViewBag.clogmin  = ViewBagclogmin("");

                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    NDcommon      dbobj = new NDcommon();
                    SqlConnection conn  = dbobj.get_conn("Aitag_DBContext");
                    SqlDataReader dr;
                    SqlCommand    sqlsmd = new SqlCommand();
                    sqlsmd.Connection = conn;
                    string sqlstr = "select crid from cardreallog where crid = '" + col.crid + "'";
                    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.clogtime  = Request["cloghour"].Trim() + Request["clogmin"].Trim() + "00";
                    col.comid     = Session["comid"].ToString();
                    col.tmpcardno = Request["cardno"].Trim();
                    col.tmpdepid  = Request["dptidname"].Trim();
                    col.bmodid    = Session["tempid"].ToString();
                    col.bmoddate  = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.cardreallog.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.empname + "<br>刷卡日期:" + col.clogdate + " " + Request["cloghour"].Trim() + Request["clogmin"].Trim() + "的資料";
                        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='/cardreallog/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='qclogsdate' name='qclogsdate' value='" + qclogsdate + "'>";
                    tmpform += "<input type=hidden id='qclogedate' name='qclogedate' value='" + qclogedate + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
Example #11
0
        public ActionResult DeleteConfirmed(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            string orderdata = "", orderdata1 = "";

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

            string qdptid = "", qempname = "", qclogsdate = "", qclogedate = "";

            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["qclogsdate"]))
            {
                qclogsdate         = Request["qclogsdate"].Trim();
                ViewBag.qclogsdate = qclogsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qclogedate"]))
            {
                qclogedate         = Request["qclogedate"].Trim();
                ViewBag.qclogedate = qclogedate;
            }

            string tmpform = "";

            tmpform  = "<body onload=qfr1.submit();>";
            tmpform += "<form name='qfr1' action='/cardreallog/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='qclogsdate' name='qclogsdate' value='" + qclogsdate + "'>";
            tmpform += "<input type=hidden id='qclogedate' name='qclogedate' value='" + qclogedate + "'>";

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


            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');</script>" + tmpform
                });
            }
            else
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("Aitag_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string ecardreallogs = dbobj.get_dbvalue(conn1, "select empname from cardreallog where crid ='" + condtionArr[i].ToString() + "'");

                        sysnote += "代碼名稱:" + ecardreallogs + ",序號:" + condtionArr[i].ToString() + "<br>";

                        dbobj.dbexecute("Aitag_DBContext", "DELETE FROM cardreallog where crid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');</script>" + tmpform
                    });
                    //return RedirectToAction("List");
                }
            }
        }
Example #12
0
        public ActionResult List(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "crid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qdptid = "", qempname = "", qclogsdate = "", qclogedate = "";

            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["qclogsdate"]))
            {
                qclogsdate         = Request["qclogsdate"].Trim();
                ViewBag.qclogsdate = qclogsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qclogedate"]))
            {
                qclogedate         = Request["qclogedate"].Trim();
                ViewBag.qclogedate = qclogedate;
            }

            IPagedList <cardreallog> result;

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                //'權限
                //mpriv = session("priv")
                //viewid = getviewpriv(funcpriv(2),mpriv(realsid,2))



                string sqlstr = "SELECT * FROM cardreallog where comid = '" + (string)Session["comid"] + "'   and";
                if (qdptid != "")
                {
                    sqlstr += " dptid = '" + qdptid + "'  and";
                }
                if (qempname != "")
                {
                    sqlstr += " empname like N'%" + qempname + "%'  and";
                }
                if (qclogsdate == "")
                {
                    qclogsdate         = DateTime.Now.ToString("yyyy/MM") + "/1";
                    ViewBag.qclogsdate = qclogsdate;
                }
                if (qclogedate == "")
                {
                    var dat = new DateTime(DateTime.Now.Year - 1, 12, 31);
                    qclogedate         = dat.AddMonths(DateTime.Now.Month).ToString("yyyy/MM/dd");
                    ViewBag.qclogedate = qclogedate;
                }
                string DateEx = "";
                try
                {
                    DateTime.Parse(qclogsdate);
                    sqlstr += " clogdate >= '" + qclogsdate + "'  and";
                }
                catch
                {
                    DateEx += @"刷卡日期起格式錯誤!!\n";
                }
                try
                {
                    DateTime.Parse(qclogedate);
                    sqlstr += " clogdate <= '" + qclogedate + "'  and";
                }
                catch
                {
                    DateEx += @"刷卡日期訖格式錯誤!!\n";
                }
                if (DateEx != "")
                {
                    ViewBag.DateEx = @"<script>alert(""" + DateEx + @""");</script>";
                }

                sqlstr  = sqlstr.Substring(0, sqlstr.Length - 5);
                sqlstr += " order by " + orderdata + " " + orderdata1;

                var query = con.cardreallog.SqlQuery(sqlstr).AsQueryable();

                result = query.ToPagedList <cardreallog>(page.Value - 1, (int)Session["pagesize"]);
            }
            ViewBag.SetOrder_ch = SetOrder_ch(orderdata, orderdata1);
            return(View(result));
        }
Example #13
0
        public ActionResult Edit(cardreallog chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "crid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qdptid = "", qempname = "", qclogsdate = "", qclogedate = "";

            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["qclogsdate"]))
            {
                qclogsdate         = Request["qclogsdate"].Trim();
                ViewBag.qclogsdate = qclogsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qclogedate"]))
            {
                qclogedate         = Request["qclogedate"].Trim();
                ViewBag.qclogedate = qclogedate;
            }

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var         data          = con.cardreallog.Where(r => r.crid == chks.crid).FirstOrDefault();
                    cardreallog ecardreallogs = con.cardreallog.Find(chks.crid);
                    if (ecardreallogs == null)
                    {
                        return(HttpNotFound());
                    }


                    ViewBag.cloghour = ViewBagcloghour(ecardreallogs.clogtime.Substring(0, 2));
                    ViewBag.clogmin  = ViewBagclogmin(ecardreallogs.clogtime.Substring(2, 2));

                    return(View(ecardreallogs));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string oldcrid = Request["oldcrid"];

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();

                        chks.clogtime         = Request["cloghour"].Trim() + Request["clogmin"].Trim() + "00";
                        chks.tmpcardno        = Request["cardno"].Trim();
                        chks.tmpdepid         = Request["dptidname"].Trim();
                        chks.bmodid           = Session["tempid"].ToString();
                        chks.bmoddate         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;
                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "申請人:" + chks.empname + "<br>刷卡日期:" + chks.clogdate + " " + Request["cloghour"].Trim() + Request["clogmin"].Trim() + "的資料";
                        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='/cardreallog/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='qclogsdate' name='qclogsdate' value='" + qclogsdate + "'>";
                        tmpform += "<input type=hidden id='qclogedate' name='qclogedate' value='" + qclogedate + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                        //return RedirectToAction("List");
                    }
                }
            }
        }
Example #14
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");
                }
            }
        }
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.Msid = Session["Msid"].ToString();
        //    farmer col = new farmer();
        //    return View(col);
        //}

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

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

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

            if (sysflag != "A")
            {
                farmer newcol = new farmer();
                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 farmer 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.farmer.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.farmername;
                        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='/farmer/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='qfarmername' name='qfarmername' value='" + qfarmername + "'>";
                    tmpform += "<input type=hidden id='qfarmerno' name='qfarmerno' value='" + qfarmerno + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
Example #16
0
        public ActionResult Edit(progparam chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "comid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qchkclass = "", qchkitem = "";
            string comid = Session["comid"].ToString();

            if (sysflag != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var       data        = con.progparam.Where(r => r.comid == comid).FirstOrDefault();
                    progparam eprogparams = con.progparam.Find(comid);

                    if (eprogparams == null)
                    {
                        eprogparams = new progparam();
                        // return HttpNotFound();
                    }
                    //else {
                    return(View(eprogparams));
                    //}
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string oldmsid = Request["oldmsid"];

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();
                        chks.bmodid           = Session["tempid"].ToString();
                        chks.bmoddate         = DateTime.Now;
                        chks.comid            = Session["comid"].ToString();
                        con.Entry(chks).State = EntityState.Modified;
                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Session["realsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "";
                        //string sysnote = "後來使用者登入後踢掉前面使用者::" + Request["ifkickuser"].ToString() + "<br>POP3 Server:" + Request["pop3server"].ToString() + "<br>SMTP Server:" + Request["smtpserver"].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='/progparam/Edit' method='post'>";
                        tmpform += "<input type=hidden name='sysflag' id='sysflag' value='A'>";
                        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='comid' id='comid' value='" + Session["comid"].ToString() + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                        //return RedirectToAction("List");
                    }
                }
            }
        }
Example #17
0
        public ActionResult Edit(Checkcode chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "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 != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var       data        = con.Checkcode.Where(r => r.cid == chks.cid).FirstOrDefault();
                    Checkcode eCheckcodes = con.Checkcode.Find(chks.cid);
                    if (eCheckcodes == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(eCheckcodes));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string oldmsid = Request["oldmsid"];

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();
                        chks.bmodid           = Session["tempid"].ToString();
                        chks.bmoddate         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;
                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "類別:" + chks.chkclasstitle + "代碼名稱:" + chks.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");
                    }
                }
            }
        }
Example #18
0
        public ActionResult List(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "wsdate";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "asc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qcomid = "", qyear = "", qwstitle = "";

            if (!string.IsNullOrWhiteSpace(Request["qcomid"]))
            {
                qcomid         = Request["qcomid"].Trim();
                ViewBag.qcomid = qcomid;
            }
            else
            {
                qcomid         = (string)Session["comid"];
                ViewBag.qcomid = qcomid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qyear"]))
            {
                qyear         = Request["qyear"].Trim();
                ViewBag.qyear = qyear;
            }
            if (!string.IsNullOrWhiteSpace(Request["qwstitle"]))
            {
                qwstitle         = Request["qwstitle"].Trim();
                ViewBag.qwstitle = qwstitle;
            }

            IPagedList <holidayschedule> result;

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                string sqlstr = "select * from holidayschedule where";

                if (qcomid != "")
                {
                    sqlstr += " comid = '" + qcomid + "'  and";
                }


                if (qyear != "")
                {
                    sqlstr += " year(wsdate) = '" + qyear + "'  and";
                }

                if (qwstitle != "")
                {
                    sqlstr += " wstitle like N'%" + qwstitle + "%'  and";
                }

                sqlstr  = sqlstr.Substring(0, sqlstr.Length - 5);
                sqlstr += " order by " + orderdata + " " + orderdata1;

                var query = con.holidayschedule.SqlQuery(sqlstr).AsQueryable();

                result = query.ToPagedList <holidayschedule>(page.Value - 1, (int)Session["pagesize"]);
            }
            return(View(result));
        }
Example #19
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");
                }
            }
        }
Example #20
0
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.Msid = Session["Msid"].ToString();
        //    holidayschedule col = new holidayschedule();
        //    return View(col);
        //}

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

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

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

            if (sysflag != "A")
            {
                holidayschedule newcol = new holidayschedule();
                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 holidayschedule where wsdate = '" + Request["wsdate"] + "' and comid = '" + Session["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();

                    //密碼加密
                    col.yhid     = Request["yhid"].ToString();
                    col.comid    = Session["comid"].ToString();
                    col.bmodid   = Session["tempid"].ToString();
                    col.bmoddate = DateTime.Now;
                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.holidayschedule.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.wstitle + "<br>日期:" + col.wsdate + "的資料";
                        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='/holidayschedule/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='qwstitle' name='qchkclass' value='" + qwstitle + "'>";
                    tmpform += "<input type=hidden id='qyear' name='qchkitem' value='" + qyear + "'>";
                    tmpform += "<input type=hidden id='qcomid' name='qchkitem' value='" + qcomid + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


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

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


            if (sysflag != "A")
            {
                delholidaylog newcol = new delholidaylog();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    NDcommon dbobj = new NDcommon();
                    //簽核
                    string tmparolestampid = "";
                    if (dbobj.get_dbnull2(Request["arolestampid"]) != "")
                    {
                        tmparolestampid = "'" + Request["arolestampid"].ToString() + "'";
                    }
                    else
                    {
                        tmparolestampid = "'" + Request["arolestampid1"].ToString() + "'";
                    }

                    string tmpmoney = "0", tmprole = "", tmpbillid = "";
                    //找出下一個角色是誰
                    string impallstring = dbobj.getnewcheck1("H", tmparolestampid, tmparolestampid, Request["hloghour"], "", "");
                    tmprole   = impallstring.Split(';')[0].ToString();
                    tmpbillid = impallstring.Split(';')[1].ToString();
                    string errmsg = "";
                    if (tmprole == "")
                    {
                        errmsg         = "請先至表單流程設定中設定首長信箱的呈核流程!";
                        ViewBag.errmsg = "<script>alert('" + errmsg + "');</script>";
                        return(View(col));
                    }
                    //簽核
                    //if ((string)Session["mplayrole"] == "")
                    //{
                    //    errmsg = "您並未設定呈核角色!";
                    //    ViewBag.errmsg = "<script>alert('" + errmsg + "');</script>";
                    //    return View(col);
                    //}


                    //'找單據編號(自動產生編號)
                    string tmpbsno = "select hdno from delholidaylog where year(cdate) = " + DateTime.Now.Year + " and month(cdate) = " + DateTime.Now.Month + "  and hdno is not null order by hdno desc";
                    using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                    {
                        tmpbsno = dbobj.get_dbvalue(conn, tmpbsno);
                    }

                    if (tmpbsno != "")
                    {
                        tmpbsno = tmpbsno.Substring(tmpbsno.Length - 3, 3);
                        tmpbsno = (int.Parse(tmpbsno) + 1).ToString("000");
                    }
                    else
                    {
                        tmpbsno = "001";
                    }
                    string tmpyear  = (DateTime.Now.Year - 1911).ToString();
                    string tmpmonth = DateTime.Now.Month.ToString("00");
                    tmpbsno = "A" + tmpyear + tmpmonth + tmpbsno;
                    //======


                    col.hdellogstatus = "0";
                    col.hdno          = tmpbsno;


                    //呈核人員
                    //======
                    if (dbobj.get_dbnull2(col.arolestampid) == "")
                    {
                        col.arolestampid = Request["arolestampid1"];
                    }
                    col.rolestampid    = tmprole;                      //'下個呈核角色
                    col.rolestampidall = tmparolestampid;              //'所有呈核角色
                    col.empstampidall  = "'" + Request["empid"] + "'"; //'所有人員帳號
                    col.billflowid     = int.Parse(tmpbillid);
                    //======

                    col.comid    = (string)Session["comid"];
                    col.bmodid   = (string)Session["empid"];
                    col.bmoddate = DateTime.Now;
                    col.deldate  = DateTime.Now;
                    col.billtime = DateTime.Now.ToString();

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        con.delholidaylog.Add(col);
                        con.SaveChanges();
                    }



                    //    '寄信
                    //'======================
                    using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                    {
                        string fromadd = "", fromaddname = "", mailtitle = "", MailContext = "";
                        fromadd     = dbobj.get_dbvalue(conn, "select enemail from employee where empid='" + Request["empid"] + "'");
                        fromaddname = dbobj.get_dbvalue(conn, "select empname from employee where empid='" + Request["empid"] + "'");

                        //'寄送mail給下一個審核角色
                        #region 寄送mail給下一個審核角
                        mailtitle   = "銷假單資料要求簽核通知";
                        MailContext = "<HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=BIG5'></HEAD><body>";
                        MailContext = MailContext + "以下為明細資料:<BR>";
                        MailContext = MailContext + "<table cellpadding=3 cellspacing=0 bordercolorlight=#000000 bordercolordark=ffffff border=1 width=400 bgcolor=ffffff style='FONT-SIZE: 11pt;FONT-FAMILY:Tahoma,Arial'>";
                        MailContext = MailContext + "<tr><td align=right width=130>申請單號:</td><td>" + tmpbsno + "</td></tr>";
                        MailContext = MailContext + "<tr><td align=right width=130>請假單號:</td><td>" + col.hsno + "</td></tr>";
                        MailContext = MailContext + "<tr><td align=right width=130>申請人:</td><td>" + col.empname + "</td></tr>";
                        MailContext = MailContext + "<tr><td align=right width=130>假別:</td><td>" + Request["hdaytitle"] + "</td></tr>";

                        string hlogsdate = dbobj.get_dbDate(col.hlogsdate, "yyyy/MM/dd");
                        string hlogedate = dbobj.get_dbDate(col.hlogedate, "yyyy/MM/dd");
                        string SEDate    = "自{0} ({1})<br>至{2} ({3})";
                        SEDate      = string.Format(SEDate, hlogsdate, col.hlogstime, hlogedate, col.hlogetime);
                        MailContext = MailContext + "<tr><td align=right width=130>日期起訖:</td><td>" + SEDate + "</td></tr>";

                        if (dbobj.get_dbnull2(col.hlogcomment) != "")
                        {
                            MailContext = MailContext + "<tr><td align=right width=130>備註:</td><td>" + col.hlogcomment.ToString().Trim().Replace(Environment.NewLine, "<br>") + "</td></tr>";
                        }
                        else
                        {
                            MailContext = MailContext + "<tr><td align=right width=130>備註:</td><td>&nbsp;</td></tr>";
                        }


                        MailContext = MailContext + "</table>";
                        MailContext = MailContext + "</body></HTML>";

                        string tmproleid = tmprole.Replace("'", "");
                        string sql       = "select enemail from viewemprole where rid = '" + tmproleid + "' and empstatus <> '4' and enemail<>''";
                        using (SqlCommand cmd = new SqlCommand(sql, conn))
                        {
                            SqlDataReader dr     = cmd.ExecuteReader();
                            string        tomail = "";
                            while (dr.Read())
                            {
                                tomail += dr["enemail"] + ",";
                            }
                            dbobj.send_mailfile("", tomail, mailtitle, MailContext, null, null);

                            dr.Close();
                        }
                        #endregion
                    }


                    //系統LOG檔
                    string sysnote = "申請人:{0}<br>申請單號:{1}的資料";
                    sysnote = string.Format(sysnote, Request["empid"], tmpbsno);
                    if (sysnote.Length > 4000)
                    {
                        sysnote = sysnote.Substring(0, 4000);
                    }
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        sysrealsid = Request["sysrealsid"].ToString();
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    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='/delholiday/logcheckList' 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 += "</form>";
                    tmpform += "</body>";
                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                }
            }
        }
Example #22
0
        public ActionResult Transfer(holidayschedule col, string sysflag, HttpPostedFileBase upfile)
        {
            if (sysflag != "A")
            {
                holidayschedule newcol = new holidayschedule();
                return(View(newcol));
            }
            else
            {
                Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                string tmpform = "";
                if (upfile != null)
                {
                    String sernonum = "";
                    //重新命名,存入檔案
                    DateTime myDate = DateTime.Now;
                    sernonum = myDate.ToString("yyyyMMddHHmmss");
                    string BasicPath  = Server.MapPath("~/upload/");
                    int    inputcount = 0;
                    string fileName   = upfile.FileName.Substring(upfile.FileName.IndexOf("."), upfile.FileName.Length - upfile.FileName.IndexOf("."));

                    if (fileName != ".exe" && fileName != ".asp" && fileName != ".aspx" && fileName != ".jsp" && fileName != ".php")
                    {
                        fileName = "udf-" + sernonum.ToString() + fileName;
                        upfile.SaveAs(Server.MapPath("~/upload/") + fileName);

                        string tmppath = BasicPath + fileName;

                        //StreamReader sr = new StreamReader(@tmppath); //讀取檔案
                        StreamReader sr     = new StreamReader(@tmppath, System.Text.Encoding.Default);
                        string       allstr = sr.ReadToEnd(); //從資料流末端存取檔案
                        sr.Close();

                        string[] tmpstridno;       //匯入資料
                        string[] toptmparry;       //匯入的第一筆資料(欄位)
                        int      tmparrycount = 0; //匯入欄位數
                        tmpstridno = allstr.Split(System.Environment.NewLine.ToCharArray());

                        //找第一筆的欄位數
                        toptmparry = tmpstridno[0].Split(',');

                        //先暫時停掉20160827
                        for (int tmpi = 0; tmpi <= toptmparry.Length - 1; tmpi++)
                        {
                            if (toptmparry[tmpi] != "")
                            {
                                tmparrycount++;
                            }
                        }

                        SqlConnection conn = dbobj.get_conn("Aitag_DBContext");
                        string[]      tmparry;
                        string        tmpvalue  = "";
                        string        tmpaddsql = "";
                        string        cmid      = "";

                        for (int i = 1; i <= tmpstridno.Length - 1; i++)
                        {
                            if (tmpstridno[i] != "")
                            {
                                inputcount++;
                                tmparry = tmpstridno[i].Split(',');
                                //判斷必填欄位
                                if (tmparry[0] != "" && tmparry[1] != "" && tmparry[2] != "")
                                {
                                    string wstype = "";
                                    if (tmparry[2] == "假日")
                                    {
                                        wstype = "0";
                                    }
                                    if (tmparry[2] == "上班")
                                    {
                                        wstype = "1";
                                    }
                                    if (tmparry[2] == "年假")
                                    {
                                        wstype = "2";
                                    }
                                    col.wstitle  = tmparry[0];
                                    col.wsdate   = Convert.ToDateTime(tmparry[1]);
                                    col.wstype   = wstype;
                                    col.comid    = Session["comid"].ToString();
                                    col.bmodid   = Session["tempid"].ToString();
                                    col.bmoddate = DateTime.Now;
                                    using (Aitag_DBContext con = new Aitag_DBContext())
                                    {
                                        con.holidayschedule.Add(col);
                                        con.SaveChanges();

                                        //系統LOG檔 //================================================= //
                                        //SqlConnection sysconn = dbobj.get_conn("MatsuEip_DBContext");
                                        //string sysrealsid = Request["sysrealsid"].ToString();
                                        //string syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                                        //string sysnote = "行事曆標題:" + col.wstitle + "<br>日期:" + col.wsdate + "的資料";
                                        //dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                                        //sysconn.Close();
                                        //sysconn.Dispose();
                                        //=================================================
                                    }


                                    //tmpform = "<body onload=javascript:alert('轉檔成功!');parent.opener.location.href='/holidayschedule/List?sid=" + Request["sid"].ToString() + "&realsid=" + Request["realsid"].ToString() + "';window.close();>";
                                }
                            }
                        }
                    }
                    else
                    {
                        ViewBag.AddModelError = @"alert('上傳格式錯誤!');";
                        return(View());
                    }
                }
                ViewBag.AddModel = @"alert('轉檔成功!');" +
                                   @"parent.opener.location.href = '/holidayschedule/list?sid=" + Request["sid"].ToString() + "&realsid=" + Request["realsid"].ToString() + "';" +
                                   @"window.close();";


                return(View());
            }
        }
        public ActionResult logcheckList(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "hdellogid";
            }

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

            string qhlogsdate = "", qhlogedate = "";

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

            NDcommon dbobj = new NDcommon();

            string DateEx = "", DateEx1 = "";

            if (dbobj.get_dbnull2(Request["qhlogsdate"]) != "")
            {
                dbobj.get_dateRang(Request["qhlogsdate"], "m", "min", @"出差日期起格式錯誤!!\n", out qhlogsdate, out DateEx);
                ViewBag.qhlogsdate = qhlogsdate;
            }
            if (dbobj.get_dbnull2(Request["qhlogedate"]) != "")
            {
                dbobj.get_dateRang(Request["qhlogedate"], "m", "max", @"出差日期訖格式錯誤!!\n", out qhlogedate, out DateEx1);
                ViewBag.qhlogedate = qhlogedate;
            }
            DateEx += DateEx1;

            if (DateEx != "")
            {
                ViewBag.DateEx = @"<script>alert(""" + DateEx + @""");</script>";
            }


            IPagedList <delholidaylog> result;

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                //多個角色時
                string tmpplay = (string)Session["mplayrole"];
                tmpplay = tmpplay.Replace("'", "");
                string[] tmpa  = tmpplay.Split(',');
                string   sql_1 = "";
                foreach (string s in tmpa)
                {
                    sql_1 += "'''" + s + "''',";
                }
                sql_1 = sql_1.Substring(0, sql_1.Length - 1);
                //====

                string sqlstr = "SELECT * FROM delholidaylog where hdellogstatus = '0'";

                if (sql_1 != "")
                {
                    sqlstr += " and rolestampid in (" + sql_1 + ")";
                }
                if (qhlogsdate != "")
                {
                    sqlstr += " and hlogsdate >= '" + qhlogsdate + "'";
                }
                if (qhlogedate != "")
                {
                    sqlstr += " and hlogedate <= '" + qhlogedate + "'";
                }

                sqlstr += " order by " + orderdata + " " + orderdata1;

                var query = con.delholidaylog.SqlQuery(sqlstr).AsQueryable();

                result = query.ToPagedList <delholidaylog>(page.Value - 1, (int)Session["pagesize"]);
            }
            ViewBag.SetOrder_ch = SetOrder_ch(orderdata, orderdata1);
            return(View(result));
        }
        public ActionResult Edit(billflow chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "bid";
            }

            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 != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var      data       = con.billflow.Where(r => r.bid == chks.bid).FirstOrDefault();
                    billflow ebillflows = con.billflow.Find(chks.bid);
                    if (ebillflows == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(ebillflows));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string oldbillid = Request["oldbillid"];

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();

                        chks.addr             = Request["addr"];
                        chks.billtype         = Request["billtype"];
                        chks.bmodid           = Session["tempid"].ToString();
                        chks.bmoddate         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;

                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn       = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid    = Request["sysrealsid"].ToString();
                        string        syssubname    = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        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 * 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");
                    }
                }
            }
        }
        public ActionResult logqryList(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "hdellogid";
            }

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

            string qhdellogstatus = "", qhlogsdate = "", qhlogedate = "";

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

            NDcommon dbobj = new NDcommon();

            string DateEx = "", DateEx1 = "";

            if (dbobj.get_dbnull2(Request["qhlogsdate"]) != "")
            {
                dbobj.get_dateRang(Request["qhlogsdate"], "m", "min", @"出差日期起格式錯誤!!\n", out qhlogsdate, out DateEx);
                ViewBag.qhlogsdate = qhlogsdate;
            }
            if (dbobj.get_dbnull2(Request["qhlogedate"]) != "")
            {
                dbobj.get_dateRang(Request["qhlogedate"], "m", "max", @"出差日期訖格式錯誤!!\n", out qhlogedate, out DateEx1);
                ViewBag.qhlogedate = qhlogedate;
            }
            DateEx += DateEx1;

            if (DateEx != "")
            {
                ViewBag.DateEx = @"<script>alert(""" + DateEx + @""");</script>";
            }


            IPagedList <delholidaylog> result;

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                string sqlstr = "SELECT * FROM delholidaylog where 1=1 "
//                    + " and empid='" + (string)Session["empid"] + "'"
                                + " and comid='" + (string)Session["comid"] + "'";

                if (qhdellogstatus != "")
                {
                    sqlstr += " and hdellogstatus = '" + qhdellogstatus + "'";
                }
                if (qhlogsdate != "")
                {
                    sqlstr += " and hlogsdate >= '" + qhlogsdate + "'";
                }
                if (qhlogedate != "")
                {
                    sqlstr += " and hlogedate <= '" + qhlogedate + "'";
                }

                sqlstr += " order by " + orderdata + " " + orderdata1;

                var query = con.delholidaylog.SqlQuery(sqlstr).AsQueryable();

                result = query.ToPagedList <delholidaylog>(page.Value - 1, (int)Session["pagesize"]);
            }
            ViewBag.SetOrder_ch = SetOrder_ch1(orderdata, orderdata1);
            return(View(result));
        }
        public ActionResult DeleteConfirmed(string id, int?page)
        {
            page = ((!page.HasValue || page < 1) ? 1 : page);
            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;
            }
            string cdel = Request["cdel"];

            if (string.IsNullOrWhiteSpace(cdel))
            {
                return(new ContentResult()
                {
                    Content = @"<script>alert('請勾選要刪除的資料!!');window.history.go(-1);</script>"
                });
            }
            else
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    NDcommon      dbobj       = new NDcommon();
                    SqlConnection conn1       = dbobj.get_conn("Aitag_DBContext");
                    string        sysnote     = "";
                    string[]      condtionArr = cdel.Split(',');
                    int           condtionLen = condtionArr.Length;
                    for (int i = 0; i < condtionLen; i++)
                    {
                        string billid        = dbobj.get_dbvalue(conn1, "select billid from billflow where bid ='" + condtionArr[i].ToString() + "'");
                        string flowcheck     = dbobj.get_dbvalue(conn1, "select flowcheck from billflow where bid ='" + condtionArr[i].ToString() + "'");
                        string flowcheck1    = "";
                        string tmpbillidname = dbobj.get_dbvalue(conn1, "select doctitle from docgroup where docid ='" + billid + "' and comid='" + Session["comid"] + "'");
                        if (!string.IsNullOrWhiteSpace(flowcheck))
                        {
                            string     sqlstr1 = "select roletitle from roleplay where rid in (" + flowcheck + ")";
                            SqlCommand cmd     = new SqlCommand();
                            cmd.Connection  = conn1;
                            cmd.CommandText = sqlstr1;
                            SqlDataReader dr1 = cmd.ExecuteReader();
                            while (dr1.Read())
                            {
                                flowcheck1 = flowcheck1 + dr1["roletitle"].ToString() + " → ";
                            }
                            if (flowcheck1 != "")
                            {
                                flowcheck1 = flowcheck1.Substring(0, flowcheck1.Length - 2);
                            }
                            dr1.Close();
                            dr1.Dispose();
                        }
                        sysnote += "呈核單類別:" + tmpbillidname + ",呈核流程:" + flowcheck1 + "<br>";

                        dbobj.dbexecute("Aitag_DBContext", "DELETE FROM billflow where bid = '" + condtionArr[i].ToString() + "'");
                    }

                    conn1.Close();
                    conn1.Dispose();
                    string sysrealsid = Request["sysrealsid"].ToString();
                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysflag    = "D";
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //======================================================
                    string tgourl = "/billflow/List?page=" + page + "&qbillid=" + qbillid + "&qcomclass=" + qcomclass;
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('刪除成功!!');location.href='" + tgourl + "'</script>"
                    });

                    //return RedirectToAction("List");
                }
            }
        }
        public ActionResult daliyreportrpt(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "empworkdepid,empid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "asc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qdptid = "", qhlogstatus = "", qempname = "", qworksdate = "", qworkedate = "", hdayid = "";

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

            //繞細項用 qhlogstatus qworksdate qworkedate
            if (!string.IsNullOrWhiteSpace(Request["qhlogstatus"]))
            {
                qhlogstatus         = Request["qhlogstatus"].Trim();
                ViewBag.qhlogstatus = qhlogstatus;
            }
            qworksdate         = NullStDate(Request["qworksdate"]);
            ViewBag.qworksdate = qworksdate;
            qworkedate         = NullTeDate(Request["qworkedate"]);
            ViewBag.qworkedate = qworkedate;
            //NullStDate 跟 NullTeDate 會判斷格式,有錯誤就 修改全域的DateEx
            if (DateEx != "")
            {
                ViewBag.DateEx = @"<script>alert(""" + DateEx + @""");</script>";
            }

            if (!string.IsNullOrWhiteSpace(Request["hdayid"]))
            {
                hdayid          = Request["hdayid"].Trim();
                ViewBag.hdayid1 = get_hdaytitle(hdayid);
            }
            else
            {
                hdayid          = "A01,A02,A03,A04,A05,A06";
                ViewBag.hdayid1 = get_hdaytitle(hdayid);
            }

            string Excel = "", Excel2 = "";
            string sqlstr = "";

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                sqlstr = "select * from employee where empstatus<>'4' and empworkcomp='" + (string)Session["comid"] + "'  and";

                //'部門 組多筆
                if (qdptid != "")
                {
                    string tmpa = "";
                    tmpa   += "'";
                    tmpa   += qdptid.Replace(",", "','");
                    tmpa   += "'";
                    sqlstr += " empworkdepid in (" + tmpa + ")  and";
                }
                if (qempname != "")
                {
                    sqlstr += " empname like N'%" + qempname + "%'  and";
                }

                sqlstr  = sqlstr.Substring(0, sqlstr.Length - 5);
                sqlstr += " order by " + orderdata + " " + orderdata1;
            }


            #region 組 Excel 格式
            Excel += "<HTML>";
            Excel += "<HEAD>";
            Excel += @"<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">";
            Excel += "</HEAD>";
            Excel += "<body>";
            Excel += "<table  border=1  cellpadding=0 cellspacing=0 bordercolor=#000000 bordercolordark=#ffffff width=900 >";
            Excel += "<tr align=center>";
            Excel += @"<td colspan=""11"" style=""font-size:14pt"">員工請假統計表  ";
            if (qworksdate != "" || qworkedate != "")
            {
                Excel += qworksdate + "~" + qworkedate;
            }
            Excel += "</td>";
            Excel += "</tr>";
            Excel += "<tr align=center>";
            int count = ViewBag.hdayid1.Count + 3;
            Excel += "<td colspan='" + count + "' ></td><td>製表日期:" + DateTime.Now.ToString("yyyy/MM/dd") + "</td>";
            Excel += "</tr>";
            Excel += "<tr align=center>";
            Excel += "<td>部門</td>";
            Excel += "<td>員工姓名</td>";
            Excel += "<td>到職日</td>";
            foreach (string v in ViewBag.hdayid1)
            {
                Excel += "<td>" + v + "</td>";
            }
            Excel += "<td>合計時</td>";


            Excel += "</tr>";
            Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
            using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
            {
                using (SqlCommand cmd = new SqlCommand(sqlstr, conn))
                {
                    SqlDataReader dr = cmd.ExecuteReader();

                    string dpttitle = "", empname = "";
                    using (SqlConnection comconn = dbobj.get_conn("Aitag_DBContext"))
                    {
                        while (dr.Read())
                        {
                            using (SqlConnection conn1 = dbobj.get_conn("Aitag_DBContext"))
                            {
                                dpttitle = dbobj.get_dbvalue(conn1, "select dpttitle form Department where dptid='" + dr["empworkdepid"] + "'");
                                empname  = dbobj.get_dbnull2(dr["empname"]);
                            }

                            Excel2 += "<tr>";
                            Excel2 += "<td>" + dpttitle + "</td>";
                            Excel2 += "<td>" + empname + "</td>";
                            Excel2 += "<td>" + Convert.ToDateTime(dr["jobdate"]).ToString("yyyy/MM/dd") + "</td>";

                            Excel2 += get_daliyreportHour(comconn, dbobj.get_dbnull2(dr["empid"]), dbobj.get_dbnull2(dr["empworkcomp"]));

                            Excel2 += "</tr>";
                            //dbobj.get_dbnull2().Trim()
                        }
                    }

                    if (Excel2 == "")
                    {
                        Excel += "<tr align=left><td colspan=6>目前沒有資料</td></tr>";
                    }
                    else
                    {
                        Excel += Excel2;
                    }
                    dr.Close();
                }
            }

            Excel += "</table>";
            Excel += "</body>";
            Excel += "</HTML>";

            #endregion

            ViewBag.Excel = Excel;
            return(View());
        }
        //[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");
                }
            }
        }
        public ActionResult Edit(battalog chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "blogid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qblogstatus = "", qempname = "", qdptid = "", qblogsdate = "", qblogedate = "", qifhdell = "";

            if (!string.IsNullOrWhiteSpace(Request["qblogstatus"]))
            {
                qblogstatus         = Request["qblogstatus"].Trim();
                ViewBag.qblogstatus = qblogstatus;
            }
            if (!string.IsNullOrWhiteSpace(Request["qempname"]))
            {
                qempname         = Request["qempname"].Trim();
                ViewBag.qempname = qempname;
            }
            if (!string.IsNullOrWhiteSpace(Request["qdptid"]))
            {
                qdptid         = Request["qdptid"].Trim();
                ViewBag.qdptid = qdptid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qblogsdate"]))
            {
                qblogsdate         = Request["qblogsdate"].Trim();
                ViewBag.qblogsdate = qblogsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qblogedate"]))
            {
                qblogedate         = Request["qblogedate"].Trim();
                ViewBag.qblogedate = qblogedate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qblogedqifhdellate"]))
            {
                qifhdell         = Request["qifhdell"].Trim();
                ViewBag.qifhdell = qifhdell;
            }

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

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();
                        chks.blogid           = int.Parse(Request["blogid"].Trim());
                        chks.bmodid           = Session["tempid"].ToString();
                        chks.bmoddate         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;
                        //con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "代碼:" + chks.blogid + "名稱:" + chks.empname;
                        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='/battamoney/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='qblogstatus' name='qblogstatus' value='" + qblogstatus + "'>";
                        tmpform += "<input type=hidden id='qempname' name='qempname' value='" + qempname + "'>";
                        tmpform += "<input type=hidden id='qdptid' name='qdptid' value='" + qdptid + "'>";
                        tmpform += "<input type=hidden id='qblogsdate' name='qblogsdate' value='" + qblogsdate + "'>";
                        tmpform += "<input type=hidden id='qblogedate' name='qblogedate' value='" + qblogedate + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                        //return RedirectToAction("List");
                    }
                }
            }
        }
Example #30
0
        public ActionResult Edit(empfunction chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "funorder";
            }

            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 != "E")
            {
                using (Aitag_DBContext con = new Aitag_DBContext())
                {
                    var         data          = con.empfunction.Where(r => r.empdid == chks.empdid).FirstOrDefault();
                    empfunction eempfunctions = con.empfunction.Find(chks.empdid);
                    if (eempfunctions == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(eempfunctions));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string empdid = Request["empdid"];

                    using (Aitag_DBContext con = new Aitag_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();
                        chks.empid            = "99999999";
                        chks.bmodid           = Session["tempid"].ToString();
                        chks.bmoddate         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;
                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        dbdata     = dbobj.get_dbvalue(sysconn, "select chkitem from checkcode where chkclass='08' and chkcode='" + chks.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");
                    }
                }
            }
        }