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