formdate 后端如何接收
/// <summary>
/// 添加
/// </summary>
/// <param name="bmgl"></param>
/// <returns></returns>
[HttpPost]
public ResultMsg Add()
{
try
{
EA_Records job = new EA_Records();
HttpFileCollection filelist = HttpContext.Current.Request.Files;
if (filelist.Count > 0)
{
HttpPostedFile file = filelist[0];//文件
string filename = file.FileName;
if (filename.Contains('\\'))
{
filename = Path.GetFileName(file.FileName);
}
string filepath = AppDomain.CurrentDomain.BaseDirectory + "/" + "UploadFiles" + "/" + filename;
job.Picture = "/" + "UploadFiles" + "/" + filename;
file.SaveAs(filepath);
}
else
{
job.Picture = "";
}
job.Number=HttpContext.Current.Request["Number"];
job.Category = HttpContext.Current.Request["Category"];
job.Classificaty = HttpContext.Current.Request["Classificaty"];
job.DeviceName = HttpContext.Current.Request["DeviceName"];
job.Dateofuse = HttpContext.Current.Request["Dateofuse"];
job.Securitylevel = HttpContext.Current.Request["Securitylevel"];
job.Installposition = HttpContext.Current.Request["Installposition"];
job.Area = HttpContext.Current.Request["Area"];
job.Management = HttpContext.Current.Request["Management"];
job.Price = HttpContext.Current.Request["Price"];
job.Usestatus = HttpContext.Current.Request["Usestatus"];
job.Runstatus = HttpContext.Current.Request["Runstatus"];
job.IsRegular = HttpContext.Current.Request["IsRegular"];
job.RegularUnit = HttpContext.Current.Request["RegularUnit"];
job.InspectionCycle = HttpContext.Current.Request["InspectionCycle"];
job.FirstDate = HttpContext.Current.Request["FirstDate"];
job.Servicelife = HttpContext.Current.Request["Servicelife"];
job.Nextdate = HttpContext.Current.Request["Nextdate"];
job.Archives = HttpContext.Current.Request["Archives"];
job.Dueyear = HttpContext.Current.Request["Dueyear"];
job.Remark = HttpContext.Current.Request["Remark"];
job.Fssb = HttpContext.Current.Request["Fssb"];
job.Company = HttpContext.Current.Request["Company"];
int mes = BLL.Add(job);
if (mes > 0)
{
return new ResultMsg()
{
code = 200,
msg = "成功",
};
}
else
{
return new ResultMsg()
{
code = 101,
msg = "失败"
};
}
}
catch (Exception ex)
{
return new ResultMsg()
{
code = 102,
msg = ex.Message.ToString()
};
}
}