/// <summary> /// 更新一条数据 /// </summary> public bool Update(MesWeb.Model.T_SpotDist_SpotInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_SpotDist_SpotInfo set "); if (model.SpotDistId != null) { strSql.Append("SpotDistId=" + model.SpotDistId + ","); } if (model.SpotInfoId != null) { strSql.Append("SpotInfoId=" + model.SpotInfoId + ","); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where Id=" + model.Id + ""); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(MesWeb.Model.T_SpotDist_SpotInfo model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.SpotDistId != null) { strSql1.Append("SpotDistId,"); strSql2.Append("" + model.SpotDistId + ","); } if (model.SpotInfoId != null) { strSql1.Append("SpotInfoId,"); strSql2.Append("" + model.SpotInfoId + ","); } strSql.Append("insert into T_SpotDist_SpotInfo("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); strSql.Append(";select @@IDENTITY"); object obj = DbHelperSQL.GetSingle(strSql.ToString()); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_SpotDist_SpotInfo DataRowToModel(DataRow row) { MesWeb.Model.T_SpotDist_SpotInfo model = new MesWeb.Model.T_SpotDist_SpotInfo(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["SpotDistId"] != null && row["SpotDistId"].ToString() != "") { model.SpotDistId = int.Parse(row["SpotDistId"].ToString()); } if (row["SpotInfoId"] != null && row["SpotInfoId"].ToString() != "") { model.SpotInfoId = int.Parse(row["SpotInfoId"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_SpotDist_SpotInfo GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" Id,SpotDistId,SpotInfoId "); strSql.Append(" from T_SpotDist_SpotInfo "); strSql.Append(" where Id=" + Id + ""); MesWeb.Model.T_SpotDist_SpotInfo model = new MesWeb.Model.T_SpotDist_SpotInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }