Esempio n. 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <System.Model.System_FAQ> DataTableToList(DataTable dt)
        {
            List <System.Model.System_FAQ> modelList = new List <System.Model.System_FAQ>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                System.Model.System_FAQ model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new System.Model.System_FAQ();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.issue  = dt.Rows[n]["issue"].ToString();
                    model.answer = dt.Rows[n]["answer"].ToString();
                    if (dt.Rows[n]["pudate"].ToString() != "")
                    {
                        model.pudate = DateTime.Parse(dt.Rows[n]["pudate"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(System.Model.System_FAQ model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into System_FAQ(");
            strSql.Append("issue,answer,pudate");
            strSql.Append(") values (");
            strSql.Append("@issue,@answer,@pudate");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@issue",  SqlDbType.NVarChar, 500),
                new SqlParameter("@answer", SqlDbType.Text),
                new SqlParameter("@pudate", SqlDbType.DateTime)
            };

            parameters[0].Value = model.issue;
            parameters[1].Value = model.answer;
            parameters[2].Value = model.pudate;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(System.Model.System_FAQ model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update System_FAQ set ");

            strSql.Append(" issue = @issue , ");
            strSql.Append(" answer = @answer , ");
            strSql.Append(" pudate = @pudate  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",     SqlDbType.Int,        4),
                new SqlParameter("@issue",  SqlDbType.NVarChar, 500),
                new SqlParameter("@answer", SqlDbType.Text),
                new SqlParameter("@pudate", SqlDbType.DateTime)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.issue;
            parameters[2].Value = model.answer;
            parameters[3].Value = model.pudate;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //常见问题id
                string id = Request["id"] != null?Utility.Helper.Checkstr(Request["id"]) : "";

                System.Model.System_FAQ faq = _bll.sfbll.GetModel(Utility.Helper.gerInt(id));

                if (faq != null)
                {
                    titles.Text      = faq.issue;
                    issue.InnerHtml  = "问: " + faq.issue;
                    answer.InnerHtml = "答: " + HttpUtility.HtmlDecode(faq.answer);
                }
            }
        }
        protected void btnBc_Click(object sender, EventArgs e)
        {
            try
            {
                string id   = Request.QueryString["id"];
                string text = Server.HtmlEncode(this.fckContent.Text.Trim());
                if (!string.IsNullOrEmpty(id))
                {
                    int jg = bll.Execute("update System_FAQ set issue='" + this.txtTitle.Text.Trim() + "',answer='" + text + "' where id='" + Request.QueryString["id"] + "'");
                    if (jg > 0)
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('编辑常见问题成功!');window.location.href='admin_feedback.aspx';", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('编辑常见问题失败!');window.location.href='admin_feedback.aspx';", true);
                    }
                }
                else
                {
                    System.Model.System_FAQ sf = new System.Model.System_FAQ();

                    sf.issue  = this.txtTitle.Text;
                    sf.pudate = System.DateTime.Now;
                    sf.answer = Server.HtmlEncode(this.fckContent.Text);
                    if (_bll.sfbll.Add(sf) > 0)
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('添加常见问题成功!');window.location.href='admin_feedback.aspx';", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Test", "alert('添加常见问题失败!');window.location.href='admin_feedback.aspx';", true);
                    }
                }
            }
            catch
            {
                Response.Redirect(ConfigurationManager.AppSettings["VirturlPath"] + "/error500.aspx?menu1=2&menu2=5");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public System.Model.System_FAQ GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, issue, answer, pudate  ");
            strSql.Append("  from System_FAQ ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            System.Model.System_FAQ model = new System.Model.System_FAQ();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.issue  = ds.Tables[0].Rows[0]["issue"].ToString();
                model.answer = ds.Tables[0].Rows[0]["answer"].ToString();
                if (ds.Tables[0].Rows[0]["pudate"].ToString() != "")
                {
                    model.pudate = DateTime.Parse(ds.Tables[0].Rows[0]["pudate"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(System.Model.System_FAQ model)
 {
     return(dal.Update(model));
 }
Esempio n. 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(System.Model.System_FAQ model)
 {
     return(dal.Add(model));
 }