public ActionResult InventoryAlteration(InventoryAlterationModel inventoryAlterationModel) { int result = 0; string InventoryAlterationMessage = string.Empty; if (inventoryAlterationModel != null) { if (inventoryAlterationModel.InventoryAlterationDetails.Count > 0) { result = _inventoryAlterationService.InsertInventoryAlteration(inventoryAlterationModel); if (result > 0) { InventoryAlterationMessage = _locService.GetLocalizedHtmlString("SaveSuccess"); } else { InventoryAlterationMessage = _locService.GetLocalizedHtmlString("SaveFailed"); } } else { InventoryAlterationMessage = _locService.GetLocalizedHtmlString("ValidInventoryAlteration"); return(Json(new { error = true, message = InventoryAlterationMessage, status = 201 })); } } else { InventoryAlterationMessage = _locService.GetLocalizedHtmlString("ValidInventoryAlteration"); return(Json(new { error = true, message = InventoryAlterationMessage, status = 201 })); } return(Json(new { error = false, message = InventoryAlterationMessage, status = 200 })); }
public ActionResult View(long?id) { InventoryAlterationModel inventoryAlterationModel = new InventoryAlterationModel(); long purchaseId = Convert.ToInt64(id); inventoryAlterationModel = _inventoryAlterationService.GetViewInventoryAlterationById(purchaseId); return(View(inventoryAlterationModel)); }
public ActionResult InventoryAlteration(int?id, int?inventoryType) { _iCommonService.GetPageWiseRoleRigths("InventoryAlteration"); InventoryAlterationModel inventoryAlterationModel = new InventoryAlterationModel(); inventoryAlterationModel.FoodMenuList = _iDropDownService.GetFoodMenuList(); inventoryAlterationModel.IngredientList = _iDropDownService.GetIngredientList(); inventoryAlterationModel.AssetItemList = _iDropDownService.GetAssetItemList(); inventoryAlterationModel.StoreList = _iDropDownService.GetStoreList(); inventoryAlterationModel.ReferenceNo = _inventoryAlterationService.ReferenceNumberInventoryAlteration(); inventoryAlterationModel.InventoryType = Convert.ToInt32(inventoryType); return(View(inventoryAlterationModel)); }
public int InsertInventoryAlteration(InventoryAlterationModel inventoryAlterationModel) { int result = 0; int foodMenuResult = 0; string foodMenuId = "NULL", ingredientId = "NULL", assetItemId = "NULL"; using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString)) { con.Open(); SqlTransaction sqltrans = con.BeginTransaction(); var query = "INSERT INTO [dbo].[InventoryAlteration] " + " ([ReferenceNo] " + " ,[EntryDate] " + " ,[StoreId] " + " ,[Notes] " + " ,[InventoryType] " + " ,[UserIdInserted] " + " ,[DateInserted] " + " ,[IsDeleted]) " + " VALUES " + " (@ReferenceNo, " + " GetUtcDate() " + " ,@StoreId, " + " @Notes, " + " @InventoryType, " + "" + LoginInfo.Userid + "," + " GetUtcDate(), " + " 0); SELECT CAST(SCOPE_IDENTITY() as int); "; result = con.ExecuteScalar <int>(query, inventoryAlterationModel, sqltrans, 0, System.Data.CommandType.Text); if (result > 0) { foreach (var foodmenu in inventoryAlterationModel.InventoryAlterationDetails) { if (foodmenu.IngredientId == 0) { ingredientId = "NULL"; } else { ingredientId = foodmenu.IngredientId.ToString(); } if (foodmenu.AssetItemId == 0) { assetItemId = "NULL"; } else { assetItemId = foodmenu.AssetItemId.ToString(); } if (foodmenu.FoodMenuId == 0) { foodMenuId = "NULL"; } else { foodMenuId = foodmenu.FoodMenuId.ToString(); } var queryDetails = "INSERT INTO [dbo].[InventoryAlterationDetail]" + " ([InventoryAlterationId] " + " ,[FoodMenuId] " + " ,[IngredientId] " + " ,[AssetItemId] " + " ,[Qty] " + " ,[InventoryStockQty] " + " ,[Amount] " + " ,[EntryDate] " + " ,[UserIdInserted]" + " ,[DateInserted]" + " ,[IsDeleted]) " + "VALUES " + "(" + result + "," + foodMenuId + "," + ingredientId + "," + assetItemId + "," + foodmenu.Qty + "," + foodmenu.InventoryStockQty + "," + foodmenu.Amount + "," + " GetUtcDate()" + "," + LoginInfo.Userid + ",GetUtcDate(),0);"; foodMenuResult = con.Execute(queryDetails, null, sqltrans, 0, System.Data.CommandType.Text); } if (foodMenuResult > 0) { sqltrans.Commit(); CommonRepository commonRepository = new CommonRepository(_ConnectionString); string sResult = commonRepository.InventoryPush("PhysicalStock", result); } else { sqltrans.Rollback(); } } else { sqltrans.Rollback(); } } return(result); }
public int InsertInventoryAlteration(InventoryAlterationModel inventoryAlterationModel) { return(_inventoryAlterationRepository.InsertInventoryAlteration(inventoryAlterationModel)); }