protected void createWWSBasedOnDateRange(DateTime startDate, DateTime endDate, int shiftType, int shiftDay) { UserAccount user = (UserAccount)Session["UserAccountObj"]; MWSBLL mwsbll = new MWSBLL(); int result = mwsbll.DoCreateMWS(user.UserId); WWSBLL wwsbll = new WWSBLL(); MWS mws = mwsbll.DoRetrieveLatestMWSByRId(user.UserId); DateTime workDate = DateTime.Parse(txtStartDate.Text); while (startDate != endDate) { if (shiftType == 1) { wwsbll.DoCreateWWS(mws.MwsId, startDate, startDate.AddHours(10), startDate.AddHours(14), startDate.AddHours(15), startDate.AddHours(19)); } else if (shiftType == 2) { wwsbll.DoCreateWWS(mws.MwsId, startDate, startDate.AddHours(11), startDate.AddHours(15), startDate.AddHours(16), startDate.AddHours(20)); } else if (shiftType == 3) { wwsbll.DoCreateWWS(mws.MwsId, startDate, startDate.AddHours(12), startDate.AddHours(16), startDate.AddHours(17), startDate.AddHours(21)); } else if (shiftType == 4) { wwsbll.DoCreateWWS(mws.MwsId, startDate, startDate.AddHours(13), startDate.AddHours(17), startDate.AddHours(18), startDate.AddHours(22)); } startDate = startDate.AddDays(1); if (shiftDay == 1) { if (startDate.DayOfWeek == DayOfWeek.Saturday) { startDate = startDate.AddDays(2); } else if (startDate.DayOfWeek == DayOfWeek.Sunday) { startDate = startDate.AddDays(1); } } else if (shiftDay == 2) { if (startDate.DayOfWeek == DayOfWeek.Sunday) { startDate = startDate.AddDays(2); } else if (startDate.DayOfWeek == DayOfWeek.Monday) { startDate = startDate.AddDays(1); } } else if (shiftDay == 3) { if (startDate.DayOfWeek == DayOfWeek.Monday) { startDate = startDate.AddDays(2); } else if (startDate.DayOfWeek == DayOfWeek.Tuesday) { startDate = startDate.AddDays(1); } } else if (shiftDay == 4) { if (startDate.DayOfWeek == DayOfWeek.Tuesday) { startDate = startDate.AddDays(2); } else if (startDate.DayOfWeek == DayOfWeek.Wednesday) { startDate = startDate.AddDays(1); } } else if (shiftDay == 5) { if (startDate.DayOfWeek == DayOfWeek.Wednesday) { startDate = startDate.AddDays(2); } else if (startDate.DayOfWeek == DayOfWeek.Thursday) { startDate = startDate.AddDays(1); } } else if (shiftDay == 6) { if (startDate.DayOfWeek == DayOfWeek.Thursday) { startDate = startDate.AddDays(2); } else if (startDate.DayOfWeek == DayOfWeek.Friday) { startDate = startDate.AddDays(1); } } else if (shiftDay == 7) { if (startDate.DayOfWeek == DayOfWeek.Friday) { startDate = startDate.AddDays(2); } else if (startDate.DayOfWeek == DayOfWeek.Saturday) { startDate = startDate.AddDays(1); } } } }