简体   繁体   English

比较SharePoint列表中的两个int列

[英]Compare two int columns in SharePoint list

I´m doing a course catalog app for sharepoint. 我正在为sharepoint开发课程目录应用程序。 And i have a list called Courses. 我有一个名为“课程”的列表。 in that list i have two columns called: seats and FreeSeats. 在该列表中,我有两列名为:seat和FreeSeats。 When you make a new course the boss decide how many can apply to the course. 当您开设新课程时,老板决定可以申请多少课程。 So for ex: 5 seats. 因此,例如:5个席位。 When the Fifth person apply there most be a stop. 当第五个人提出申请时,大多数人都会停下来。 So i thought if i have the column FreeSeats, it can count up everytime someone apply. 所以我想,如果我有FreeSeats栏,那么每次有人申请时它都可以算在内。 And when it is the same as the column Seats it will NOT be able to apply. 如果与“席位”列相同,将无法应用。 So i guess i need some sort of count that add 1 everytime someone apply to the FreeSeat column. 所以我想我需要某种计数,每当有人向FreeSeat栏申请时,该计数就加1。 And in a if loop check if the value of freeSeats are smaller than Seats, you can apply. 然后在if循环中检查freeSeats的值是否小于Seats,可以申请。 If its bigger than Seats it will come a stop message. 如果它大于Seats,则会出现停止消息。

Someone have any idea how a code like this looks like? 有人知道这样的代码是什么样的吗? I have never done this before. 我以前从未做过。

Since your new to this I would advise you go through this MSDN tutorial. 由于您是新手,因此建议您阅读本MSDN教程。

It outlines how you would do some basic CRUD functionality in a SharePoint app. 它概述了如何在SharePoint应用程序中执行一些基本的CRUD功能。

You can then adapt it for your particular purpose. 然后,您可以根据自己的特定目的对其进行调整。 This is how I started out :) good luck. 这就是我开始的方式:)祝你好运。 Ignore the fact it mentions Napa the app structure should be similar in VS 忽略它提到Napa的事实,即VS中的应用程序结构应该相似

MSDN SharePoint CRUD in App 应用中的MSDN SharePoint CRUD

Cheers 干杯

Truez Truez

You can actually set this up without any code by creating a list of Free Seats with Titles ranging from 1 to #. 实际上,您可以通过创建标题从1到#的免费席位列表来设置此程序而无需任何代码。 In your signup lists you would create a lookup column for each course that points to the corresponding list of free seats and select the "Enforce unique values" option. 在注册列表中,您将为每个课程创建一个查找列,以指向相应的免费席位列表,然后选择“强制唯一值”选项。 That way, when a user signs up for the course, they must select one of the free seat values you have created, and cannot sign up for a value selected previously. 这样,当用户注册课程时,他们必须选择您创建的免费座位值之一,并且不能注册以前选择的值。 You can use a workflow to update a list elsewhere to give you your signup counts for tracking if you wish. 您可以使用工作流来更新其他地方的列表,以便在需要时为您提供注册计数以进行跟踪。

To do this programmatically you would need a workflow or event receiver that counted the total number of list items with a Free Seats value selected and then remove the contribute rights for the list that people are using to signup. 要以编程方式执行此操作,您将需要一个工作流或事件接收器,该工作流将对列表项的总数进行计数,并选择“免费席位”值,然后删除人们用于注册的列表的贡献权。 There is no other way to stop people from adding a new item once your quota is satisfied. 一旦您的配额得到满足,没有其他方法可以阻止人们添加新项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM