Fork me on GitHub

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()
};
}
}

posted @ 2023-02-16 19:51  残风飞雪  阅读(51)  评论(0编辑  收藏  举报

博客地址 - 创建于 2022年4月12日

这是一位.Net软件研发工程师的个人站,内容主要是网站开发方面的技术文章,大部分来自学习或工作,部分来源于网络,希望对大家有所帮助。

致力于web网站开发工作,专注软件开发,关注互联网前沿技术与趋势。


Font Awesome Bootstrap中文网