|
Hmm - I would do this differently. In order to get the dates that had already been selected, I would call back to the server to retrieve those dates and use that to blank out those dates in the UI.
|
|
|
|
|
|
Maybe, for simplicities sake, you should just stick to informing the user that the date they picked is invalid. You seem very new to this, and adding complexity like this could well be beyond you right now - unfortunately, I don't have the time to write a fully working sample for you to demonstrate how this all hangs together.
|
|
|
|
|
No problem pete, yeah i'm a beginner at this stuff. Will just have to keep at it.
Thanks for the help though
|
|
|
|
|
No problem. Sorry I couldn't be more help here.
|
|
|
|
|
So the user can select 2 different dates, a start date and an end date from 2 calendars, when they click 'add' the dates between&including the dates selected will be added to the DB, each date as a separate record.
This works fine however I dont want weekends to be added to the DB.
Iv updated the UI of datepicker http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerCustomCellRender.html but if a user selects fri-mon for example fri,sat,sun and mon will be added to the db Iv tried to only run the code if datyofweek is not saturday or sunday
public ActionResult listHolidays(Holiday holiday, int? PersonId, string HolidayDate, string endDate)
{
DateTime startDates = Convert.ToDateTime(HolidayDate),
endDates = Convert.ToDateTime(endDate);
while (startDates <= endDates)
{
if (startDates.DayOfWeek != DayOfWeek.Saturday || startDates.DayOfWeek != DayOfWeek.Sunday)
{
Holiday holiday1 = new Holiday();
holiday1.PersonId = PersonId.Value;
holiday1.HolidayDate = startDates;
db.Holidays.AddObject(holiday1);
db.SaveChanges();
startDates = startDates.AddDays(1);
}
}
return RedirectToAction("Index");
}
any help?
Thanks
|
|
|
|
|
xnaLearner wrote: if (startDates.DayOfWeek != DayOfWeek.Saturday || startDates.DayOfWeek != DayOfWeek.Sunday)
That's an AND condition, not an OR condition. It should read:
if (startDates.DayOfWeek != DayOfWeek.Saturday && startDates.DayOfWeek != DayOfWeek.Sunday)
|
|
|
|
|
|
|
Hi,
I have created a windows service, I want to deploy it on the server. Can anybody please help me in deploying it. When I googled for it, I found that I have to have project installer file in my project.
What is project installer file, how should I write it to deploy my windows service. I am new to this windows service field, any kind of help, code snippet, or link would be very helpful.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
As long as you aren't using Visual Studio 2012, this[^] should help.
|
|
|
|
|
Hi,
I am using Visual Studio 2010 but .Net Framework 3.5, I think it should work?
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
It should work. The steps really didn't change.
|
|
|
|
|
So I am using the JQuery.datePicker example... http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerStartEnd.html
I had the Jquery calendar working fine, but it olnly allowed me to enter 1 date at a time and save it to the DB.
I want the user to select a start and a multiple date, run a loop through the dates and each day to the DB.
Slightly lost at the minute and any help would be appreciated....
Here is part of my view for my ActionResult create()//which allows the user to add a new day.
<form action ="ListHolidays" id="listHolidays" method="post">
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Holiday</legend>
<div>
@Html.LabelFor(model => model.PersonId, "Person")
</div>
<div>
@Html.DropDownListFor(model => model.PersonId,
new SelectList(ViewBag.Id, "Value", "Text"),
"---Select---"
)
@Html.ValidationMessageFor(model => model.PersonId)
</div>
<div>
@Html.LabelFor(model => model.HolidayDate)
</div>
<div>
@Html.TextBoxFor(model => model.HolidayDate)
@Html.TextBoxFor(model => model.endDate)
<script>
$("#HolidayDate").addClass('date-pick');
$("#endDate").addClass('date-pick');
$(function ()
{
$('.date-pick').datePicker()
$('#HolidayDate').bind('dpClosed',
function (e, selectedDates)
{
var d = selectedDates[0];
if (d)
{
d = new Date(d);
$('#endDate').dpSetStartDate(d.addDays(1).asString());
}
}
);
$('#endDate').bind('dpClosed',
function (e, selectedDates)
{
var d = selectedDates[0];
if (d)
{
d = new Date(d);
$('#HolidayDate').dpSetEndDate(d.addDays(-1).asString());
}
}
);
});
</script>
@Html.ValidationMessageFor(model => model.HolidayDate)
</div>
<p>
<input type="submit" value="Create"/>
</p>
and my post for listHolidays:
[HttpPost]
public ActionResult listHolidays(Holiday holiday, int? PersonId, string HolidayDate, string endDate)
{
IList<DateTime> dates = new List<DateTime>();
dates.Add(DateTime.Parse(HolidayDate));
dates.Add(DateTime.Parse(endDate));
List<DateTime> orderedDates = dates.OrderBy(d => d).ToList();
for (int i = 0; i < orderedDates.Count; i++ )
{
db.Holidays.AddObject(holiday);
db.SaveChanges();
return View();
}
return RedirectToAction("Index");
}
The problem being in my list Holidays, im not sure how to run through the loop from start to end date, and add a new record to the DB for each one.
Please advise
|
|
|
|
|
I've updated my code to:
[HttpPost]
public ActionResult listHolidays(Holiday holiday, int? PersonId, string HolidayDate, string endDate)
{
DateTime startDates = Convert.ToDateTime(HolidayDate),
endDates = Convert.ToDateTime(endDate);
while (startDates < endDates)
{
startDates.AddDays(1);
db.Holidays.AddObject(holiday);
db.SaveChanges();
}
return RedirectToAction("Index");
however I debugged using breakpoint, it runs through the loop once but on the second attempt it stops at db.Holidays.Addobject(holiday);
and I receive the error: An object with the same key already exists in the ObjecttateManager. the existing objects is in the unchanged state. An ibject can only be added to the objectStateManager again if it is i the added state.
if anyone can help that would be great
|
|
|
|
|
So im just using an ASP.NET atm
Iv added 4 textboxes from the toolbox TextBox1, TextBox2, TextBox3, TextBox 4 and a button 'button1'
I want the user to enter data into the textboxs, compare them by .length and produce the output in order.
So before ordering them I am just trying to display them in the order of boxes textbox1, textbox2, textbox3.
protected void Button1_Click(object sender, EventArgs e)
{
DatesInOrderTextBox.Text = "Dates in order are" + TextBox1 + ", " + TextBox2 + ", " + TextBox3;
}
After that I intend to do something like the following
if (date1.Length > date2.Length && date1.Length > date3.Length)
{
if (date2.Length > date3.Length)
{
FirstDateOrder = date1;
SecondDateOrder = date2;
ThirdDateOrder = date3;
System.Windows.Forms.MessageBox.Show("Order is 1, 2, 3");
ViewBag.DateOrder = "Order is 1,2,3";
return RedirectToAction("Index");
}
else
{
FirstDateOrder = date1;
SecondDateOrder = date3;
ThirdDateOrder = date2;
System.Windows.Forms.MessageBox.Show("Order is 1, 3, 2");
return RedirectToAction("Index");
}
}
Although when I click the button textbox4 is displaying
Dates in order areSystem.Web.UI.WebControls.TextBox, System.Web.UI.WebControls.TextBox, System.Web.UI.WebControls.TextBox
prob something simple just dont know how to fix it...thank you guys
|
|
|
|
|
Try
protected void Button1_Click(object sender, EventArgs e)
{
DatesInOrderTextBox.Text = "Dates in order are: " + TextBox1.Text + ", " + TextBox2.Text + ", " + TextBox3.Text;
}
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
ahh thats great thanks for the reply
|
|
|
|
|
how to memorise such a big .netframework?is there any methode?
|
|
|
|
|
Yes, it's called "studying". Perhaps you've learned the technique in school??
|
|
|
|
|
You do not "memorize" it, it's too big - and by the time you know it by heart, there'll be a new version. You'd learn how to use it; once you worked through a C#-book, you should be able to use the documentation[^].
|
|
|
|
|
I agree with this.
I'd add that when I started out I invested in a copy of the Base Class Library text (it was c# 2005 at the time). That was a great book for showing me a great, useful slice of the framework, how it works, and what it can do.
Once you get in the 'mindset' of the framework, how it goes about things etc. You can, more often than not, predict where in the documentation you'll need to look to solve your problem.
|
|
|
|
|
I doubt how much storage capacity you had to memorize the entire .Net framework . Its a bad idea too and save your time doing other interesting stuffs rather running behind memorizing .net framework.
you better store in stack - use it throw it.
Jibesh.V.P
India
|
|
|
|
|
Hey guys so im attempting to throw a project together to increase my knowledge of MVC3 but I have hit a wall...
So from my HolidaysController inside my index 'view' I have created a hyperlink which will navigate the user to the 'create3' ActionResult
@Html.ActionLink("Select 3 Dates", "Create3")
-------------------
In my create3 page I want the user to enter 3 dates into text boxes and when they click 'create' the user will be returned to the previous HolidaysController/Index page
where the dates will be displayed in order of ascending date....ATM I have this working up until the user enters 3 dates and clicks 'create'...However I only know
how to display a message box displaying the order, it is working I just need help getting the order to be displayed from the index page.
Please see my code:
Code for HolidayController/Index:
--------------
[HttpPost]
public ViewResult Index(int HolidayDate)
{
var holidays = db.Holidays.Include("Person");
HolidayList model = new HolidayList();
model.currentPersonID = HolidayDate;
model.PList4DD = db.People.ToList();
model.Categories = holidays.Select(x => new SelectListItem
{
Value = x.Id.ToString(),
Text = x.Person.Name
}
);
int data = HolidayDate;
model.HList4DD = db.Holidays.Where(h => h.PersonId == HolidayDate).ToList();
return View(model);
}
[HttpGet]
public ViewResult Index(string sortOrder, int? currentPersonID)
{
var holidays = db.Holidays.Include("Person");
HolidayList model = new HolidayList();
if (currentPersonID.HasValue)
{
model.currentPersonID = currentPersonID.Value;
}
else
{
model.currentPersonID = 0;
}
model.PList4DD = db.People.ToList();
ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "date" : "";
var dates = from d in db.Holidays
where d.PersonId == currentPersonID.Value
select d;
switch (sortOrder)
{
case "date":
dates = dates.OrderBy(p => p.HolidayDate);
break;
}
model.HList4DD = dates.ToList();
return View(model);
}
-----------------------
//View for Index
@*@model IEnumerable<HolidayBookingApp.Models.Holiday>*@
@model HolidayBookingApp.Models.HolidayList
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<p>
@Html.ActionLink("Select 3 Dates", "Create3")
</p>
<table>
<tr>
<th>
PersonId
</th>
<th>
@*HolidayDate*@
@Html.ActionLink("HolidayDate", "Index", new { sortOrder = ViewBag.NameSortParm, currentPersonID = Model.currentPersonID })
</th>
<th></th>
</tr>
<tr>
</tr>
@foreach (var item in Model.HList4DD)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.PersonId)
</td>
<td>
@Html.DisplayFor(modelItem => item.HolidayDate)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>}
<tr>
<div class="editor-label">
@* @Html.LabelFor(model => model.PList4DD, "Person")*@
</div>
<div class="editor-field">
<form action ="/Holidays/Index" id="some" method="post">
@Html.DropDownListFor(model => model.HList4DD.First().HolidayDate, new SelectList(Model.PList4DD, "Id", "Name", Model.currentPersonID), "--select--")
<script>
function updateFormEnabled()
{
if (verifyAdSettings())
{
$('#sbmt').removeAttr('disabled');
}
else
{
$('#sbmt').attr('disabled', 'disabled');
}
}
function verifyAdSettings()
{
if ($('#HolidayDate').val() != '')
{
return true;
}
else
{
return false;
}
}
$('#HolidayDate').change(updateFormEnabled);
</script>
<input type="submit" id= "sbmt" name="ViewHolidaysDD" value="View"/>
</form>
<script>
$('#sbmt').attr('disabled', '');
</script>
</div>
</table>
<br />
<br />
<table>
<div>
Judging by your selection the order of dates are: //HERE IS WHERE I WANT TO DISPLAY THE ORDER OF DATES
</div>
</table>
Just above is where I want to display my dates in order, ascending
------------
-----------------------------------
[HttpGet]
public ActionResult Create3()
{
return View();
}
[HttpPost]
public ActionResult Create3(string date1, string date2, string date3)
{
string FirstDateOrder, SecondDateOrder, ThirdDateOrder;
if (date1.Length > date2.Length && date1.Length > date3.Length)
{
if (date2.Length > date3.Length)
{
FirstDateOrder = date1;
SecondDateOrder = date2;
ThirdDateOrder = date3;
System.Windows.Forms.MessageBox.Show("Order is 1, 2, 3");
return RedirectToAction("Index");
}
else
{
FirstDateOrder = date1;
SecondDateOrder = date3;
ThirdDateOrder = date2;
System.Windows.Forms.MessageBox.Show("Order is 1, 3, 2");
return RedirectToAction("Index");
}
}
if (date2.Length > date1.Length && date2.Length > date3.Length)
{
if (date1.Length > date3.Length)
{
FirstDateOrder = date2;
SecondDateOrder = date1;
ThirdDateOrder = date3;
System.Windows.Forms.MessageBox.Show("Order is 2, 1, 3");
return RedirectToAction("Index");
}
else
{
FirstDateOrder = date2;
SecondDateOrder = date3;
ThirdDateOrder = date1;
System.Windows.Forms.MessageBox.Show("Order is 2, 3, 1");
return RedirectToAction("Index");
}
}
if (date3.Length > date1.Length && date3.Length > date2.Length)
{
if (date1.Length > date2.Length)
{
FirstDateOrder = date3;
SecondDateOrder = date1;
ThirdDateOrder = date2;
System.Windows.Forms.MessageBox.Show("Order is 3, 1, 2");
return RedirectToAction("Index");
}
else
{
FirstDateOrder = date3;
SecondDateOrder = date2;
ThirdDateOrder = date1;
System.Windows.Forms.MessageBox.Show("Order is 3, 2, 1");
return RedirectToAction("Index");
}
}
return RedirectToAction("Index");
}
-----------------------------
--------------
and my view:
@model HolidayBookingApp.Models.Dates
@{
ViewBag.Title = "Create3";
}
<h2>Create3</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Dates</legend>
<div class="editor-label">
@Html.LabelFor(model => model.date1)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.date1)
@Html.ValidationMessageFor(model => model.date1)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.date2)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.date2)
@Html.ValidationMessageFor(model => model.date2)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.date3)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.date3)
@Html.ValidationMessageFor(model => model.date3)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>"Index")
</div>
---------------
Not sure where to go from here something like create a paramter in the Index View which pulls across the order?
Any help would be great thanks guys and sorry about the essay
|
|
|
|
|
Hi,
I'm developing an application that runs in a Windows CE 5.0 environment and I'm using VB.NET in Visual Studio 2008 Pro.
In a Form I have a TabControl with some pages.
My problem is to understand when a page of the TabControl is selected to perform some actions in that page automatically.
In the Compact Framework there isn't the event Control.Enter so I can't use it, that would be the right one...
Does anyone have any idea?
Thanks
|
|
|
|
|