public ActionResult SubmitOutForm(InventoryOutEntity inventoryOutEntity, string id = "") { double remainder = Convert.ToDouble(DbHelper.ExecuteToString("select isnull((select isnull(cast(Weight as decimal),0) from Inventory where Id = '" + inventoryOutEntity.InventoryId + "') - (select isnull(sum(cast(Weight as decimal)),0) from InventoryOut where InventoryId = '" + inventoryOutEntity.InventoryId + "'),0)")); if (remainder < inventoryOutEntity.Weight) { return(Error("库存不足!")); } inventoryOutApp.SubmitForm(inventoryOutEntity, id); return(Success("出库成功!")); }
public void SubmitForm(InventoryOutEntity inventoryOutEntity, string id) { if (!string.IsNullOrEmpty(id)) { inventoryOutEntity.Modify(id); service.Update(inventoryOutEntity); } else { inventoryOutEntity.Create(); service.Insert(inventoryOutEntity); new LogApp().WriteDbLog( new ProductApp().GetNameByCode( new InventoryApp().GetForm(inventoryOutEntity.InventoryId).ProductType) + "出库:" + inventoryOutEntity.Weight + "吨", DbLogType.Create); } }
public ActionResult GetOutGridJson(string inventoryId) { DataView dvOut = DbHelper.ExecuteToDataView("select b.F_RealName,a.CreatorTime,a.Weight from InventoryOut a left join Sys_User b on a.CreatorUserId=b.Id where a.InventoryId='" + inventoryId + "' order by a.CreatorTime desc"); List <InventoryOutEntity> inventoryOutEntitys = new List <InventoryOutEntity>(); foreach (DataRowView drv in dvOut) { InventoryOutEntity inventoryOutEntity = new InventoryOutEntity() { CreatorUserId = Convert.ToString(drv["F_RealName"]), CreatorTime = Convert.ToDateTime(drv["CreatorTime"]), Weight = Convert.ToDouble(drv["Weight"]) }; inventoryOutEntitys.Add(inventoryOutEntity); } return(Content(inventoryOutEntitys.ToJson())); }