Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ALS.Model.warncode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_warncode set ");
            strSql.Append("code=@code,");
            strSql.Append("content=@content,");
            strSql.Append("reason=@reason,");
            strSql.Append("deal=@deal");
            strSql.Append(" where ID=@ID ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@code",    MySqlDbType.VarChar, 255),
                new MySqlParameter("@content", MySqlDbType.Text),
                new MySqlParameter("@reason",  MySqlDbType.Text),
                new MySqlParameter("@deal",    MySqlDbType.Text),
                new MySqlParameter("@ID",      MySqlDbType.Int32, 20)
            };
            parameters[0].Value = model.code;
            parameters[1].Value = model.content;
            parameters[2].Value = model.reason;
            parameters[3].Value = model.deal;
            parameters[4].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ALS.Model.warncode DataRowToModel(DataRow row)
 {
     ALS.Model.warncode model = new ALS.Model.warncode();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = long.Parse(row["ID"].ToString());
         }
         if (row["code"] != null)
         {
             model.code = row["code"].ToString();
         }
         if (row["content"] != null)
         {
             model.content = row["content"].ToString();
         }
         if (row["reason"] != null)
         {
             model.reason = row["reason"].ToString();
         }
         if (row["deal"] != null)
         {
             model.deal = row["deal"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ALS.Model.warncode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_warncode(");
            strSql.Append("ID,code,content,reason,deal)");
            strSql.Append(" values (");
            strSql.Append("@ID,@code,@content,@reason,@deal)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID",      MySqlDbType.Int32,    20),
                new MySqlParameter("@code",    MySqlDbType.VarChar, 255),
                new MySqlParameter("@content", MySqlDbType.Text),
                new MySqlParameter("@reason",  MySqlDbType.Text),
                new MySqlParameter("@deal",    MySqlDbType.Text)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.code;
            parameters[2].Value = model.content;
            parameters[3].Value = model.reason;
            parameters[4].Value = model.deal;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        public ALS.Model.warncode GetModel(string code)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,code,content,reason,deal,grade,dealSteps,dealImg from tb_warncode ");
            strSql.Append(" where code=@code ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@code", MySqlDbType.VarChar)
            };
            parameters[0].Value = code;

            ALS.Model.warncode model = new ALS.Model.warncode();
            DataSet            ds    = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ALS.Model.warncode GetModel(long ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,code,content,reason,deal from tb_warncode ");
            strSql.Append(" where ID=@ID ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID", MySqlDbType.Int32, 20)
            };
            parameters[0].Value = ID;

            ALS.Model.warncode model = new ALS.Model.warncode();
            DataSet            ds    = DbHelperMySQL.Query(strSql.ToString(), parameters);

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