显示内部服务器错误使用MVC插入值

时间:2016-10-28 01:42:12

标签: sql asp.net-mvc razor

控制器:

//控制器保存详细信息///     [HttpPost]      SaveTeam任务详细信息WebService和WCF服务在该层中没有问题面临内部服务器错误的问题。

 public async Task<JsonResult> SaveTeamTaskDetails(string jsClient)
        {

            var TeamTask = System.Web.Helpers.Json.Decode<TeamTaskClaimSave>(jsClient);
            var xml = TeamTask.Serialize("TeamTaskDetails");
            var result = await this.handsService.SaveTeamTaskDetails(xml);

            if (result.Data == null)
                this.Response.StatusCode = (int)HttpStatusCode.InternalServerError;

            return null;
        }

型号:

//要检索的模型值//

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;

using System.Web.Mvc;
namespace Equip.Areas.ClinicalReview.Models
{
    [XmlType("TeamTaskClaimSave")]

    public class TeamTaskClaimSave
    {
        [XmlElement("Assigineeid")]
        public int Assigineeid { get; set; }

        [XmlElement("AssigineeList")]
        public List<TeamTaskClaimDetails> AssigineeList { get; set; }

        [XmlElement("ID")]
        public int ID { get; set; }
        //public string claimid { get; set; }

        [XmlElement("claimid")]
        public List<SelectListItem> claimid { get; set; }

        [XmlElement("contactID")]
        public string contactID { get; set; }

        [XmlElement("taskpriority")]
        public string taskpriority { get; set; }

        [XmlElement("Creator")]
        public string Creator { get; set; }

        [XmlElement("Description")]
        public string Description { get; set; }

        [XmlElement("status")]
        public string status { get; set; }
        [XmlElement("StartDate")]
        public string StartDate { get; set; }

        [XmlElement("EndDate")]
        public string EndDate { get; set; }

        [XmlElement("ForensicDueDate")]
        public string ForensicDueDate { get; set; }

        [XmlElement("ForensicDueTime")]
        public string ForensicDueTime { get; set; }

        [XmlElement("PatientFirstName")]
        public string PatientFirstName { get; set; }

        [XmlElement("PatientLastName")]
        public string PatientLastName { get; set; }


        [XmlElement("Client")]
        public string Client { get; set; }

        [XmlElement("ProviderName")]
        public string ProviderName { get; set; }

        [XmlElement("FirstName")]
        public string FirstName { get; set; }
        [XmlElement("LastName")]
        public string LastName { get; set; }

        [XmlElement("PreScreen")]
        public string PreScreen { get; set; }


        [XmlElement("Priority")]
        public string Priority { get; set; }

        [XmlElement("Edit")]
        public string Edit { get; set; }


        [XmlElement("Comment")]
        public string Comment { get; set; }

        [XmlElement("Assiginee")]
        public string Assiginee
        {
            get
            {
                return string.Format("{0} {1}", this.FirstName ?? string.Empty, this.LastName ?? string.Empty).Trim();
            }
            set
            {

            }

        }
        [XmlElement("Patient")]
        public string Patient
        {
            get
            {
                return string.Format("{0} {1}", this.PatientFirstName ?? string.Empty, this.PatientLastName ?? string.Empty).Trim();
            }

        }

 }

}

查看:

//查看//

的值
 @{
    var isReadOnly = ViewBag.IsReadOnly;
    var claimid = ViewBag.claimid as string;
    var FirstName = ViewBag.FirstName as string;
    var cid = ViewBag.contactid as string;
    var isCreate = string.IsNullOrWhiteSpace(claimid) || claimid == "0";
    Layout = null;
}

@model Equip.Areas.ClinicalReview.Models.TeamTaskClaimSave



<style>
    label {
        color: rgb(51,51,51);
        font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
        font-size: 12px;
        font-weight: bold;
    }
</style>

<div id="clinicalreview-TeamTaskcontainer" class="dialog"></div>
<div id="clinicalreview-addTeamTask-container">
    <div class="col-xs-12">
        <label for="clinicalreview-addpayment-dateposted">Create Date:</label>
        @Html.TextBoxFor(m => m.StartDate, new { @style = "width: 380px;height:35px;", @class = "form-control", @readonly = "readonly" })
    </div>
    <div class="col-xs-12">
        <label for="clinicalreview-addpayment-amount">Due Date:</label>
        @Html.TextBoxFor(m => m.EndDate, new { @style = "width: 380px;height:35px;", @class = "form-control", @readonly = "readonly" })
    </div>
    <div class="col-xs-12">
        <label for="clinicalreview-addpayment-applytoclaim">Start Date:</label>
        @Html.TextBoxFor(m => m.ForensicDueDate, new { @style = "width: 380px;height:35px;", @class = "form-control ", @readonly = "readonly" })
    </div>

    <div class="col-xs-12">
        <label for="clinicalreview-addpayment-applytoclaim">Assigned To:</label>



        @Html.DropDownListFor(m => m.claimid, new SelectList(ViewBag.Task, "Value", "Text"), new { @style = "width: 380px;height:35px;", @class = "form-control " })

    </div>

    <div class="col-xs-12">
        <label for="clinicalreview-addpayment-applytoclaim">Priority:</label>

        @* @Html.DropDownListFor(m => m.claimid, new SelectList(ViewBag.TaskPriority, "Value", "Text"), new { @style = "width: 380px;height:35px;", @class = "form-control " })*@

        @Html.DropDownList("Priority", new List<SelectListItem>
           {
             new SelectListItem{ Text="HIGH", Value = "1" },
             new SelectListItem{ Text="LOW", Value = "2" },
             new SelectListItem{ Text="MEDIUM", Value = "3" },
            }, new { @style = "width: 180px;height:30px;", @class = "form-control" })
    </div>

    <div class="col-xs-12">
        <label for="clinicalreview-addpayment-applytoclaim">Comment:</label>
        @Html.TextAreaFor(m => m.Comment, new { @class = "form-control date" })
    </div>
    <div class="col-xs-12" style="margin-top: 10px;"></div>
    <div class="form-group col-xs-6">
        @*<button type="button" class="btn btn-primary col-xs-12" id="btnSubmit">*@

        <button type="button" id="btnSubmit" data-bind="click: $root.create">
            <span>Save</span>
        </button>
    </div>

</div>



<script type="text/javascript">

        function TeamTaskDetailedValues(value) {

        }

        function TeamTaskViewModel() {
            var self = this;

            self.StartDate = ko.observable("");
            self.EndDate = ko.observable("");
            self.ForensicDueDate = ko.observable("");
            self.claimid = ko.observable("");
            self.Comment = ko.observable("");

            var Team = {
                StartDate: self.StartDate,
                EndDate: self.EndDate,
                ForensicDueDate: self.ForensicDueDate,
                claimid: self.claimid
            };

            self.Team = ko.observable();
            self.Teams = ko.observableArray();



            self.create = function () {
                //if (Team.StartDate() != "" && Team.EndDate() != "" && Team.ForensicDueDate() != "")
                //{
                    $.ajax({
                        url: '@Url.Action("SaveTeamTaskDetails", "ClinicalReviewDataScreen")',
                        cache: false,
                        type: 'POST',
                        contentType: 'application/json; charset=utf-8',
                        data: ko.toJSON(Team),
                        success: function (data) {
                            self.Teams.push(data);
                            self.StartDate("");
                            self.EndDate("");
                            self.ForensicDueDate("");
                            self.claimid("");

                        }
                    }).fail(
                         function (xhr, textStatus, err) {
                             alert(err);
                         });

                //}
                //else {
                //    alert('Please Enter All the Values !!');
                //}

            }

                    self.cancel = function () {
                    self.Team(null);

                }
            }
                          var viewModel = new TeamTaskViewModel();
                          ko.applyBindings(viewModel);

</script>

存储过程:

插入值的存储过程:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[Equip_SaveTeamTaskAssigineeDetails] (
@saveDataXML xml)
AS
BEGIN

  DECLARE @claimid INT ,
    @createdate DATETIME ,
    @duedate DATETIME ,
    @startdate DATETIME ,
    @assignmentid INT ,
    @assignedto VARCHAR(50) ,
    @piority VARCHAR(50) ,
    @comment VARCHAR(4000)

SELECT  @claimid = node.value('@claimid', 'int') ,
        @createdate = node.value('@createdate', 'datetime') ,
        @duedate = node.value('@duedate', 'datetime') ,
        @startdate = node.value('@startdate', 'datetime') ,
        @assignmentid = node.value('@assignmentid', 'int') ,
        @assignedto = node.value('@assignedto', 'varchar(50)') ,
        @piority = node.value('@piority', 'varchar(50)') ,
        @comment = node.value('@comment', 'varchar(4000)')
FROM    @saveDataXML.nodes('/TeamTaskDetails/Task') nodes ( node )  


SELECT  claimid = @claimid ,
        createdate = @createdate ,
        duedate = @duedate ,
        startdate = @startdate ,
        assignedid = @assignedto ,
        assiginedto = @assignedto ,
        priority = @piority ,
        comment = @comment

    IF (@claimid != 0) BEGIN
        INSERT INTO  [dbo].[TeamTaskAssiginment]
               ([claimid],
                [createdate],
                [duedate],
                [startdate],
                [assignedid],
                [assiginedto],
                [priority],
                [comment])




             VALUES
            (@claimid,
            @createdate,
            @duedate,
            @startdate ,
            @assignmentid ,
            @assignedto ,
            @piority ,
            @comment
                )

         END ELSE BEGIN
            Update [dbo].[TeamTaskAssiginment] set


                 claimid=@claimid ,
                createdate=@createdate,
                duedate=@duedate,
                startdate=@startdate,
                assignedid=@assignedto,
                assiginedto=@assignedto,
                priority=@piority,
                comment=@comment

      END
END

请帮助解决问题。

0 个答案:

没有答案