예제 #1
0
        private void UpdateRowWithStockCountLine(DataRow row, ISCJournalTransaction line)
        {
            // Update columns that are included in ISCJournalTransaction
            row[DataAccessConstants.ItemNumber] = line.ItemId;
            row[DataAccessConstants.ItemName]   = line.ItemName;
            row[DataAccessConstants.Counted]    = line.Counted;
            row[DataAccessConstants.JournalId]  = this.SelectedJournalId;
            row[DataAccessConstants.RecId]      = line.RecId;

            // Always set to zero because only delta will be shown and submitted
            row[DataAccessConstants.Quantity] = 0;

            row[DataAccessConstants.ConfigId]      = line.ConfigId;
            row[DataAccessConstants.InventSizeId]  = line.InventSizeId;
            row[DataAccessConstants.InventColorId] = line.InventColorId;
            row[DataAccessConstants.InventStyleId] = line.InventStyleId;
        }
예제 #2
0
        private void btnCommit_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                // commit local stock counts to AX via webservice
                SaveStockCounts();

                LoadStockCountsFromDB();

                // Commit local stock counts to AX via webservice
                ISCJournal scJournal = StockCount.InternalApplication.Services.StoreInventoryServices.CommitStockCounts(this.SelectedJournalId, this.SelectedRecordId);

                // Remove rows that are successfully submitted
                List <DataRow> removeRows = new List <DataRow>();

                if (scJournal != null)
                {
                    foreach (DataRow row in entryTable.Rows)
                    {
                        ISCJournalTransaction updatedLine = scJournal.SCJournalLines.Where(line => string.Equals(line.Guid, row["GUID"].ToString(), StringComparison.OrdinalIgnoreCase) &&
                                                                                           line.UpdatedInAx == true).FirstOrDefault();

                        if (updatedLine != null)
                        {
                            removeRows.Add(row);
                        }
                    }
                }

                // If lines were submitted successfully
                if (removeRows.Count > 0)
                {
                    foreach (DataRow row in removeRows)
                    {
                        // Remove line from local DB
                        scData.DeleteStockCount(row["GUID"].ToString());

                        // Remove line from form
                        entryTable.Rows.Remove(row);
                        entryTable.AcceptChanges();
                    }

                    if (removeRows.Count == scJournal.SCJournalLines.Count)
                    {
                        // Delete header
                        scData.DeleteJournal(scJournal.RecId);

                        // Show commit succeeded message
                        using (frmMessage dialog = new frmMessage(10314011, MessageBoxButtons.OK, MessageBoxIcon.Information))
                        {
                            POSFormsManager.ShowPOSForm(dialog);
                            if (dialog.DialogResult == DialogResult.OK)
                            {
                                this.DialogResult = DialogResult.OK;
                                Close();
                            }
                        }
                    }
                    else
                    {
                        // Show partial commit success message
                        using (frmMessage dialog = new frmMessage(10314012, MessageBoxButtons.OK, MessageBoxIcon.Information))
                        {
                            POSFormsManager.ShowPOSForm(dialog);
                        }
                        grInventory.DataSource = entryTable;
                        entryTable.AcceptChanges();
                    }
                }
                else
                {
                    // Show commit failure message
                    using (frmMessage dialog = new frmMessage(10314013, MessageBoxButtons.OK, MessageBoxIcon.Information))
                    {
                        POSFormsManager.ShowPOSForm(dialog);
                    }
                    grInventory.DataSource = entryTable;
                    entryTable.AcceptChanges();
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }