Esempio n. 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int id = int.Parse(Request["id"].ToString());
        string empNo = this.currentUser.empNo;
        string empNm = this.currentUser.empNm;

        LForumAnswerData forumAnswerData = new LForumAnswerData();
        LForumAnswerBB forumAnswerBB = new LForumAnswerBB();
        try
        {
            forumAnswerData.questionId = id;
            forumAnswerData.answerEmpNo = empNo;
            forumAnswerData.answerEmpNm = empNm;
            forumAnswerData.answerDt = DateTime.Now.ToString();
            forumAnswerData.answerContent = this.txtAnswerContent.Text;

            forumAnswerBB.AddRecord(forumAnswerData);
        }
        finally
        {
            forumAnswerBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
    }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(LForumAnswerData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into LForumAnswer(");
            strSql.Append(@"questionId,answerEmpNo,answerEmpNm,answerDt,answerContent)");
            strSql.Append(" values (");
            strSql.Append(@"@questionId,@answerEmpNo,@answerEmpNm,@answerDt,@answerContent)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@questionId", SqlDbType.Int),
                    new SqlParameter("@answerEmpNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@answerEmpNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@answerDt", SqlDbType.DateTime),
                    new SqlParameter("@answerContent", SqlDbType.NText)
                };
            parameters[0].Value = model.questionId;
            parameters[1].Value = model.answerEmpNo;
            parameters[2].Value = model.answerEmpNm;
            parameters[3].Value = model.answerDt == string.Empty ? null : model.answerDt;
            parameters[4].Value = model.answerContent;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(LForumAnswerData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update LForumAnswer set ");
            strSql.Append("questionId=@questionId,");
            strSql.Append("answerEmpNo=@answerEmpNo,");
            strSql.Append("answerEmpNm=@answerEmpNm,");
            strSql.Append("answerDt=@answerDt,");
            strSql.Append("answerContent=@answerContent");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@questionId", SqlDbType.Int),
                    new SqlParameter("@answerEmpNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@answerEmpNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@answerDt", SqlDbType.DateTime),
                    new SqlParameter("@answerContent", SqlDbType.NText)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.questionId;
            parameters[2].Value = model.answerEmpNo;
            parameters[3].Value = model.answerEmpNm;
            parameters[4].Value = model.answerDt == string.Empty ? null : model.answerDt;
            parameters[5].Value = model.answerContent;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public LForumAnswerData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,questionId,answerEmpNo,answerEmpNm,answerDt,answerContent from LForumAnswer");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            LForumAnswerData model = new LForumAnswerData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["questionId"] != DBNull.Value)
                {
                    model.questionId = Convert.ToInt32(row["questionId"]);
                }
                if (row["answerEmpNo"] != DBNull.Value)
                {
                    model.answerEmpNo = Convert.ToString(row["answerEmpNo"]);
                }
                if (row["answerEmpNm"] != DBNull.Value)
                {
                    model.answerEmpNm = Convert.ToString(row["answerEmpNm"]);
                }
                if (row["answerDt"] != DBNull.Value)
                {
                    model.answerDt = Convert.ToString(row["answerDt"]);
                }
                if (row["answerContent"] != DBNull.Value)
                {
                    model.answerContent = Convert.ToString(row["answerContent"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(LForumAnswerData model)
 {
     return this.forumAnswerDB.ModifyRecord(model);
 }
Esempio n. 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(LForumAnswerData model)
 {
     return this.forumAnswerDB.AddRecord(model);
 }