我很抱歉这个问题,但不知何故我停电了(我知道这不是借口),但我怎样才能从RadNumbericTextBox
使用按钮中检索值来发送值(我需要一个 int)
<div class="fromRowDiv">
<asp:Label ID="label1" CssClass="fromLabel" runat="server" Text="From Date" ></asp:Label>
<telerik:RadNumericTextBox ID="fromYear" runat="server" MinValue="2000" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator="" ></telerik:RadNumericTextBox>
<asp:Label ID="Tolabel2" CssClass="fromLabel" runat="server" Text="To Date"></asp:Label>
<telerik:RadNumericTextBox ID="toYear" runat="server" MinValue="2000" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator=""></telerik:RadNumericTextBox>
</div>
protected void CalcButton_Click(object sender, EventArgs e)
{
AnnualVacationManager mng = new AnnualVacationManager();
mng.CalcForNextYear(fromYear,toYear);
}
我需要来自 RadNumbericTextBox 的值(动态)
public AnnualVacationManager() {
}
public void CalcForNextYear(int fromYear, int toYear)
{
IEnumerable<HtUser> allUsers = HtUser.GetAll();
List<AnnualVacation> newAnnualVacations = new List<AnnualVacation>();
if (allUsers.Any()) {
foreach (HtUser user in allUsers) {
//int fromYear = 2013;
//int toYear = 2014;
IEnumerable<AnnualVacation> usersCurrentAnnualVacation = new List<AnnualVacation>(user.AnnualVacations.Where(a =>a.FromDate.Value.Year >= fromYear && a.FromDate.Value.Year < toYear));
if (usersCurrentAnnualVacation.Any()) {
foreach (AnnualVacation existing in usersCurrentAnnualVacation) {
AnnualVacation newAnnualVacation = new AnnualVacation();
//Year stuff
DateTime newFromDate = existing.FromDate.Value;
newFromDate.AddYears(toYear - fromYear);
DateTime newToDate = existing.ToDate.Value;
newToDate.AddYears(toYear - fromYear);
//
newAnnualVacation.FromDate = newFromDate;
newAnnualVacation.ToDate = newToDate;
newAnnualVacation.WorkingTime = existing.WorkingTime;
newAnnualVacation.VacationDays = existing.VacationDays + (existing.VacationDays - user.GetBookedVacation(fromYear));
newAnnualVacations.Add(newAnnualVacation);
newAnnualVacation.HtUser = user;
}
}
}
HtEntityFactory.Context.SaveChanges();
}
}
}
}