Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to Pass Parameter For Datetime From UI
    text
    copied!<p>Problem with Datetime . I am able to pass datetime only upto 12-12-2013 and if i pass datetime parameter (13-12-2013 or 12-13-2013) it shows me error ( It is not valid date ).Culture using is en-US I have given my code below</p> <p><strong>code:</strong> </p> <pre><code> ** my view page is** @model Hms.ViewModels.DoctorModel @{ ViewBag.Title = "CreateDoctor"; Layout = "~/Views/Shared/_LayoutMaster.cshtml"; } &lt;span class="title"&gt;CreateDoctor&lt;/span&gt; &lt;section class="content-innerPage"&gt; @using (Html.BeginForm()) { @Html.ValidationSummary(true) &lt;table class="doctortable"&gt; &lt;tr&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Dr_Id) @Html.TextBoxFor(M =&gt; Model.Doctor.Dr_Id) @Html.ValidationMessageFor(model =&gt; model.Doctor.Dr_Id) &lt;/td&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.CompanyCode) @Html.TextBoxFor(M =&gt; Model.Doctor.CompanyCode) @Html.ValidationMessageFor(model =&gt; model.Doctor.CompanyCode) &lt;/td&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Dr_Name) @Html.TextBoxFor(M =&gt; Model.Doctor.Dr_Name) @Html.ValidationMessageFor(model =&gt; model.Doctor.Dr_Name) &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Dr_Add1) @Html.TextBoxFor(M =&gt; Model.Doctor.Dr_Add1) &lt;/td&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Dr_Add2) @Html.TextBoxFor(M =&gt; Model.Doctor.Dr_Add2) &lt;/td&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Dr_City) @Html.TextBoxFor(M =&gt; Model.Doctor.Dr_City) &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Dr_Pincode) @Html.TextBoxFor(M =&gt; Model.Doctor.Dr_Pincode) &lt;/td&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Dr_Phone) @Html.TextBoxFor(M =&gt; Model.Doctor.Dr_Phone) &lt;/td&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Dr_Cell) @Html.TextBoxFor(M =&gt; Model.Doctor.Dr_Cell) &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Dr_DOB) @Html.TextBoxFor(M =&gt; Model.Doctor.Dr_DOB) @Html.ValidationMessageFor(M =&gt; Model.Doctor.Dr_DOB) &lt;/td&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Morningfrm) @Html.TextBoxFor(M =&gt; Model.Doctor.Morningfrm) &lt;/td&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Morningto) @Html.TextBoxFor(M =&gt; Model.Doctor.Morningto) &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Eveningfrm) @Html.TextBoxFor(M =&gt; Model.Doctor.Eveningfrm) &lt;/td&gt; &lt;td&gt; @Html.LabelFor(M =&gt; Model.Doctor.Eveningto) @Html.TextBoxFor(M =&gt; Model.Doctor.Eveningto) &lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div class="checkboxforweek"&gt; @Html.CheckBoxListFor(M =&gt; Model.WeekViewModel.PostedDaysofWeek.DayIDs, M =&gt; Model.WeekViewModel.AvailableDays, c =&gt; c.week_Id, c =&gt; c.weeK_Name, M =&gt; Model.WeekViewModel.SelectedDays, Position.Horizontal) &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Create" /&gt; &lt;/p&gt; } &lt;div&gt; @Html.ActionLink("Back to List", "DoctorList") &lt;/div&gt; &lt;/section&gt; @section Scripts { @Scripts.Render("~/bundles/jqueryval") } **MyController Code:** Gema_Doctor gema_Doctor = new Gema_Doctor(); [HttpPost] public ActionResult CreateDoctor(Gema_Doctor doctor, WeekViewModel weekViewModel) { if (ModelState.IsValid) { bool isUpdated = false; isUpdated = gema_Doctor.InsertDoctor(doctor, weekViewModel); if (isUpdated == false) { ViewBag.Message = "False"; return View(GetDoctorValues()); } return RedirectToAction("DoctorList"); } return View(GetDoctorValues()); } **MasterModel.cs** public class Gema_Doctor : IDisposable { [Required] [Display(Name= "DoctorId")] public int Dr_Id { get; set; } [Required] [Display(Name = "CompanyCode")] public int CompanyCode { get; set; } [Required] [Display(Name = "Dr_Name")] public string Dr_Name { get; set; } [Required] [Display(Name = "Dr_DOB")] public DateTime Dr_DOB { get; set; } } DoctorServiceReference.DoctorServiceClient doctorServiceRef = new DoctorServiceReference.DoctorServiceClient(); public bool InsertDoctor(Gema_Doctor doctor, WeekViewModel weekViewModel) { DoctorServiceReference.Doctor docRef = DoctorToDoctorSerRef(doctor, weekViewModel); DoctorServiceReference.InsertDoctorRequest insertReq = new DoctorServiceReference.InsertDoctorRequest(); DoctorServiceReference.InsertDoctorResponse insertRes = new DoctorServiceReference.InsertDoctorResponse(); insertReq.doctor = docRef; insertRes = doctorServiceRef.InsertDoctor(insertReq); return insertRes.InsertDoctorResult; } private DoctorServiceReference.Doctor DoctorToDoctorSerRef(Gema_Doctor doctor, WeekViewModel weekViewModel) { Hms.DoctorServiceReference.Doctor docRef = new Hms.DoctorServiceReference.Doctor(); docRef.CompanyCode = doctor.CompanyCode; docRef.Dr_Id = doctor.Dr_Id; docRef.Dr_Name = doctor.Dr_Name; docRef.Dr_Add1 = doctor.Dr_Add1; docRef.Dr_Add2 = doctor.Dr_Add2; docRef.Dr_City = doctor.Dr_City; docRef.Dr_Pincode = doctor.Dr_Pincode; docRef.Dr_Phone = doctor.Dr_Phone; docRef.Dr_Cell = doctor.Dr_Cell; docRef.Dr_DOB = (DateTime)(doctor.Dr_DOB); docRef.Dr_Remarks = doctor.Dr_Remarks; docRef.Activeflag = 1; docRef.CreatedBy = 1; docRef.CreatedDate = (DateTime)(DateTime.Now); docRef.ModifiedBy = 1; docRef.ModifiedDate = (DateTime)(DateTime.Now); docRef.visitflag = 1; if (weekViewModel.PostedDaysofWeek != null) { var visitDays = DoctorVisitDays(doctor, weekViewModel); docRef.daysun = visitDays.daysun; docRef.daymon = visitDays.daymon; docRef.daytue = visitDays.daytue; docRef.daywed = visitDays.daywed; docRef.daythu = visitDays.daythu; docRef.dayfri = visitDays.dayfri; docRef.daysat = visitDays.daysat; } else { docRef.daysun = 0; docRef.daymon = 0; docRef.daytue = 0; docRef.daywed = 0; docRef.daythu = 0; docRef.dayfri = 0; docRef.daysat = 0; } docRef.date1 = "1"; docRef.Time = (DateTime)(DateTime.Now); docRef.Morningfrm = doctor.Morningfrm; docRef.Morningto = doctor.Morningto; docRef.Eveningfrm = doctor.Eveningfrm; docRef.Eveningto = doctor.Eveningto; docRef.Active = 1; return docRef; } **My Service Code For Insert** public bool InsertDoctor(Doctor doctor) { try { using (var dbContext = new Redim_HMSMasterEntities()) { dbContext.Gema_Doctor.AddObject(new Gema_Doctor { CompanyCode = doctor.CompanyCode, Dr_Id = doctor.Dr_Id, Dr_Name = doctor.Dr_Name, Dr_Add1 = doctor.Dr_Add1, Dr_Add2 = doctor.Dr_Add2, Dr_City = doctor.Dr_City, Dr_Pincode = doctor.Dr_Pincode, Dr_Phone = doctor.Dr_Phone, Dr_Cell = doctor.Dr_Cell, Dr_DOB = (DateTime)(doctor.Dr_DOB), Dr_Remarks = doctor.Dr_Remarks, Activeflag = doctor.Activeflag, CreatedBy = doctor.CreatedBy, CreatedDate = doctor.CreatedDate, ModifiedBy = (int)(doctor.ModifiedBy), ModifiedDate = (DateTime)doctor.ModifiedDate, visitflag = (int)(doctor.visitflag), daysun = (int)(doctor.daysun), daymon = (int)(doctor.daymon), daytue = (int)(doctor.daytue), daywed = (int)(doctor.daywed), daythu = (int)(doctor.daythu), dayfri = (int)(doctor.dayfri), daysat = (int)(doctor.daysat), date1 = doctor.date1, Time = (DateTime)(doctor.Time), Morningfrm = doctor.Morningfrm, Morningto = doctor.Morningto, Eveningfrm = doctor.Eveningfrm, Eveningto = doctor.Eveningto, Active = (int)(doctor.Active) }); dbContext.SaveChanges(); return true; } } catch (Exception exception) { Debug.WriteLine(exception); return false; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload