/// <summary> /// 得到一个对象实体 /// </summary> public t_index_banner DataRowToModel(DataRow row) { t_index_banner model = new t_index_banner(); if (row != null) { if (row["iAutoID"] != null && row["iAutoID"].ToString() != "") { model.iAutoID = int.Parse(row["iAutoID"].ToString()); } if (row["sName"] != null) { model.sName = row["sName"].ToString(); } if (row["sImg"] != null) { model.sImg = row["sImg"].ToString(); } if (row["sBackGround"] != null) { model.sBackGround = row["sBackGround"].ToString(); } if (row["sUrl"] != null) { model.sUrl = row["sUrl"].ToString(); } if (row["iType"] != null && row["iType"].ToString() != "") { model.iType = int.Parse(row["iType"].ToString()); } if (row["iAdminID"] != null && row["iAdminID"].ToString() != "") { model.iAdminID = int.Parse(row["iAdminID"].ToString()); } if (row["iOnline"] != null && row["iOnline"].ToString() != "") { model.iOnline = int.Parse(row["iOnline"].ToString()); } if (row["iSort"] != null && row["iSort"].ToString() != "") { model.iSort = int.Parse(row["iSort"].ToString()); } if (row["iStatus"] != null && row["iStatus"].ToString() != "") { model.iStatus = int.Parse(row["iStatus"].ToString()); } if (row["iCreateTime"] != null && row["iCreateTime"].ToString() != "") { model.iCreateTime = int.Parse(row["iCreateTime"].ToString()); } if (row["iUpdateTime"] != null && row["iUpdateTime"].ToString() != "") { model.iUpdateTime = int.Parse(row["iUpdateTime"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(t_index_banner model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_index_banner set "); strSql.Append("sName=@sName,"); strSql.Append("sImg=@sImg,"); strSql.Append("sBackGround=@sBackGround,"); strSql.Append("sUrl=@sUrl,"); strSql.Append("iType=@iType,"); strSql.Append("iAdminID=@iAdminID,"); strSql.Append("iOnline=@iOnline,"); strSql.Append("iSort=@iSort,"); strSql.Append("iStatus=@iStatus,"); strSql.Append("iCreateTime=@iCreateTime,"); strSql.Append("iUpdateTime=@iUpdateTime"); strSql.Append(" where iAutoID=@iAutoID"); MySqlParameter[] parameters = { new MySqlParameter("@sName", MySqlDbType.VarChar, 255), new MySqlParameter("@sImg", MySqlDbType.VarChar, 500), new MySqlParameter("@sBackGround", MySqlDbType.VarChar, 50), new MySqlParameter("@sUrl", MySqlDbType.VarChar, 200), new MySqlParameter("@iType", MySqlDbType.Int32, 1), new MySqlParameter("@iAdminID", MySqlDbType.Int32, 10), new MySqlParameter("@iOnline", MySqlDbType.Int32, 1), new MySqlParameter("@iSort", MySqlDbType.Int32, 1), new MySqlParameter("@iStatus", MySqlDbType.Int32, 1), new MySqlParameter("@iCreateTime", MySqlDbType.Int32, 10), new MySqlParameter("@iUpdateTime", MySqlDbType.Int32, 10), new MySqlParameter("@iAutoID", MySqlDbType.Int32, 10) }; parameters[0].Value = model.sName; parameters[1].Value = model.sImg; parameters[2].Value = model.sBackGround; parameters[3].Value = model.sUrl; parameters[4].Value = model.iType; parameters[5].Value = model.iAdminID; parameters[6].Value = model.iOnline; parameters[7].Value = model.iSort; parameters[8].Value = model.iStatus; parameters[9].Value = model.iCreateTime; parameters[10].Value = model.iUpdateTime; parameters[11].Value = model.iAutoID; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(t_index_banner model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_index_banner("); strSql.Append("sName,sImg,sBackGround,sUrl,iType,iAdminID,iOnline,iSort,iStatus,iCreateTime,iUpdateTime)"); strSql.Append(" values ("); strSql.Append("@sName,@sImg,@sBackGround,@sUrl,@iType,@iAdminID,@iOnline,@iSort,@iStatus,@iCreateTime,@iUpdateTime)"); MySqlParameter[] parameters = { new MySqlParameter("@sName", MySqlDbType.VarChar, 255), new MySqlParameter("@sImg", MySqlDbType.VarChar, 500), new MySqlParameter("@sBackGround", MySqlDbType.VarChar, 50), new MySqlParameter("@sUrl", MySqlDbType.VarChar, 200), new MySqlParameter("@iType", MySqlDbType.Int32, 1), new MySqlParameter("@iAdminID", MySqlDbType.Int32, 10), new MySqlParameter("@iOnline", MySqlDbType.Int32, 1), new MySqlParameter("@iSort", MySqlDbType.Int32, 1), new MySqlParameter("@iStatus", MySqlDbType.Int32, 1), new MySqlParameter("@iCreateTime", MySqlDbType.Int32, 10), new MySqlParameter("@iUpdateTime", MySqlDbType.Int32, 10) }; parameters[0].Value = model.sName; parameters[1].Value = model.sImg; parameters[2].Value = model.sBackGround; parameters[3].Value = model.sUrl; parameters[4].Value = model.iType; parameters[5].Value = model.iAdminID; parameters[6].Value = model.iOnline; parameters[7].Value = model.iSort; parameters[8].Value = model.iStatus; parameters[9].Value = model.iCreateTime; parameters[10].Value = model.iUpdateTime; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public t_index_banner GetModel(int iAutoID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select iAutoID,sName,sImg,sBackGround,sUrl,iType,iAdminID,iOnline,iSort,iStatus,iCreateTime,iUpdateTime from t_index_banner "); strSql.Append(" where iAutoID=@iAutoID"); MySqlParameter[] parameters = { new MySqlParameter("@iAutoID", MySqlDbType.Int32) }; parameters[0].Value = iAutoID; t_index_banner model = new t_index_banner(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(t_index_banner model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(t_index_banner model) { return(dal.Add(model)); }