/// <summary> /// 更新一条数据 /// </summary> public bool Update(NCPEP.Model.T_Dyzt model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Dyzt set "); strSql.Append("binid=@binid,"); strSql.Append("dyzt=@dyzt"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@binid", SqlDbType.VarChar, 50), new SqlParameter("@dyzt", SqlDbType.VarChar, 50), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.binid; parameters[1].Value = model.dyzt; parameters[2].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(NCPEP.Model.T_Dyzt model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Dyzt("); strSql.Append("binid,dyzt)"); strSql.Append(" values ("); strSql.Append("@binid,@dyzt)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@binid", SqlDbType.VarChar, 50), new SqlParameter("@dyzt", SqlDbType.VarChar, 50) }; parameters[0].Value = model.binid; parameters[1].Value = model.dyzt; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public NCPEP.Model.T_Dyzt DataRowToModel(DataRow row) { NCPEP.Model.T_Dyzt model = new NCPEP.Model.T_Dyzt(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["binid"] != null) { model.binid = row["binid"].ToString(); } if (row["dyzt"] != null) { model.dyzt = row["dyzt"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public NCPEP.Model.T_Dyzt GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,binid,dyzt from T_Dyzt "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; NCPEP.Model.T_Dyzt model = new NCPEP.Model.T_Dyzt(); DataSet ds = DbHelperSQL.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(NCPEP.Model.T_Dyzt model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(NCPEP.Model.T_Dyzt model) { return(dal.Add(model)); }