/// <summary> /// 增加一条数据 /// </summary> public bool Add(ZhongLi.Model.Friends model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@PerID", SqlDbType.Int, 4), new SqlParameter("@SerUserID", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime) }; parameters[0].Value = model.PerID; parameters[1].Value = model.SerUserID; parameters[2].Value = model.CreateTime; DbHelperSQL.RunProcedure("Friends_ADD", parameters, out rowsAffected); return(rowsAffected > 0); }
/// <summary> /// 得到一个对象实体 /// </summary> public ZhongLi.Model.Friends DataRowToModel(DataRow row) { ZhongLi.Model.Friends model = new ZhongLi.Model.Friends(); if (row != null) { if (row["PerID"] != null && row["PerID"].ToString() != "") { model.PerID = int.Parse(row["PerID"].ToString()); } if (row["SerUserID"] != null && row["SerUserID"].ToString() != "") { model.SerUserID = int.Parse(row["SerUserID"].ToString()); } if (row["CreateTime"] != null && row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public ZhongLi.Model.Friends GetModel(int PerID, int SerUserID) { SqlParameter[] parameters = { new SqlParameter("@PerID", SqlDbType.Int, 4), new SqlParameter("@SerUserID", SqlDbType.Int, 4) }; parameters[0].Value = PerID; parameters[1].Value = SerUserID; ZhongLi.Model.Friends model = new ZhongLi.Model.Friends(); DataSet ds = DbHelperSQL.RunProcedure("Friends_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ZhongLi.Model.Friends model) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@PerID", SqlDbType.Int, 4), new SqlParameter("@SerUserID", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime) }; parameters[0].Value = model.PerID; parameters[1].Value = model.SerUserID; parameters[2].Value = model.CreateTime; DbHelperSQL.RunProcedure("Friends_Update", parameters, out rowsAffected); if (rowsAffected > 0) { return(true); } else { return(false); } }