Ejemplo n.º 1
0
        // If it's an Insert we fetch the @@Identity value and stuff it in the proper column
        protected void OnRowUpdated(object sender, MySqlRowUpdatedEventArgs e)
        {
            try
            {
                if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
                {
                    TransactionMgr txMgr = TransactionMgr.ThreadTransactionMgr();

                    string identityCol = this.GetAutoKeyColumns();

                    MySqlCommand cmd = new MySqlCommand();

                    cmd.CommandText = "SELECT LAST_INSERT_ID();";

                    // We make sure we enlist in the ongoing transaction, otherwise, we
                    // would most likely deadlock
                    txMgr.Enlist(cmd, this);
                    object o = cmd.ExecuteScalar();                     // Get the Identity Value
                    txMgr.DeEnlist(cmd, this);

                    if (o != null)
                    {
                        e.Row[identityCol] = o;
                    }

                    e.Row.AcceptChanges();
                }
            }
            catch {}
        }
Ejemplo n.º 2
0
        // If it's an Insert we fetch the @@Identity value and stuff it in the proper column
        protected void OnRowUpdated(object sender, OleDbRowUpdatedEventArgs e)
        {
            try
            {
                if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
                {
                    TransactionMgr txMgr = TransactionMgr.ThreadTransactionMgr();

                    OleDbCommand cmd = new OleDbCommand("SELECT @@IDENTITY");

                    // We make sure we enlist in the ongoing transaction, otherwise, we
                    // would most likely deadlock
                    txMgr.Enlist(cmd, this);
                    object o = cmd.ExecuteScalar();                     // Get the Identity Value
                    txMgr.DeEnlist(cmd, this);

                    if (o != null)
                    {
                        e.Row[this.GetAutoKeyColumn()] = o;
                        e.Row.AcceptChanges();
                    }
                }
            }
            catch {}
        }
Ejemplo n.º 3
0
        // If it's an Insert we fetch the @@Identity value and stuff it in the proper column
        protected void OnRowUpdated(object sender, RowUpdatedEventArgs e)
        {
            try
            {
                if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
                {
                    TransactionMgr txMgr = TransactionMgr.ThreadTransactionMgr();

                    string[] identityCols = this.GetAutoKeyColumns().Split(';');

                    SQLiteCommand cmd = new SQLiteCommand();

                    foreach (string col in identityCols)
                    {
                        cmd.CommandText = "SELECT last_insert_rowid()";

                        // We make sure we enlist in the ongoing transaction, otherwise, we
                        // would most likely deadlock
                        txMgr.Enlist(cmd, this);
                        object o = cmd.ExecuteScalar();                         // Get the Identity Value
                        txMgr.DeEnlist(cmd, this);

                        if (o != null)
                        {
                            e.Row[col] = o;
                        }
                    }

                    e.Row.AcceptChanges();
                }
            }
            catch {}
        }
Ejemplo n.º 4
0
        private void ReturnToStoreForQuantityEdit()
        {
            //TODO: finish updating the changed locations
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
            transaction.BeginTransaction();
            try
            {
                PalletLocation pl        = new PalletLocation();
                String         reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

                int ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);

                if (gridDetailView.DataSource == null)
                {
                    return;
                }

                BLL.ReceiveDoc recDoc = new ReceiveDoc();
                recDoc.LoadByReceiptID(ReceiptID);
                recDoc.SetStatusAsDraft(CurrentContext.UserId);

                BLL.Receipt receiptStatus = new BLL.Receipt();
                receiptStatus.LoadByPrimaryKey(ReceiptID);
                receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.DRAFT_RECEIPT, null, this.GetFormIdentifier(), CurrentContext.UserId, "Returned To Draft");

                transaction.CommitTransaction();
                XtraMessageBox.Show("Receipt Returned!", "Success", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                BindFormContents();
            }
            catch (Exception exp)
            {
                transaction.RollbackTransaction();
                XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void ConfirmQuantityAndLocation()
        {
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
            transaction.BeginTransaction();
            try
            {
                PalletLocation pl = new PalletLocation();
                DataRow        dr = gridReceiveView.GetFocusedDataRow();
                if (dr == null)
                {
                    throw new Exception("Nothing to confirm!");
                }

                int ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);

                if (gridDetailView.DataSource == null)
                {
                    return;
                }

                BLL.ReceiveDoc receiveDoc = new ReceiveDoc();
                receiveDoc.LoadByReceiptIDWithReceivePallet(ReceiptID);

                while (!receiveDoc.EOF)
                {
                    int palletLocationID = Convert.ToInt32(receiveDoc.GetColumn("PalletLocationID"));
                    pl.LoadByPrimaryKey(palletLocationID);
                    pl.Confirmed = true;
                    pl.Save();

                    receiveDoc.MoveNext();
                }
                BLL.ReceiveDoc recDoc = new ReceiveDoc();
                recDoc.LoadByReceiptID(ReceiptID);

                recDoc.ConfirmQuantityAndLocation(CurrentContext.UserId);
                BLL.Receipt receiptStatus = new BLL.Receipt();
                receiptStatus.LoadByPrimaryKey(ReceiptID);
                receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED, null, this.GetFormIdentifier(), CurrentContext.UserId, "Receive Confirmed");

                transaction.CommitTransaction();
                XtraMessageBox.Show("Receipt Confirmed!", "Success", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                BindFormContents();
            }
            catch (Exception exp)
            {
                transaction.RollbackTransaction();
                XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This must be called after RollbackTransaction or no futher database activity will happen successfully on the current thread.
        /// </summary>
        public static void ThreadTransactionMgrReset()
        {
            TransactionMgr txMgr = TransactionMgr.ThreadTransactionMgr();

            try
            {
                if (txMgr.txCount > 0 && txMgr.hasRolledBack == false)
                {
                    txMgr.RollbackTransaction();
                }
            }
            catch {}

            Thread.SetData(txMgrSlot, null);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// This static method is how you obtain a reference to the TransactionMgr. You cannot call "new" on TransactionMgr.
        /// If a TransactionMgr doesn't exist on the current thread, one is created and returned to you.
        /// </summary>
        /// <returns>The one and only TransactionMgr for this thread.</returns>
        public static TransactionMgr ThreadTransactionMgr()
        {
            TransactionMgr txMgr = null;

            object obj = Thread.GetData(txMgrSlot);

            if (obj != null)
            {
                txMgr = (TransactionMgr)obj;
            }
            else
            {
                txMgr = new TransactionMgr();
                Thread.SetData(txMgrSlot, txMgr);
            }

            return(txMgr);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Execute the Query and loads your BusinessEntity.
        /// You can pass in the conjustion that will be used between the WHERE parameters, either, "AND" or "OR". "AND" is the default.
        /// Also, if you need to be notified that this is being called override BusinessEntity.OnQueryLoad().
        /// </summary>
        /// <returns>True if at least one record was loaded</returns>
        public bool Load(string conjuction)
        {
            bool      loaded = false;
            DataTable dt     = null;

            try
            {
                if ((_aggregateParameters == null || _aggregateParameters.Count <= 0) &&
                    _resultColumns.Length <= 0 && _countAll == false)
                {
                    this._entity._canSave = true;
                }

                this._entity.OnQueryLoad(conjuction);

                IDbCommand cmd = _Load(conjuction);
                _lastQuery = cmd.CommandText;

                IDbDataAdapter da = this._entity.CreateIDbDataAdapter();
                da.SelectCommand = cmd;

                TransactionMgr txMgr = TransactionMgr.ThreadTransactionMgr();

                dt = new DataTable(_entity.MappingName);

                txMgr.Enlist(cmd, _entity);
                DbDataAdapter dbDataAdapter = this._entity.ConvertIDbDataAdapter(da);
                dbDataAdapter.Fill(dt);
                txMgr.DeEnlist(cmd, _entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                this._entity.DataTable = dt;
                loaded = (dt.Rows.Count > 0);
            }

            return(loaded);
        }
Ejemplo n.º 9
0
		/// <summary>
		/// This static method is how you obtain a reference to the TransactionMgr. You cannot call "new" on TransactionMgr.
		/// If a TransactionMgr doesn't exist on the current thread, one is created and returned to you.
		/// </summary>
		/// <returns>The one and only TransactionMgr for this thread.</returns>
		public static TransactionMgr ThreadTransactionMgr()
		{
			TransactionMgr txMgr = null;

			object obj = Thread.GetData(txMgrSlot);

			if(obj != null)
			{
				txMgr = (TransactionMgr)obj;
			}
			else
			{
				txMgr = new TransactionMgr();
				Thread.SetData(txMgrSlot, txMgr);
			}

			return txMgr;
		}