/// <summary> /// 更新一条数据 /// </summary> public bool Update(LEANJU.Model.Remark model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Remark set "); strSql.Append("emailorMbl=@emailorMbl,"); strSql.Append("pcount=@pcount,"); strSql.Append("remark=@remark"); strSql.Append(" where Hno=@Hno "); SqlParameter[] parameters = { new SqlParameter("@emailorMbl", SqlDbType.NVarChar, 20), new SqlParameter("@pcount", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.NVarChar, 50), new SqlParameter("@Hno", SqlDbType.NVarChar, 20) }; parameters[0].Value = model.emailorMbl; parameters[1].Value = model.pcount; parameters[2].Value = model.remark; parameters[3].Value = model.Hno; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(LEANJU.Model.Remark model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Remark("); strSql.Append("Hno,emailorMbl,pcount,remark)"); strSql.Append(" values ("); strSql.Append("@Hno,@emailorMbl,@pcount,@remark)"); SqlParameter[] parameters = { new SqlParameter("@Hno", SqlDbType.NVarChar, 20), new SqlParameter("@emailorMbl", SqlDbType.NVarChar, 20), new SqlParameter("@pcount", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Hno; parameters[1].Value = model.emailorMbl; parameters[2].Value = model.pcount; parameters[3].Value = model.remark; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public LEANJU.Model.Remark DataRowToModel(DataRow row) { LEANJU.Model.Remark model = new LEANJU.Model.Remark(); if (row != null) { if (row["Hno"] != null) { model.Hno = row["Hno"].ToString(); } if (row["emailorMbl"] != null) { model.emailorMbl = row["emailorMbl"].ToString(); } if (row["pcount"] != null && row["pcount"].ToString() != "") { model.pcount = int.Parse(row["pcount"].ToString()); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public LEANJU.Model.Remark GetModel(string Hno) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Hno,emailorMbl,pcount,remark from Remark "); strSql.Append(" where Hno=@Hno "); SqlParameter[] parameters = { new SqlParameter("@Hno", SqlDbType.NVarChar, 20) }; parameters[0].Value = Hno; LEANJU.Model.Remark model = new LEANJU.Model.Remark(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }