/// <summary> /// 更新一条数据 /// </summary> public bool Update(LPWeb.Model.User2LoanType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update User2LoanType set "); #warning 系统发现缺少更新的字段,请手工确认如此更新是否正确! strSql.Append("UserID=@UserID,"); strSql.Append("LoanType=@LoanType"); strSql.Append(" where UserID=@UserID and LoanType=@LoanType "); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@LoanType", SqlDbType.NVarChar, 255) }; parameters[0].Value = model.UserID; parameters[1].Value = model.LoanType; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public LPWeb.Model.User2LoanType GetModel(int UserID, string LoanType) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 UserID,LoanType from User2LoanType "); strSql.Append(" where UserID=@UserID and LoanType=@LoanType "); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@LoanType", SqlDbType.NVarChar, 50) }; parameters[0].Value = UserID; parameters[1].Value = LoanType; LPWeb.Model.User2LoanType model = new LPWeb.Model.User2LoanType(); 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()); } model.LoanType = ds.Tables[0].Rows[0]["LoanType"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(LPWeb.Model.User2LoanType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into User2LoanType("); strSql.Append("UserID,LoanType)"); strSql.Append(" values ("); strSql.Append("@UserID,@LoanType)"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@LoanType", SqlDbType.NVarChar, 255) }; parameters[0].Value = model.UserID; parameters[1].Value = model.LoanType; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }