public void UpdateStockOut(int selectedId, int[] selectedIds, int[] selectedValues, string user) { var newList = new List <StockOutDetail>(outList); var index = newList.FindIndex(n => n.detailId == selectedId); if (index >= 0) { var note = newList[index]; note.detailUser = user; note.detailDateAdded = DateTime.Now; if (selectedIds.Length > 0) { //Roll back bool isRolledBack = RolledBack(note.detailProductList, note.detailStockChange, isPlus: false); //New status if (isRolledBack) { note.detailProductList.Clear(); note.detailStockChange.Clear(); List <Product> changedProducts = new List <Product>(); (note.detailProductList, note.detailStockChange, changedProducts) = UpdateNoteProductList(selectedIds, selectedValues, isPlus: false); if (note.detailProductList != null && note.detailStockChange != null && changedProducts != null) { UpdateProductList(note.detailProductList); LocalDataAccess.WriteDataStockOut(rootPath, stockOutFile, newList); } } } } }
public void AddStockOut(int[] selectedIds, int[] selectedValues, string user) { StockOutDetail note = new StockOutDetail(); note.detailProductList = new List <Product>(); var newList = new List <StockOutDetail>(); if (outList == null) { note.detailId = 1; } else { note.detailId = outList.Last().detailId + 1; newList = new List <StockOutDetail>(outList); } //Assign value for new note note.detailUser = user; note.detailDateAdded = DateTime.Now; note.detailProductList = new List <Product>(); note.detailStockChange = new List <StockTracker>(); List <Product> changedProducts = new List <Product>(); (note.detailProductList, note.detailStockChange, changedProducts) = UpdateNoteProductList(selectedIds, selectedValues, isPlus: false); if (note.detailProductList != null && note.detailStockChange != null && changedProducts != null) { newList.Add(note); //Update database UpdateProductList(changedProducts); LocalDataAccess.WriteDataStockOut(rootPath, stockOutFile, newList); } }
public void DeleteStockOut(int selectedId) { var newList = new List <StockOutDetail>(outList); var note = newList.Find(n => n.detailId == selectedId); if (note != null) { //Roll back bool isRolledBack = RolledBack(note.detailProductList, note.detailStockChange, isPlus: false); if (isRolledBack) { newList.Remove(note); LocalDataAccess.WriteDataStockOut(rootPath, stockOutFile, newList); } } }