Пример #1
0
        public async Task <IActionResult> UpdateRow(string id, string rowId, [FromBody] Dictionary <string, string> model)
        {
            var row = new SpreadSheetRow
            {
                Id   = rowId,
                Data = model
            };

            var savedRow = await _spreadSheetRepo.UpdateRow(id, row);

            return(Ok(savedRow));
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(ListView listview, TextBox barcodeBox)
        {
            StatusBar             = new StatusBar();
            _statusBar.StatusText = "Start Scanning!";

            TotalsBar              = new Totals();
            _totalsBar.TotalRows   = 9999;
            _totalsBar.TotalFound  = 9999;
            _totalsBar.NumberScans = 9999;

            Scans        = new List <string>();
            Rows         = new List <SpreadSheetRow>();
            SearchResult = new SpreadSheetRow();

            this.SpreadSheetGrid = listview;
            this.BarcodeTextBox  = barcodeBox;

            ChooseSpreadsheet();
            this.SearchSheetCommand       = new RelayCommand <string>(this.SearchSheet);
            this.SaveDataCommand          = new RelayCommand(this.SaveData);
            this.ChooseSpreadsheetCommand = new RelayCommand(this.ChooseSpreadsheet);
        }
Пример #3
0
        public async Task <SpreadSheetRow> UpdateRow(string spreadSheetId, SpreadSheetRow row)
        {
            var filename = Path.Combine(_workDir, spreadSheetId);

            if (!File.Exists(filename))
            {
                throw new AppValidationException("Spreadsheet not found");
            }

            var json = await File.ReadAllTextAsync(filename);

            var savedSpreadSheet = JsonSerializer.Deserialize <SpreadSheet>(json);

            var savedRow = savedSpreadSheet.Rows?.FirstOrDefault(x => x.Id == row.Id);

            if (savedRow == null)
            {
                throw new AppValidationException("Spreadsheet row not found");
            }

            foreach (var pair in row.Data)
            {
                if (savedRow.Data.ContainsKey(pair.Key))
                {
                    savedRow.Data[pair.Key] = pair.Value;
                }
                else
                {
                    savedRow.Data.Add(pair.Key, pair.Value);
                }
            }

            json = JsonSerializer.Serialize(savedSpreadSheet);
            await File.WriteAllTextAsync(filename, json);

            return(savedRow);
        }
Пример #4
0
        private void LoadSpreadsheetExecute()
        {
            DataSet SpreadsheetData; //Original Spreedsheet in DS form

            try
            {
                using (FileStream stream = File.Open(XlsFileName, FileMode.Open, FileAccess.Read))
                {
                    using (IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream))
                    {
                        excelReader.IsFirstRowAsColumnNames = true;
                        DataSet result = excelReader.AsDataSet();
                        SpreadsheetData = result;
                    }
                }
            }
            catch
            {
                MessageBox.Show("Unable to open spreadsheet!");
                return;
            }

            //SpreadsheetView.ItemsSource = SpreadsheetData.Tables[Properties.Settings.Default.SheetName].DefaultView;
            DataTable table = SpreadsheetData.Tables[0];

            //store the columns for later.
            SpreadsheetColumns = table.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToList();

            _rowList = new List <SpreadSheetRow>();
            int index = 1;

            foreach (DataRow row in table.Rows)
            {
                SpreadSheetRow newRow = new SpreadSheetRow();
                newRow.RowId    = index;
                newRow.Asin     = row["Asin"].ToString();
                newRow.UPC      = row["UPC"].ToString();
                newRow.EAN      = row["EAN"].ToString();
                newRow.LPN      = row["LPN"].ToString();
                newRow.FCSKU    = row["FCSKU"].ToString();
                newRow.ItemDesc = row["itemDesc"].ToString();

                #region "rows that we dont need to display/query"
                newRow.LiquidatorVendorCode = row["LiquidatorVendorCode"].ToString();
                newRow.InventoryLocation    = row["InventoryLocation"].ToString();
                newRow.FC                = row["FC"].ToString();
                newRow.IOG               = row["IOG"].ToString();
                newRow.RemovalReason     = row["RemovalReason"].ToString();
                newRow.ShipmentClosed    = row["ShipmentClosed"].ToString();
                newRow.BOL               = row["BOL"].ToString();
                newRow.Carrier           = row["Carrier"].ToString();
                newRow.ShipToCity        = row["ShipToCity"].ToString();
                newRow.RemovalOrderID    = row["RemovalOrderID"].ToString();
                newRow.ReturnID          = row["ReturnID"].ToString();
                newRow.ReturnItemID      = row["ReturnItemID"].ToString();
                newRow.ShipmentRequestID = row["ShipmentRequestID"].ToString();
                newRow.PkgID             = row["PkgID"].ToString();
                newRow.GL                = row["GL"].ToString();
                newRow.GLDesc            = row["GLDesc"].ToString();
                newRow.CategoryCode      = row["CategoryCode"].ToString();
                newRow.CategoryDesc      = row["CategoryDesc"].ToString();
                newRow.SubcatCode        = row["SubcatCode"].ToString();
                newRow.SubcatDesc        = row["SubcatDesc"].ToString();
                newRow.Units             = row["Units"].ToString();
                newRow.ItemPkgWeight     = row["ItemPkgWeight"].ToString();
                newRow.ItemPkgWeightUOM  = row["ItemPkgWeightUOM"].ToString();
                newRow.CostSource        = row["CostSource"].ToString();
                newRow.CurrencyCode      = row["CurrencyCode"].ToString();
                newRow.UnitCost          = row["UnitCost"].ToString();
                newRow.AmazonPrice       = row["AmazonPrice"].ToString();
                newRow.UnitRecovery      = row["UnitRecovery"].ToString();
                newRow.TotalCost         = row["TotalCost"].ToString();
                newRow.TotalRecovery     = row["TotalRecovery"].ToString();
                newRow.RecoveryRate      = row["RecoveryRate"].ToString();
                newRow.RecoveryRateType  = row["RecoveryRateType"].ToString();
                newRow.AdjTotalRecovery  = row["AdjTotalRecovery"].ToString();
                newRow.AdjRecoveryRate   = row["AdjRecoveryRate"].ToString();
                newRow.AdjReason         = row["AdjReason"].ToString();
                newRow.FNSku             = row["FNSku"].ToString();
                #endregion
                newRow.Found      = false;
                newRow.Selected   = false;
                newRow.FoundCount = 0;
                _rowList.Add(newRow);

                index++;
            }
        }