/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hch.iDisk.Model.FriendV model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update FriendV set "); strSql.Append("FrOwnerId=@FrOwnerId,"); strSql.Append("FrFriendId=@FrFriendId,"); strSql.Append("ULoginName=@ULoginName"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@FrOwnerId", SqlDbType.Int, 4), new SqlParameter("@FrFriendId", SqlDbType.Int, 4), new SqlParameter("@ULoginName", SqlDbType.VarChar, 20) }; parameters[0].Value = model.FrOwnerId; parameters[1].Value = model.FrFriendId; parameters[2].Value = model.ULoginName; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Hch.iDisk.Model.FriendV GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 FrOwnerId,FrFriendId,ULoginName from FriendV "); strSql.Append(" where "); SqlParameter[] parameters = { }; Hch.iDisk.Model.FriendV model = new Hch.iDisk.Model.FriendV(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["FrOwnerId"].ToString() != "") { model.FrOwnerId = int.Parse(ds.Tables[0].Rows[0]["FrOwnerId"].ToString()); } if (ds.Tables[0].Rows[0]["FrFriendId"].ToString() != "") { model.FrFriendId = int.Parse(ds.Tables[0].Rows[0]["FrFriendId"].ToString()); } if (ds.Tables[0].Rows[0]["ULoginName"] != null) { model.ULoginName = ds.Tables[0].Rows[0]["ULoginName"].ToString(); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Hch.iDisk.Model.FriendV model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into FriendV("); strSql.Append("FrOwnerId,FrFriendId,ULoginName)"); strSql.Append(" values ("); strSql.Append("@FrOwnerId,@FrFriendId,@ULoginName)"); SqlParameter[] parameters = { new SqlParameter("@FrOwnerId", SqlDbType.Int, 4), new SqlParameter("@FrFriendId", SqlDbType.Int, 4), new SqlParameter("@ULoginName", SqlDbType.VarChar, 20) }; parameters[0].Value = model.FrOwnerId; parameters[1].Value = model.FrFriendId; parameters[2].Value = model.ULoginName; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public Hch.iDisk.Model.FriendV GetModel() { //�ñ���������Ϣ�����Զ�������/�����ֶ� StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 FrOwnerId,FrFriendId,ULoginName from FriendV "); strSql.Append(" where "); SqlParameter[] parameters = { }; Hch.iDisk.Model.FriendV model=new Hch.iDisk.Model.FriendV(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["FrOwnerId"].ToString()!="") { model.FrOwnerId=int.Parse(ds.Tables[0].Rows[0]["FrOwnerId"].ToString()); } if(ds.Tables[0].Rows[0]["FrFriendId"].ToString()!="") { model.FrFriendId=int.Parse(ds.Tables[0].Rows[0]["FrFriendId"].ToString()); } if(ds.Tables[0].Rows[0]["ULoginName"]!=null) { model.ULoginName=ds.Tables[0].Rows[0]["ULoginName"].ToString(); } return model; } else { return null; } }