如何在ASP.net MVC4中编辑附件文件

时间:2014-03-06 12:12:35

标签: asp.net-mvc-4

我在CRUD操作中创建了一个项目列表,其中我已成功创建了一个包含上传附件的项目列表。我的问题是,当我更新项目列表时。我无法读取插入的文件,也无法上传附件文件。

企业访问层代码

public bool UpdateProject(ProjectInfoModel upd)
    {
        try
        {
            int ProjectID = upd.ProjectID;
            string ProjectCode = upd.ProjectCode;
            string ProjectName = upd.ProjectName;
            int ProjectTechnologiesID = upd.ProjectTechnologiesID;
            int ProjectEngagementModelID = upd.ProjectEngagementModelID;
            int ClientID = upd.ClientID;
            DateTime ProjectStartDate = upd.ProjectStartDate;
            DateTime ProjectEndDate = upd.ProjectEndDate;
            string Remarks = upd.Remarks;
            DateTime CreatedDateTime = upd.CreatedDateTime;
            int CreatedBy = upd.CreatedBy;
            int LastModifiedBy = upd.LastModifiedBy;
            DateTime LastModifiedDateTime = upd.LastModifiedDateTime;
            string ProjectStatus = upd.ProjectStatus;

            int ProjectLeadID = upd.ProjectLeadID;
            int AccountManagerID = upd.AccountManagerID;

            // below code for stored procedure

            DB.ProjectUpdate(ProjectID, ProjectCode, ProjectName, ProjectTechnologiesID, ProjectEngagementModelID, ClientID, ProjectStartDate, ProjectEndDate, Remarks, CreatedDateTime, CreatedBy, LastModifiedBy, LastModifiedDateTime, ProjectStatus, ProjectLeadID, AccountManagerID);   



       }
        catch (Exception e)
        {


        }
        return true;
    }

控制器代码


public ActionResult UpdateProject(string id)
    {
       ProjectInfoModel pm = new ProjectInfoModel();

        try
        {
            pm = objPMSBAL.getproject(Convert.ToInt32(id));
            ViewBag.ClientID = new SelectList(objPMSBAL.ListClientId(), "ClientID", "ClientID");
            ViewBag.ProjectEngagementModelID = new SelectList(objPMSBAL.ListEngagementId(), "ProjectEngagementModelID", "ProjectEngagementModelID");
            ViewBag.ResourceID = new SelectList(objPMSBAL.ListResourceId(), "ResourceID", "ResourceID");
            ViewBag.TechnologyID = new SelectList(objPMSBAL.ListTechnologyId(), "ProjectTechID", "ProjectTechID");

        }

        catch (Exception e)
        {


        }
        return View(pm);


    }


    [HttpPost]
    public ActionResult UpdateProject(ProjectInfoModel UP)
    {
        if (ModelState.IsValid)
        {


           objPMSBAL.UpdateProject(UP);       // Calling BAL method


        }

        return RedirectToAction("ProjectList1");
    }

所以我需要帮助来解决我的问题。提前谢谢。

0 个答案:

没有答案