在这里,我添加产品并保存图像路径,一切正常,图像路径已保存
public ActionResult AddProduct(Product p, HttpPostedFileBase prodImg, decimal[] price)
{
try
{
string absoluthFolderPath = Server.MapPath("\\Images");
string pathOfImage = System.IO.Path.GetExtension(prodImg.FileName);
string newFileName = Guid.NewGuid() + pathOfImage;
absoluthFolderPath += "\\" + newFileName;
prodImg.SaveAs(absoluthFolderPath);
string relitivePath = @"\Images\" + newFileName;
p.ImagePath = relitivePath;
p.Blocked = false;
new ProductsBL().AddProduct(p);
ViewData\["msg"\] = "Successfuly";
}
catch(Exception ex)
{
}
ModelState.Clear();
return View();
}
尝试更新图片路径时,它会在屏幕截图中显示错误
public ActionResult Update(Product modifieDetails, HttpPostedFileBase updImg)
{
string absoluthFolderPath = Server.MapPath("\\Images");
string pathOfImage = System.IO.Path.GetExtension(updImg.FileName);
string newFileName = Guid.NewGuid() + pathOfImage;
absoluthFolderPath += "\\" + newFileName;
updImg.SaveAs(absoluthFolderPath);
string relitivePath = @"\Images\" + newFileName;
modifieDetails.ImagePath = relitivePath;
modifieDetails.Blocked = false;
new ProductsBL().UpdateProduct(modifieDetails);
return RedirectToAction("ListProduct");
}
[1]: http://i.stack.imgur.com/wgE88.png
答案 0 :(得分:1)
您需要将其拆分:
select date,
(select COUNT(1) FROM dbo.TASKS WHERE
OPENDATE<=date AND
(CLSDDATE>=date Or CLSDDATE is null))as 'Pending jobs',
(select COUNT(1) FROM dbo.TASKS WHERE
month(CLSDDATE)=MONTH(date) AND YEAR(clsddate)=YEAR(date)) as 'Completed jobs',
(select AVG(datediff(DAY,OPENDATE, CLSDDATE)) as avgDays FROM dbo.TASKS WHERE
month(CLSDDATE)=MONTH(date) AND YEAR(clsddate)=YEAR(date)) as 'AvgDays'
from dbo.CalendarMonths
where date<=GETDATE()
为了将实体的更新保存回商店,您必须设置&#34; IsModified&#34;在实体上,然后保存上下文。像这样......
new ProductsBL().AddProduct(p);
实际上,您正在创建一个新实体并将其添加到商店,而不是更新现有实体。
而且,如果你用英语编码,请修改拼写:修改,相对,绝对。