Example #1
0
        private void SelectTag()
        {
            string returnStr = "未查到相关标签";
            string tag       = "";

            if (!string.IsNullOrEmpty(Request.QueryString["tag"]))
            {
                tag = InText.SafeStr(InText.SafeSql(Request.QueryString["tag"].ToString()));
            }
            if (tag.Trim() != "")
            {
                String    sql = "select * from t_tag where tag_name like '%" + tag + "%' ";
                DataTable dt  = artBll.SelectToDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    returnStr = "<ul>";
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        returnStr += "<li><a href='javascript:void(0)' onclick='SetTag(\"" + dt.Rows[i]["tag_name"].ToString() + "\")'>" + dt.Rows[i]["tag_name"].ToString() + "</a></li>";
                    }
                    returnStr += "</ul>";
                }
            }
            Response.Write(returnStr);
        }
Example #2
0
        //添加按钮
        protected void imgBtn_Click(object sender, ImageClickEventArgs e)
        {
            int       order      = 0;
            string    sql        = "select max(link_order) as maxOrder from t_friendlink";
            DataTable dtMaxOrder = artBll.SelectToDataTable(sql);

            if (dtMaxOrder.Rows.Count > 0)
            {
                order = Convert.ToInt32(dtMaxOrder.Rows[0]["maxOrder"]) + 1;
            }

            string name = InText.SafeSql(InText.SafeStr(this.txtAddLinkName.Value));
            string link = InText.SafeSql(InText.SafeStr(this.txtAddLink.Value));

            if (name.Trim() != "" && link.Trim() != "")
            {
                sql = string.Format("insert into t_friendlink (link_name,link,link_order,update_date) values ('{0}','{1}',{2},getdate())", name, link, order);

                if (artBll.ExecuteSQLNonquery(sql))
                {
                    this.CteateHTML(url + "index927_2.aspx", "/", "");        //重新生成首页
                    InText.AlertAndRedirect("添加成功!", Request.Url.ToString()); //刷新当前页
                }
            }
        }
Example #3
0
        public string GetDaoyu(string daoyu, string content, int length)
        {
            daoyu   = InText.SafeStr(daoyu);
            content = InText.SafeStr(content);

            if (daoyu.Trim() != "" && daoyu.Trim() != "no")
            {
                //return GetPartContent(InText.SafeStr(daoyu), length) + "...";
                if (daoyu.Length > length)
                {
                    return(daoyu.Substring(0, length) + "...");
                }
                else
                {
                    return(daoyu + "...");
                }
            }
            else
            {
                //return GetPartContent(InText.SafeStr(content), length) + "...";
                if (content.Length > length)
                {
                    return(content.Substring(0, length) + "...");
                }
                else
                {
                    return(content + "...");
                }
            }
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            adminId = new AdminMethod().CheckAdminLogin();//-----------------------------

            if (!string.IsNullOrEmpty(Request.QueryString["html"]))
            {
                html = InText.SafeStr(Request.QueryString["html"].ToString());
                this.txt_html.Value = html;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["dateMin"]))
            {
                update_date_min = InText.SafeSql(InText.SafeStr(Request.QueryString["dateMin"].ToString()));
                this.txt_update_date_min.Value = update_date_min;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["dateMax"]))
            {
                update_date_max = InText.SafeSql(InText.SafeStr(Request.QueryString["dateMax"].ToString()));
                this.txt_update_date_max.Value = update_date_max;
            }


            if (!IsPostBack)
            {
                BindList();
            }
        }
Example #5
0
        private void SelectEmailExist()
        {
            string email = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["email"]))
            {
                email = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["email"]));
            }
            int result = userBll.SelectEmailExist(email);

            StringWriter sw = new StringWriter();

            Newtonsoft.Json.JsonWriter writer = new Newtonsoft.Json.JsonTextWriter(sw);

            if (result == 0)
            {
                writer.WriteStartObject();
                writer.WritePropertyName("status");
                writer.WriteValue("200");
                writer.WriteEndObject();
                writer.Flush();
            }
            else
            {
                writer.WriteStartObject();
                writer.WritePropertyName("status");
                writer.WriteValue("500");
                writer.WriteEndObject();
                writer.Flush();
            }
            string jsonText = sw.GetStringBuilder().ToString();

            Response.Write(jsonText);
        }
Example #6
0
        //保存按钮
        protected void btn_Update_Click(object sender, EventArgs e)
        {
            name   = InText.SafeSql(InText.SafeStr(this.txt_name.Value));
            pwd    = WebBasic.Encryption.Encrypt(InText.SafeSql(InText.SafeStr(this.txt_pwd.Value)));
            remark = InText.SafeSql(InText.SafeStr(this.txt_remark.Value));

            if (admin_id != 0)//执行修改
            {
                string sql  = string.Format("update t_admin set name='{0}',pwd='{1}',remark='{2}' where id={3}", name, pwd, remark, admin_id);
                bool   isOk = artBll.ExecuteSQLNonquery(sql);
                if (isOk)
                {
                    InText.AlertAndRedirect("修改成功", "/xzdd927/admin/admin_list.aspx");// Request.Url.AbsoluteUri
                }
            }
            else //执行添加
            {
                string sql  = string.Format("insert into t_admin (name,pwd,remark) values ('{0}','{1}','{2}')", name, pwd, remark);
                bool   isOk = artBll.ExecuteSQLNonquery(sql);
                if (isOk)
                {
                    InText.AlertAndRedirect("添加成功", "/xzdd927/admin/admin_list.aspx");// Request.Url.AbsoluteUri
                }
            }
        }
Example #7
0
        private bool BindList()
        {
            bool ifOk = true;

            int pageIndex   = 1;
            int pageSize    = 30;//pager.PageSize;//每页显示20条信息
            int totalRecord = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"]))
            {
                pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString())));
            }

            string where = " where 1=1";

            if (html.Trim() != "")
            {
                where += " and html like '%" + html + "%'";
            }
            if (update_date_min != "")
            {
                where += " and  DateDiff( day,  '" + update_date_min + "',t_article_pic.update_date) >=0 ";
            }
            if (update_date_max != "")
            {
                where += " and  DateDiff( day,  '" + update_date_max + "',t_article_pic.update_date) <=0 ";
            }


            string strSql = " Select t_article_pic.id as pic_id,t_article.title,t_article.html,t_article_pic.pic,t_article_pic.update_date   "
                            + " ,row_number() over(order by t_article_pic.id desc) as rowNumber "
                            + " FROM t_article_pic "
                            + " LEFT JOIN t_article ON t_article_pic.article_id=t_article.id ";
            DataTable dt = artBll.ExecutePager(strSql + where, pageSize, pageIndex, ref totalRecord);

            if (dt.Rows.Count > 0)
            {
                ifOk = true;

                pager.PageSize              = pageSize;
                pager.RecordCount           = totalRecord;
                this.repList_Img.DataSource = dt;
                this.repList_Img.DataBind();

                this.labInfoCount.Text = totalRecord.ToString();

                if (totalRecord <= pageSize)//只有一页,隐藏分页控件
                {
                    this.divFenye.Visible = false;
                }
            }
            else
            {
                this.divFenye.Visible = false;
                ifOk = false;
            }
            return(ifOk);
        }
Example #8
0
        //生成二维码按钮
        protected void imgBtnSubmit_Click(object sender, ImageClickEventArgs e)
        {
            string content = InText.SafeStr(this.textContent.Value);//
            int    size    = Convert.ToInt32(this.ddlSize.SelectedValue);

            size = size * 3;

            if (content.Trim() != "")
            {
                create_two(content, size);
            }
        }
Example #9
0
        //添加分类按钮
        protected void imgBtn_Click(object sender, ImageClickEventArgs e)
        {
            string type_name    = InText.SafeSql(InText.SafeStr(this.txtAddType.Value));
            string type_keyword = InText.SafeSql(InText.SafeStr(this.txtAddTypeKeyword.Value));

            if (type_name.Trim() != "")
            {
                string sql = string.Format("insert into t_article_type (type_name,type_keyword,remark) values ('{0}','{1}','')", type_name, type_keyword);

                if (artBll.ExecuteSQLNonquery(sql))
                {
                    InText.AlertAndRedirect("添加成功!", Request.Url.ToString());//刷新当前页
                }
            }
        }
Example #10
0
        private void TestJSONP()
        {
            string cb = "";

            if (!string.IsNullOrEmpty(Request.QueryString["cb"]))
            {
                cb = InText.SafeStr(Request.QueryString["cb"].ToString());
            }

            StringWriter sw     = new StringWriter();
            JsonWriter   writer = new JsonTextWriter(sw);

            //writer.writest

            writer.WriteStartArray();

            writer.WriteStartObject();
            writer.WritePropertyName("name");
            writer.WriteValue("王晓明");
            writer.WritePropertyName("age");
            writer.WriteValue("95");
            writer.WriteEndObject();
            writer.Flush();

            writer.WriteStartObject();
            writer.WritePropertyName("name");
            writer.WriteValue("王晓明1");
            writer.WritePropertyName("age");
            writer.WriteValue("951");
            writer.WriteEndObject();
            writer.Flush();

            writer.WriteEndArray();

            string jsonText = sw.GetStringBuilder().ToString();
            //string aaa = "[{\"name\":\"王晓明\",\"age\":\"95\"},{\"name\":\"王晓明1\",\"age\":\"951\"}]";
            string retrunStr = "{\"man\":" + jsonText + "}";

            if (cb.Trim() != "")
            {
                retrunStr = cb + "(" + retrunStr + ")";
            }
            Response.Write(retrunStr);
        }
Example #11
0
        private bool BindList()
        {
            bool ifOk = true;

            int pageIndex   = 1;
            int pageSize    = 100;//pager.PageSize;//每页显示20条信息
            int totalRecord = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"]))
            {
                pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString())));
            }

            string    strSql = " Select id,tag_name,tag_keyword,article_num  " + " ,row_number() over(order by t_tag.article_num desc ) as rowNumber " + " FROM t_tag where t_tag.article_num>0 ";
            DataTable dt     = artBll.ExecutePager(strSql, pageSize, pageIndex, ref totalRecord);

            if (dt.Rows.Count > 0)
            {
                ifOk = true;

                pager.PageSize          = pageSize;
                pager.RecordCount       = totalRecord;
                this.repList.DataSource = dt;
                this.repList.DataBind();

                //this.labInfoCount.Text = totalRecord.ToString();

                if (totalRecord <= pageSize)//只有一页,隐藏分页控件
                {
                    this.divFenye.Visible = false;
                }
            }
            else
            {
                this.divFenye.Visible = false;
                ifOk = false;
            }
            return(ifOk);
        }
Example #12
0
        //添加/修改按钮
        protected void btn_add_Click(object sender, EventArgs e)
        {
            int huandeng1 = 0;

            if (this.chkHuandeng1.Checked)//是否首页幻灯
            {
                huandeng1 = 1;
            }

            string title  = InText.SafeSql(InText.SafeStr(this.txt_title.Text));
            string title1 = InText.SafeSql(InText.SafeStr(this.txt_title1.Text));

            if (title1.Trim() == "")
            {
                title1 = title;
            }
            string source          = InText.SafeSql(InText.SafeStr(this.txt_source.Text));
            int    articleType     = Convert.ToInt32(this.ddl_articleType.SelectedValue);
            string articleTypeName = this.ddl_articleType.SelectedItem.Text;
            string content         = this.hidDes.Value.Trim();//素材内容(编辑器)   //InText.SafeSql(InText.SafeSqlContent(content2.Text));
            int    declare_mark    = Convert.ToInt32(this.ddl_declare_mark.SelectedValue);
            string keyword         = InText.SafeSql(InText.SafeStr(this.txt_keyword.Text));
            string search_keyword  = InText.SafeSql(InText.SafeStr(this.txt_search_keyword.Text));
            string daoyu           = InText.SafeSql(InText.SafeStr(this.txt_daoyu.Text));
            string tag             = InText.SafeSql(InText.SafeStr(this.txt_tag.Text));
            int    right_type      = Convert.ToInt32(this.ddl_right_type.SelectedValue);

            //================================上传图片附件============================================================================
            string savePath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString();

            //int result = 0;
            //文章图片
            if (this.fu_image.HasFile)
            {
                //修改文章时,删除原来的图片
                if (articleId != 0)
                {
                    if (artPic.Trim() != "")
                    {
                        string sql  = "update t_article set pic='' where id=" + articleId;
                        bool   isOk = artBll.ExecuteSQLNonquery(sql);
                        if (isOk)
                        {
                            string strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + artPic;       //删除原图
                            CommonMethod.FilePicDelete(strPath);
                            strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + "100_100_" + artPic; //删除缩略图
                            CommonMethod.FilePicDelete(strPath);
                        }
                    }
                }

                artPic = "";
                int len = fu_image.PostedFile.ContentLength;
                if (fu_image.PostedFile.ContentLength <= 10240000)//10M内
                {
                    //if (FileUpload.PostedFile.ContentLength<=)
                    if (CommonMethod.IsAllowedExtension(fu_image))//验证下文件是否为图片
                    {
                        string filepath      = fu_image.PostedFile.FileName;
                        string filename_user = filepath.Substring(filepath.LastIndexOf("\\") + 1);
                        artPic = imageNamePre + DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString("N") + ".jpg";
                        string serverpath = savePath + "img_" + artPic;
                        fu_image.PostedFile.SaveAs(serverpath);                            //保存原图片

                        string smallPath = savePath + artPic;                              //缩略图路径
                        //CommonMethod.MakeThumbnail(serverpath, smallPath, 500, 500, "W");//保存成最大500*500
                        smallPath = savePath + "100_100_" + artPic;                        //缩略图路径
                        CommonMethod.MakeThumbnail(serverpath, smallPath, 300, 300, "HW"); //生成缩略图150*150

                        CommonMethod.FilePicDelete(serverpath);                            //删除原图片
                    }
                }
            }
            artPic = this.hid_artPic.Value;

            //幻灯图片
            if (this.fu_image_huandeng1.HasFile)
            {
                savePath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["hd1"].ToString();

                //修改文章时,删除原来的图片
                if (articleId != 0)
                {
                    if (artPic_huandeng1.Trim() != "")
                    {
                        string sql  = "update t_article set huandeng1_pic='' where id=" + articleId;
                        bool   isOk = artBll.ExecuteSQLNonquery(sql);
                        if (isOk)
                        {
                            string strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + artPic_huandeng1;//删除原图
                            CommonMethod.FilePicDelete(strPath);
                        }
                    }
                }

                artPic_huandeng1 = "";
                int len = fu_image_huandeng1.PostedFile.ContentLength;
                if (fu_image_huandeng1.PostedFile.ContentLength <= 10240000) //10M内
                {
                    if (CommonMethod.IsAllowedExtension(fu_image_huandeng1)) //验证下文件是否为图片
                    {
                        string filepath      = fu_image_huandeng1.PostedFile.FileName;
                        string filename_user = filepath.Substring(filepath.LastIndexOf("\\") + 1);
                        artPic_huandeng1 = imageNamePre + "hd1_" + DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString("N") + ".jpg";
                        string serverpath = savePath + artPic_huandeng1;
                        fu_image_huandeng1.PostedFile.SaveAs(serverpath);//保存原图片

                        //string smallPath = savePath + artPic;//缩略图路径
                        //CommonMethod.MakeThumbnail(serverpath, smallPath, 500, 500, "W");//保存成最大500*500

                        //CommonMethod.FilePicDelete(serverpath);//删除原图片
                        huandeng1 = 1;
                    }
                }
            }
            //======================================上传图片附件==========================================================================

            string tagIdHtml = ""; //要引用的标签静态页ID(第一个标签的ID)
            string tagId     = ""; //要保存的多个标签ID
            string tagStr    = ""; //要保存的多个标签

            if (this.txt_tag.Text.Trim() != "")
            {
                tagStr = InText.SafeSql(InText.SafeStr(this.txt_tag.Text));

                //生成标签
                string[] arrayTag = tagStr.Split(' ');
                for (int i = 0; i < arrayTag.Length; i++)
                {
                    if (arrayTag[i].Trim() != "")
                    {
                        string tag_id = SelectOneTag(arrayTag[i]);
                        if (tag_id != "")
                        {
                            //CreateOneTag(tag_id);
                            if (tagIdHtml == "")
                            {
                                tagIdHtml = tag_id;
                            }
                            tagId += tag_id + ",";
                        }
                    }
                }
                tagId = "," + tagId;
            }



            if (articleId != 0)//执行修改
            {
                string sql = string.Format("update t_article set title='{0}',keyword='{1}',daoyu='{2}',content='{3}',type={4},declare_mark={5},pic='{6}',remark='{7}',source='{9}',huandeng1={10},huandeng1_pic='{11}',tag='{12}',tag_id='{13}',right_type={14},title1='{15}',search_keyword='{16}' where id={8}",
                                           title, keyword, daoyu, content, articleType, declare_mark, artPic, "article/", articleId, source, huandeng1, artPic_huandeng1, tagStr, tagId, right_type, title1, search_keyword);//

                bool isOk = artBll.ExecuteSQLNonquery(sql);

                GetLastNext(articleId, articleType);//获取上一篇、下一篇

                //更新上一篇、下一篇
                sql  = "update t_article set last_id=" + last_id + ",next_id=" + next_id + " where id=" + articleId;
                isOk = artBll.ExecuteSQLNonquery(sql);

                //更新上一篇文章的下一篇id
                sql  = "update t_article set next_id=" + articleId + " where id=" + last_id;
                isOk = artBll.ExecuteSQLNonquery(sql);

                //生成静态页
                CommonMethod.CreateArticleHtml(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tagId, tagIdHtml, Convert.ToDateTime(update_date).ToString("yyyy年M月d日"), last_html, last_title, next_html, next_title, search_keyword);

                //生成wap版静态页
                CommonMethod.CreateArticleHtml_Wap(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tagId, tagIdHtml, search_keyword);

                //重新生成上一篇文章(更新“下一篇”链接)
                CommonMethod.CreateOneArticleHtml(last_id);
                //sql = "select top 1 * from t_article where id <" + articleId + " order by id desc";
                //DataTable dtLast = artBll.SelectToDataTable(sql);
                //if (dtLast.Rows.Count > 0)
                //{
                //    int last_id = Convert.ToInt32(dtLast.Rows[0]["id"]);
                //    //string article_html_last = dtLast.Rows[0]["html"].ToString();
                //    CommonMethod.CreateOneArticleHtml(last_id);
                //}
            }
            else //执行添加
            {
                string sql = string.Format("insert into t_article (title,keyword,daoyu,content,type,update_date,declare_mark,pic,remark,source,huandeng1,huandeng1_pic,tag,tag_id,right_type,title1,search_keyword) values ('{0}','{1}','{2}','{3}',{4},getdate(),{5},'{6}','{7}','{8}',{9},'{10}','{11}','{12}',{13},'{14}','{15}')",
                                           title, keyword, daoyu, content, articleType, declare_mark, artPic, "article/", source, huandeng1, artPic_huandeng1, tagStr, tagId, right_type, title1, search_keyword);

                bool isOk = artBll.ExecuteSQLNonquery(sql);
                if (isOk)
                {
                    DataTable dtMaxId = artBll.SelectToDataTable("select max(id) as id from t_article");
                    if (dtMaxId.Rows.Count > 0)
                    {
                        articleId = Convert.ToInt32(dtMaxId.Rows[0]["id"]);
                        string id_show = CommonMethod.GetIDEncrypt(articleId);//对ID进行加密

                        DataTable dtIdShow = artBll.SelectToDataTable("select id from t_article where id_show='" + id_show + "' ");
                        while (dtIdShow.Rows.Count > 0)
                        {
                            id_show  = CommonMethod.GetIDEncrypt(articleId);//有重复,再次对ID进行加密
                            dtIdShow = artBll.SelectToDataTable("select id from t_article where id_show='" + id_show + "' ");
                        }
                        articleId    = Convert.ToInt32(dtMaxId.Rows[0]["id"]);
                        article_html = staticPath + id_show + ".shtml";
                        sql          = "update t_article set html='" + article_html + "',id_show='" + id_show + "' where id=" + articleId;
                        isOk         = artBll.ExecuteSQLNonquery(sql); //将静态页名称保存到数据库

                        GetLastNext(articleId, articleType);           //获取上一篇、下一篇

                        //更新上一篇、下一篇
                        sql  = "update t_article set last_id=" + last_id + ",next_id=" + next_id + " where id=" + articleId;
                        isOk = artBll.ExecuteSQLNonquery(sql);

                        //更新上一篇文章的下一篇id
                        sql  = "update t_article set next_id=" + articleId + " where id=" + last_id;
                        isOk = artBll.ExecuteSQLNonquery(sql);

                        //生成静态页
                        CommonMethod.CreateArticleHtml(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tagId, tagIdHtml, DateTime.Now.ToString("yyyy年M月d日"), last_html, last_title, next_html, next_title, search_keyword);

                        //生成wap版静态页
                        CommonMethod.CreateArticleHtml_Wap(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tagId, tagIdHtml, search_keyword);

                        //重新生成上一篇文章(更新“下一篇”链接)
                        CommonMethod.CreateOneArticleHtml(last_id);
                        //sql = "select top 1 * from t_article where id <" + articleId + " order by id desc";
                        //DataTable dtLast = artBll.SelectToDataTable(sql);
                        //if (dtLast.Rows.Count > 0)
                        //{
                        //    last_id = Convert.ToInt32(dtLast.Rows[0]["id"]);
                        //    //string article_html_last = dtLast.Rows[0]["html"].ToString();
                        //    CommonMethod.CreateOneArticleHtml(last_id);
                        //}
                    }
                }
            }

            if (this.txt_tag.Text.Trim() != "")
            {
                tagStr = InText.SafeSql(InText.SafeStr(this.txt_tag.Text));

                //生成标签
                string[] arrayTag = tagStr.Split(' ');
                for (int i = 0; i < arrayTag.Length; i++)
                {
                    if (arrayTag[i].Trim() != "")
                    {
                        string tag_id = SelectOneTag(arrayTag[i]);
                        if (tag_id != "")
                        {
                            CreateOneTag(tag_id);
                            if (tagIdHtml == "")
                            {
                                tagIdHtml = tag_id;
                            }
                            //select count(id) from t_article where tag_id like '*,9,*'

                            if (tag_id_a.Trim() == "")
                            {
                                //添加文章,更新该标签下的文章数量
                                artBll.ExecuteSQLNonquery("update t_tag set article_num=article_num+1 where id=" + tag_id);
                            }
                            tagId += tag_id + ",";
                        }
                    }
                }
                tagId = "," + tagId;
            }

            //生成右侧
            //CommonMethod.CteateHTML(url + "template/Side_2.aspx", "", "/userControl/Side_2.html");

            //生成404页面
            CommonMethod.CteateHTML(url + "template/404.aspx", "", "/404.html");

            if (articleId != 0)                                                        //执行修改
            {
                InText.AlertAndRedirect("修改成功", "/xzdd927/article/article_list.aspx"); //
            }
            else //执行添加
            {
                InText.AlertAndRedirect("添加成功", "/xzdd927/article/add_article.aspx");//  /xzdd927/article/article_list.aspx
            }
        }
Example #13
0
        public string navStr = "";// ?at=1 ?tag=1

        protected void Page_Load(object sender, EventArgs e)
        {
            CommonMethod.ValidUrl();

            if (!string.IsNullOrEmpty(Request.QueryString["title"]))
            {
                title = InText.SafeSql(InText.SafeStr(Request.QueryString["title"].ToString()));
                //this.txt_search.Value = title;
                articleTypeName        = "&gt " + "“" + title + "”的搜索结果";
                html_title             = "“" + title + "”" + "的搜索结果_好宝宝早教网";
                tishi                  = title;
                this.div_tishi.Visible = true;

                description = "好宝宝早教网为您提供有关" + title + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容";
                keywords    = title + "_" + @ConfigurationManager.AppSettings["title"].ToString();
            }
            if (!string.IsNullOrEmpty(Request.QueryString["tag"]))
            {
                tag_id = (Utils.CheckInt(Request.QueryString["tag"].ToString()));
                if (tag_id != 0)
                {
                    tagName                = this.SelectOneTagName(tag_id.ToString());
                    html_title             = tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString();
                    tishi                  = tagName;
                    this.div_tishi.Visible = true;

                    description = "好宝宝早教网为您提供有关" + tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容";
                    keywords    = tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString();

                    navStr = "tag=" + tag_id.ToString();
                    this.div_nav.Visible = true;
                }
            }
            if (!string.IsNullOrEmpty(Request.QueryString["at"]) && MetarnetRegex.IsNumeric(Request.QueryString["at"]))
            {
                articleType = Utils.CheckInt(Request.QueryString["at"].ToString());

                string    sql    = "select type_name,type_keyword from t_article_type where id=" + articleType;
                DataTable dtType = accessBll.SelectToDataTable(sql);
                if (dtType.Rows.Count > 0)
                {
                    articleTypeName = "&gt <span style='color:#36648b'>" + dtType.Rows[0]["type_name"].ToString() + "</span>";
                    if (dtType.Rows[0]["type_keyword"].ToString().Trim() != "")//分类关键词
                    {
                        html_title = dtType.Rows[0]["type_name"].ToString() + "_" + dtType.Rows[0]["type_keyword"].ToString() + "_好宝宝早教网";

                        description = "好宝宝早教网为您提供有关" + dtType.Rows[0]["type_name"].ToString() + "_" + dtType.Rows[0]["type_keyword"].ToString() + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容";
                        keywords    = dtType.Rows[0]["type_name"].ToString() + "," + dtType.Rows[0]["type_keyword"].ToString() + "," + @ConfigurationManager.AppSettings["title"].ToString().Replace("|", ",");
                    }
                    else
                    {
                        html_title = dtType.Rows[0]["type_name"].ToString() + "_好宝宝早教网";

                        description = "好宝宝早教网为您提供有关" + dtType.Rows[0]["type_name"].ToString() + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容";
                        keywords    = dtType.Rows[0]["type_name"].ToString() + "," + @ConfigurationManager.AppSettings["title"].ToString().Replace("|", ",");
                    }
                    tishi = dtType.Rows[0]["type_name"].ToString();

                    navStr = "at=" + articleType.ToString();
                    this.div_nav.Visible = true;
                }
            }

            if (html_title.Trim() == "")
            {
                html_title = @ConfigurationManager.AppSettings["title"].ToString();
            }

            if (tishi.Trim() == "")
            {
                this.div_tishi.Visible = false;
            }

            if (!IsPostBack)
            {
                BindList();//绑定列表

                //GetTypeList();//绑定文章分类
                //BindHotList();//绑定热门文章
            }
        }
Example #14
0
        private bool BindList()
        {
            bool ifOk = true;

            int pageIndex   = 1;
            int pageSize    = 30;//pager.PageSize;//每页显示10条信息
            int totalRecord = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"]))
            {
                pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString())));
            }

            string where = " where 1=1";
            if (articleId != 0)
            {
                where += " and articleId=" + articleId;
            }
            if (title.Trim() != "")
            {
                where += " and (title like '%" + title + "%' or keyword like '%" + title + "%' or tag_name like '%" + title + "%' or search_keyword like '%" + title + "%')";
            }
            if (tag_id != 0)
            {
                where += " and tag_id like '%," + tag_id + ",%'";
            }
            if (articleType != 0)
            {
                where += " and type=" + articleType;
            }

            if (where == " where 1=1")
            {
                //where += " and daoyu<>'no' ";
            }

            string strSql = " Select t_article.id as articleId,t_article.title,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,tag,tag_id,tag_name "
                            + " ,row_number() over(order by t_article.id desc) as rowNumber "
                            + " FROM t_article  "
                            + "  LEFT JOIN t_article_type ON t_article.type=t_article_type.id "
                            + " LEFT JOIN t_tag ON replace(t_article.tag_id,',','')=t_tag.id ";
            DataTable dt = artBll.ExecutePager(strSql + where, pageSize, pageIndex, ref totalRecord);

            //string strShow = " articleId,title,keyword,daoyu,content,type,update_date,declare_mark,pic,remark,type_name,html,tag,tag_id ";//要显示的字段
            //int PageCount = 0;
            //DataTable dt = artBll.ExecutePager(strSql, pageSize, pageIndex, ref totalRecord);

            //string sqlCount = "select count(*) from t_article left join t_article_type on t_article.type=t_article_type.id " + where;
            //totalRecord = accessBll.MaxCount(sqlCount);
            if (dt.Rows.Count > 0)
            {
                ifOk = true;

                pager.PageSize           = pageSize;
                pager.RecordCount        = totalRecord;
                this.repList1.DataSource = dt;
                this.repList1.DataBind();

                //this.labInfoCount.Text = totalRecord.ToString();

                if (totalRecord <= pageSize)//只有一页,隐藏分页控件
                {
                    this.divFenye.Visible = false;
                }

                //this.div_news.Visible = true;
            }
            else
            {
                this.divFenye.Visible = false;
                ifOk = false;

                //绑定最新发布的前N条文章
                sql = "Select top 20 t_article.id as articleId,t_article.title,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,source,tag,tag_id FROM t_article  " +
                      " LEFT JOIN t_article_type ON t_article.type=t_article_type.id  ";

                sql += " where daoyu<>'no' ";

                sql += " order by update_date desc ";
                dt   = artBll.SelectToDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    this.repList2.DataSource = dt;
                    this.repList2.DataBind();
                }
                this.div_nonews1.Visible = true;
                this.div_nonews2.Visible = true;
            }
            return(ifOk);
        }
Example #15
0
        private bool BindList()
        {
            bool ifOk = true;

            int pageIndex   = 1;
            int pageSize    = 20;//pager.PageSize;//每页显示10条信息
            int totalRecord = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"]))
            {
                pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString())));
            }

            string where = " where 1=1";
            if (articleId != 0)
            {
                where += " and articleId=" + articleId;
            }
            if (title.Trim() != "")
            {
                where += " and title like '%" + title + "%'";
            }
            if (tag_id != 0)
            {
                where += " and tag_id like '%," + tag_id + ",%'";
            }
            if (articleType != 0)
            {
                where += " and type=" + articleType;
            }

            if (where == " where 1=1")
            {
                where += " and daoyu<>'no' ";
            }
            //string strSql = " Select P.ProductID,P.ProClassID,P.ProductName,P.ProFlag,P.DateTime,P.ProductImage,C.ProClassName,C.ProClassKey,C.ProClassDes FROM ProductInfo P  " +
            //                    " LEFT JOIN ProClass C ON P.ProClassID=C.ProClassID ";
            //string strShow = " ProductID,ProductName,DateTime,ProductImage,ProFlag,ProClassName,ProClassKey,ProClassDes ";
            //return ClassFile.AccessHelper.ExecutePager(PageIndex, PageSize, "ProductID", strShow, strSql, strWhere, " ProductID DESC ", out PageCount, out RecordCount);

            string strSql = " Select t_article.id as articleId,t_article.title,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,tag,tag_id FROM t_article  " +
                            " LEFT JOIN t_article_type ON t_article.type=t_article_type.id ";
            string    strShow   = " articleId,title,keyword,daoyu,content,type,update_date,declare_mark,pic,remark,type_name,html,tag,tag_id ";//要显示的字段
            int       PageCount = 0;
            DataTable dt        = accessBll.ExecutePager(pageIndex, pageSize, "articleId", strShow, strSql, where, " update_date DESC ", out PageCount, out totalRecord);

            string sqlCount = "select count(*) from t_article left join t_article_type on t_article.type=t_article_type.id " + where;

            //totalRecord = accessBll.MaxCount(sqlCount);
            if (dt.Rows.Count > 0)
            {
                ifOk = true;

                pager.PageSize           = pageSize;
                pager.RecordCount        = totalRecord;
                this.repList1.DataSource = dt;
                this.repList1.DataBind();

                //this.labInfoCount.Text = totalRecord.ToString();

                if (totalRecord <= pageSize)//只有一页,隐藏分页控件
                {
                    this.divFenye.Visible = false;
                }

                this.div_news.Visible = true;
            }
            else
            {
                this.divFenye.Visible = false;
                ifOk = false;

                //绑定最新发布的前N条文章
                sql = "Select top 30 t_article.id as articleId,t_article.title,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,source,tag,tag_id FROM t_article  " +
                      " LEFT JOIN t_article_type ON t_article.type=t_article_type.id  ";

                sql += " where daoyu<>'no' ";

                sql += " order by update_date desc ";
                dt   = accessBll.SelectToDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    this.repList2.DataSource = dt;
                    this.repList2.DataBind();
                }
                this.div_nonews1.Visible = true;
                this.div_nonews2.Visible = true;
            }
            return(ifOk);
        }
Example #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            adminId = new AdminMethod().CheckAdminLogin();//-----------------------------

            if (!IsPostBack)
            {
                InitArticle();
            }

            if (!string.IsNullOrEmpty(Request.QueryString["a_id"]) && MetarnetRegex.IsNumeric(Request.QueryString["a_id"]))
            {
                articleId = Utils.CheckInt(Request.QueryString["a_id"].ToString());
                this.txt_article_id.Value = InText.SafeSql(InText.SafeStr(Request.QueryString["a_id"].ToString()));
            }
            if (!string.IsNullOrEmpty(Request.QueryString["title"]))
            {
                title = InText.SafeStr(Request.QueryString["title"].ToString());
                this.txt_title.Value = title;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["search_keyword"]))
            {
                search_keyword = InText.SafeStr(Request.QueryString["search_keyword"].ToString());
                this.txt_search_keyword.Value = title;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["a_t"]) && MetarnetRegex.IsNumeric(Request.QueryString["a_t"]))
            {
                articleType = Utils.CheckInt(Request.QueryString["a_t"].ToString());
                this.ddl_articleType.SelectedValue = InText.SafeStr(Request.QueryString["a_t"].ToString());
            }

            if (!string.IsNullOrEmpty(Request.QueryString["dateMin"]))
            {
                update_date_min = InText.SafeSql(InText.SafeStr(Request.QueryString["dateMin"].ToString()));
                this.txt_update_date_min.Value = update_date_min;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["dateMax"]))
            {
                update_date_max = InText.SafeSql(InText.SafeStr(Request.QueryString["dateMax"].ToString()));
                this.txt_update_date_max.Value = update_date_max;
            }

            if (!string.IsNullOrEmpty(Request.QueryString["tag"]))
            {
                tag = InText.SafeStr(Request.QueryString["tag"].ToString());
                this.txt_tag.Value = tag;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["html"]))
            {
                html = InText.SafeStr(Request.QueryString["html"].ToString());
                this.txt_html.Value = html;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["hd1"]) && MetarnetRegex.IsNumeric(Request.QueryString["hd1"]))
            {
                isHuandeng1 = Utils.CheckInt(Request.QueryString["hd1"].ToString());
                this.chkIsHuandeng1.Checked = true;
            }

            if (!string.IsNullOrEmpty(Request.QueryString["r_t"]) && MetarnetRegex.IsNumeric(Request.QueryString["r_t"]))
            {
                right_type = Utils.CheckInt(Request.QueryString["r_t"].ToString());
                this.ddl_right_type.SelectedValue = InText.SafeStr(Request.QueryString["r_t"].ToString());
            }

            if (!IsPostBack)
            {
                BindList();//绑定列表
            }
        }
Example #17
0
        private bool BindList()
        {
            bool ifOk = true;

            int pageIndex   = 1;
            int pageSize    = 20;//pager.PageSize;//每页显示20条信息
            int totalRecord = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"]))
            {
                pageIndex = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString())));
            }

            string where = " where 1=1";
            if (articleId != 0)
            {
                where += " and t_article.id=" + articleId;
            }
            if (title.Trim() != "")
            {
                where += " and title like '%" + title + "%'";
            }
            if (search_keyword.Trim() != "")
            {
                where += " and search_keyword like '%" + search_keyword + "%'";
            }

            if (articleType != 0)
            {
                where += " and type=" + articleType;
            }
            if (right_type != 0)
            {
                where += " and right_type=" + right_type;
            }
            if (update_date_min != "")
            {
                where += " and  DateDiff( day,  '" + update_date_min + "',update_date) >=0 ";
            }
            if (update_date_max != "")
            {
                where += " and  DateDiff( day,  '" + update_date_max + "',update_date) <=0 ";
            }
            if (tag.Trim() != "")
            {
                where += " and tag like '%" + tag + "%'";
            }
            if (html.Trim() != "")
            {
                where += " and html like '%" + html + "%'";
            }
            if (isHuandeng1 != 0)
            {
                where += " and huandeng1=1 ";
            }

            //string strSql = " Select P.ProductID,P.ProClassID,P.ProductName,P.ProFlag,P.DateTime,P.ProductImage,C.ProClassName,C.ProClassKey,C.ProClassDes FROM ProductInfo P  " +
            //                    " LEFT JOIN ProClass C ON P.ProClassID=C.ProClassID ";
            //string strShow = " ProductID,ProductName,DateTime,ProductImage,ProFlag,ProClassName,ProClassKey,ProClassDes ";
            //return ClassFile.AccessHelper.ExecutePager(PageIndex, PageSize, "ProductID", strShow, strSql, strWhere, " ProductID DESC ", out PageCount, out RecordCount);

            string strSql = " Select t_article.id as articleId,t_article.title,t_article.keyword,t_article.search_keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic,t_article.html,t_article.remark,t_article_type.type_name,source,t_article.tag,t_article.tag_id,t_article.huandeng1,right_type,t_article.ts_baidu "
                            + " ,row_number() over(order by t_article.id desc) as rowNumber "
                            + " FROM t_article  "
                            + " LEFT JOIN t_article_type ON t_article.type=t_article_type.id ";
            DataTable dt = artBll.ExecutePager(strSql + where, pageSize, pageIndex, ref totalRecord);

            if (dt.Rows.Count > 0)
            {
                ifOk = true;

                pager.PageSize          = pageSize;
                pager.RecordCount       = totalRecord;
                this.repList.DataSource = dt;
                this.repList.DataBind();

                this.labInfoCount.Text = totalRecord.ToString();

                if (totalRecord <= pageSize)//只有一页,隐藏分页控件
                {
                    this.divFenye.Visible = false;
                }
            }
            else
            {
                this.divFenye.Visible = false;
                ifOk = false;
            }
            return(ifOk);
        }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CommonMethod.ValidUrl();

            if (!string.IsNullOrEmpty(Request.QueryString["title"]))
            {
                title       = InText.SafeSql(InText.SafeStr(Request.QueryString["title"].ToString()));
                tishi       = "“" + title + "”的搜索结果";
                html_title  = "“" + title + "”" + "的搜索结果_好宝宝早教网";
                description = "好宝宝早教网为您提供有关" + title + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容";
                keywords    = title + "_" + @ConfigurationManager.AppSettings["title"].ToString();
            }
            if (!string.IsNullOrEmpty(Request.QueryString["tag"]))
            {
                tag_id = (Utils.CheckInt(Request.QueryString["tag"].ToString()));
                if (tag_id != 0)
                {
                    String    sql = "select * from t_tag where id=" + tag_id;
                    DataTable dt  = artBll.SelectToDataTable(sql);
                    if (dt.Rows.Count > 0)
                    {
                        tagName = dt.Rows[0]["tag_name"].ToString();
                        if (dt.Rows[0]["tag_keyword"].ToString().Trim() != "")
                        {
                            html_title  = tagName + "_" + dt.Rows[0]["tag_keyword"].ToString() + "_好宝宝早教网";
                            description = "好宝宝早教网为您提供有关" + tagName + "_" + dt.Rows[0]["tag_keyword"].ToString() + "的相关内容";
                            keywords    = tagName + "_" + dt.Rows[0]["tag_keyword"].ToString();
                        }
                        else
                        {
                            html_title  = tagName + "_好宝宝早教网";//+ "_" + @ConfigurationManager.AppSettings["title"].ToString();
                            description = "好宝宝早教网为您提供有关" + tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容";
                            keywords    = tagName + "_" + @ConfigurationManager.AppSettings["title"].ToString();
                        }
                        tishi = tagName;

                        miaoshu_pic   = dt.Rows[0]["tag_pic"].ToString();
                        miaoshu       = dt.Rows[0]["tag_miaoshu"].ToString();
                        miaoshu_title = tagName;
                        if (miaoshu.Trim() != "")
                        {
                            this.div_miaoshu.Visible = true;//显示描述div
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(Request.QueryString["at"]) && MetarnetRegex.IsNumeric(Request.QueryString["at"]))
            {
                articleType         = Utils.CheckInt(Request.QueryString["at"].ToString());
                this.hid_type.Value = Request.QueryString["at"].ToString();

                string    sql    = "select type_name,type_keyword from t_article_type where id=" + articleType;
                DataTable dtType = artBll.SelectToDataTable(sql);
                if (dtType.Rows.Count > 0)
                {
                    articleTypeName = dtType.Rows[0]["type_name"].ToString();
                    if (dtType.Rows[0]["type_keyword"].ToString().Trim() != "")//分类关键词
                    {
                        html_title = dtType.Rows[0]["type_name"].ToString() + "_" + dtType.Rows[0]["type_keyword"].ToString() + "_好宝宝早教网";

                        description = "好宝宝早教网为您提供有关" + dtType.Rows[0]["type_name"].ToString() + "_" + dtType.Rows[0]["type_keyword"].ToString() + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容";
                        keywords    = dtType.Rows[0]["type_name"].ToString() + "," + dtType.Rows[0]["type_keyword"].ToString() + "," + @ConfigurationManager.AppSettings["title"].ToString().Replace("|", ",");
                    }
                    else
                    {
                        html_title = dtType.Rows[0]["type_name"].ToString() + "_好宝宝早教网";

                        description = "好宝宝早教网为您提供有关" + dtType.Rows[0]["type_name"].ToString() + "_" + @ConfigurationManager.AppSettings["title"].ToString() + "的相关内容";
                        keywords    = dtType.Rows[0]["type_name"].ToString() + "," + @ConfigurationManager.AppSettings["title"].ToString().Replace("|", ",");
                    }
                    tishi = dtType.Rows[0]["type_name"].ToString();
                }
            }
            if (html_title.Trim() == "")
            {
                html_title = @ConfigurationManager.AppSettings["title"].ToString();
            }

            if (!string.IsNullOrEmpty(Request.QueryString["p"]) && MetarnetRegex.IsNumeric(Request.QueryString["p"]))
            {
                int p = Convert.ToInt32(InText.SafeSql(InText.SafeStr(Request.QueryString["p"].ToString())));
                if (p > 1)
                {
                    html_title += "_第" + p + "页";
                }
            }

            if (!IsPostBack)
            {
                BindList();//绑定列表
            }
        }
Example #19
0
        private void Login()
        {
            //string username = "";
            //if (!string.IsNullOrEmpty(HttpContext.Current.Request["username"]))
            //{
            //    username = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["username"]));
            //}
            //string pwd = "";
            //if (!string.IsNullOrEmpty(HttpContext.Current.Request["pwd"]))
            //{
            //    pwd = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["pwd"]));
            //    //pwd = WebBasic.Encryption.Encrypt(pwd);
            //    pwd = Utils.Encrypt(pwd);
            //}
            string username = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["username"]))
            {
                username = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request.Form["username"]));
            }
            string pwd = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["pwd"]))
            {
                pwd = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request.Form["pwd"]));
                //pwd = WebBasic.Encryption.Encrypt(pwd);
                pwd = Utils.Encrypt(pwd);
            }
            int valid_type = 1;//1、根据用户名判断  2、根据邮箱判断

            if (username.Contains("@"))
            {
                valid_type = 2;
            }
            int result = 0;

            if (userBll.SelectUsernameEmailExist(username) > 0)

            {
                int count = userBll.SelectUserPwdIsTrue(username, pwd, valid_type);
                if (count > 0)
                {
                    result = UserLogin(username);//执行登录,并返回登录结果
                }
                else
                {
                    result = 2;//用户名或密码错误
                }
            }
            else
            {
                result = 4;//用户名不存在
            }
            StringWriter sw = new StringWriter();

            Newtonsoft.Json.JsonWriter writer = new Newtonsoft.Json.JsonTextWriter(sw);

            writer.WriteStartObject();
            writer.WritePropertyName("status");
            writer.WriteValue("200");
            writer.WritePropertyName("result");
            writer.WriteValue(result.ToString());
            writer.WriteEndObject();
            writer.Flush();

            string jsonText = sw.GetStringBuilder().ToString();

            Response.Write(jsonText);
        }
Example #20
0
        private void register()
        {
            string username = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["username"]))
            {
                username = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["username"]));
            }
            string pwd = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["pwd"]))
            {
                pwd = Utils.Encrypt(InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["pwd"])));
            }
            string email = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["email"]))
            {
                email = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["email"]));
            }
            int sex = 2;

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["sex"]))
            {
                sex = Utils.CheckInt(HttpContext.Current.Request["sex"]);
            }
            int baby = 2;

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["baby"]))
            {
                baby = Utils.CheckInt(HttpContext.Current.Request["baby"]);
            }
            DateTime baby_date = DateTime.Now;

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["baby_date"]))
            {
                baby_date = Convert.ToDateTime(HttpContext.Current.Request["baby_date"]);
            }
            string remark = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["remark"]))
            {
                remark = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["remark"]));
            }

            int result = userBll.Add_User(username, pwd, email, sex, baby, baby_date, remark);

            StringWriter sw = new StringWriter();

            Newtonsoft.Json.JsonWriter writer = new Newtonsoft.Json.JsonTextWriter(sw);

            if (result > 0)
            {
                writer.WriteStartObject();
                writer.WritePropertyName("status");
                writer.WriteValue("200");
                writer.WritePropertyName("newid");
                writer.WriteValue(result.ToString());
                writer.WriteEndObject();
                writer.Flush();
            }
            else
            {
                writer.WriteStartObject();
                writer.WritePropertyName("status");
                writer.WriteValue("500");
                writer.WriteEndObject();
                writer.Flush();
            }
            string jsonText = sw.GetStringBuilder().ToString();

            Response.Write(jsonText);
        }