/* Update */
        public override void Update(Document doc, NorthwindConfig config, ref List <TransactionResult> result)
        {
            List <TransactionResult> transactionResult = new List <TransactionResult>();
            UnitOfMeasureDocument    uomDoc            = doc as UnitOfMeasureDocument;

            #region check input values

            if (uomDoc == null)
            {
                result.Add(doc.SetTransactionStatus(TransactionStatus.UnRecoverableError, Resources.ErrorMessages_DocumentTypeNotSupported));
                return;
            }

            // check id

            #endregion

            DataSets.ProductTableAdapters.ProductsTableAdapter tableAdapter;


            DataSets.Product             productDataset = new DataSets.Product();
            DataSets.Product.ProductsRow row;
            tableAdapter = new DataSets.ProductTableAdapters.ProductsTableAdapter();
            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                connection.Open();

                tableAdapter.Connection = connection;
                int recordCount = tableAdapter.FillBy(productDataset.Products, Convert.ToInt32(uomDoc.Id));
                if (recordCount == 0)
                {
                    doc.SetTransactionStatus(TransactionStatus.UnRecoverableError, "Product does not exists");
                    return;
                }
                row = (DataSets.Product.ProductsRow)productDataset.Products.Rows[0];

                try
                {
                    // active???

                    if (uomDoc.name.IsNull)
                    {
                        row.SetQuantityPerUnitNull();
                    }
                    else
                    {
                        row.QuantityPerUnit = (string)uomDoc.name.Value;
                    }

                    // units ???

                    // defaultvalue ???

                    // familyId ???

                    // ModifyID
                    row.ModifyID   = config.SequenceNumber;
                    row.ModifyUser = config.CrmUser;
                }
                catch (Exception e)
                {
                    uomDoc.Id = "";
#warning Check error message
                    result.Add(uomDoc.SetTransactionStatus(TransactionStatus.UnRecoverableError, e.ToString()));
                    return;
                }

                tableAdapter            = new DataSets.ProductTableAdapters.ProductsTableAdapter();
                tableAdapter.Connection = connection;

                tableAdapter.Update(productDataset.Products);

                result.Add(doc.SetTransactionStatus(TransactionStatus.Success));
            }
        }
        /* Add */
        public override void Add(Document doc, NorthwindConfig config, ref List <TransactionResult> result)
        {
            List <TransactionResult> transactionResult = new List <TransactionResult>();
            UnitOfMeasureDocument    uomDoc            = doc as UnitOfMeasureDocument;

            #region check input values

            if (uomDoc == null)
            {
                result.Add(doc.SetTransactionStatus(TransactionStatus.UnRecoverableError, Resources.ErrorMessages_DocumentTypeNotSupported));
                return;
            }
            #endregion

            DataSets.ProductTableAdapters.ProductsTableAdapter tableAdapter;


            DataSets.Product             productDataset = new DataSets.Product();
            DataSets.Product.ProductsRow row            = productDataset.Products.NewProductsRow();


            #region fill dataset from document

            try
            {
                // active???

                if (uomDoc.name.IsNull)
                {
                    row.SetQuantityPerUnitNull();
                }
                else
                {
                    row.QuantityPerUnit = (string)uomDoc.name.Value;
                }

                // units ???

                // defaultvalue ???

                // familyId ???

                /* CreateID and ModifyID */
                row.CreateID   = config.SequenceNumber;
                row.CreateUser = config.CrmUser;

                row.ModifyID   = config.SequenceNumber;
                row.ModifyUser = config.CrmUser;
            }
            catch (Exception e)
            {
                uomDoc.Id = "";
#warning Check error message
                result.Add(uomDoc.SetTransactionStatus(TransactionStatus.UnRecoverableError, e.ToString()));
                return;
            }

            #endregion

            using (OleDbConnection connection = new OleDbConnection(config.ConnectionString))
            {
                connection.Open();

                tableAdapter            = new DataSets.ProductTableAdapters.ProductsTableAdapter();
                tableAdapter.Connection = connection;

                productDataset.Products.AddProductsRow(row);

                tableAdapter.Update(productDataset.Products);

                OleDbCommand Cmd = new OleDbCommand("SELECT @@IDENTITY", connection);

                object lastid = Cmd.ExecuteScalar();

                uomDoc.Id = ((int)lastid).ToString();
            }

            result.Add(doc.SetTransactionStatus(TransactionStatus.Success));
        }