/// <summary> /// 更新一条数据 /// </summary> public bool Update(book_shop.Model.CheckEmailModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update CheckEmail set "); strSql.Append("Actived=@Actived,"); strSql.Append("ActiveCode=@ActiveCode"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Actived", SqlDbType.Bit, 1), new SqlParameter("@ActiveCode", SqlDbType.NVarChar, 50), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.Actived; parameters[1].Value = model.ActiveCode; parameters[2].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public book_shop.Model.CheckEmailModel DataRowToModel(DataRow row) { book_shop.Model.CheckEmailModel model = new book_shop.Model.CheckEmailModel(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["Actived"] != null && row["Actived"].ToString() != "") { if ((row["Actived"].ToString() == "1") || (row["Actived"].ToString().ToLower() == "true")) { model.Actived = true; } else { model.Actived = false; } } if (row["ActiveCode"] != null) { model.ActiveCode = row["ActiveCode"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(book_shop.Model.CheckEmailModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CheckEmail("); strSql.Append("Actived,ActiveCode)"); strSql.Append(" values ("); strSql.Append("@Actived,@ActiveCode)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Actived", SqlDbType.Bit, 1), new SqlParameter("@ActiveCode", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Actived; parameters[1].Value = model.ActiveCode; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public book_shop.Model.CheckEmailModel GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,Actived,ActiveCode from CheckEmail "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; book_shop.Model.CheckEmailModel model = new book_shop.Model.CheckEmailModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }