Exemple #1
0
        public ActionResult monthcard(int?page, string orderdata, string orderdata1)
        {
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "dptid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
            string qdptid = "", qempname = "", qclogsdate = "", qclogedate = "", qcchkstatus = "";

            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["qcchkstatus"]))
            {
                qcchkstatus         = Request["qcchkstatus"].Trim();
                ViewBag.qcchkstatus = qcchkstatus;
            }
            string DateEx = "", DateEx1 = "";

            dbobj.get_dateRang(Request["qclogsdate"], "acd", "min", @"日期起格式錯誤!!\n", out qclogsdate, out DateEx);
            ViewBag.qclogsdate = qclogsdate;

            dbobj.get_dateRang(Request["qclogedate"], "acd", "max", @"日期訖格式錯誤!!\n", out qclogedate, out DateEx1);
            ViewBag.qclogedate = qclogedate;

            DateEx += DateEx1;

            //NullStDate 跟 NullTeDate 會判斷格式,有錯誤就 修改全域的DateEx
            if (DateEx != "")
            {
                ViewBag.DateEx = @"<script>alert(""" + DateEx + @""");</script>";
            }



            IPagedList <cardjudgelog> result;

            using (Aitag_DBContext con = new Aitag_DBContext())
            {
                string sqlstr = "select CAST(CAST(NEWID() AS binary(3)) AS int) as cjid, empid, empname, dptid ,NULL as clogdate,'' as clogstime, '' as clogetime, '' as clogstatus, '' as clogcomment,   sum(cloghour) as cloghour , '' as comid, '' as bmodid, NULL as bmoddate, cchkstatus, '' as cchkcomment, '' as cchkownman, NULL as cchkowndate  from cardjudgelog where comid='" + Session["comid"].ToString() + "'  and";

                if (!string.IsNullOrWhiteSpace(ViewBag.qdptid))
                {
                    sqlstr += " dptid = '" + ViewBag.qdptid + "'  and ";
                }
                if (!string.IsNullOrWhiteSpace(ViewBag.qempname))
                {
                    sqlstr += " empname like '%" + ViewBag.qempname + "%'  and ";
                }
                if (!string.IsNullOrWhiteSpace(ViewBag.qclogsdate))
                {
                    sqlstr += " clogdate >= '" + ViewBag.qclogsdate + "'  and ";
                }
                if (!string.IsNullOrWhiteSpace(ViewBag.qclogedate))
                {
                    sqlstr += " clogdate <= '" + ViewBag.qclogedate + "'  and ";
                }
                if (!string.IsNullOrWhiteSpace(ViewBag.qcchkstatus))
                {
                    sqlstr += " cchkstatus = '" + ViewBag.qcchkstatus + "'  and ";
                }
                sqlstr  = sqlstr.Substring(0, sqlstr.Length - 5);
                sqlstr += " group by dptid, empid, empname, cchkstatus order by dptid,empid";
                var query = con.cardjudgelog.SqlQuery(sqlstr).AsQueryable();

                result = query.ToPagedList <cardjudgelog>(page.Value - 1, (int)Session["pagesize"]);
            }
            ViewBag.SetOrder_ch = SetOrder_ch(orderdata, orderdata1);
            return(View(result));
        }