public ActionResult DeleteLocation(string productLocationID) { IDatabase database = DataFactory.Database(); DbTransaction isOpenTrans = database.BeginTrans(); try { string message = "删除成功。"; ProductLocationEntity productLoacation = database.FindEntity <ProductLocationEntity>("ProductLocationID", productLocationID); if (productLoacation == null) { throw new Exception("获取储位数据失败,请刷新重试!"); } database.Delete <ProductLocationEntity>("ProductLocationID", productLocationID, isOpenTrans); database.Commit(); return(Content(new JsonMessage { Success = true, Code = "1", Message = message }.ToString())); } catch (Exception ex) { database.Rollback(); return(Content(new JsonMessage { Success = false, Code = "-1", Message = "操作失败:" + ex.Message }.ToString())); } }
public ActionResult SaveAddLocation(ProductLocationEntity productLocation) { IDatabase database = DataFactory.Database(); DbTransaction isOpenTrans = database.BeginTrans(); try { string message = "新增成功。"; bool flag = _productBLL.IsExistProductLocation(productLocation.ProductId, productLocation.MerchantId, productLocation.WarehouseId, productLocation.ZoneId); if (flag) { throw new Exception("同一个商户+仓库+库区只能存在一个默认储位,请删除已存在储位后再新增!"); } productLocation.Create(); database.Insert(productLocation, isOpenTrans); database.Commit(); return(Content(new JsonMessage { Success = true, Code = "1", Message = message }.ToString())); } catch (Exception ex) { database.Rollback(); return(Content(new JsonMessage { Success = false, Code = "-1", Message = "操作失败:" + ex.Message }.ToString())); } }