コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }