public ActionResult DeletePartForm(string keyValue) { string PartsImagePath = "~/Files/PartsImg/"; EquipmentPartsEntity equipmentPartsEntity = new EquipmentPartsEntity(); equipmentPartsEntity = equipmentPartsApp.GetForm(keyValue); equipmentPartsApp.DeleteForm(equipmentPartsEntity); if (!string.IsNullOrEmpty(equipmentPartsEntity.FFileName)) { System.IO.File.Delete(Path.Combine(HostingEnvironment.MapPath(PartsImagePath) + subDir, (equipmentPartsEntity.FFileName.ToString() + ".jpg"))); } return(Success("删除成功。")); }
public void SubmitForm(EquipmentPartsEntity entity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); service.Update(entity); } else { entity.Create(); service.Insert(entity); } }
public ActionResult SubmitPartForm(FormCollection collection) { EquipmentPartsEntity equipmentPartsEntity = new EquipmentPartsEntity(); if (!"".Equals(collection["FId"].ToString())) { equipmentPartsEntity = equipmentPartsApp.GetForm(collection["FId"].ToString()); } equipmentPartsEntity.FItemId = collection["FItemId"].ToString(); equipmentPartsEntity.FSystemId = collection["FSystemId"].ToString(); equipmentPartsEntity.FName = collection["FName"].ToString(); if (!string.IsNullOrEmpty(collection["FImage"])) { var CurrentContext = HttpContext; string PartsImagePath = "~/Files/PartsImg/"; String fullPath = Path.Combine(HostingEnvironment.MapPath(PartsImagePath)); Directory.CreateDirectory(fullPath); if (!string.IsNullOrEmpty(equipmentPartsEntity.FFileName)) { System.IO.File.Delete(Path.Combine(HostingEnvironment.MapPath(PartsImagePath) + subDir, (equipmentPartsEntity.FFileName.ToString() + ".jpg"))); } string base64 = collection["FImage"].Substring(collection["FImage"].IndexOf(',') + 1); base64 = base64.Trim('\0'); byte[] myData = Convert.FromBase64String(base64); string saveFileName = DateTime.Now.ToFileTime().ToString(); MemoryStream ms = new MemoryStream(myData); Bitmap bmp = new Bitmap(ms); Image returnImage = bmp; returnImage.Save(Server.MapPath(PartsImagePath) + saveFileName + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); string filename = saveFileName; equipmentPartsEntity.FContentLength = Ext.ToString(base64.Length); equipmentPartsEntity.FContentType = "image/jpg"; equipmentPartsEntity.FFileName = filename; } equipmentPartsApp.SubmitForm(equipmentPartsEntity, collection["FId"].ToString()); return(Success("操作成功。")); }
public void DeleteForm(EquipmentPartsEntity entity) { service.Delete(entity); }