Exemple #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(RequestionModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tbRequestion(");
            strSql.Append("ftypeid,ftitle,fcontent,CreateBy,CreateTime,UpdateBy,UpdateTime");
            strSql.Append(") values (");
            strSql.Append("@ftypeid,@ftitle,@fcontent,@CreateBy,@CreateTime,@UpdateBy,@UpdateTime");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ftypeid",    SqlDbType.Int,        4),
                new SqlParameter("@ftitle",     SqlDbType.NVarChar,  50),
                new SqlParameter("@fcontent",   SqlDbType.Text),
                new SqlParameter("@CreateBy",   SqlDbType.NVarChar,  50),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@UpdateBy",   SqlDbType.NVarChar,  50),
                new SqlParameter("@UpdateTime", SqlDbType.DateTime)
            };

            parameters[0].Value = model.ftypeid;
            parameters[1].Value = model.ftitle;
            parameters[2].Value = model.fcontent;
            parameters[3].Value = model.CreateBy;
            parameters[4].Value = model.CreateTime;
            parameters[5].Value = model.UpdateBy;
            parameters[6].Value = model.UpdateTime;
            object obj = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.connStr, CommandType.Text, strSql.ToString(), parameters));

            return(Convert.ToInt32(obj));
        }
Exemple #2
0
        public ActionResult AddRequestion()
        {
            try
            {
                UserModel       uInfo         = ViewData["Account"] as UserModel;
                RequestionModel requestionAdd = new RequestionModel();
                requestionAdd.ftitle     = Request["FTitle"];
                requestionAdd.ftypeid    = int.Parse(Request["FTypeId"]);
                requestionAdd.fcontent   = Request["FContent"];
                requestionAdd.CreateBy   = uInfo.AccountName;
                requestionAdd.CreateTime = DateTime.Now;
                requestionAdd.UpdateBy   = uInfo.AccountName;
                requestionAdd.UpdateTime = DateTime.Now;

                int id = new RequestionBLL().Add(requestionAdd);
                if (id > 0)
                {
                    return(Content("{\"msg\":\"添加成功!\",\"success\":true}"));
                }
                else
                {
                    return(Content("{\"msg\":\"添加失败!\",\"success\":false}"));
                }
            }
            catch (Exception ex)
            {
                return(Content("{\"msg\":\"修改失败," + ex.Message + "\",\"success\":false}"));
            }
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RequestionModel GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, ftypeid, ftitle, fcontent, CreateTime, CreateBy, UpdateBy, UpdateTime  ");
            strSql.Append("  from tbRequestion ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            RequestionModel model = new RequestionModel();
            DataTable       dt    = SqlHelper.GetDataTable(SqlHelper.connStr, CommandType.Text, strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(dt.Rows[0]["id"].ToString());
                }
                if (dt.Rows[0]["ftypeid"].ToString() != "")
                {
                    model.ftypeid = int.Parse(dt.Rows[0]["ftypeid"].ToString());
                }
                model.ftitle   = dt.Rows[0]["ftitle"].ToString();
                model.fcontent = dt.Rows[0]["fcontent"].ToString();
                model.CreateBy = dt.Rows[0]["CreateBy"].ToString();
                if (dt.Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(dt.Rows[0]["CreateTime"].ToString());
                }
                model.UpdateBy = dt.Rows[0]["UpdateBy"].ToString();
                if (dt.Rows[0]["UpdateTime"].ToString() != "")
                {
                    model.UpdateTime = DateTime.Parse(dt.Rows[0]["UpdateTime"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(RequestionModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbRequestion set ");

            strSql.Append(" ftypeid = @ftypeid , ");
            strSql.Append(" ftitle = @ftitle , ");
            strSql.Append(" fcontent = @fcontent , ");
            strSql.Append(" CreateBy = @CreateBy , ");
            strSql.Append(" CreateTime = @CreateTime , ");
            strSql.Append(" UpdateBy = @UpdateBy , ");
            strSql.Append(" UpdateTime = @UpdateTime  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",         SqlDbType.Int,        4),
                new SqlParameter("@ftypeid",    SqlDbType.Int,        4),
                new SqlParameter("@ftitle",     SqlDbType.NVarChar,  50),
                new SqlParameter("@fcontent",   SqlDbType.Text),
                new SqlParameter("@CreateBy",   SqlDbType.NVarChar,  50),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@UpdateBy",   SqlDbType.NVarChar,  50),
                new SqlParameter("@UpdateTime", SqlDbType.DateTime)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.ftypeid;
            parameters[2].Value = model.ftitle;
            parameters[3].Value = model.fcontent;
            parameters[4].Value = model.CreateBy;
            parameters[5].Value = model.CreateTime;
            parameters[6].Value = model.UpdateBy;
            parameters[7].Value = model.UpdateTime;
            object obj = SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), parameters);

            return(Convert.ToInt32(obj));
        }
Exemple #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(RequestionModel model)
 {
     return(dal.Update(model));
 }
Exemple #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(RequestionModel model)
 {
     return(dal.Add(model));
 }