Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(abc.Model.Model.AskNotifyPlan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AskNotifyPlan(");
            strSql.Append("AskId,Content,OrderBy,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("SQL2012AskId,SQL2012Content,SQL2012OrderBy,SQL2012CreateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012AskId",      SqlDbType.Int,        4),
                new SqlParameter("SQL2012Content",    SqlDbType.VarChar, 4000),
                new SqlParameter("SQL2012OrderBy",    SqlDbType.Int,        4),
                new SqlParameter("SQL2012CreateTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.AskId;
            parameters[1].Value = model.Content;
            parameters[2].Value = model.OrderBy;
            parameters[3].Value = model.CreateTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public abc.Model.Model.AskNotifyPlan DataRowToModel(DataRow row)
 {
     abc.Model.Model.AskNotifyPlan model = new abc.Model.Model.AskNotifyPlan();
     if (row != null)
     {
         if (row["NotifyId"] != null && row["NotifyId"].ToString() != "")
         {
             model.NotifyId = int.Parse(row["NotifyId"].ToString());
         }
         if (row["AskId"] != null && row["AskId"].ToString() != "")
         {
             model.AskId = int.Parse(row["AskId"].ToString());
         }
         if (row["Content"] != null)
         {
             model.Content = row["Content"].ToString();
         }
         if (row["OrderBy"] != null && row["OrderBy"].ToString() != "")
         {
             model.OrderBy = int.Parse(row["OrderBy"].ToString());
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(abc.Model.Model.AskNotifyPlan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AskNotifyPlan set ");
            strSql.Append("Content=SQL2012Content,");
            strSql.Append("OrderBy=SQL2012OrderBy,");
            strSql.Append("CreateTime=SQL2012CreateTime");
            strSql.Append(" where NotifyId=SQL2012NotifyId");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012Content",    SqlDbType.VarChar,   4000),
                new SqlParameter("SQL2012OrderBy",    SqlDbType.Int,          4),
                new SqlParameter("SQL2012CreateTime", SqlDbType.DateTime),
                new SqlParameter("SQL2012NotifyId",   SqlDbType.Int,          4),
                new SqlParameter("SQL2012AskId",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Content;
            parameters[1].Value = model.OrderBy;
            parameters[2].Value = model.CreateTime;
            parameters[3].Value = model.NotifyId;
            parameters[4].Value = model.AskId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public abc.Model.Model.AskNotifyPlan GetModel(int NotifyId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 NotifyId,AskId,Content,OrderBy,CreateTime from AskNotifyPlan ");
            strSql.Append(" where NotifyId=SQL2012NotifyId");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012NotifyId", SqlDbType.Int, 4)
            };
            parameters[0].Value = NotifyId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }