根据开始日期和周数查找结束日期c#.net ... [英] Find end date based on start date and number of weeks c#.net...
问题描述
朋友们,
我正在使用gridview,因为我有一个绑定字段和3个文本框模板字段,如此
-------------------------------------------- ----------------- ---------
阶段持续时间(周)SrartDate EndDate
----- -------------------------------------------------- ----------------
在gridview的一边我有字段:一周的工作日:
ex:5 0r 6
如果我在持续时间文本框中输入1或1.5周,则开始日期:12-05-2017,如果我在一个工作日内总共工作日周:5根据此值删除星期六和星期日,找到并显示
结束日期在gridview。
如果一周工作日6天只删除星期日并找到EndDate并在gridview中显示它。
示例:
如果我们将持续时间视为1周,工作日在一个星期6
然后在12-05-2017之后去除太阳计算日期和最终结束日期应打印
20-05-2017
怎么样这个怎么样?
我尝试了什么:
我试过了使用Adddays方法给出日期
添加天数并查看之后的工作日(周日和周六加一天或两天):
// 添加天数
dt.AddDays(周* 7 );
// 如果结束日期是星期日,请选择星期一
if (dt.DayOfWeek == DayOfWeek.Sunday)
dt.AddDays( 1 );
// 如果结束日期是星期六,星期六不是工作日,请选择星期一
其他 if (workingDays < 6 && dt.DayOfWeek == DayOfWeek.Saturday)
dt.AddDays( 2 );
hi friends,
I am using gridview in that I have one bound field and 3 textbox template fields like this
------------------------------------------------------------- ---------
phase Duration(weeks) SrartDate EndDate
-----------------------------------------------------------------------
out side of gridview I have field: working days in a week:
ex: 5 0r 6
If I enter 1 or 1.5 week in Duration textbox , start Date : 12-05-2017 and if total working days in a week: 5 based on this values remove sturdays and sundays and find and display
End Date in gridview.
if working days in a week 6 days remove only sundays and find EndDate and display it in gridview.
Example:
If we Consider duration as 1 week,Working days in a week 6
then after 12-05-2017 then remove sunday date from calculation and the final End Date should print
20-05-2017
how to achive this??
What I have tried:
I tried using Adddays Method to given date
Add the number of days and check the week day afterwards (add one or two days for Sunday and Saturday):
// Add number of days dt.AddDays(weeks * 7); // Choose Monday if end date is Sunday if (dt.DayOfWeek == DayOfWeek.Sunday) dt.AddDays(1); // Choose Monday if end date is Saturday and Saturday is not a working day else if (workingDays < 6 && dt.DayOfWeek == DayOfWeek.Saturday) dt.AddDays(2);
这篇关于根据开始日期和周数查找结束日期c#.net ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!