.net mvc页面UI之Jquery博客日历控件实现代码(3)


//日历控件获取当前月发布文章的天

        public ActionResult getCalandDay(string year, string month)

        {

           

            string userId = getBlogUserId();

            StringBuilder output = new StringBuilder("");

            DateTime dt = System.DateTime.Now;

            string curMonth = year.ToString() + (month.Length == 1 ? ("0" + month) : month);

            var res = db.Database.SqlQuery<CurMonthArticleViewModel>("select id,createtime from article where mid='" + userId + "' and to_char(createtime,'YYYYMM')='" + curMonth + "'").ToList();

            int i=0;

            output.Append("new Array(");

            foreach (var cc in res)

            {

                if (i == 0)

                    output.Append("{ hDongD:"+cc.CREATETIME.Day+", hDongUrl: '"+cc.ID+"' }");

                else

                {

                    string curDay = cc.CREATETIME.Day.ToString();

                    string resultDay = output.ToString();

                    string[] str = resultDay.Split(','); //得到一个str的数组{“1”,”2“,“3”,”4“,“5”,”6“}

                    Boolean c = true;

                    foreach (string s in str)

                    {

                        if (s == curDay) c = false;

                    }

                    if (c)

                    {

                        output.Append(",{ hDongD:" + cc.CREATETIME.Day + ", hDongUrl: '/" + cc.ID + "--" + cc.CREATETIME + "' }");

                    }

                }

                i++;

            }

            output.Append(");");

            return Json(output.ToString());

            //return Json("new Array({ hDongD: 4, hDongUrl: 'https://www.jb51.net' },  { hDongD: 14, hDongUrl: 'http://play.jb51.net' });");

        }

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjggyj.html