/// <summary> /// 得到一个对象实体 /// </summary> public Hch.iDisk.Model.Admin GetModel(int UserId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 UserId from Admin "); strSql.Append(" where UserId=@UserId "); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int, 4) }; parameters[0].Value = UserId; Hch.iDisk.Model.Admin model = new Hch.iDisk.Model.Admin(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["UserId"].ToString() != "") { model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Hch.iDisk.Model.Admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Admin("); strSql.Append("UserId)"); strSql.Append(" values ("); strSql.Append("@UserId)"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int, 4) }; parameters[0].Value = model.UserId; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hch.iDisk.Model.Admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Admin set "); #warning 系统发现缺少更新的字段,请手工确认如此更新是否正确! strSql.Append("UserId=@UserId"); strSql.Append(" where UserId=@UserId "); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int, 4) }; parameters[0].Value = model.UserId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public Hch.iDisk.Model.Admin GetModel(int UserId) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 UserId from Admin "); strSql.Append(" where UserId=@UserId "); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int,4)}; parameters[0].Value = UserId; Hch.iDisk.Model.Admin model=new Hch.iDisk.Model.Admin(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["UserId"].ToString()!="") { model.UserId=int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString()); } return model; } else { return null; } }